     1                                  ; ****************************************************************************
     2                                  ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.3
     3                                  ; ----------------------------------------------------------------------------
     4                                  ; Last Update: 07/03/2021
     5                                  ; ----------------------------------------------------------------------------
     6                                  ; Beginning: 04/01/2016
     7                                  ; ----------------------------------------------------------------------------
     8                                  ; Assembler: NASM version 2.15 (trdos386.s)
     9                                  ; ----------------------------------------------------------------------------
    10                                  ; Turkish Rational DOS
    11                                  ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                                  ;
    13                                  ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    14                                  ; unix386.s (03/01/2016)
    15                                  ;
    16                                  ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    17                                  ; TRDOS2.ASM (09/11/2011)
    18                                  ; 
    19                                  ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
    20                                  ; ****************************************************************************
    21                                  ; nasm trdos386.s -l trdos386.txt -o TRDOS386.SYS
    22                                  
    23                                  
    24                                  KLOAD	equ 10000h ; Kernel loading address
    25                                  	; NOTE: Retro UNIX 8086 v1 boot code loads kernel at 1000h:0000h 
    26                                  KCODE	equ 08h	; Code segment descriptor (ring 0)
    27                                  KDATA	equ 10h	; Data segment descriptor (ring 0)
    28                                  ; 19/03/2015
    29                                  UCODE	equ 1Bh ; 18h + 3h  (ring 3)
    30                                  UDATA	equ 23h ; 20h + 3h  (ring 3)
    31                                  ; 24/03/2015
    32                                  TSS	equ 28h	; Task state segment descriptor (ring 0)
    33                                  ; 19/03/2015
    34                                  CORE	equ 400000h  ; Start of USER's virtual/linear address space 
    35                                  		     ; (at the end of the 1st 4MB)
    36                                  ECORE	equ 0FFC00000h ; End of USER's virtual address space (4GB - 4MB)
    37                                  		     ; ULIMIT = (ECORE/4096) - 1 = 0FFBFFh (in GDT)
    38                                  
    39                                  ;; 27/12/2013
    40                                  ;KEND	equ KLOAD + 65536 ; (28/12/2013) (end of kernel space)
    41                                  ; 04/07/2016
    42                                  KEND    equ KERNELFSIZE + KLOAD
    43                                  
    44                                  
    45                                  ; IBM PC/AT BIOS ----- 10/06/85 (postequ.inc)
    46                                  ;--------- CMOS TABLE LOCATION ADDRESS'S -------------------------------------
    47                                  CMOS_SECONDS	EQU	00H		; SECONDS (BCD)
    48                                  CMOS_SEC_ALARM	EQU	01H		; SECONDS ALARM (BCD)
    49                                  CMOS_MINUTES	EQU	02H		; MINUTES (BCD)
    50                                  CMOS_MIN_ALARM	EQU	03H		; MINUTES ALARM (BCD) 	
    51                                  CMOS_HOURS	EQU	04H		; HOURS (BCD
    52                                  CMOS_HR_ALARM	EQU	005H		; HOURS ALARM   (BCD)
    53                                  CMOS_DAY_WEEK	EQU	06H		; DAY OF THE WEEK  (BCD)
    54                                  CMOS_DAY_MONTH	EQU	07H		; DAY OF THE MONTH (BCD) 
    55                                  CMOS_MONTH	EQU	08H		; MONTH (BCD)
    56                                  CMOS_YEAR	EQU	09H		; YEAR (TWO DIGITS) (BCD)
    57                                  CMOS_CENTURY	EQU	32H		; DATE CENTURY BYTE (BCD)
    58                                  CMOS_REG_A	EQU	0AH		; STATUS REGISTER A
    59                                  CMOS_REG_B	EQU	00BH		; STATUS REGISTER B  ALARM
    60                                  CMOS_REG_C	EQU	00CH		; STATUS REGISTER C  FLAGS
    61                                  CMOS_REG_D	EQU	0DH		; STATUS REGISTER D  BATTERY
    62                                  CMOS_SHUT_DOWN	EQU	0FH		; SHUTDOWN STATUS COMMAND BYTE
    63                                  ;----------------------------------------
    64                                  ;	CMOS EQUATES FOR THIS SYSTEM	;
    65                                  ;-----------------------------------------------------------------------------
    66                                  CMOS_PORT	EQU	070H		; I/O ADDRESS OF CMOS ADDRESS PORT
    67                                  CMOS_DATA	EQU	071H		; I/O ADDRESS OF CMOS DATA PORT
    68                                  NMI		EQU	10000000B	; DISABLE NMI INTERRUPTS MASK -
    69                                  					; HIGH BIT OF CMOS LOCATION ADDRESS
    70                                  
    71                                  ; Memory Allocation Table Address
    72                                  ; 05/11/2014
    73                                  ; 31/10/2014
    74                                  MEM_ALLOC_TBL	equ	100000h		; Memory Allocation Table at the end of
    75                                  					; the 1st 1 MB memory space.
    76                                  					; (This address must be aligned
    77                                  					;  on 128 KB boundary, if it will be
    78                                  					;  changed later.)
    79                                  					; ((lower 17 bits of 32 bit M.A.T.
    80                                  					;   address must be ZERO)).
    81                                  					; ((((Reason: 32 bit allocation 
    82                                  					;     instructions, dword steps)))
    83                                  					; (((byte >> 12 --> page >> 5)))  
    84                                  ;04/11/2014	
    85                                  PDE_A_PRESENT	equ	1		; Present flag for PDE
    86                                  PDE_A_WRITE	equ 	2		; Writable (write permission) flag
    87                                  PDE_A_USER	equ	4		; User (non-system/kernel) page flag
    88                                  ;
    89                                  PTE_A_PRESENT	equ	1		; Present flag for PTE (bit 0)
    90                                  PTE_A_WRITE	equ 	2		; Writable (write permission) flag (bit 1)
    91                                  PTE_A_USER	equ	4		; User (non-system/kernel) page flag (bit 2)
    92                                  PTE_A_ACCESS    equ	32		; Accessed flag (bit 5) ; 09/03/2015
    93                                  
    94                                  ; 17/02/2015 (unix386.s)
    95                                  ; 10/12/2014 - 30/12/2014 (0B000h -> 9000h) (dsectrm2.s)
    96                                  DPT_SEGM equ 09000h  ; FDPT segment (EDD v1.1, EDD v3)
    97                                  ;
    98                                  HD0_DPT	 equ 0	    ; Disk parameter table address for hd0
    99                                  HD1_DPT	 equ 32	    ; Disk parameter table address for hd1
   100                                  HD2_DPT	 equ 64	    ; Disk parameter table address for hd2
   101                                  HD3_DPT	 equ 96	    ; Disk parameter table address for hd3
   102                                  
   103                                  ; 15/11/2020
   104                                  VBE3INFOSEG equ 97E0h ; 512 bytes before Video_Pg_Backup
   105                                  ; 15/12/2020
   106                                  VBE3MODEINFOSEG equ 97C0h ; 512 bytes before VBE3INFOBLOCK 
   107                                  
   108                                  ; 29/11/2020
   109                                  VBE3INFOBLOCK equ 97E00h ; linear address (512 bytes)
   110                                  VBE3MODEINFOBLOCK equ 97C00h ; linear address (256 bytes)
   111                                  VBE3SAVERESTOREBLOCK equ 97600h ; linear address (2048 bytes)
   112                                  VBE3CRTCINFOBLOCK equ 97D80h ; linear address (64 bytes) ; 17/01/2021 
   113                                  VBE3BIOSDATABLOCK equ 97000h ; linear address (1536 bytes)
   114                                  VBE3STACKADDR equ 96000h ; linear address (1024 bytes)
   115                                  ; VBE3 32 bit Protected Mode Interface (16 bit) Selectors (in GDT)
   116                                  VBE3CS equ 30h ; _vbe3_CS:
   117                                  VBE3BDS equ 38h ; _vbe3_BDS:
   118                                  VBE3A000 equ 40h ; _A0000Sel:
   119                                  VBE3B000 equ 48h ; _B0000Sel:
   120                                  VBE3B800 equ 50h ; _B8000Sel:
   121                                  VBE3DS equ 58h ; _vbe3_DS:
   122                                  VBE3SS equ 60h ; _vbe3_SS:
   123                                  VBE3ES equ 68h ; _vbe3_ES:
   124                                  KCODE16 equ 70h ; _16bit_CS:
   125                                  ; 14/01/2021
   126                                  ; 06/12/2020
   127                                  VBE3VIDEOSTATE equ 95800h ; 2048 bytes
   128                                  ; 05/01/2021
   129                                  VGAFONT16USER equ 94000h ; 8x16 pixels user font (256 chars)	
   130                                  			 ; (reserved/allocated font space: 4096 bytes) 
   131                                  
   132                                  VGAFONT8USER equ 95000h	; 8x8 pixels user font (256 chars)	
   133                                  			; (reserved/allocated font space: 2048 bytes)
   134                                  ; 17/01/2021
   135                                  ; temporary (initial) location for EDID information
   136                                  VBE3EDIDINFOBLOCK equ 97D00h ; linear address (128 bytes)
   137                                   
   138                                  ; FDPT (Phoenix, Enhanced Disk Drive Specification v1.1, v3.0)
   139                                  ;      (HDPT: Programmer's Guide to the AMIBIOS, 1993)
   140                                  ;
   141                                  FDPT_CYLS	equ 0 ; 1 word, number of cylinders
   142                                  FDPT_HDS	equ 2 ; 1 byte, number of heads
   143                                  FDPT_TT		equ 3 ; 1 byte, A0h = translated FDPT with logical values
   144                                  		      ; otherwise it is standard FDPT with physical values 	
   145                                  FDPT_PCMP	equ 5 ; 1 word, starting write precompensation cylinder
   146                                  		      ; (obsolete for IDE/ATA drives)
   147                                  FDPT_CB		equ 8 ; 1 byte, drive control byte
   148                                  			; Bits 7-6 : Enable or disable retries (00h = enable)
   149                                  			; Bit 5	: 1 = Defect map is located at last cyl. + 1
   150                                  			; Bit 4 : Reserved. Always 0
   151                                  			; Bit 3 : Set to 1 if more than 8 heads
   152                                  			; Bit 2-0 : Reserved. Always 0
   153                                  FDPT_LZ		equ 12 ; 1 word, landing zone (obsolete for IDE/ATA drives)
   154                                  FDPT_SPT	equ 14 ; 1 byte, sectors per track
   155                                  
   156                                  ; Floppy Drive Parameters Table (Programmer's Guide to the AMIBIOS, 1993)
   157                                  ; (11 bytes long) will be used by diskette handler/bios
   158                                  ; which is derived from IBM PC-AT BIOS (DISKETTE.ASM, 21/04/1986).
   159                                  
   160                                  ; 01/02/2016
   161                                  Logical_DOSDisks equ 90000h + 100h ; 26*256 = 6656 bytes
   162                                  Directory_Buffer equ 80000h ; max = 64K Bytes
   163                                  FAT_Buffer	 equ 91C00h ; 1536 bytes (3 sectors)
   164                                  ; 15/02/2016
   165                                  Cluster_Buffer	 equ 70000h ; max = 64K Bytes ; buffer for file read & write
   166                                  ; 11/04/2016
   167                                  Env_Page:	 equ 93000h ; 512 bytes (4096 bytes)
   168                                  Env_Page_Size	 equ 512    ; (4096 bytes)
   169                                  ; 30/07/2016
   170                                  Video_Pg_Backup	 equ 98000h ; Mode 3h, video page backup (32K, 8 pages)
   171                                  
   172                                  ; 29/11/2020
   173                                  ; Free/Reserved memory blocks (in 1st 1MB): 93200h to 96000h (available)
   174                                  ; 06/12/2020
   175                                  ; Free/Reserved memory blocks (in 1st 1MB): 93200h to 95800h (available)
   176                                  
   177                                  ; 15/12/2020
   178                                  LFB_ADDR	equ LFB_Info+LFBINFO.LFB_addr
   179                                  LFB_SIZE	equ LFB_Info+LFBINFO.LFB_size
   180                                   
   181                                  [BITS 16]       ; We need 16-bit intructions for Real mode
   182                                  
   183                                  [ORG 0] 
   184                                  	; 12/11/2014
   185                                  	; Save boot drive number (that is default root drive)
   186 00000000 8816[0A6E]              	mov	[boot_drv], dl ; physical drv number
   187                                  
   188                                  	; Determine installed memory
   189                                  	; 31/10/2014
   190                                  	;
   191 00000004 B801E8                  	mov	ax, 0E801h ; Get memory size 
   192 00000007 CD15                    	int	15h	   ; for large configurations
   193 00000009 7308                    	jnc	short chk_ms
   194 0000000B B488                    	mov	ah, 88h    ; Get extended memory size 
   195 0000000D CD15                    	int	15h
   196                                  	;	   
   197                                  	;mov	al, 17h	; Extended memory (1K blocks) low byte
   198                                  	;out	70h, al ; select CMOS register
   199                                  	;in	al, 71h ; read data (1 byte)
   200                                  	;mov	cl, al
   201                                  	;mov	al, 18h ; Extended memory (1K blocks) high byte
   202                                  	;out	70h, al ; select CMOS register
   203                                  	;in	al, 71h ; read data (1 byte)
   204                                  	;mov	ch, al
   205                                   	;      
   206 0000000F 89C1                    	mov	cx, ax
   207 00000011 31D2                    	xor	dx, dx
   208                                  chk_ms:
   209 00000013 890E[066E]              	mov	[mem_1m_1k], cx
   210 00000017 8916[086E]              	mov	[mem_16m_64k], dx
   211                                  	; 05/11/2014
   212                                  	;and	dx, dx
   213                                  	;jz	short L2
   214 0000001B 81F90004                        cmp     cx, 1024
   215                                  	;jnb	short L0
   216 0000001F 7351                    	jnb	short V0 ; 14/11/2020
   217                                  		 ; insufficient memory_error	
   218                                  		 ; Minimum 2 MB memory is needed... 
   219                                  	; 05/11/2014
   220                                  	; (real mode error printing)
   221 00000021 FB                      	sti
   222 00000022 BE[3600]                	mov	si, msg_out_of_memory
   223 00000025 BB0700                  	mov	bx, 7
   224 00000028 B40E                    	mov	ah, 0Eh	; write tty
   225                                  oom_1:
   226 0000002A AC                      	lodsb
   227 0000002B 08C0                    	or	al, al
   228 0000002D 7404                    	jz	short oom_2
   229 0000002F CD10                    	int	10h
   230 00000031 EBF7                    	jmp	short oom_1
   231                                  oom_2:
   232 00000033 F4                              hlt
   233 00000034 EBFD                    	jmp	short oom_2
   234                                  
   235                                  ; 20/02/2017
   236                                  ; 05/11/2014
   237                                  msg_out_of_memory:
   238 00000036 070D0A                  	db 	07h, 0Dh, 0Ah
   239 00000039 496E73756666696369-             db      'Insufficient memory !'
   239 00000042 656E74206D656D6F72-
   239 0000004B 792021             
   240 0000004E 0D0A                    	db	0Dh, 0Ah
   241                                  _int13h_48h_buffer: ; 07/07/2016
   242 00000050 284D696E696D756D20-     	db	'(Minimum 2MB memory is needed.)'
   242 00000059 324D42206D656D6F72-
   242 00000062 79206973206E656564-
   242 0000006B 65642E29           
   243 0000006F 0D0A00                   	db	0Dh, 0Ah, 0
   244                                  V0:
   245                                  	; 15/12/2020
   246 00000072 8B36[086E]              	mov	si, [mem_16m_64k]
   247 00000076 8936[E90E]              	mov	[real_mem_16m_64k], si
   248                                  	; 15/11/2020
   249                                  	; 14/11/2020 (TRDOS 386 v2.0.3)
   250                                  	; check VESA (VBE) VIDEO BIOS version
   251                                  
   252 0000007A B8034F                  	mov	ax, 4F03h  ; Return current VBE mode
   253 0000007D CD10                    	int	10h
   254 0000007F 83F84F                  	cmp	ax, 004Fh  ; successful (vbe) function call
   255 00000082 7567                    	jne	short L0   ; not a VESA VBE compatible bios	
   256                                  
   257                                  	;mov	ah, 3
   258                                  	;;jmp	short v1	
   259                                  	
   260                                  	; 15/11/2020
   261 00000084 BBE097                  	mov	bx, VBE3INFOSEG  ; 97E0h for current version 
   262 00000087 8EC3                    	mov	es, bx
   263 00000089 31FF                    	xor	di, di
   264 0000008B 2666C70556424532        	mov	dword [es:di], 'VBE2' ; request VESA VBE3 info
   265                                  		; es:di = buffer address (512 bytes)
   266                                  	;mov	ax, 4F00h ; Return VBE controller information
   267 00000093 86C4                    	xchg	al, ah
   268 00000095 CD10                    	int	10h
   269                                  	
   270                                  	; dx = cs
   271                                  	; es = VBE3INFOSEG (97E0h)
   272                                  	; di = 0
   273                                  	; ss = (endofkernelfile/16)+16
   274                                  	; sp = 0FFFEh
   275                                  
   276 00000097 83F84F                  	cmp	ax, 004Fh
   277 0000009A 754D                    	jne	short V1 ; old vga bios (not VESA compatible)
   278                                  
   279                                  	; 15/11/2020
   280 0000009C 2666813D56455341        	cmp	dword [es:di], 'VESA'
   281 000000A4 7543                    	jne	short V1
   282                                  	
   283                                  	;mov	ax, [es:di+4]
   284                                  	;	; ax = vbe version in BCD format (0200h or 0300h)
   285                                  	;mov	[vbe3], ah ; version number (major) 	
   286                                  
   287                                  	; 15/11/2020
   288 000000A6 268A4505                	mov	al, [es:di+5]
   289                                  		; al = high byte of VBE version number (02h or 03h)
   290                                  
   291 000000AA A2[5C09]                	mov	[vbe3], al ; version number (major) 	
   292                                  			   ; 02h or 03h is expected
   293                                  	; 17/01/2021
   294                                  	; Read EDID
   295 000000AD B301                    	mov	bl, 01h	; Read EDID
   296 000000AF 31C9                    	xor	cx, cx	; Controller unit number
   297                                  			; (00 = primary controller)
   298 000000B1 31D2                    	xor	dx, dx	; EDID block number = 0
   299 000000B3 B8C097                  	mov	ax, VBE3MODEINFOSEG  ; 97C0h for current version
   300 000000B6 8EC0                    	mov	es, ax
   301 000000B8 BF0001                  	mov	di, VBE3EDIDINFOBLOCK - VBE3MODEINFOBLOCK
   302                                  	; es:di = temporary address of 128 bytes EDID information 
   303 000000BB B8154F                  	mov	ax, 4F15h ; VBE/DDC Services 
   304 000000BE CD10                    	int	10h
   305                                  	;cmp	ax, 4Fh
   306                                  	;jne	short v2
   307 000000C0 A2[3743]                	mov	[edid], al ; 4Fh > 0	
   308                                  ;V2:
   309                                  	; 17/01/2021
   310 000000C3 31FF                    	xor	di, di
   311                                  	; 15/12/2020
   312                                  	; Get linear frame buffer info (for VESA VBE mode 118h)
   313                                  	;mov	si, VBE3MODEINFOSEG  ; 97C0h for current version
   314                                  	;mov	es, si
   315                                   	; di = 0
   316 000000C5 B91841                  	mov	cx, 04118h  ; 1024*768, 24 bpp, LFB
   317 000000C8 B8014F                  	mov	ax, 4F01h ; Return VBE mode information
   318 000000CB CD10                    	int	10h
   319                                  	;cmp	ax, 4Fh
   320                                  	;jne	short V1
   321                                  	; 19/12/2020
   322                                  	;mov	si, [es:di+MODEINFO.PhysBasePtr+2]
   323                                  			; hw of LFB base address
   324                                  	; MODEINFO structure starts from offset -2
   325 000000CD 268B752A                	mov	si, [es:di+MODEINFO.PhysBasePtr] ; hw of LFB addr
   326 000000D1 8936[EB0E]              	mov	[def_LFB_addr], si ; k_LFB_size = 3145728 bytes
   327 000000D5 81EE0001                	sub	si, 256
   328                                  	
   329                                  	; 15/12/2020
   330                                  	; check memory and decrease it to 3.5 GB if it is 4GB
   331                                  	; (reserve upper memory for LFB)
   332 000000D9 8B3E[086E]              	mov	di, [mem_16m_64k]
   333 000000DD 893E[E90E]              	mov	[real_mem_16m_64k], di
   334                                  
   335 000000E1 39F7                    	cmp	di, si
   336 000000E3 7604                    	jna	short V1
   337                                  
   338 000000E5 8936[086E]              	mov	[mem_16m_64k], si
   339                                  
   340                                  	; VESA VBE3 video hardware 
   341                                  	; (example: NVIDIA GEFORCE FX550, 256 MB)
   342                                  	; uses upper memory from 0D0000000h to 0DFFFFFFFh
   343                                  	
   344                                  	;;cmp	di, 0CF00h ; 3328 MB - 16MB
   345                                  	;jna	short V1  ; <= 3328 MB memory, it is not required
   346                                  			  ; decrease
   347                                  	;cmp	al, 3 
   348                                  	;jb	short V2 
   349                                  	; VESA VBE 3
   350                                  	;mov	word [mem_16m_64k], 0CF00h ; 3328 MB - 16MB
   351                                  	;jmp	short V1 	
   352                                  ;V2:
   353                                  	; VESA VBE 2
   354                                  	; Check Bochs/Qemu/VirtualBox Emulator
   355                                  	; LFB base address: 0E0000000h
   356                                  	;sub	ax, ax ; 0
   357                                  	;mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
   358                                  	;out	dx, ax ; VBE_DISPI_INDEX_ID register
   359                                  	;inc	dx
   360                                  	;in	ax, dx
   361                                  	;and	al, 0F0h
   362                                  	;cmp	ax, 0B0C0h
   363                                  	;jne	short V1
   364                                  	;
   365                                  	; BOCHS/QEMU/VIRTUALBOX
   366                                  	;mov	word [mem_16m_64k], 0DF00h ; 3584 MB - 16MB	
   367                                  V1:
   368 000000E9 1E                      	push	ds
   369 000000EA 07                      	pop	es ; restore extra data segment	
   370                                  L0:
   371                                  
   372                                  %include 'diskinit.s' ; 07/03/2015
   373                              <1> ; ****************************************************************************
   374                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.2 - diskinit.s
   375                              <1> ; ----------------------------------------------------------------------------
   376                              <1> ; Last Update: 29/08/2020
   377                              <1> ; ----------------------------------------------------------------------------
   378                              <1> ; Beginning: 24/01/2016
   379                              <1> ; ----------------------------------------------------------------------------
   380                              <1> ; Assembler: NASM version 2.14 (trdos386.s)
   381                              <1> ; ----------------------------------------------------------------------------
   382                              <1> ; Turkish Rational DOS
   383                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
   384                              <1> ;
   385                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
   386                              <1> ; diskinit.inc (10/07/2015)
   387                              <1> ;
   388                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
   389                              <1> ; ****************************************************************************
   390                              <1> 
   391                              <1> ; Retro UNIX 386 v1 Kernel - DISKINIT.INC
   392                              <1> ; Last Modification: 10/07/2015
   393                              <1> 
   394                              <1> ; DISK I/O SYSTEM INITIALIZATION - Erdogan Tan (Retro UNIX 386 v1 project)
   395                              <1> 
   396                              <1> ; ///////// DISK I/O SYSTEM STRUCTURE INITIALIZATION ///////////////
   397                              <1> 
   398                              <1> 	; 29/08/2020
   399                              <1> 	; 17/07/2020
   400                              <1> 	; 14/07/2020 (TRDOS 386 v2.0.2)
   401                              <1> 	; 10/12/2014 - 02/02/2015 - dsectrm2.s
   402                              <1> ;L0:
   403                              <1> 	; 12/11/2014 (Retro UNIX 386 v1 - beginning)
   404                              <1> 	; Detecting disk drives... (by help of ROM-BIOS)
   405 000000EB BA7F00              <1> 	mov	dx, 7Fh
   406                              <1> L1:	
   407 000000EE FEC2                <1> 	inc	dl
   408 000000F0 B441                <1> 	mov	ah, 41h ; Check extensions present
   409                              <1> 			; Phoenix EDD v1.1 - EDD v3
   410 000000F2 BBAA55              <1> 	mov	bx, 55AAh
   411 000000F5 CD13                <1> 	int 	13h
   412 000000F7 721A                <1> 	jc	short L2
   413                              <1> 
   414 000000F9 81FB55AA            <1> 	cmp	bx, 0AA55h
   415 000000FD 7514                <1> 	jne	short L2
   416 000000FF FE06[0D6E]          <1> 	inc	byte [hdc]	; count of hard disks (EDD present)
   417 00000103 8816[0C6E]          <1>         mov     [last_drv], dl  ; last hard disk number
   418 00000107 BB[906D]            <1> 	mov	bx, hd0_type - 80h
   419 0000010A 01D3                <1> 	add	bx, dx	 
   420 0000010C 880F                <1> 	mov	[bx], cl ; Interface support bit map in CX
   421                              <1> 			 ; Bit 0 - 1, Fixed disk access subset ready
   422                              <1> 			 ; Bit 1 - 1, Drv locking and ejecting ready
   423                              <1> 			 ; Bit 2 - 1, Enhanced Disk Drive Support
   424                              <1>                          ;            (EDD) ready (DPTE ready)
   425                              <1> 			 ; Bit 3 - 1, 64bit extensions are present
   426                              <1>                          ;            (EDD-3)
   427                              <1> 			 ; Bit 4 to 15 - 0, Reserved
   428 0000010E 80FA83              <1> 	cmp	dl, 83h	 ; drive number < 83h
   429 00000111 72DB                <1> 	jb	short L1
   430                              <1> L2:
   431                              <1> 	; 23/11/2014
   432                              <1> 	; 19/11/2014
   433 00000113 30D2                <1> 	xor	dl, dl  ; 0
   434                              <1> 	; 04/02/2016 (esi -> si)
   435 00000115 BE[0E6E]            <1> 	mov	si, fd0_type
   436                              <1> L3:
   437                              <1> 	; 14/01/2015
   438 00000118 8816[0B6E]          <1> 	mov	[drv], dl
   439                              <1> 	;
   440 0000011C B408                <1> 	mov 	ah, 08h ; Return drive parameters
   441 0000011E CD13                <1> 	int	13h	
   442 00000120 7210                <1> 	jc	short L4
   443                              <1> 		; BL = drive type (for floppy drives)
   444                              <1> 		; DL = number of floppy drives
   445                              <1> 		;		
   446                              <1> 		; ES:DI = Address of DPT from BIOS
   447                              <1> 		;
   448 00000122 881C                <1> 	mov	[si], bl ;  Drive type
   449                              <1> 			; 4 = 1.44 MB, 80 track, 3 1/2"
   450                              <1> 	; 14/01/2015
   451 00000124 E8DE01              <1> 	call	set_disk_parms
   452                              <1> 	; 10/12/2014
   453 00000127 81FE[0E6E]          <1> 	cmp	si, fd0_type
   454 0000012B 7705                <1> 	ja	short L4
   455 0000012D 46                  <1> 	inc	si ; fd1_type
   456 0000012E B201                <1> 	mov	dl, 1
   457 00000130 EBE6                <1> 	jmp	short L3
   458                              <1> L4:
   459 00000132 B27F                <1> 	mov	dl, 7Fh
   460                              <1> 	; 24/12/2014
   461 00000134 803E[0D6E]00        <1> 	cmp	byte [hdc], 0 ; EDD present or not ?	
   462 00000139 0F878700            <1>         ja      L10       ; yes, all fixed disk operations
   463                              <1> 			  ; will be performed according to
   464                              <1> 			  ; present EDD specification
   465                              <1> 
   466                              <1> 	; 17/07/2020
   467                              <1> 	; Note: Virtual CPU will not come here while 
   468                              <1> 	; running in QEMU, Bochs, VirtualBox emulators !!!
   469                              <1> 	
   470                              <1> 	; 17/07/2020
   471                              <1> 	; Older BIOS (INT 13h, AH = 48h is not available)
   472                              <1> L6:
   473 0000013D FEC2                <1> 	inc 	dl
   474 0000013F 8816[0B6E]          <1>         mov     [drv], dl
   475 00000143 8816[0C6E]          <1>         mov     [last_drv], dl ; 14/01/2015
   476 00000147 B408                <1> 	mov 	ah, 08h ; Return drive parameters
   477 00000149 CD13                <1> 	int	13h	; (conventional function)
   478 0000014B 0F82A801            <1>         jc      L13	; fixed disk drive not ready
   479 0000014F 8816[0D6E]          <1>         mov     [hdc], dl ; number of drives
   480                              <1> 	;; 14/01/2013
   481                              <1> 	;;push	cx
   482 00000153 E8AF01              <1> 	call	set_disk_parms
   483                              <1> 	;;pop	cx
   484                              <1> 	;
   485                              <1> 	;;and	cl, 3Fh	 ; sectors per track (bits 0-6)
   486 00000156 8A16[0B6E]          <1>         mov     dl, [drv]
   487 0000015A BB0401              <1> 	mov	bx, 65*4 ; hd0 parameters table (INT 41h)	
   488 0000015D 80FA80              <1> 	cmp	dl, 80h
   489 00000160 7603                <1> 	jna	short L7
   490 00000162 83C314              <1> 	add	bx, 5*4	 ; hd1 parameters table (INT 46h)
   491                              <1> L7:	
   492 00000165 31C0                <1> 	xor	ax, ax
   493 00000167 8ED8                <1> 	mov	ds, ax
   494 00000169 8B37                <1>         mov     si, [bx]
   495 0000016B 8B4702              <1>         mov     ax, [bx+2] 
   496 0000016E 8ED8                <1> 	mov	ds, ax
   497 00000170 3A4C0E              <1>         cmp     cl, [si+FDPT_SPT] ; sectors per track 
   498 00000173 0F857C01            <1>         jne     L12 ; invalid FDPT
   499 00000177 BF0000              <1> 	mov	di, HD0_DPT
   500 0000017A 80FA80              <1> 	cmp	dl, 80h
   501 0000017D 7603                <1> 	jna	short L8
   502 0000017F BF2000              <1> 	mov	di, HD1_DPT 
   503                              <1> L8:
   504                              <1> 	; 30/12/2014
   505 00000182 B80090              <1> 	mov	ax, DPT_SEGM
   506 00000185 8EC0                <1> 	mov	es, ax
   507                              <1> 	; 24/12/2014
   508 00000187 B90800              <1> 	mov	cx, 8
   509 0000018A F3A5                <1> 	rep	movsw  ; copy 16 bytes to the kernel's DPT location
   510 0000018C 8CC8                <1> 	mov	ax, cs
   511 0000018E 8ED8                <1> 	mov	ds, ax
   512                              <1> 
   513                              <1> 	; 02/02/2015
   514                              <1> 	;mov	cl, [drv]
   515                              <1> 	;mov	bl, cl
   516                              <1> 	;mov	ax, 1F0h
   517                              <1> 	;and	bl, 1
   518                              <1> 	;jz	short L9
   519                              <1> 	;shl	bl, 4
   520                              <1> 	;sub	ax, 1F0h-170h
   521                              <1> 
   522                              <1> 	; 17/07/2020 
   523                              <1> 	; (Only 1F0h port address must be valid for old ROM BIOSes)
   524 00000190 B8F001              <1> 	mov	ax, 1F0h
   525 00000193 B3A0                <1> 	mov	bl, 0A0h
   526 00000195 80FA80              <1> 	cmp	dl, 80h
   527 00000198 7603                <1> 	jna	short L9
   528                              <1> 	; dl = 81h
   529 0000019A 80C310              <1> 	add	bl, 10h  ; slave disk
   530                              <1> 	;sub	ax, 1F0h-170h
   531                              <1> L9:
   532 0000019D AB                  <1> 	stosw	; I/O PORT Base Address (1F0h, 170h)
   533 0000019E 050602              <1> 	add	ax, 206h
   534 000001A1 AB                  <1> 	stosw	; CONTROL PORT Address (3F6h, 376h)	
   535 000001A2 88D8                <1> 	mov	al, bl  ; bit 4, master/slave disk bit
   536                              <1> 	;add	al, 0A0h ; 17/07/2020
   537 000001A4 AA                  <1> 	stosb	; Device/Head Register upper nibble
   538                              <1> 	;
   539 000001A5 FE06[0B6E]          <1> 	inc	byte [drv]
   540 000001A9 BB[906D]            <1> 	mov	bx, hd0_type - 80h
   541 000001AC 01CB                <1> 	add	bx, cx
   542 000001AE 800F80              <1>         or      byte [bx], 80h  ; present sign (when lower nibble is 0)
   543 000001B1 A0[0D6E]            <1> 	mov	al, [hdc]
   544 000001B4 FEC8                <1> 	dec	al
   545 000001B6 0F843D01            <1>         jz      L13
   546 000001BA 80FA80              <1> 	cmp	dl, 80h
   547 000001BD 0F867CFF            <1>         jna	L6 ; Max. 2 hard disks  ; 17/07/2020 
   548 000001C1 E93301              <1>         jmp     L13
   549                              <1> L10:
   550 000001C4 FEC2                <1> 	inc 	dl
   551                              <1> 	; 25/12/2014
   552 000001C6 8816[0B6E]          <1> 	mov	[drv], dl
   553 000001CA B408                <1> 	mov 	ah, 08h ; Return drive parameters
   554 000001CC CD13                <1> 	int	13h	; (conventional function)
   555 000001CE 0F822501            <1>         jc      L13
   556                              <1> 	; 14/01/2015
   557 000001D2 8A16[0B6E]          <1> 	mov	dl, [drv]
   558 000001D6 52                  <1> 	push	dx
   559 000001D7 51                  <1> 	push	cx
   560 000001D8 E82A01              <1> 	call	set_disk_parms
   561 000001DB 59                  <1> 	pop	cx
   562 000001DC 5A                  <1> 	pop	dx
   563                              <1> 	; 06/07/2016 (BugFix for >64K kernel files)
   564                              <1> 	; 04/02/2016 (esi -> si)
   565                              <1> 	;mov	si, _end ; 30 byte temporary buffer address 	
   566                              <1> 	;		 ; at the '_end' of kernel.
   567                              <1> 	;mov	word [si], 30
   568                              <1> 	; 06/07/2016
   569 000001DD BE[5000]            <1> 	mov	si, _int13h_48h_buffer
   570                              <1> 	; 09/07/2016
   571 000001E0 B81E00              <1> 	mov	ax, 001Eh
   572 000001E3 8824                <1> 	mov	[si], ah ; 0
   573 000001E5 46                  <1> 	inc	si
   574 000001E6 8904                <1> 	mov	word [si], ax
   575                              <1>  	; word [si] = 30
   576                              <1> 	;
   577 000001E8 B448                <1> 	mov	ah, 48h	 ; Get drive parameters (EDD function)
   578 000001EA CD13                <1> 	int	13h
   579 000001EC 0F820701            <1>         jc      L13
   580                              <1> 
   581                              <1> 	; 29/08/2020
   582                              <1> 	; 04/02/2016 (ebx -> bx)
   583                              <1> 	; 14/01/2015
   584 000001F0 28FF                <1> 	sub	bh, bh
   585 000001F2 88D3                <1> 	mov	bl, dl
   586                              <1> 	;sub	bl, 80h
   587                              <1> 	; 29/08/2020
   588 000001F4 81C3[906D]          <1> 	add	bx, (hd0_type - 80h)
   589                              <1> 	;mov 	al, [bx]
   590 000001F8 8A07                <1> 	mov	al, [bx]
   591 000001FA 0C80                <1> 	or	al, 80h
   592 000001FC 8807                <1> 	mov 	[bx], al	
   593 000001FE 81EB[0E6E]          <1> 	sub	bx, hd0_type - 2 ; 15/01/2015
   594                              <1> 	;add	bx, drv.status
   595                              <1> 	;mov	[bx], al
   596                              <1> 	; 29/08/2020
   597 00000202 8887[5A6E]          <1> 	mov	[bx+drv.status], al
   598                              <1> 	; 04/02/2016 (eax -> ax)
   599                              <1> 	;mov	ax, [si+16]
   600                              <1> 	; 14/07/2020
   601                              <1> 	;mov	di, [si+18] 
   602                              <1> 	;;test	ax, [si+18]
   603                              <1> 	;test	ax, di ; 14/07/2020
   604                              <1> 	;jz	short L10_A0h ; (!) ; 17/07/2020
   605                              <1> 			; 'CHS only' disks on EDD system 
   606                              <1> 			;  are reported with ZERO disk size
   607                              <1> 			; (if so, we must not overwrite
   608                              <1> 			; calculated disk size in 'set_disk_parms')
   609                              <1> 	; 29/08/2020
   610 00000206 8B4410              <1> 	mov	ax, [si+16]
   611 00000209 8B7C12              <1> 	mov	di, [si+18]
   612 0000020C 09C0                <1> 	or	ax, ax
   613 0000020E 7504                <1> 	jnz	short L10_LBA
   614 00000210 09FF                <1> 	or	di, di
   615 00000212 740B                <1> 	jz	short L10_A0h
   616                              <1> L10_LBA:
   617                              <1> 	;sub	bx, drv.status
   618 00000214 C1E302              <1> 	shl	bx, 2
   619                              <1> 	;add	bx, drv.size ; disk size (in sectors)
   620                              <1> 	;mov	[bx], ax
   621                              <1> 	; 29/08/2020
   622 00000217 8987[3E6E]          <1> 	mov	[bx+drv.size], ax
   623                              <1> 	;mov	ax, [si+18]
   624                              <1> 	;;mov	[bx], ax
   625                              <1> 	;mov	[bx+2], ax ; BugFix ; 15/07/2020
   626                              <1> 	; 14/07/2020
   627                              <1> 	;mov	[bx+2], di ; 15/07/2020
   628                              <1> 	; 29/08/2020
   629 0000021B 89BF[406E]          <1> 	mov	[bx+drv.size+2], di
   630                              <1> L10_A0h: 
   631                              <1> 	; 17/07/2020
   632                              <1> 	; Note: Virtual CPU will jump here from above (!) test
   633                              <1> 	;	while running in QEMU
   634                              <1> 
   635                              <1> 	; Jump here to fix a ZERO (LBA) disk size problem 
   636                              <1> 	; for CHS disks (28/02/2015)
   637                              <1> 	
   638                              <1> 	; 30/12/2014
   639 0000021F BF0000              <1> 	mov	di, HD0_DPT
   640 00000222 88D0                <1> 	mov	al, dl
   641 00000224 83E003              <1> 	and 	ax, 3
   642 00000227 C0E005              <1> 	shl	al, 5 ; * 32
   643 0000022A 01C7                <1> 	add 	di, ax
   644 0000022C B80090              <1> 	mov	ax, DPT_SEGM
   645 0000022F 8EC0                <1> 	mov	es, ax
   646                              <1> 	;
   647 00000231 88E8                <1> 	mov	al, ch	; max. cylinder number (bits 0-7)
   648 00000233 88CC                <1> 	mov	ah, cl	
   649 00000235 C0EC06              <1> 	shr	ah, 6	; max. cylinder number (bits 8-9)
   650 00000238 40                  <1>  	inc	ax	; logical cylinders (limit 1024)
   651 00000239 AB                  <1> 	stosw		
   652 0000023A 88F0                <1> 	mov	al, dh	; max. head number
   653                              <1> 	;
   654 0000023C 30F6                <1> 	xor	dh, dh  ; 29/08/2020 (dh = 0 is needed here)
   655                              <1> 	;
   656 0000023E FEC0                <1> 	inc	al
   657 00000240 AA                  <1> 	stosb		; logical heads (limits 256)
   658 00000241 B0A0                <1> 	mov	al, 0A0h ; Indicates translated table
   659 00000243 AA                  <1> 	stosb
   660 00000244 8A440C              <1> 	mov	al, [si+12]
   661 00000247 AA                  <1> 	stosb		 ; physical sectors per track
   662 00000248 31C0                <1>  	xor	ax, ax
   663                              <1> 	;dec	ax	 ; 02/01/2015 
   664 0000024A AB                  <1> 	stosw		 ; precompensation (obsolete)
   665                              <1> 	;xor	al, al	 ; 02/01/2015	
   666 0000024B AA                  <1> 	stosb		 ; reserved
   667 0000024C B008                <1> 	mov	al, 8	 ; drive control byte
   668                              <1> 		         ; (do not disable retries, 
   669                              <1> 			 ; more than 8 heads)
   670 0000024E AA                  <1> 	stosb
   671 0000024F 8B4404              <1> 	mov	ax, [si+4]
   672 00000252 AB                  <1> 	stosw		 ; physical number of cylinders	
   673                              <1> 	;push	ax	 ; 02/01/2015
   674 00000253 8A4408              <1> 	mov	al, [si+8]
   675 00000256 AA                  <1> 	stosb		 ; physical num. of heads (limit 16)
   676 00000257 29C0                <1> 	sub 	ax, ax
   677                              <1> 	;pop	ax	 ; 02/01/2015	
   678 00000259 AB                  <1> 	stosw		 ; landing zone (obsolete)
   679 0000025A 88C8                <1> 	mov	al, cl	 ; logical sectors per track (limit 63)
   680 0000025C 243F                <1> 	and 	al, 3Fh	
   681 0000025E AA                  <1> 	stosb
   682                              <1> 	;sub	al, al	 ; checksum
   683                              <1> 	;stosb
   684                              <1> 	;
   685 0000025F 83C61A              <1> 	add	si, 26   ; (BIOS) DPTE address pointer
   686 00000262 AD                  <1> 	lodsw
   687 00000263 50                  <1> 	push	ax ; *	 ; (BIOS) DPTE offset
   688 00000264 AD                  <1> 	lodsw
   689 00000265 50                  <1> 	push	ax ; **	 ; (BIOS) DPTE segment
   690                              <1> 	;
   691                              <1> 	; checksum calculation
   692 00000266 89FE                <1> 	mov	si, di
   693 00000268 06                  <1> 	push	es
   694 00000269 1F                  <1> 	pop	ds
   695                              <1> 	;mov	cx, 16
   696 0000026A B90F00              <1> 	mov 	cx, 15
   697 0000026D 29CE                <1> 	sub	si, cx
   698 0000026F 30E4                <1> 	xor	ah, ah
   699                              <1> 	;del	cl
   700                              <1> L11:		
   701 00000271 AC                  <1> 	lodsb
   702 00000272 00C4                <1> 	add	ah, al
   703 00000274 E2FB                <1> 	loop	L11
   704                              <1> 	;
   705 00000276 88E0                <1> 	mov	al, ah
   706 00000278 F6D8                <1> 	neg	al	; -x+x = 0
   707 0000027A AA                  <1> 	stosb		; put checksum in byte 15 of the tbl
   708                              <1> 	;
   709 0000027B 1F                  <1> 	pop	ds ; **	; (BIOS) DPTE segment
   710 0000027C 5E                  <1> 	pop	si ; *	; (BIOS) DPTE offset	
   711                              <1> 	;
   712                              <1> 	; 14/07/2020
   713                              <1> 	; 0FFFFh:0FFFFh = invalid DPTE address
   714 0000027D 8B0C                <1> 	mov	cx, [si]
   715 0000027F 8B4402              <1> 	mov	ax, [si+2]
   716 00000282 21C1                <1> 	and	cx, ax
   717 00000284 41                  <1> 	inc	cx 
   718 00000285 7404                <1> 	jz	short L11c ; 0FFFFh:0FFFFh
   719 00000287 0B04                <1> 	or	ax, [si]
   720 00000289 752A                <1> 	jnz	short L11e ; <> 0
   721                              <1> L11c:
   722                              <1> 	; 17/07/2020
   723                              <1> 	; TRDOS 386 v2 DRVINIT assumptions:
   724                              <1> 	; (also by regarding QEMU, Bochs and VirtualBox settings)
   725                              <1> 	;	Hard disk 0 port address: 1F0h
   726                              <1> 	;	Hard disk 1 port address: 1F0h
   727                              <1> 	;	Hard disk 2 port address: 170h
   728                              <1> 	;	Hard disk 3 port address: 170h
   729                              <1> 
   730                              <1> 	; in QEMU, hda=hd0 (1F0h) and hdb=hd1 (1F0h) -IRQ14-
   731                              <1> 	;      and hdc=hd2 (170h) and hdd=hd3 (170h) -IRQ15-
   732                              <1> 
   733 0000028B B8F001              <1> 	mov	ax, 1F0h
   734                              <1> 
   735                              <1> 	; 15/07/2020
   736                              <1> 	; 14/07/2020
   737                              <1> 	; Invalid DPTE address...
   738                              <1> 	; Default DPTE parms must be set for DISK_IO_CONT
   739                              <1> 	; (diskio.s)
   740                              <1> 	; 17/07/2020
   741                              <1> 
   742                              <1> 	;mov	bl, dl
   743                              <1> 	;and	bl, 1
   744                              <1> 	;jz	short L11d
   745                              <1> 
   746 0000028E B3A0                <1> 	mov	bl, 0A0h
   747                              <1> 
   748 00000290 F6C201              <1> 	test	dl, 1
   749 00000293 7403                <1> 	jz	short L11g  ; Master (as default, for 80h & 82h))
   750                              <1> 	;shl	bl, 4 ; bl = 16 (bit 4 = 1 -> slave)
   751 00000295 80C310              <1> 	add	bl, 10h  ; Slave (as default, for 81h & 83h)
   752                              <1> L11g:
   753                              <1> 	; 17/07/2020
   754 00000298 80FA82              <1> 	cmp	dl, 82h	; Hard disk 3 or 4 ?
   755 0000029B 7203                <1> 	jb	short L11d ; Primary ATA channel (hd0, hd1)
   756                              <1> 			   ; (port address = 1F0h)
   757                              <1> 	
   758                              <1> 	; Secondary ATA channel (hd2, hd3)
   759                              <1> 	; (port address = 170h)
   760                              <1> 
   761 0000029D 2D8000              <1> 	sub	ax, 1F0h-170h
   762                              <1> L11d:
   763                              <1> 	; 14/07/2020
   764 000002A0 AB                  <1> 	stosw	; I/O PORT Base Address (1F0h, 170h)
   765 000002A1 050602              <1> 	add	ax, 206h
   766 000002A4 AB                  <1> 	stosw	; CONTROL PORT Address (3F6h, 376h)	
   767 000002A5 88D8                <1> 	mov	al, bl  ; Master/Slave bit (0 = Master)
   768                              <1> 	; 17/07/2020
   769                              <1> 	;or	al, 0A0h ; CHS (LBA enable bit = 0)
   770                              <1> 			 ; (Bits 5&7, reserved bits  =  1)
   771 000002A7 30E4                <1> 	xor	ah, ah
   772                              <1> 	;stosb	; Device/Head Register upper nibble
   773 000002A9 AB                  <1> 	stosw
   774 000002AA 30C0                <1> 	xor	al, al
   775 000002AC B90500              <1> 	mov	cx, 5
   776 000002AF F3AB                <1> 	rep	stosw ; clear remain part of the (fake) DPTE
   777 000002B1 0E                  <1> 	push	cs
   778 000002B2 1F                  <1> 	pop	ds
   779 000002B3 EB2E                <1> 	jmp	short L11f
   780                              <1> L11e:
   781                              <1> 	; 23/02/2015
   782 000002B5 57                  <1> 	push	di
   783                              <1> 	; ES:DI points to DPTE (FDPTE) location
   784                              <1> 	;;mov	cx, 8
   785                              <1> 	;mov	cl, 8
   786 000002B6 B90800              <1> 	mov	cx, 8 ; 14/07/2020
   787 000002B9 F3A5                <1> 	rep	movsw	
   788                              <1> 	;
   789                              <1> 	; 23/02/2015
   790                              <1> 	; (P)ATA drive and LBA validation
   791                              <1> 	; (invalidating SATA drives and setting
   792                              <1> 	; CHS type I/O for old type fixed disks)
   793 000002BB 5B                  <1> 	pop	bx
   794 000002BC 8CC8                <1> 	mov	ax, cs
   795 000002BE 8ED8                <1> 	mov	ds, ax
   796 000002C0 268B07              <1> 	mov	ax, [es:bx]
   797 000002C3 3DF001              <1> 	cmp	ax, 1F0h
   798 000002C6 7413                <1> 	je	short L11a
   799 000002C8 3D7001              <1> 	cmp	ax, 170h
   800 000002CB 740E                <1> 	je	short L11a
   801                              <1> 	; invalidation 
   802                              <1> 	; (because base port address is not 1F0h or 170h)
   803                              <1> 	;xor	bh, bh
   804                              <1> 	;mov	bl, dl
   805                              <1> 	; 29/08/2020
   806                              <1> 	;xor	dh, dh ; 0
   807 000002CD 89D3                <1> 	mov	bx, dx
   808                              <1> 	;sub	bl, 80h
   809                              <1> 	;mov	byte [bx+hd0_type], 0 ; not a valid disk drive !		
   810                              <1>         ;or	byte [bx+drv.status+2], 0F0h ; (failure sign)
   811                              <1> 	; 29/08/2020
   812 000002CF C687[906D]00        <1> 	mov	byte [bx+hd0_type-80h], 0
   813 000002D4 808F[DC6D]F0        <1> 	or	byte [bx+drv.status-7Eh], 0F0h
   814 000002D9 EB0F                <1> 	jmp	short L11b
   815                              <1> L11a:	
   816                              <1> 	; LBA validation
   817 000002DB 268A4704            <1> 	mov	al, [es:bx+4] ; Head register upper nibble
   818 000002DF A840                <1> 	test	al, 40h ; LBA bit (bit 6)
   819 000002E1 7507                <1> 	jnz	short L11b ; LBA type I/O is OK! (E0h or F0h)
   820                              <1> L11f:
   821                              <1> 	; force CHS type I/O for this drive (A0h or B0h)
   822                              <1> 	;sub	bh, bh
   823                              <1> 	;mov	bl, dl
   824                              <1> 	; 29/08/2020
   825                              <1> 	;xor	dh, dh ; 0
   826 000002E3 89D3                <1> 	mov	bx, dx
   827                              <1> 	;sub	bl, 80h ; 26/02/2015
   828                              <1>         ;and	byte [bx+drv.status+2], 0FEh ; clear bit 0
   829                              <1> 				; bit 0 = LBA ready bit
   830                              <1> 	; 29/08/2020
   831 000002E5 80A7[DC6D]FE        <1> 	and	byte [bx+drv.status-7Eh], 0FEh
   832                              <1> 	; 'diskio' procedure will check this bit !
   833                              <1> L11b:
   834 000002EA 3A16[0C6E]          <1> 	cmp	dl, [last_drv] ; 25/12/2014
   835 000002EE 7307                <1>         jnb     short L13
   836 000002F0 E9D1FE              <1>         jmp     L10
   837                              <1> 
   838                              <1> L12:
   839                              <1> 	; Restore data registers
   840 000002F3 8CC8                <1> 	mov	ax, cs
   841 000002F5 8ED8                <1> 	mov	ds, ax	
   842                              <1> L13:
   843                              <1> 	; 13/12/2014
   844 000002F7 0E                  <1> 	push	cs
   845 000002F8 07                  <1> 	pop	es
   846                              <1> L14:
   847                              <1> 	; clear keyboard buffer
   848 000002F9 B411                <1> 	mov 	ah, 11h
   849 000002FB CD16                <1> 	int 	16h
   850 000002FD 744D                <1> 	jz 	short L16 ; no keys in keyboard buffer
   851 000002FF B010                <1> 	mov	al, 10h
   852 00000301 CD16                <1> 	int 	16h
   853 00000303 EBF4                <1> 	jmp 	short L14
   854                              <1> 
   855                              <1> set_disk_parms:
   856                              <1> 	; 29/08/2020
   857                              <1> 	; 04/02/2016 (ebx -> bx)
   858                              <1> 	; 10/07/2015
   859                              <1> 	; 14/01/2015
   860                              <1> 	;push	bx
   861 00000305 28FF                <1> 	sub	bh, bh
   862 00000307 8A1E[0B6E]          <1> 	mov	bl, [drv]
   863 0000030B 80FB80              <1> 	cmp	bl, 80h
   864 0000030E 7203                <1> 	jb	short sdp0
   865 00000310 80EB7E              <1> 	sub	bl, 7Eh
   866                              <1> sdp0:	
   867                              <1> 	;add	bx, drv.status
   868                              <1>   	;mov	byte [bx], 80h ; 'Present' flag
   869                              <1> 	; 29/08/2020
   870 00000313 C687[5A6E]80        <1> 	mov	byte [bx+drv.status], 80h
   871                              <1> 	;
   872 00000318 88E8                <1> 	mov	al, ch ; last cylinder (bits 0-7)
   873 0000031A 88CC                <1> 	mov	ah, cl ; 
   874 0000031C C0EC06              <1> 	shr	ah, 6  ; last cylinder (bits 8-9)
   875                              <1> 	;sub	bx, drv.status
   876 0000031F D0E3                <1> 	shl	bl, 1
   877                              <1> 	;add	bx, drv.cylinders
   878 00000321 40                  <1> 	inc	ax  ; convert max. cyl number to cyl count		
   879                              <1> 	;mov	[bx], ax
   880                              <1> 	; 29/08/2020
   881 00000322 8987[146E]          <1> 	mov	[bx+drv.cylinders], ax
   882 00000326 50                  <1> 	push	ax ; ** cylinders
   883                              <1> 	;sub	bx, drv.cylinders
   884                              <1> 	;add	bx, drv.heads
   885 00000327 30E4                <1> 	xor	ah, ah
   886 00000329 88F0                <1> 	mov	al, dh ; heads
   887 0000032B 40                  <1> 	inc	ax
   888                              <1> 	;mov	[bx], ax
   889                              <1> 	; 29/08/2020
   890 0000032C 8987[226E]          <1>         mov	[bx+drv.heads], ax
   891                              <1> 	;sub     bx, drv.heads
   892                              <1>         ;add     bx, drv.spt
   893 00000330 30ED                <1> 	xor	ch, ch
   894 00000332 80E13F              <1> 	and	cl, 3Fh	; sectors (bits 0-6)
   895                              <1> 	;mov	[bx], cx
   896                              <1>         ; 29/08/2020
   897 00000335 898F[306E]          <1> 	mov	[bx+drv.spt], cx
   898                              <1> 	;sub	bx, drv.spt
   899 00000339 D1E3                <1> 	shl	bx, 1
   900                              <1> 	;add	bx, drv.size ; disk size (in sectors)
   901                              <1> 	; LBA size = cylinders * heads * secpertrack
   902 0000033B F7E1                <1> 	mul	cx 
   903 0000033D 89C2                <1> 	mov	dx, ax	; heads*spt					
   904 0000033F 58                  <1> 	pop	ax ; ** cylinders
   905 00000340 48                  <1> 	dec	ax ; 1 cylinder reserved (!?)
   906 00000341 F7E2                <1> 	mul	dx ; cylinders * (heads*spt)		
   907                              <1> 	;mov	[bx], ax
   908                              <1> 	;mov	[bx+2], dx
   909                              <1> 	; 29/08/2020
   910 00000343 8987[3E6E]          <1> 	mov	[bx+drv.size], ax
   911 00000347 8997[406E]          <1> 	mov	[bx+drv.size+2], dx
   912                              <1> 	;
   913                              <1> 	;pop	bx
   914 0000034B C3                  <1> 	retn
   915                              <1> 
   916                              <1> L16:	; 28/05/2016
   373                                  
   374                                  	; 10/11/2014
   375 0000034C FA                           	cli	; Disable interrupts (clear interrupt flag)
   376                                  		; Reset Interrupt MASK Registers (Master&Slave)
   377                                  	;mov	al, 0FFh	; mask off all interrupts
   378                                  	;out	21h, al		; on master PIC (8259)
   379                                  	;jmp 	$+2  ; (delay)
   380                                  	;out	0A1h, al	; on slave PIC (8259)
   381                                  	;
   382                                  	; Disable NMI 
   383 0000034D B080                    	mov   	al, 80h 
   384 0000034F E670                    	out   	70h, al		; set bit 7 to 1 for disabling NMI
   385                                  	;23/02/2015
   386                                  	;nop			;
   387                                  	;in	al, 71h		; read in 71h just after writing out to 70h
   388                                  				; for preventing unknown state (!?)
   389                                  	;
   390                                   	; 20/08/2014
   391                                  	; Moving the kernel 64 KB back (to physical address 0)
   392                                  	; DS = CS = 1000h
   393                                  	; 05/11/2014
   394 00000351 31C0                    	xor	ax, ax
   395 00000353 8EC0                    	mov	es, ax ; ES = 0
   396                                  	;
   397                                  	; 04/07/2016 - TRDOS 386 (64K - 128K kernel)
   398 00000355 31F6                          	xor	si, si
   399 00000357 31FF                    	xor	di, di
   400 00000359 B90040                  	mov	cx, 16384
   401 0000035C F366A5                  	rep	movsd
   402                                  	;
   403 0000035F 06                      	push	es ; 0
   404 00000360 68[6403]                	push	L17
   405 00000363 CB                      	retf
   406                                  L17:
   407 00000364 B90010                  	mov	cx, 1000h
   408 00000367 8EC1                    	mov	es, cx  ; 1000h 
   409 00000369 01C9                    	add	cx, cx
   410 0000036B 8ED9                    	mov	ds, cx  ; 2000h
   411 0000036D 29F6                    	sub	si, si
   412 0000036F 29FF                    	sub	di, di
   413 00000371 B90040                  	mov	cx, 16384
   414 00000374 F366A5                  	rep	movsd
   415                                  	
   416                                  	; Turn off the floppy drive motor
   417 00000377 BAF203                          mov     dx, 3F2h
   418 0000037A EE                              out     dx, al ; 0 ; 31/12/2013
   419                                  
   420                                  	; Enable access to memory above one megabyte
   421                                  L18:
   422 0000037B E464                    	in	al, 64h
   423 0000037D A802                    	test	al, 2
   424 0000037F 75FA                            jnz     short L18
   425 00000381 B0D1                    	mov	al, 0D1h	; Write output port
   426 00000383 E664                    	out	64h, al
   427                                  L19:
   428 00000385 E464                    	in	al, 64h
   429 00000387 A802                    	test	al, 2
   430 00000389 75FA                            jnz     short L19
   431 0000038B B0DF                    	mov	al, 0DFh	; Enable A20 line
   432 0000038D E660                    	out	60h, al
   433                                  ;L20:
   434                                  	;
   435                                  	; Load global descriptor table register
   436                                  
   437                                          ;mov     ax, cs
   438                                          ;mov     ds, ax
   439                                  
   440 0000038F 2E0F0116[786D]                  lgdt    [cs:gdtd]
   441                                  
   442 00000395 0F20C0                          mov     eax, cr0
   443                                  	; or 	eax, 1
   444 00000398 40                      	inc     ax
   445 00000399 0F22C0                  	mov     cr0, eax
   446                                  
   447                                  	; Jump to 32 bit code
   448                                  	
   449 0000039C 66                      	db 66h 			; Prefix for 32-bit
   450 0000039D EA                      	db 0EAh 		; Opcode for far jump
   451 0000039E [A4030000]              	dd StartPM 		; Offset to start, 32-bit
   452                                  				; (1000h:StartPM = StartPM + 10000h)
   453 000003A2 0800                    	dw KCODE		; This is the selector for CODE32_DESCRIPTOR,
   454                                  				; assuming that StartPM resides in code32
   455                                  
   456                                  ; 20/02/2017
   457                                  
   458                                  
   459                                  [BITS 32] 
   460                                  
   461                                  StartPM:
   462                                  	; Kernel Base Address = 0 ; 30/12/2013
   463 000003A4 66B81000                	mov ax, KDATA           ; Save data segment identifier
   464 000003A8 8ED8                            mov ds, ax              ; Move a valid data segment into DS register
   465 000003AA 8EC0                           	mov es, ax              ; Move data segment into ES register
   466 000003AC 8EE0                           	mov fs, ax              ; Move data segment into FS register
   467 000003AE 8EE8                          	mov gs, ax              ; Move data segment into GS register
   468 000003B0 8ED0                            mov ss, ax              ; Move data segment into SS register
   469 000003B2 BC00000900                      mov esp, 90000h         ; Move the stack pointer to 090000h
   470                                  
   471                                  clear_bss: ; Clear uninitialized data area
   472                                  	; 11/03/2015
   473 000003B7 31C0                    	xor  eax, eax ; 0
   474 000003B9 B9D9620000              	mov  ecx, (bss_end - bss_start)/4
   475                                  	;shr  ecx, 2 ; bss section is already aligned for double words
   476 000003BE BF[46870100]            	mov  edi, bss_start	
   477 000003C3 F3AB                    	rep  stosd  		
   478                                  
   479                                  memory_init:
   480                                  	; Initialize memory allocation table and page tables
   481                                  	; 16/11/2014
   482                                  	; 15/11/2014
   483                                  	; 07/11/2014
   484                                  	; 06/11/2014
   485                                  	; 05/11/2014
   486                                  	; 04/11/2014
   487                                  	; 31/10/2014 (Retro UNIX 386 v1 - Beginning) 
   488                                  	;
   489                                  ;	xor	eax, eax
   490                                  ;	xor 	ecx, ecx
   491 000003C5 B108                    	mov	cl, 8
   492 000003C7 BF00001000              	mov	edi, MEM_ALLOC_TBL	
   493 000003CC F3AB                    	rep	stosd		   ; clear Memory Allocation Table
   494                                  				   ; for the first 1 MB memory
   495                                  	;
   496 000003CE 668B0D[066E0000]        	mov	cx, [mem_1m_1k]	   ; Number of contiguous KB between
   497                                  				   ; 1 and 16 MB, max. 3C00h = 15 MB.
   498 000003D5 66C1E902                	shr	cx, 2		   ; convert 1 KB count to 4 KB count
   499 000003D9 890D[388A0100]          	mov	[free_pages], ecx
   500 000003DF 668B15[086E0000]        	mov	dx, [mem_16m_64k]  ; Number of contiguous 64 KB blocks
   501                                  				   ; between 16 MB and 4 GB.	
   502 000003E6 6609D2                  	or	dx, dx
   503 000003E9 7413                    	jz	short mi_0
   504                                  	;
   505 000003EB 6689D0                  	mov	ax, dx
   506 000003EE C1E004                  	shl	eax, 4		   ; 64 KB -> 4 KB (page count)
   507 000003F1 0105[388A0100]          	add	[free_pages], eax
   508 000003F7 0500100000              	add	eax, 4096	   ; 16 MB = 4096 pages
   509 000003FC EB07                    	jmp	short mi_1
   510                                  mi_0:
   511 000003FE 6689C8                  	mov	ax, cx
   512 00000401 66050001                	add	ax, 256		   ; add 256 pages for the first 1 MB		 
   513                                  mi_1:
   514 00000405 A3[348A0100]            	mov	[memory_size], eax ; Total available memory in pages
   515                                  				   ; 1 alloc. tbl. bit = 1 memory page
   516                                  				   ; 32 allocation bits = 32 mem. pages   
   517                                  	;
   518 0000040A 05FF7F0000              	add	eax, 32767	   ; 32768 memory pages per 1 M.A.T. page 	
   519 0000040F C1E80F                  	shr	eax, 15		   ; ((32768 * x) + y) pages (y < 32768)
   520                                  				   ;  --> x + 1 M.A.T. pages, if y > 0
   521                                  				   ;  --> x M.A.T. pages, if y = 0
   522 00000412 66A3[488A0100]          	mov	[mat_size], ax	   ; Memory Alloc. Table Size in pages		
   523 00000418 C1E00C                  	shl	eax, 12		   ; 1 M.A.T. page = 4096 bytes
   524                                  	;			   ; Max. 32 M.A.T. pages (4 GB memory)
   525 0000041B 89C3                    	mov	ebx, eax	   ; M.A.T. size in bytes
   526                                  	; Set/Calculate Kernel's Page Directory Address
   527 0000041D 81C300001000            	add	ebx, MEM_ALLOC_TBL
   528 00000423 891D[308A0100]          	mov	[k_page_dir], ebx  ; Kernel's Page Directory address
   529                                  				   ; just after the last M.A.T. page
   530                                  	;
   531 00000429 83E804                  	sub	eax, 4		   ; convert M.A.T. size to offset value
   532 0000042C A3[408A0100]            	mov	[last_page], eax   ; last page ofset in the M.A.T.
   533                                  	;			   ; (allocation status search must be 
   534                                  				   ; stopped after here)	
   535 00000431 31C0                    	xor	eax, eax
   536 00000433 48                      	dec	eax		   ; FFFFFFFFh (set all bits to 1)	
   537 00000434 6651                    	push	cx
   538 00000436 C1E905                  	shr	ecx, 5		   ; convert 1 - 16 MB page count to 
   539                                  				   ; count of 32 allocation bits
   540 00000439 F3AB                    	rep	stosd
   541 0000043B 6659                    	pop	cx
   542 0000043D 40                      	inc	eax		   ; 0	
   543 0000043E 80E11F                  	and	cl, 31		   ; remain bits
   544 00000441 7412                    	jz	short mi_4
   545 00000443 8907                    	mov	[edi], eax	   ; reset	
   546                                  mi_2:
   547 00000445 0FAB07                  	bts	[edi], eax	   ; 06/11/2014		
   548 00000448 FEC9                    	dec	cl
   549 0000044A 7404                    	jz	short mi_3
   550 0000044C FEC0                    	inc	al
   551 0000044E EBF5                    	jmp	short mi_2
   552                                  mi_3:
   553 00000450 28C0                    	sub	al, al	   	   ; 0
   554 00000452 83C704                  	add	edi, 4		   ; 15/11/2014
   555                                  mi_4:
   556 00000455 6609D2                  	or	dx, dx		  ; check 16M to 4G memory space	
   557 00000458 7421                    	jz	short mi_6	  ; max. 16 MB memory, no more...
   558                                  	;	
   559 0000045A B900021000              	mov	ecx, MEM_ALLOC_TBL + 512 ; End of first 16 MB memory
   560                                  	;	
   561 0000045F 29F9                    	sub	ecx, edi	  ; displacement (to end of 16 MB)
   562 00000461 7406                    	jz	short mi_5	  ; jump if EDI points to 
   563                                  				  ;         end of first 16 MB	
   564 00000463 D1E9                    	shr	ecx, 1		  ; convert to dword count
   565 00000465 D1E9                    	shr	ecx, 1		  ; (shift 2 bits right) 
   566 00000467 F3AB                    	rep 	stosd		  ; reset all bits for reserved pages
   567                                  				  ; (memory hole under 16 MB)
   568                                  mi_5:
   569 00000469 6689D1                  	mov	cx, dx		  ; count of 64 KB memory blocks
   570 0000046C D1E9                    	shr	ecx, 1		  ; 1 alloc. dword per 128 KB memory
   571 0000046E 9C                      	pushf			  ; 16/11/2014		
   572 0000046F 48                      	dec	eax		  ; FFFFFFFFh (set all bits to 1)
   573 00000470 F3AB                    	rep	stosd
   574 00000472 40                      	inc	eax		  ; 0
   575 00000473 9D                      	popf			  ; 16/11/2014
   576 00000474 7305                    	jnc	short mi_6
   577 00000476 6648                    	dec	ax		  ; eax = 0000FFFFh
   578 00000478 AB                      	stosd
   579 00000479 6640                    	inc	ax		  ; 0		
   580                                  mi_6:
   581 0000047B 39DF                    	cmp	edi, ebx	  ; check if EDI points to 	
   582 0000047D 730A                    	jnb	short mi_7	  ; end of memory allocation table
   583                                  	;			  ; (>= MEM_ALLOC_TBL + 4906) 
   584 0000047F 89D9                    	mov	ecx, ebx	  ; end of memory allocation table
   585 00000481 29F9                    	sub	ecx, edi	  ; convert displacement/offset
   586 00000483 D1E9                    	shr	ecx, 1		  ; to dword count 	 		
   587 00000485 D1E9                    	shr	ecx, 1		  ; (shift 2 bits right) 
   588 00000487 F3AB                    	rep 	stosd		  ; reset all remain M.A.T. bits
   589                                  mi_7:
   590                                  	; Reset M.A.T. bits in M.A.T. (allocate M.A.T. pages)
   591 00000489 BA00001000              	mov	edx, MEM_ALLOC_TBL
   592                                  	;sub	ebx, edx	  ; Mem. Alloc. Tbl. size in bytes
   593                                  	;shr	ebx, 12		  ; Mem. Alloc. Tbl. size in pages	
   594 0000048E 668B0D[488A0100]        	mov	cx, [mat_size]	  ; Mem. Alloc. Tbl. size in pages
   595 00000495 89D7                    	mov	edi, edx
   596 00000497 C1EF0F                  	shr	edi, 15		  ; convert M.A.T. address to
   597                                  				  ; byte offset in M.A.T.
   598                                  				  ; (1 M.A.T. byte points to 
   599                                  				  ;	      32768 bytes)
   600                                  				  ; Note: MEM_ALLOC_TBL address 
   601                                  				  ; must be aligned on 128 KB 
   602                                  				  ; boundary!
   603 0000049A 01D7                    	add	edi, edx	  ; points to M.A.T.'s itself	
   604                                  	; eax = 0
   605 0000049C 290D[388A0100]          	sub	[free_pages], ecx ; 07/11/2014
   606                                  mi_8:
   607 000004A2 0FB307                  	btr	[edi], eax	  ; clear bit 0 to bit x (1 to 31)
   608                                  	;dec	bl
   609 000004A5 FEC9                    	dec	cl
   610 000004A7 7404                    	jz	short mi_9
   611 000004A9 FEC0                    	inc	al
   612 000004AB EBF5                    	jmp	short mi_8
   613                                  mi_9:
   614                                  	;
   615                                  	; Reset Kernel's Page Dir. and Page Table bits in M.A.T.
   616                                  	;		(allocate pages for system page tables)
   617                                  
   618                                  	; edx = MEM_ALLOC_TBL
   619 000004AD 8B0D[348A0100]          	mov	ecx, [memory_size] ; memory size in pages (PTEs)
   620 000004B3 81C1FF030000            	add	ecx, 1023	 ; round up (1024 PTEs per table)	 	
   621 000004B9 C1E90A                  	shr	ecx, 10		 ; convert memory page count to 
   622                                  				 ; page table count (PDE count)
   623                                  	;
   624 000004BC 51                      	push	ecx		 ; (**) PDE count (<= 1024)
   625                                  	;
   626 000004BD 41                      	inc	ecx		 ; +1 for kernel page directory	
   627                                  	;
   628 000004BE 290D[388A0100]          	sub	[free_pages], ecx ; 07/11/2014
   629                                  	;
   630 000004C4 8B35[308A0100]          	mov	esi, [k_page_dir] ; Kernel's Page Directory address
   631 000004CA C1EE0C                  	shr	esi, 12		 ; convert to page number
   632                                  mi_10:
   633 000004CD 89F0                    	mov	eax, esi	 ; allocation bit offset		 
   634 000004CF 89C3                    	mov	ebx, eax
   635 000004D1 C1EB03                  	shr	ebx, 3		 ; convert to alloc. byte offset
   636 000004D4 80E3FC                  	and	bl,  0FCh	 ; clear bit 0 and bit 1
   637                                  				 ;   to align on dword boundary
   638 000004D7 83E01F                  	and	eax, 31		 ; set allocation bit position 
   639                                  				 ;  (bit 0 to bit 31)
   640                                  	;
   641 000004DA 01D3                    	add	ebx, edx	 ; offset in M.A.T. + M.A.T. address 
   642                                  	;
   643 000004DC 0FB303                  	btr 	[ebx], eax	 ; reset relevant bit (0 to 31)
   644                                  	;
   645 000004DF 46                      	inc	esi		 ; next page table
   646 000004E0 E2EB                    	loop	mi_10		 ; allocate next kernel page table 
   647                                  				 ; (ecx = page table count + 1)		
   648                                  	;
   649 000004E2 59                      	pop	ecx		 ; (**) PDE count (= pg. tbl. count)
   650                                  	;
   651                                  	; Initialize Kernel Page Directory and Kernel Page Tables
   652                                  	;
   653                                  	; Initialize Kernel's Page Directory
   654 000004E3 8B3D[308A0100]          	mov	edi, [k_page_dir]
   655 000004E9 89F8                    	mov	eax, edi
   656 000004EB 0C03                    	or	al, PDE_A_PRESENT + PDE_A_WRITE
   657                                  				; supervisor + read&write + present
   658 000004ED 89CA                    	mov	edx, ecx 	; (**) PDE count (= pg. tbl. count)	
   659                                  mi_11:
   660 000004EF 0500100000              	add	eax, 4096	; Add page size (PGSZ)
   661                                  			        ; EAX points to next page table
   662 000004F4 AB                      	stosd
   663 000004F5 E2F8                    	loop	mi_11
   664 000004F7 29C0                    	sub	eax, eax	; Empty PDE
   665 000004F9 66B90004                	mov	cx, 1024	; Entry count (PGSZ/4)
   666 000004FD 29D1                    	sub	ecx, edx
   667 000004FF 7402                    	jz	short mi_12
   668 00000501 F3AB                    	rep	stosd 		; clear remain (empty) PDEs
   669                                  	;
   670                                  	; Initialization of Kernel's Page Directory is OK, here.
   671                                  mi_12:
   672                                  	; Initialize Kernel's Page Tables
   673                                  	;
   674                                  	; (EDI points to address of page table 0)
   675                                  	; eax = 0
   676 00000503 8B0D[348A0100]          	mov	ecx, [memory_size] ; memory size in pages
   677 00000509 89CA                    	mov	edx, ecx	; (***)
   678 0000050B B003                    	mov	al, PTE_A_PRESENT + PTE_A_WRITE
   679                                  			     ; supervisor + read&write + present 	
   680                                  mi_13:
   681 0000050D AB                      	stosd
   682 0000050E 0500100000              	add	eax, 4096	
   683 00000513 E2F8                    	loop	mi_13	
   684 00000515 6681E2FF03              	and	dx, 1023	; (***)
   685 0000051A 740B                    	jz	short mi_14
   686 0000051C 66B90004                	mov	cx, 1024	
   687 00000520 6629D1                  	sub	cx, dx		; from dx (<= 1023) to 1024
   688 00000523 31C0                    	xor	eax, eax
   689 00000525 F3AB                    	rep	stosd		; clear remain (empty) PTEs 
   690                                  				; of the last page table
   691                                  mi_14:
   692                                  	;  Initialization of Kernel's Page Tables is OK, here.
   693                                  	;
   694 00000527 89F8                    	mov	eax, edi	; end of the last page table page
   695                                  			        ; (beginging of user space pages)
   696 00000529 C1E80F                  	shr	eax, 15		; convert to M.A.T. byte offset
   697 0000052C 24FC                    	and	al, 0FCh	; clear bit 0 and bit 1 for
   698                                  				; aligning on dword boundary	
   699                                  	 
   700 0000052E A3[448A0100]            	mov	[first_page], eax
   701 00000533 A3[3C8A0100]            	mov	[next_page], eax ; The first free page pointer
   702                                  				 ; for user programs
   703                                  				 ; (Offset in Mem. Alloc. Tbl.)	
   704                                  	;
   705                                  	; Linear/FLAT (1 to 1) memory paging for the kernel is OK, here.
   706                                  	;
   707                                  	
   708                                  	; Enable paging
   709                                  	;
   710 00000538 A1[308A0100]                    mov     eax, [k_page_dir]
   711 0000053D 0F22D8                  	mov	cr3, eax
   712 00000540 0F20C0                  	mov	eax, cr0
   713 00000543 0D00000080              	or	eax, 80000000h	; set paging bit (bit 31)
   714 00000548 0F22C0                  	mov	cr0, eax
   715                                          ;jmp    KCODE:StartPMP
   716                                  
   717 0000054B EA                      	db 0EAh 		; Opcode for far jump
   718 0000054C [52050000]                      dd StartPMP		; 32 bit offset
   719 00000550 0800                    	dw KCODE		; kernel code segment descriptor
   720                                  
   721                                  StartPMP:
   722                                  	; 06/11//2014
   723                                  	; Clear video page 0
   724                                  	;
   725                                  	; Temporary Code
   726                                  	;
   727 00000552 B9E8030000              	mov	ecx, 80*25/2
   728 00000557 BF00800B00              	mov	edi, 0B8000h
   729                                  	; 30/01/2016
   730                                  	;xor	eax, eax	; black background, black fore color
   731 0000055C B800070007              	mov	eax, 07000700h  ; black background, light gray fore color
   732 00000561 F3AB                    	rep	stosd
   733                                  	
   734                                  	; 19/08/2014
   735                                  	; Kernel Base Address = 0
   736                                  	; It is mapped to (physically) 0 in the page table.
   737                                  	; So, here is exactly 'StartPMP' address.
   738                                  
   739                                   	; 29/01/2016 (TRDOS 386 = TRDOS v2.0)
   740 00000563 BE[A24D0100]            	mov	esi, starting_msg
   741                                  	;; 14/08/2015 (kernel version message will appear
   742                                  	;;	       when protected mode and paging is enabled)
   743 00000568 BF00800B00              	mov	edi, 0B8000h ; 27/08/2014
   744                                  	
   745                                  	; 30/11/2020
   746                                  	; 14/11/2020 (TRDOS 386 v2.0.3)
   747                                  	;cmp	byte [vbe3], 3 ; 03h
   748                                  	;jne	short pkv_1
   749                                  	;;mov	ah, 0Bh ; Black background, light cyan forecolor
   750                                  	;; Light red TRDOS 386 version text shows VBE3 is ready !
   751                                  	;mov	ah, 0Ch ; Black background, light red forecolor
   752                                  	;jmp	short pkv_2
   753                                  ;pkv_1:
   754 0000056D B40A                    	mov	ah, 0Ah ; Black background, light green forecolor
   755                                  ;pkv_2:
   756                                  	; 20/08/2014
   757 0000056F E8DE030000              	call	printk
   758                                  
   759                                  	; 'UNIX v7/x86' source code by Robert Nordier (1999)
   760                                  	; // Set IRQ offsets
   761                                  	;
   762                                  	;  Linux (v0.12) source code by Linus Torvalds (1991)
   763                                  	;
   764                                  					;; ICW1
   765 00000574 B011                    	mov	al, 11h			; Initialization sequence
   766 00000576 E620                    	out	20h, al			; 	8259A-1
   767                                  	; jmp 	$+2
   768 00000578 E6A0                    	out	0A0h, al		; 	8259A-2
   769                                  					;; ICW2
   770 0000057A B020                    	mov	al, 20h			; Start of hardware ints (20h)
   771 0000057C E621                    	out	21h, al			;	for 8259A-1
   772                                  	; jmp 	$+2
   773 0000057E B028                    	mov	al, 28h			; Start of hardware ints (28h)
   774 00000580 E6A1                    	out	0A1h, al		; 	for 8259A-2
   775                                  					;
   776 00000582 B004                    	mov	al, 04h			;; ICW3
   777 00000584 E621                    	out	21h, al			; 	IRQ2 of 8259A-1 (master)
   778                                  	; jmp 	$+2
   779 00000586 B002                    	mov	al, 02h			; 	is 8259A-2 (slave)
   780 00000588 E6A1                    	out	0A1h, al		;
   781                                  					;; ICW4
   782 0000058A B001                    	mov	al, 01h	 		;
   783 0000058C E621                    	out	21h, al			; 	8086 mode, normal EOI	
   784                                  	; jmp 	$+2
   785 0000058E E6A1                    	out	0A1h, al		;	for both chips.
   786                                  
   787                                  	;mov	al, 0FFh	; mask off all interrupts for now
   788                                  	;out	21h, al
   789                                  	;; jmp 	$+2
   790                                  	;out	0A1h, al
   791                                  
   792                                  	; 02/04/2015
   793                                  	; 26/03/2015 System call (INT 30h) modification
   794                                  	;  DPL = 3 (Interrupt service routine can be called from user mode)			
   795                                  	;
   796                                  	;; Linux (v0.12) source code by Linus Torvalds (1991)
   797                                  	;  setup_idt:
   798                                  	;
   799                                          ;; 16/02/2015
   800                                  	;;mov     dword [DISKETTE_INT], fdc_int ; IRQ 6 handler
   801                                  	; 21/08/2014 (timer_int)
   802 00000590 BE[404A0100]            	mov	esi, ilist
   803 00000595 8D3D[48870100]          	lea	edi, [idt]
   804                                  	; 26/03/2015
   805 0000059B B930000000              	mov	ecx, 48		; 48 hardware interrupts (INT 0 to INT 2Fh)
   806                                  	; 02/04/2015
   807 000005A0 BB00000800              	mov	ebx,  80000h
   808                                  rp_sidt1:
   809 000005A5 AD                      	lodsd
   810 000005A6 89C2                    	mov	edx, eax
   811 000005A8 66BA008E                	mov	dx, 8E00h
   812 000005AC 6689C3                  	mov	bx, ax
   813 000005AF 89D8                    	mov	eax, ebx	; /* selector = 0x0008 = cs */
   814                                         			        ; /* interrupt gate - dpl=0, present */
   815 000005B1 AB                      	stosd	; selector & offset bits 0-15 	
   816 000005B2 89D0                    	mov	eax, edx
   817 000005B4 AB                      	stosd	; attributes & offset bits 16-23
   818 000005B5 E2EE                    	loop	rp_sidt1
   819                                  	; 15/04/2016
   820                                  	; TRDOS 386 (TRDOS v2.0) /// 32 sofware interrupts ///
   821                                  	;mov	cl, 16        ; 16 software interrupts (INT 30h to INT 3Fh)
   822 000005B7 B120                    	mov	cl, 32	      ; 32 software interrupts (INT 30h to INT 4Fh)	
   823                                  rp_sidt2:
   824 000005B9 AD                      	lodsd
   825 000005BA 21C0                    	and	eax, eax
   826 000005BC 7413                    	jz	short rp_sidt3
   827 000005BE 89C2                    	mov	edx, eax
   828 000005C0 66BA00EE                	mov	dx, 0EE00h	; P=1b/DPL=11b/01110b
   829 000005C4 6689C3                  	mov	bx, ax
   830 000005C7 89D8                    	mov	eax, ebx	; selector & offset bits 0-15 	
   831 000005C9 AB                      	stosd
   832 000005CA 89D0                    	mov	eax, edx
   833 000005CC AB                      	stosd
   834 000005CD E2EA                    	loop	rp_sidt2
   835 000005CF EB16                    	jmp	short sidt_OK
   836                                  rp_sidt3:
   837 000005D1 B8[7D0D0000]            	mov	eax, ignore_int
   838 000005D6 89C2                    	mov	edx, eax
   839 000005D8 66BA00EE                	mov	dx, 0EE00h	; P=1b/DPL=11b/01110b
   840 000005DC 6689C3                  	mov	bx, ax
   841 000005DF 89D8                    	mov	eax, ebx	; selector & offset bits 0-15 	
   842                                  rp_sidt4:
   843 000005E1 AB                      	stosd
   844 000005E2 92                      	xchg	eax, edx
   845 000005E3 AB                      	stosd
   846 000005E4 92                      	xchg	edx, eax
   847 000005E5 E2FA                    	loop	rp_sidt4
   848                                  sidt_OK: 
   849 000005E7 0F011D[7E6D0000]        	lidt 	[idtd]
   850                                  	;
   851                                  	; TSS descriptor setup ; 24/03/2015
   852 000005EE B8[C8890100]            	mov	eax, task_state_segment
   853 000005F3 66A3[2A6D0000]          	mov	[gdt_tss0], ax
   854 000005F9 C1C010                  	rol	eax, 16
   855 000005FC A2[2C6D0000]            	mov	[gdt_tss1], al
   856 00000601 8825[2F6D0000]          	mov	[gdt_tss2], ah
   857 00000607 66C705[2E8A0100]68-     	mov	word [tss.IOPB], tss_end - task_state_segment
   857 0000060F 00                 
   858                                  		; 
   859                                  		; IO Map Base address (When this address points
   860                                  		; to end of the TSS, CPU does not use IO port 
   861                                  		; permission bit map for RING 3 IO permissions, 
   862                                  		; access to any IO ports in ring 3 will be forbidden.)
   863                                   		;
   864                                  	;mov	[tss.esp0], esp ; TSS offset 4
   865                                  	;mov	word [tss.ss0], KDATA ; TSS offset 8 (SS)
   866 00000610 66B82800                   	mov	ax, TSS  ; It is needed when an interrupt 
   867                                  			 ; occurs (or a system call -software INT- is requested)
   868                                  			 ; while cpu running in ring 3 (in user mode).				
   869                                  			 ; (Kernel stack pointer and segment will be loaded
   870                                  			 ; from offset 4 and 8 of the TSS, by the CPU.)	 
   871 00000614 0F00D8                  	ltr	ax  ; Load task register
   872                                  	;
   873                                  esp0_set0:
   874                                  	; 30/07/2015
   875 00000617 8B0D[348A0100]          	mov 	ecx, [memory_size] ; memory size in pages
   876 0000061D C1E10C                  	shl 	ecx, 12 ; convert page count to byte count
   877 00000620 81F900004000            	cmp	ecx, CORE ; beginning of user's memory space (400000h)
   878                                  			  ; (kernel mode virtual address)
   879 00000626 7605                    	jna	short esp0_set1
   880                                  	;
   881                                  	; If available memory > CORE (end of the 1st 4 MB)
   882                                  	; set stack pointer to CORE
   883                                  	;(Because, PDE 0 is reserved for kernel space in user's page directory)
   884                                  	;(PDE 0 points to page table of the 1st 4 MB virtual address space)
   885 00000628 B900004000              	mov	ecx, CORE
   886                                  esp0_set1:
   887 0000062D 89CC                    	mov	esp, ecx ; top of kernel stack (**tss.esp0**)
   888                                  esp0_set_ok:
   889                                  	; 30/07/2015 (**tss.esp0**) 
   890 0000062F 8925[CC890100]          	mov	[tss.esp0], esp
   891 00000635 66C705[D0890100]10-             mov     word [tss.ss0], KDATA
   891 0000063D 00                 
   892                                  	; 14/08/2015
   893                                  	; 10/11/2014 (Retro UNIX 386 v1 - Erdogan Tan)
   894                                  	;
   895                                  	;cli	; Disable interrupts (for CPU)
   896                                  	;    (CPU will not handle hardware interrupts, except NMI!)
   897                                  	;
   898 0000063E 30C0                    	xor	al, al		; Enable all hardware interrupts!
   899 00000640 E621                    	out	21h, al		; (IBM PC-AT compatibility)
   900 00000642 EB00                    	jmp 	$+2		; (All conventional PC-AT hardware
   901 00000644 E6A1                    	out	0A1h, al	;  interrupts will be in use.)	
   902                                  				; (Even if related hardware component
   903                                  				;  does not exist!)
   904                                  	; Enable NMI 
   905 00000646 B07F                    	mov	al, 7Fh		; Clear bit 7 to enable NMI (again)
   906 00000648 E670                    	out  	70h, al
   907                                  	; 23/02/2015
   908 0000064A 90                      	nop
   909 0000064B E471                    	in	al, 71h		; read in 71h just after writing out to 70h
   910                                  				; for preventing unknown state (!?)
   911                                  	;
   912                                  	; Only a NMI can occur here... (Before a 'STI' instruction)
   913                                  	;
   914                                  	; 02/09/2014
   915 0000064D 6631DB                  	xor	bx, bx
   916 00000650 66BA0002                	mov	dx, 0200h	; Row 2, column 0  ; 07/03/2015
   917 00000654 E8461D0000              	call	_set_cpos	; 24/01/2016
   918                                  
   919                                  	; 14/11/2020 (TRDOS 386 v2.0.3)
   920                                  	; Check VBE3 protected mode interface/feature(s)
   921                                  
   922                                  	;cmp	byte [vbe3], 3 ; 03h
   923                                  	;jne	short display_mem_info
   924                                  
   925                                  	; 20/11/2020
   926 00000659 803D[5C090000]02        	cmp	byte [vbe3], 2 ; 02h
   927 00000660 770B                    	ja	short vbe3_pmid_chk
   928                                  	;jb	short display_mem_info
   929 00000662 0F82CA010000            	jb	display_mem_info ; 02/12/2020
   930 00000668 E9FE010000              	jmp	check_boch_plex86_vbe
   931                                  vbe3_pmid_chk:	
   932 0000066D B9EA7F0000              	mov	ecx, 32768 - (20+2) ; 32766 - PMInfoBlockSize
   933 00000672 BE02000C00              	mov	esi, 0C0002h ; 1st word of the video bios rom is 0AA55h
   934                                  	
   935                                  chk_pmi_sign:
   936                                  	;mov	eax, [esi] 
   937                                  	;cmp	eax, 'PMID'
   938                                  	; 30/11/2020
   939                                  	;cmp	al, 'P'
   940                                  	;jne	short chk_pmi_sign_next
   941 00000677 813E504D4944            	cmp	dword [esi], 'PMID'
   942                                  	;je	short display_vbios_product_name
   943 0000067D 740E                    	je	short verify_pmib_chksum ; 15/11/2020
   944                                  ;chk_pmi_sign_next:
   945 0000067F 46                      	inc	esi  ; inc si
   946 00000680 E2F5                    	loop	chk_pmi_sign
   947                                  
   948                                  not_valid_pmib:
   949 00000682 FE0D[5C090000]          	dec	byte [vbe3] ; 2 = VBE2 compatible 
   950                                  			    ; (vbe3 feature is defective in this vbios)
   951                                  	;jmp	short display_mem_info
   952                                  	; 02/12/2020
   953 00000688 E9A5010000              	jmp	display_mem_info
   954                                  
   955                                  verify_pmib_chksum:
   956                                  	; 15/11/2020
   957 0000068D 31C0                    	xor	eax, eax
   958                                  	;mov	ecx, eax 
   959                                  	;mov	cl, 20
   960 0000068F 66B91400                	mov	cx, 20 ; 30/11/2020
   961 00000693 56                      	push	esi
   962                                  pmib_sum_bytes:
   963 00000694 AC                      	lodsb
   964 00000695 00C4                    	add	ah, al
   965 00000697 E2FB                    	loop	pmib_sum_bytes
   966 00000699 5E                      	pop	esi
   967 0000069A 08E4                    	or	ah, ah
   968 0000069C 75E4                    	jnz	short not_valid_pmib ; AH must be 0
   969                                  
   970                                  	; 28/02/2021
   971                                  	; Set default (initial) truecolor bpp value to 32
   972                                  	; (for VBE3 video bios.. because vbe3 video bioses
   973                                  	;  use 32bpp -for truecolor modes- instead of 24bpp)
   974                                  	; (This setting may be changed via 'sysvideo' bx=0908h)
   975                                  	
   976 0000069E C605[F7860100]20        	mov	byte [truecolor], 32 ; (RGB: 00RRGGBBh)
   977                                  
   978                                  display_vbios_product_name: ; 14/11/2020
   979                                  
   980                                  	; ESI points to 'PMID' (0C0000h + 'PMID' offset)
   981                                  
   982                                  	; 15/11/2020
   983                                  	;mov	[pmid_addr], si	; PMInfoBlock offset
   984                                  	;		; (in VGA bios, 0C0000h + offset)
   985                                  	; 02/12/2020
   986                                  	;push	esi ; * pmid_addr
   987 000006A5 89F7                    	mov	edi, esi
   988                                  
   989                                  	;mov	esi, [VBE3INFOBLOCK+22] ; 097E00h + 16h
   990                                  	;		; OemVendorNamePtr (seg16:off16)
   991 000006A7 8B35067E0900            	mov	esi, [VBE3INFOBLOCK+6] ; 097E00h + 06h
   992                                  			; OemStringPtr (seg16:off16)
   993 000006AD 30C0                    	xor	al, al  ; eax = 0
   994 000006AF 6696                    	xchg	ax, si	; ax = offset, si = 0
   995 000006B1 C1EE0C                  	shr	esi, 12 ; (to convert segment to base addr)
   996 000006B4 6601C6                  	add	si, ax  ; esi has an address < 1 MB limit
   997                                  			; (OemVendorName is in VBE3INFOBLOCK)
   998                                  			; Example: 
   999                                  			; TRDOS 386 v2.0.3 VESA VBE3 protected mode
  1000                                  			; interface development reference is ...
  1001                                  			; NVIDIA GeForce FX5500 VGA BIOS -C000h:029Ch-
  1002                                  			; Version 4.34.20.54.00 -C000h:02EDh- 	  
  1003                                  			; ((OemString is 'NVIDIA'))
  1004                                  			; ((OemVendorName is 'NVIDIA Corporation'))
  1005                                  			; ((OemProductName is 'NV34 Board - p162-1nz))
  1006                                  
  1007                                  	;mov	ah, 0Eh ; Black background, yellow forecolor
  1008                                  	; 30/11/2020
  1009 000006B7 B40C                    	mov	ah, 0Ch ; Black background, light red forecolor
  1010                                  
  1011 000006B9 E8E23B0000              	call	print_kmsg
  1012                                  
  1013                                  	;mov	ah, 07h
  1014                                  
  1015 000006BE BE[D9860100]            	mov	esi, vesa_vbe3_bios_msg
  1016                                  	;call	print_kmsg
  1017 000006C3 E8DE3B0000              	call	pkmsg_loop ; 30/11/2020
  1018                                  
  1019                                  	; 02/12/2020
  1020                                  	;pop	edi ; * pmid_addr
  1021                                  
  1022                                  	; 30/11/2020
  1023                                  	; 29/11/2020 - TRDOS 386 v2.0.3
  1024                                  
  1025                                  struc PMInfo  ;  VESA VBE3 PMInfoBlock ('PMID' block)
  1026                                  
  1027 00000000 ????????                 .Signature:	resb 4  ; db 'PMID' ; PM Info Block Signature
  1028 00000004 ????                     .EntryPoint:	resw 1	; Offset of PM entry point within BIOS
  1029 00000006 ????                     .PMInitialize: resw 1	; Offset of PM initialization entry point
  1030 00000008 ????                     .BIOSDataSel:	resw 1 	; Selector to BIOS data area emulation block
  1031 0000000A ????                     .A0000Sel:	resw 1	; Selector to access A0000h physical mem
  1032 0000000C ????                     .B0000Sel:	resw 1  ; Selector to access B0000h physical mem
  1033 0000000E ????                     .B8000Sel:	resw 1	; Selector to access B8000h physical mem
  1034 00000010 ????                     .CodeSegSel:	resw 1	; Selector to access code segment as data
  1035 00000012 ??                       .InProtectMode: resb 1 ; Set to 1 when in protected mode
  1036 00000013 ??                       .Checksum:	resb 1	; Checksum byte for structure
  1037                                   .size:
  1038                                  
  1039                                  endstruc
  1040                                  
  1041                                  	; 29/11/2020
  1042                                  vbe3pminit:
  1043                                  	; 30/11/2020
  1044                                  	;cmp	byte [vbe3], 3 ; is VESA VBE3 PMI ready ?
  1045                                  	;jne	short di4
  1046                                  
  1047                                  	; Allocate 64KB contiguous (kernel) memory block
  1048 000006C8 31C0                    	xor	eax, eax
  1049 000006CA B900000100              	mov	ecx, 65536
  1050 000006CF E8B15D0000              	call	allocate_memory_block
  1051                                  	;jc	short di4
  1052 000006D4 0F8251010000            	jc	di0 ; 30/11/2020
  1053                                  
  1054                                  	; of course this block must be in the 1st 16MB
  1055                                  	; because vbe3 pmi segments will be 16 bit segments
  1056                                  	; (80286 type segment descriptors in GDT)
  1057                                  
  1058 000006DA A3[20120300]            	mov	[vbe3bios_addr], eax
  1059                                  
  1060                                  	; set [pmid_addr] to the new location
  1061 000006DF BE00000C00              	mov	esi, 0C0000h
  1062                                  
  1063                                  	; 30/11/2020
  1064 000006E4 29F7                    	sub	edi, esi ; izolate offset
  1065 000006E6 01C7                    	add	edi, eax ; new address
  1066 000006E8 893D[24120300]          	mov	[pmid_addr], edi ; new 'PMID' location	
  1067                                  
  1068                                  	; Move VIDEO BIOS from 0C0000h to EAX
  1069 000006EE B900400000              	mov	ecx, 65536/4
  1070 000006F3 89C7                    	mov	edi, eax ; 30/11/2020
  1071 000006F5 F3A5                    	rep	movsd
  1072                                  
  1073                                  	; 02/12/2020
  1074                                  	; 30/11/2020
  1075                                  	; set vbe3 segment selectors
  1076                                  
  1077                                  	; VBE3CS (VESA VBE3 video bios code segment)
  1078 000006F7 BF[326D0000]            	mov	edi, _vbe3_CS+2 ; base address bits 0..15
  1079 000006FC 66AB                    	stosw	; edi = _vbe3_CS+4
  1080 000006FE C1C810                  	ror	eax, 16
  1081 00000701 8807                    	mov	[edi], al ; base address, bits 16..23
  1082                                  
  1083                                  	; VBE3DS ('CodeSegSel' in PMInfoBlock)
  1084 00000703 BF[5C6D0000]            	mov	edi, _vbe3_DS+4 ; base addr bits 16..23
  1085 00000708 8807                    	mov	[edi], al 
  1086 0000070A C1C010                  	rol	eax, 16
  1087 0000070D 668947FE                	mov	[edi-2], ax ; base address, bits 0..15
  1088                                  
  1089                                  	; VBE3BDS (BIOSDataSel in PMInfoBlock)
  1090 00000711 BF[3A6D0000]            	mov	edi, _vbe3_BDS+2 ; base addr bits 0..15
  1091 00000716 B800700900              	mov	eax, VBE3BIOSDATABLOCK ; 1536 bytes
  1092 0000071B 66AB                    	stosw	; edi = _vbe3_BDS+4
  1093 0000071D C1E810                  	shr	eax, 16
  1094 00000720 8807                    	mov	[edi], al ; base address, bits 16..23
  1095                                  
  1096                                  	; VBE3SS (1024 bytes)
  1097 00000722 BF[626D0000]            	mov	edi, _vbe3_SS+2 ; base addr bits 0..15
  1098 00000727 B800600900              	mov	eax, VBE3STACKADDR ; size = 1024 bytes
  1099 0000072C 66AB                    	stosw	; edi = _vbe3_SS+4
  1100 0000072E C1E810                  	shr	eax, 16
  1101 00000731 8807                    	mov	[edi], al ; base address, bits 16..23
  1102                                  
  1103                                  	; stack pointer (esp) will be set to 1020
  1104                                  	; (before VBE3 PMI call)
  1105                                  
  1106                                  	; VBE3ES (max: 2048 bytes)
  1107 00000733 BF[6A6D0000]            	mov	edi, _vbe3_ES+2 ; base addr bits 0..15
  1108 00000738 B800760900              	mov	eax, VBE3SAVERESTOREBLOCK
  1109 0000073D 66AB                    	stosw	; edi = _vbe3_ES+4
  1110 0000073F C1E810                  	shr	eax, 16
  1111 00000742 8807                    	mov	[edi], al ; base address, bits 16..23 	
  1112                                  
  1113                                  	;Note: low word of _VBE3_ES base address will be
  1114                                  	;      set -again- by VBE3 PMI caller routine 
  1115                                  
  1116                                  	; 09/12/2020
  1117                                  	;; set pmi32 (as VBE3 PMI is ready)
  1118                                  	;inc	byte [pmi32] ; = 1 
  1119                                  
  1120                                  	; KCODE16 (set PMI far return segment)
  1121 00000744 BF[726D0000]            	mov	edi, _16bit_CS+2 ; base addr bits 0..15
  1122 00000749 B8[D2070000]            	mov	eax, pminit_return_addr16
  1123 0000074E 66AB                    	stosw	; edi = _16bit_CS+4
  1124 00000750 C1E810                  	shr	eax, 16
  1125 00000753 8807                    	mov	[edi], al ; base address, bits 16..23 
  1126                                  
  1127                                  	; 30/11/2020
  1128                                  	; clear mem from VBE3 BIOS data area emu block
  1129                                  	; to end of vbe3 buffers
  1130                                  
  1131                                  	; 01/12/2020
  1132 00000755 BF00700900              	mov	edi, VBE3BIOSDATABLOCK ; 97000h
  1133                                  	;mov	cx, (VBE3INFOBLOCK-VBE3BIOSDATABLOCK)/4
  1134                                  	;	; ecx = 3584/4 double words
  1135                                  	; 21/12/2020
  1136 0000075A 66B90003                	mov	cx, (VBE3MODEINFOBLOCK-VBE3BIOSDATABLOCK)/4
  1137                                  		; ecx = 3072/4 double words
  1138                                  	;xor	eax, eax
  1139 0000075E 30C0                    	xor	al, al
  1140 00000760 F3AB                    	rep	stosd
  1141                                  
  1142                                  	; Filling PMInfoBlock selector fields
  1143 00000762 8B3D[24120300]          	mov	edi, [pmid_addr]
  1144 00000768 66C747083800            	mov	word [edi+PMInfo.BIOSDataSel], VBE3BDS
  1145 0000076E 66C7470A4000            	mov	word [edi+PMInfo.A0000Sel], VBE3A000
  1146 00000774 66C7470C4800            	mov	word [edi+PMInfo.B0000Sel], VBE3B000
  1147 0000077A 66C7470E5000            	mov	word [edi+PMInfo.B8000Sel], VBE3B800	
  1148 00000780 66C747105800            	mov	word [edi+PMInfo.CodeSegSel], VBE3DS
  1149 00000786 C6471201                	mov	byte [edi+PMInfo.InProtectMode], 1
  1150                                  
  1151                                  	; Calculate and write checksum byte
  1152 0000078A 89FE                    	mov	esi, edi
  1153 0000078C B113                    	mov	cl, PMInfo.size - 1
  1154                                  	;xor	ah, ah
  1155                                  pmid_chksum:
  1156 0000078E AC                      	lodsb	
  1157 0000078F 00C4                    	add	ah, al
  1158 00000791 E2FB                    	loop	pmid_chksum
  1159 00000793 F6DC                    	neg	ah ; 1 -> 255, 255 -> 1
  1160 00000795 8826                    	mov	byte [esi], ah  ; checksum
  1161                                  
  1162                                  	; far call PM initialization
  1163                                  	; (VBE3 video bios will return via 'retf')
  1164                                  
  1165 00000797 668B4706                	mov	ax, [edi+PMInfo.PMInitialize]
  1166                                  	; 30/11/2020
  1167 0000079B C1E010                  	shl	eax, 16 ; save entry address in hw
  1168                                  	; ax = 0 
  1169                                  
  1170                                  	; 02/12/2020
  1171 0000079E 68[F6070000]            	push	pminit_ok ; normal, near return address
  1172                                  
  1173                                  	; 30/11/2020
  1174                                  _VBE3PMI_fcall:
  1175                                  	; ax = function, hw of eax = entry address
  1176 000007A3 9C                      	pushf	; save 32 bit flags
  1177 000007A4 56                      	push	esi ; *
  1178 000007A5 55                      	push	ebp ; **
  1179                                  
  1180 000007A6 89E5                    	mov	ebp, esp ; save 32 bit stack pointer
  1181                                  	
  1182 000007A8 89C6                    	mov	esi, eax
  1183                                  
  1184 000007AA FA                      	cli
  1185                                  
  1186                                  	; Disable interrupts (clear interrupt flag)
  1187                                  	; Reset Interrupt MASK Registers (Master&Slave)
  1188 000007AB B0FF                    	mov	al, 0FFh	; mask off all interrupts
  1189 000007AD E621                    	out	21h, al		; on master PIC (8259)
  1190 000007AF EB00                    	jmp 	$+2  ; (delay)
  1191 000007B1 E6A1                    	out	0A1h, al	; on slave PIC (8259)
  1192                                  
  1193                                  	; 02/12/2020
  1194 000007B3 66B86000                	mov	ax, VBE3SS
  1195 000007B7 8ED0                    	mov	ss, ax
  1196                                  	
  1197 000007B9 BCFC030000              	mov	esp, 1020 ; 30/11/2020
  1198                                  
  1199                                  	; 01/12/2020
  1200                                  	;lss	esp, [stack16]
  1201                                  
  1202 000007BE C1E810                  	shr	eax, 16	; now, entry address is in lw
  1203                                  
  1204                                  	; 30/11/2020 - 16 bit pm selector test (OK)
  1205                                  	; (32 bit stack push/pop & retf with 32 bit code segment)
  1206                                  	; (16 bit stack push/pop with 16 bit code segment)
  1207                                  	
  1208                                  	; return
  1209                                  	;push	KCODE16
  1210                                  	;push	0 ; 30/11/2020 (pminit_return_addr16)
  1211                                  
  1212                                  	; 30/11/2020 (16 bit stack during retf from video bios)
  1213 000007C1 C7042400007000          	mov	dword [esp], KCODE16 << 16
  1214                                  				; ip = 0, cs = KCODE16 
  1215                                  	; 01/12/2020
  1216                                  	;mov	dword [VBE3STACKADDR+1020], KCODE16*65536
  1217                                  
  1218                                  	;mov	[jumpfar16], eax
  1219                                  
  1220                                  	; 02/12/2020
  1221                                  	; 30/11/2020 (32 bit stack during retf from kernel)
  1222                                  	; far jump/call via retf
  1223 000007C8 6A30                    	push	VBE3CS ; VBE3 video bios's code segment
  1224 000007CA 50                      	push	eax ; PMInitialize or EntryPoint
  1225                                  
  1226 000007CB 6689F0                  	mov	ax, si ; restore function
  1227                                  	
  1228                                  	; 02/12/2020
  1229 000007CE 31F6                    	xor	esi, esi ; (not necessary, it is not used)
  1230                                  	
  1231 000007D0 CB                      	retf 	; far return (to 16 bit code segment)
  1232                                  
  1233                                  	; 01/12/2020
  1234                                  	;db	0EAh  ; far jump to 16 bit code segment
  1235                                  ;jumpfar16:
  1236                                  	;dd	0		
  1237                                  	;dw	VBE3CS
  1238                                  
  1239                                  ;stack16:
  1240                                  	;dd	1020
  1241                                  	;dw	VBE3SS
  1242                                  
  1243 000007D1 90                      	align 2	
  1244                                  
  1245                                  pminit_return_addr16:
  1246                                  	; 02/12/2020
  1247                                  	; 30/11/2020
  1248                                  	;;db	66h 		     ; Prefix for 32-bit
  1249                                  	;db	0EAh 		     ; Opcode for far jump
  1250                                  	;dd	pminit_return_addr32 ; 32 bit Offset
  1251                                  	;dw	KCODE		     ; 32 bit code segment
  1252                                  	; 01/12/2020
  1253 000007D2 EA[D9070000]0800        	jmp	KCODE:pminit_return_addr32
  1254                                  
  1255                                  pminit_return_addr32:
  1256                                  	; restore 32 bit kernel selectors and 32 bit stack addr
  1257 000007D9 BE10000000              	mov	esi, KDATA
  1258 000007DE 8EDE                    	mov	ds, si
  1259 000007E0 8EC6                    	mov	es, si
  1260 000007E2 8ED6                    	mov	ss, si
  1261 000007E4 89EC                    	mov	esp, ebp  ; top of stack = iretd return addr
  1262                                  
  1263 000007E6 5D                      	pop	ebp ; **
  1264 000007E7 5E                      	pop	esi ; *
  1265 000007E8 9D                      	popf	; restore 32 bit flags
  1266                                  
  1267                                  	; enable interrupts
  1268                                  
  1269 000007E9 FA                      	cli
  1270                                  
  1271                                  	; 21/12/2020
  1272 000007EA 50                      	push	eax
  1273                                  
  1274 000007EB 30C0                    	xor	al, al	   ; Enable all hardware interrupts!
  1275 000007ED E621                    	out	21h, al	   ; (IBM PC-AT compatibility)
  1276 000007EF EB00                    	jmp 	$+2	   ; (All conventional PC-AT hardware
  1277 000007F1 E6A1                    	out	0A1h, al   ;  interrupts will be in use.)	
  1278                                  			   ; (Even if related hardware component
  1279                                  			   ;  does not exist!)
  1280 000007F3 58                      	pop	eax
  1281                                  	
  1282 000007F4 FB                      	sti
  1283                                  
  1284                                  	; top of stack = return address 
  1285                                  	; ('pminit_ok' for PMinit)
  1286                                  
  1287 000007F5 C3                      	retn
  1288                                  
  1289                                  pminit_ok:
  1290                                  	; 03/12/2020
  1291                                  	; (set [pmid_addr] to PMI entry point for next calls)
  1292 000007F6 8305[24120300]04        	add	dword [pmid_addr], PMInfo.EntryPoint ; + 4
  1293                                  
  1294                                  	; 17/01/2021
  1295                                  	; copy EDID data from temporary location to final address
  1296 000007FD 803D[37430000]4F        	cmp	byte [edid], 4Fh
  1297 00000804 7511                    	jne	short vbe3h_chcl
  1298 00000806 B920000000              	mov	ecx, 32 ; 128 bytes, 32 dwords
  1299 0000080B BE007D0900              	mov	esi, VBE3EDIDINFOBLOCK ; 97D00h
  1300 00000810 BF[9C110300]            	mov	edi, edid_info
  1301 00000815 F3A5                    	rep	movsd
  1302                                  	; 17/01/2021
  1303                                  vbe3h_chcl:
  1304                                  	; 16/01/2021
  1305                                  	;; 06/12/2020
  1306                                  	;; Save video mode 03h regs/dac/bios state
  1307                                  	;
  1308                                  	;mov	ax, 4F04h ; VESA VBE Function 04h
  1309                                  	;		  ; Save/Restore State
  1310                                  	;sub	dl, dl	; 0 = return buffer size
  1311                                  	;mov	cx, 0Fh  ; ctrl/bios/dac/regs
  1312                                  	;
  1313                                  	;call	int10h_32bit_pmi
  1314                                   	;; bx = number of 64-byte blocks to hold the state buff
  1315                                  	;	
  1316                                  	;;mov	[vbe3stbufsize], bx
  1317                                  	;; 16/01/2021
  1318                                  	;or	word [vbe3stbsflags], 32768  ; set bit 15
  1319                                  	;mov	ax, bx
  1320                                  	;shl	ax, 6  ; * 64
  1321                                  	;mov	[vbestatebufsize+30], ax
  1322                                  	;
  1323                                  	;; 06/12/2020	
  1324                                  	;; check 'vbe3stbufsize' (it must be <= 32)
  1325                                  	;
  1326                                  	;cmp	bx, 32
  1327                                  	;ja	short display_mem_info ; light red forecolor
  1328                                  	;
  1329                                  	;; 16/01/2021
  1330                                  	;or	byte [vbe3stbsflags], 1 ; set bit 0
  1331                                  
  1332                                  	; 30/11/2020
  1333                                  	; Change VESA VBE3 BIOS text color in order to give
  1334                                  	; "VBE3 PMI initialization has been successed" meaning 	
  1335                                  
  1336 00000817 BE40810B00              	mov	esi, 0B8000h + 160*2 ; row 2
  1337 0000081C 89F7                    	mov	edi, esi
  1338                                  vbe3h_chcl_next:
  1339 0000081E 66AD                    	lodsw
  1340 00000820 80FC0C                  	cmp	ah, 0Ch	; light red forecolor
  1341 00000823 750D                    	jne	short display_mem_info
  1342 00000825 B40E                    	mov	ah, 0Eh ; yellow forecolor
  1343 00000827 66AB                    	stosw
  1344 00000829 EBF3                    	jmp	short vbe3h_chcl_next
  1345                                  
  1346                                  di0:
  1347                                  	; 30/11/2020
  1348                                  	; Memory allocation error !
  1349 0000082B C605[5C090000]00        	mov	byte [vbe3], 0 ; disable VBE3
  1350                                  
  1351                                  display_mem_info:
  1352                                  	; 19/12/2020
  1353                                  	; temporary
  1354 00000832 E8853A0000              	call	default_lfb_info
  1355                                  	;
  1356                                  	; 06/11/2014
  1357 00000837 E80B3A0000              	call	memory_info
  1358                                  	; 14/08/2015
  1359                                  	;call getch ; 28/02/2015
  1360                                  drv_init:
  1361 0000083C FB                      	sti	; Enable Interrupts 
  1362                                  	; 06/02/2015
  1363 0000083D 8B15[106E0000]          	mov	edx, [hd0_type] ; hd0, hd1, hd2, hd3
  1364 00000843 668B1D[0E6E0000]        	mov	bx, [fd0_type] ; fd0, fd1
  1365                                  	; 22/02/2015
  1366 0000084A 6621DB                  	and	bx, bx
  1367 0000084D 756C                    	jnz	short di1
  1368                                  	;
  1369 0000084F 09D2                    	or 	edx, edx
  1370 00000851 757A                    	jnz	short di2
  1371                                  	;
  1372                                  setup_error:
  1373 00000853 BE[464D0100]            	mov 	esi, setup_error_msg
  1374                                  psem:	
  1375 00000858 AC                      	lodsb
  1376 00000859 08C0                    	or	al, al
  1377                                  	;jz	short haltx ; 22/02/2015
  1378 0000085B 747B                    	jz	short di3
  1379 0000085D 56                      	push	esi
  1380                                  	; 13/05/2016
  1381 0000085E BB07000000              	mov	ebx, 7	; Black background, 
  1382                                  			; light gray forecolor
  1383                                  			; Video page 0 (BH=0)
  1384 00000863 E89D1A0000              	call	_write_tty
  1385 00000868 5E                      	pop	esi
  1386 00000869 EBED                    	jmp	short psem
  1387                                  
  1388                                  check_boch_plex86_vbe:
  1389                                  	; 20/11/2020
  1390                                  	; check Bochs/Plex86 VGABios VBE extension
  1391                                  	; (check if TRDOS 386 v2 is running on emulators)
  1392                                  	; BOCHS/QEMU/VIRTUALBOX
  1393                                  	;
  1394                                  	; ref: vbe_display_api.txt
  1395                                  
  1396                                  	; bochs/plex86 VGAbios VBE source code
  1397                                  	;  by Jeroen Janssen (2002)
  1398                                  	;  and Volker Ruppert (2003-2020)
  1399                                  
  1400 0000086B 29C0                    	sub	eax, eax ; 0
  1401 0000086D 66BACE01                	mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
  1402 00000871 66EF                    	out	dx, ax ; VBE_DISPI_INDEX_ID register
  1403                                  	;mov	ax, 0B0C0h ; VBE_DISPI_ID0
  1404                                  	;mov	dx, 1CFh ; VBE_DISPI_IOPORT_DATA
  1405 00000873 6642                    	inc	dx
  1406                                  	;out	dx, ax
  1407                                  	;nop
  1408 00000875 66ED                    	in	ax, dx
  1409 00000877 80FCB0                  	cmp	ah, 0B0h
  1410                                  	;jne	short not_boch_qemu_vbe
  1411 0000087A 75B6                    	jne	short display_mem_info
  1412 0000087C 3CC5                    	cmp	al, 0C5h ; it must be 0B0C4h or 0B0C5h ..
  1413                                  	;ja	short not_boch_qemu_vbe
  1414 0000087E 77B2                    	ja	short display_mem_info
  1415 00000880 3CC0                    	cmp	al, 0C0h ; 0B0C0h to 0B0C5h .. ; Qemu
  1416                                  	;cmp	al, 0C4h ; 0BC04h or 0B0C5h is OK ; Bochs
  1417                                  	;jb	short not_boch_qemu_vbe
  1418 00000882 72AE                    	jb	short display_mem_info
  1419                                  
  1420                                  	; save VESA VBE2 bios (bochs/qemu) signature
  1421                                  	; for enabling VBE2 functions in TRDOS 386 v2 kernel
  1422 00000884 A2[5D090000]            	mov	[vbe2bios], al ; 0C4h or 0C5h (for BOCHS) 
  1423                                  			       ; (0C0h-0C5h for QEMU)
  1424 00000889 C605[E2860100]32        	mov	byte [vbe_vnumber], "2"
  1425                                  	; 26/11/2020
  1426                                  	; "BOCHS/QEMU/VIRTUALBOX VBE2 Video BIOS ..".
  1427 00000890 BE[C4860100]            	mov	esi, vbe2_bochs_vbios ; BOCH/QEMU vbios msg
  1428 00000895 B40E                    	mov	ah, 0Eh  ; Yellow font
  1429 00000897 E8043A0000              	call	print_kmsg
  1430                                  	
  1431                                  	; this is not necessary ! (20/11/2020)
  1432 0000089C 803D[5D090000]C4        	cmp	byte [vbe2bios], 0C4h 
  1433 000008A3 728D                    	jb	display_mem_info	; (QEMU) 
  1434                                  
  1435                                  	; Display kernel version message if 0E9h hack port
  1436                                  	; is enabled (bochs emulator feature)
  1437 000008A5 66BAE900                	mov	dx, 0E9h ; hack port for BOCHS
  1438 000008A9 BE[1D870100]            	mov	esi, kernel_version_msg
  1439                                  kvmsg_next_char:
  1440 000008AE AC                      	lodsb	
  1441 000008AF 08C0                    	or	al, al
  1442 000008B1 7505                    	jnz	short put_kvmsg_in_hack_port
  1443                                  not_boch_qemu_vbe:
  1444 000008B3 E97AFFFFFF               	jmp	display_mem_info
  1445                                  put_kvmsg_in_hack_port:	
  1446 000008B8 EE                      	out	dx, al
  1447 000008B9 EBF3                    	jmp	short kvmsg_next_char
  1448                                  
  1449                                  di1:
  1450                                  	; supress 'jmp short T6'
  1451                                  	;  (activate fdc motor control code)
  1452 000008BB 66C705[BE090000]90-     	mov	word [T5], 9090h ; nop
  1452 000008C3 90                 
  1453                                  	;
  1454                                  	;mov	ax, int_0Eh	; IRQ 6 handler
  1455                                  	;mov	di, 0Eh*4	; IRQ 6 vector
  1456                                  	;stosw
  1457                                  	;mov 	ax, cs
  1458                                  	;stosw
  1459                                  	;; 16/02/2015
  1460                                          ;;mov     dword [DISKETTE_INT], fdc_int ; IRQ 6 handler
  1461                                  	;
  1462 000008C4 E82A490000              	CALL	DSKETTE_SETUP	; Initialize Floppy Disks
  1463                                  	;
  1464 000008C9 09D2                    	or	edx, edx
  1465 000008CB 740B                            jz      short di3
  1466                                  di2:
  1467 000008CD E868490000              	call   	DISK_SETUP	; Initialize Fixed Disks
  1468 000008D2 0F827BFFFFFF                    jc      setup_error
  1469                                  di3:
  1470 000008D8 E83E390000              	call	setup_rtc_int	; 22/05/2015 (dsectrpm.s)
  1471                                  	;
  1472 000008DD E8FA420100              	call	display_disks ; 07/03/2015  (Temporary)
  1473                                  ;haltx:
  1474                                  	; 14/08/2015
  1475                                  	;call	getch ; 22/02/2015
  1476                                  	;sti	; Enable interrupts (for CPU)
  1477                                  ;	; 29/01/2016
  1478                                  ;	sub	ah, ah ;  read time count
  1479                                  ;	call	int1Ah
  1480                                  ;	mov	edx, ecx ; 18.2 * seconds
  1481                                  ;md_info_msg_wait1:
  1482                                  ;	; 29/01/2016
  1483                                  ;	mov	ah, 1
  1484                                  ;	call	int16h
  1485                                  ;	jz	short md_info_msg_wait2
  1486                                  ;	xor	ah, ah ; 0
  1487                                  ;       call    int16h
  1488                                  ;	jmp 	short md_info_msg_ok
  1489                                  ;md_info_msg_wait2:
  1490                                  ;	sub	ah, ah  ; read time count
  1491                                  ;	call	int1Ah
  1492                                  ;	cmp	edx, ecx ; ; 18.2 * seconds
  1493                                  ;	jna	short md_info_msg_wait3
  1494                                  ;	xchg 	edx, ecx	
  1495                                  ;md_info_msg_wait3:
  1496                                  ;	sub	ecx, edx
  1497                                  ;	cmp	ecx, 127 ; 7 seconds (18.2 * 7)
  1498                                  ;	jb	short md_info_msg_wait1		
  1499                                  ;md_info_msg_ok:
  1500                                  
  1501                                  	; 15/12/2020
  1502                                  	; set initial values of LFB parameters
  1503                                  
  1504 000008E2 803D[5C090000]02        	cmp	byte [vbe3], 2
  1505 000008E9 7214                    	jb	short di4
  1506                                  
  1507                                  	;mov	ax, [def_LFB_addr]
  1508                                  	;shl	eax, 16
  1509                                  	;mov	[LFB_ADDR], eax
  1510                                  	;mov	eax, 1024*768*3
  1511                                  	;mov	[LFB_SIZE], eax
  1512                                  
  1513 000008EB BEFE7B0900              	mov	esi, VBE3MODEINFOBLOCK - 2
  1514 000008F0 66C7061801              	mov	word [esi], 0118h ; default vbe mode
  1515                                  				  ; 1024*768, 24bpp
  1516 000008F5 E8AD310000              	call	set_lfbinfo_table
  1517                                  
  1518 000008FA E8DC600000              	call	allocate_lfb_pages_for_kernel
  1519                                  di4:
  1520                                  	; 08/09/2016
  1521 000008FF 0F20C0                  	mov	eax, cr0
  1522 00000902 A810                    	test	al, 10h  ; Bit 4, ET (Extension Type)
  1523 00000904 7408                    	jz	short sysinit
  1524                                  	; 27/02/2017
  1525 00000906 FE05[EC960100]          	inc	byte [fpready]
  1526                                  	; 80387 (FPU) is ready
  1527 0000090C DBE3                    	fninit ; Initialize Floating-Point Unit
  1528                                  sysinit:
  1529                                  	; 30/06/2015
  1530 0000090E E8336B0000              	call	sys_init
  1531                                  	;
  1532                                  	;jmp 	cpu_reset ; 22/02/2015
  1533                                  hang:  
  1534                                  	; 23/02/2015
  1535                                  	;sti			; Enable interrupts
  1536 00000913 F4                      	hlt
  1537                                  	;
  1538                                  	;nop
  1539                                  	;; 03/12/2014
  1540                                  	;; 28/08/2014
  1541                                  	;mov	ah, 11h
  1542                                  	;call	getc
  1543                                  	;jz      _c8
  1544                                  	;
  1545                                  	; 23/02/2015
  1546                                  	; 06/02/2015
  1547                                  	; 07/09/2014
  1548 00000914 31DB                    	xor	ebx, ebx
  1549 00000916 8A1D[5E8A0100]          	mov	bl, [ptty]	; active_page
  1550 0000091C 89DE                    	mov	esi, ebx
  1551 0000091E 66D1E6                  	shl 	si, 1
  1552 00000921 81C6[608A0100]          	add	esi, ttychr
  1553 00000927 668B06                  	mov	ax, [esi]
  1554 0000092A 6621C0                  	and	ax, ax
  1555                                  	;jz	short _c8
  1556 0000092D 74E4                    	jz	short hang
  1557 0000092F 66C7060000              	mov	word [esi], 0
  1558 00000934 80FB03                  	cmp	bl, 3		; Video page 3
  1559                                  	;jb	short _c8
  1560 00000937 72DA                    	jb	short hang
  1561                                  	;	
  1562                                  	; 13/05/2016
  1563                                  	; 07/09/2014
  1564                                  nxtl:
  1565 00000939 6653                    	push	bx
  1566 0000093B 66BB0E00                	mov	bx, 0Eh 	; Yellow character 
  1567                                  				; on black background
  1568                                  				; bh = 0 (video page 0)
  1569                                  				; Retro UNIX 386 v1 - Video Mode 0
  1570                                  				; (PC/AT Video Mode 3 - 80x25 Alpha.)
  1571 0000093F 6650                    	push	ax
  1572 00000941 E8BF190000              	call 	_write_tty
  1573 00000946 6658                    	pop	ax
  1574 00000948 665B                    	pop	bx
  1575 0000094A 3C0D                    	cmp	al, 0Dh		; carriage return (enter)
  1576                                  	;jne	short _c8
  1577 0000094C 75C5                    	jne	short hang
  1578 0000094E B00A                    	mov	al, 0Ah		; next line
  1579 00000950 EBE7                    	jmp	short nxtl
  1580                                  	
  1581                                  ;_c8:
  1582                                  ;	; 25/08/2014
  1583                                  ;	cli				; Disable interrupts
  1584                                  ;	mov	al, [scounter + 1]
  1585                                  ;	and	al, al
  1586                                  ;	jnz	hang
  1587                                  ;	call	rtc_p
  1588                                  ;	jmp     hang
  1589                                  
  1590                                  	; 27/08/2014
  1591                                  	; 20/08/2014
  1592                                  printk:
  1593                                          ;mov    edi, [scr_row]
  1594                                  pkl:
  1595 00000952 AC                      	lodsb
  1596 00000953 08C0                    	or 	al, al
  1597 00000955 7404                    	jz	short pkr
  1598 00000957 66AB                    	stosw
  1599 00000959 EBF7                    	jmp	short pkl
  1600                                  pkr:
  1601 0000095B C3                      	retn
  1602                                  
  1603                                  ; 14/11/2020 (TRDOS 386 v2.0.3)
  1604 0000095C 00                      vbe3:	db 0  ; VESA VBE version (must be 03h)
  1605                                  	      ; for using video bios calls in protected mode
  1606                                  vbe2bios:
  1607 0000095D B0                      	db 0B0h ; 
  1608                                  ;pmid_addr: 		
  1609                                  	;dw 0  ; > 0 if 'PMID' sign is found 
  1610                                  	;     ;	('pmid' offset addr in VGA bios seg, 0C000h)
  1611                                  	;; 02/12/2020
  1612                                  	;dw 0	; 32 bit address in pmid_addr
  1613                                  		
  1614                                  ; 28/02/2017
  1615                                  ; 22/01/2017
  1616                                  ; 15/01/2017
  1617                                  ; 14/01/2017
  1618                                  ; 02/01/2017
  1619                                  ; 25/12/2016
  1620                                  ; 19/12/2016
  1621                                  ; 10/12/2016 (callback)
  1622                                  ; 06/06/2016
  1623                                  ; 23/05/2016
  1624                                  ; 22/05/2016 - TRDOS 386 (TRDOS v2.0) Timer Event Modifications
  1625                                  ; 25/07/2015
  1626                                  ; 14/05/2015 (multi tasking -time sharing- 'clock', x_timer)
  1627                                  ; 17/02/2015
  1628                                  ; 06/02/2015 (unix386.s)
  1629                                  ; 11/12/2014 - 22/12/2014 (dsectrm2.s) 
  1630                                  ;
  1631                                  ; IBM PC-XT Model 286 Source Code - BIOS2.ASM (06/10/85)
  1632                                  ;
  1633                                  ;-- HARDWARE INT  08 H - ( IRQ LEVEL 0 ) ---------------------------------------
  1634                                  ;	THIS ROUTINE HANDLES THE TIMER INTERRUPT FROM FROM CHANNEL 0 OF        :
  1635                                  ;	THE 8254 TIMER.  INPUT FREQUENCY IS 1.19318 MHZ AND THE DIVISOR        :
  1636                                  ;	IS 65536, RESULTING IN APPROXIMATELY 18.2 INTERRUPTS EVERY SECOND.     :
  1637                                  ;									       :
  1638                                  ;	THE INTERRUPT HANDLER MAINTAINS A COUNT (40:6C) OF INTERRUPTS SINCE    :
  1639                                  ;	POWER ON TIME, WHICH MAY BE USED TO ESTABLISH TIME OF DAY.	       :
  1640                                  ;	THE INTERRUPT HANDLER ALSO DECREMENTS THE MOTOR CONTROL COUNT (40:40)  :
  1641                                  ;	OF THE DISKETTE, AND WHEN IT EXPIRES, WILL TURN OFF THE 	       :
  1642                                  ;	DISKETTE MOTOR(s), AND RESET THE MOTOR RUNNING FLAGS.		       :
  1643                                  ;	THE INTERRUPT HANDLER WILL ALSO INVOKE A USER ROUTINE THROUGH	       :
  1644                                  ;	INTERRUPT 1CH AT EVERY TIME TICK.  THE USER MUST CODE A 	       :
  1645                                  ;	ROUTINE AND PLACE THE CORRECT ADDRESS IN THE VECTOR TABLE.	       :
  1646                                  ;-------------------------------------------------------------------------------
  1647                                  ;
  1648                                  
  1649                                  timer_int:	; IRQ 0
  1650                                  ;int_08h:	; Timer
  1651                                  	; 14/10/2015
  1652                                  	; Here, we are simulating system call entry (for task switch)
  1653                                  	; (If multitasking is enabled, 
  1654                                  	; 'clock' procedure may jump to 'sysrelease')
  1655                                  
  1656 0000095E 1E                      	push	ds
  1657 0000095F 06                      	push	es
  1658 00000960 0FA0                    	push	fs
  1659 00000962 0FA8                    	push	gs
  1660                                  
  1661 00000964 60                      	pushad	; eax, ecx, edx, ebx, esp -before pushad-, ebp, esi, edi
  1662 00000965 66B91000                	mov     cx, KDATA
  1663 00000969 8ED9                            mov     ds, cx
  1664 0000096B 8EC1                            mov     es, cx
  1665 0000096D 8EE1                            mov     fs, cx
  1666 0000096F 8EE9                            mov     gs, cx
  1667                                  
  1668 00000971 0F20D9                  	mov	ecx, cr3
  1669 00000974 890D[5C040300]          	mov	[cr3reg], ecx ; save current cr3 register value/content
  1670                                  
  1671                                  	; 14/01/2017
  1672 0000097A 3B0D[308A0100]          	cmp 	ecx, [k_page_dir]
  1673 00000980 7409                    	je	short T3
  1674                                  
  1675 00000982 8B0D[308A0100]          	mov	ecx, [k_page_dir]
  1676 00000988 0F22D9                  	mov	cr3, ecx
  1677                                  T3:
  1678                                  	;sti				; INTERRUPTS BACK ON
  1679 0000098B 66FF05[B08A0100]        	INC	word [TIMER_LOW]	; INCREMENT TIME
  1680 00000992 7507                    	JNZ	short T4		; GO TO TEST_DAY
  1681 00000994 66FF05[B28A0100]        	INC	word [TIMER_HIGH]	; INCREMENT HIGH WORD OF TIME
  1682                                  T4:					; TEST_DAY
  1683 0000099B 66833D[B28A0100]18      	CMP	word [TIMER_HIGH],018H	; TEST FOR COUNT EQUALING 24 HOURS
  1684 000009A3 7519                    	JNZ	short T5		; GO TO DISKETTE_CTL
  1685 000009A5 66813D[B08A0100]B0-     	CMP	word [TIMER_LOW],0B0H
  1685 000009AD 00                 
  1686 000009AE 750E                    	JNZ	short T5		; GO TO DISKETTE_CTL
  1687                                  
  1688                                  ;-----	TIMER HAS GONE 24 HOURS
  1689                                  	;;SUB	AX,AX
  1690                                  	;MOV	[TIMER_HIGH],AX
  1691                                  	;MOV	[TIMER_LOW],AX
  1692 000009B0 29C0                    	sub	eax, eax
  1693 000009B2 A3[B08A0100]            	mov	[TIMER_LH], eax
  1694                                  	;	
  1695 000009B7 C605[B48A0100]01        	MOV	byte [TIMER_OFL],1
  1696                                  
  1697                                  ;-----	TEST FOR DISKETTE TIME OUT
  1698                                  
  1699                                  T5:
  1700                                  	; 23/12/2014
  1701 000009BE EB1D                    	jmp	short T6		; will be replaced with nop, nop
  1702                                  					; (9090h) if a floppy disk
  1703                                  					; is detected.
  1704                                  	;mov	al,[CS:MOTOR_COUNT]
  1705 000009C0 A0[B78A0100]            	mov	al, [MOTOR_COUNT]
  1706 000009C5 FEC8                    	dec	al
  1707                                  	;mov	[CS:MOTOR_COUNT], al	; DECREMENT DISKETTE MOTOR CONTROL
  1708 000009C7 A2[B78A0100]            	mov	[MOTOR_COUNT], al
  1709                                  	;mov	[ORG_MOTOR_COUNT], al
  1710 000009CC 750F                    	JNZ	short T6		; RETURN IF COUNT NOT OUT
  1711 000009CE B0F0                    	mov 	al,0F0h
  1712                                  	;AND	[CS:MOTOR_STATUS],al 	; TURN OFF MOTOR RUNNING BITS
  1713 000009D0 2005[B68A0100]          	and	[MOTOR_STATUS], al
  1714                                  	;and	[ORG_MOTOR_STATUS], al
  1715 000009D6 B00C                    	MOV	AL,0CH			; bit 3 = enable IRQ & DMA, 
  1716                                  					; bit 2 = enable controller
  1717                                  					;	1 = normal operation
  1718                                  					;	0 = reset	
  1719                                  					; bit 0, 1 = drive select
  1720                                  					; bit 4-7 = motor running bits 
  1721 000009D8 66BAF203                	MOV	DX,03F2H		; FDC CTL PORT
  1722 000009DC EE                      	OUT	DX,AL			; TURN OFF THE MOTOR
  1723                                  T6:	
  1724                                  	;inc	word [CS:wait_count]	; 22/12/2014 (byte -> word)
  1725                                  					; TIMER TICK INTERRUPT
  1726                                  	;;inc	word [wait_count] ;;27/02/2015
  1727                                  	;INT	1CH			; TRANSFER CONTROL TO A USER ROUTINE
  1728                                  	;cli
  1729 000009DD E857040000              	call 	u_timer			; TRANSFER CONTROL TO A USER ROUTINE
  1730                                  	; 23/05/2016
  1731 000009E2 E835230100              	call	clock			; Multi Tasking control procedure
  1732                                  T7:
  1733                                  	; 14/10/2015
  1734 000009E7 B020                    	MOV	AL,EOI			; GET END OF INTERRUPT MASK
  1735 000009E9 FA                      	CLI				; DISABLE INTERRUPTS TILL STACK CLEARED
  1736 000009EA E620                    	OUT	INTA00,AL		; END OF INTERRUPT TO 8259 - 1	
  1737                                  	;
  1738                                  rtc_int_2:
  1739                                  	; 26/12/2016
  1740                                  	;mov	ecx, [cr3reg]
  1741                                  	; 13/01/2017
  1742 000009EC 803D[D4030300]00        	cmp	byte [u.t_lock], 0  	; T_LOCK
  1743 000009F3 7730                    	ja	short timer_int_return  ; Timer Lock : 'sysrele' is needed !
  1744                                  	; 28/02/2017
  1745                                  	; We need to exit if the user's IRQ callback service is in progress!
  1746                                  	; (To prevent a conflict!)
  1747 000009F5 803D[D8030300]00        	cmp	byte [u.r_lock], 0	; R_LOCK, IRQ callback service lock !
  1748 000009FC 7727                    	ja	short timer_int_return  ; Timer Lock : 'sysrele' is needed !	
  1749                                  	; 15/01/2017
  1750 000009FE 803D[C0960100]02        	cmp	byte [priority], 2
  1751 00000A05 733A                    	jnb	short T8  ; current process has a timer event (15/01/2017)
  1752                                  	; 22/05/2016
  1753 00000A07 803D[C1960100]00        	cmp	byte [p_change], 0 ; in 'set_run_sequence', in 'rtc_p'
  1754 00000A0E 7615                    	jna	short timer_int_return ; 23/05/2016
  1755                                  
  1756                                  	; 15/01/2017
  1757                                  	
  1758                                  	; present process must be changed with high priority process	
  1759                                  	;xor	al, al
  1760 00000A10 31C0                    	xor	eax, eax ; 26/12/2016
  1761 00000A12 A2[C1960100]            	mov	[p_change], al ; 0
  1762                                  	;mov	byte [priority], 2 ; 15/01/2017 (there is a timer event)
  1763                                  
  1764 00000A17 803D[5B030300]FF        	cmp     byte [sysflg], 0FFh ; user or system space ?
  1765 00000A1E 7416                    	je	short rtc_int_3     ; user space ([sysflg]= 0FFh)
  1766                                  
  1767                                  	; system space, wait for 'sysret'
  1768                                  	; to change running process 	
  1769                                  	; with high priority (event) process
  1770                                  
  1771 00000A20 A2[A8030300]            	mov	[u.quant], al ; 0
  1772                                  
  1773                                  timer_int_return: ; 23/05/2016 - jump from 'rtc_int' ('rtc_int_2')
  1774 00000A25 8B0D[5C040300]          	mov 	ecx, [cr3reg] 	; previous value/content of cr3 register
  1775 00000A2B 0F22D9                   	mov	cr3, ecx	; restore cr3 register content
  1776                                  	;
  1777 00000A2E 61                      	popad ; edi, esi, ebp, temp (icrement esp by 4), ebx, edx, ecx, eax
  1778                                  	;
  1779 00000A2F 0FA9                    	pop	gs
  1780 00000A31 0FA1                    	pop	fs
  1781 00000A33 07                      	pop	es
  1782 00000A34 1F                      	pop	ds
  1783                                  	;
  1784 00000A35 CF                      	iretd	; return from interrupt
  1785                                  
  1786                                  rtc_int_3:
  1787 00000A36 FE05[5B030300]          	inc	byte [sysflg] 	; now, we are in system space
  1788                                  	;
  1789 00000A3C E9EBCE0000                      jmp     sysrelease ; change running process immediatelly 
  1790                                  
  1791                                  T8:
  1792                                  	; 13/01/2017 (eax -> ebx)
  1793                                  	; callback checking... (19/12/2016)
  1794 00000A41 31DB                    	xor	ebx, ebx
  1795 00000A43 871D[D0030300]          	xchg	ebx, [u.tcb] ; callback address (0 = normal return)
  1796 00000A49 09DB                    	or	ebx, ebx
  1797 00000A4B 74D8                    	jz	short timer_int_return
  1798                                  
  1799                                  	; Set user's callback routine as return address from this interrupt
  1800                                  	; and set normal return address as return address from callback
  1801                                  	; routine!!! (19/12/2016)
  1802                                  	
  1803                                  	; 14/01/2017
  1804                                  	; 13/01/2017 - Timer Lock (T_LOCK)
  1805 00000A4D FE05[D4030300]          	inc	byte [u.t_lock]
  1806 00000A53 8A0D[5B030300]          	mov	cl, [sysflg]
  1807 00000A59 880D[D5030300]          	mov	[u.t_mode], cl 
  1808                                  
  1809 00000A5F 8B2D[CC890100]          	mov	ebp, [tss.esp0] ; kernel stack address (for ring 0)
  1810 00000A65 83ED14                  	sub	ebp, 20		; eip, cs, eflags, esp, ss
  1811 00000A68 892D[5C030300]           	mov	[u.sp], ebp
  1812 00000A6E 8925[60030300]          	mov	[u.usp], esp
  1813                                  
  1814                                  	;or	word [ebp+8], 200h ; 22/01/2017, force enabling interrupts
  1815                                  
  1816 00000A74 8B44241C                	mov	eax, [esp+28] ; pushed eax
  1817 00000A78 A3[64030300]            	mov	[u.r0], eax
  1818                                  
  1819 00000A7D E8960F0100              	call	wswap ; save user's registers & status
  1820                                  
  1821                                  	; software int is in ring 0 but timer int must return to ring 3
  1822                                  	; so, ring 3 return address and stack registers
  1823                                  	; (eip, cs, eflags, esp, ss) 
  1824                                  	; must be copied to timer int return
  1825                                  	; eip will be replaced by callback service routine address
  1826                                  
  1827 00000A82 C605[5B030300]FF        	mov	byte [sysflg], 0FFh ; user mode
  1828                                  
  1829                                  	; system mode (system call)
  1830                                  	;mov	ebp, [u.sp] ; EIP (u), CS (UCODE), EFLAGS (u),
  1831                                  			    ; ESP (u), SS (UDATA)
  1832                                  
  1833 00000A89 8B4510                  	mov	eax, [ebp+16]	; SS (UDATA
  1834 00000A8C 89E6                    	mov	esi, esp
  1835 00000A8E 50                      	push	eax
  1836 00000A8F 50                      	push	eax
  1837 00000A90 89E7                    	mov	edi, esp
  1838 00000A92 893D[60030300]          	mov	[u.usp], edi
  1839 00000A98 B908000000              	mov	ecx, ((ESPACE/4) - 4) ; except DS, ES, FS, GS
  1840 00000A9D F3A5                    	rep	movsd
  1841 00000A9F B104                    	mov	cl, 4	
  1842 00000AA1 F3AB                    	rep	stosd
  1843 00000AA3 893D[5C030300]          	mov	[u.sp], edi
  1844 00000AA9 89EE                    	mov	esi, ebp
  1845 00000AAB B105                    	mov	cl, 5 ; EIP (u), CS (UCODE), EFLAGS (u), ESP (u), SS (UDATA)
  1846 00000AAD F3A5                    	rep	movsd
  1847                                  
  1848 00000AAF 8B0D[B8030300]          	mov	ecx, [u.pgdir]
  1849 00000AB5 890D[5C040300]          	mov	[cr3reg], ecx
  1850                                  
  1851                                  	; 13/01/207 (eax -> ebx)
  1852                                  	; EBX = callback routine address (virtual, not physical address!)
  1853                                  
  1854                                  	; 09/01/2017
  1855                                  	; !!! CALLBACK ROUTINE MUST BE ENDED/RETURNED WITH 'sysrele'
  1856                                  	;     system call !!!	
  1857                                  	; 25/12/2016
  1858                                  	; Callback Note: (19/12/2016)
  1859                                  	; !!! CALLBACK ROUTINE MUST BE ENDED/RETURNED WITH 'RETN' !!!
  1860                                  	;	pushf ; save flags	
  1861                                  	; 	<callback service code>
  1862                                  	; 	popf  ; restore flags
  1863                                  	; 	retn ; return to normal running address
  1864                                  	;
  1865                                  
  1866                                  	; 15/01/2017
  1867                                  	; 14/01/2017
  1868                                  	; 13/01/2017 (eax -> ebx)
  1869                                  	; 10/01/2017
  1870                                  set_callback_addr:
  1871                                  	; 09/01/2017 (**)
  1872                                  	; 02/01/2017 (*)
  1873                                  	; 25/12/2016 (*)
  1874                                  	; 19/12/2016 (TRDOS 386 feature only!)
  1875                                  	;
  1876                                  	; This routine sets return address
  1877                                  	; to start of user's interrupt
  1878                                  	; service (callback) address
  1879                                  	;; and sets callback 'retn' address to normal
  1880                                  	;; return address of user's running code! 
  1881                                  	;
  1882                                  	; INPUT:
  1883                                  	;	EBX = callback routine/service address
  1884                                  	;	      (virtual, not physical address!)	
  1885                                  	;	[u.sp] = kernel stack, points to
  1886                                  	;		 user's EIP,CS,EFLAGS,ESP,SS
  1887                                  	;		 registers.
  1888                                  	; OUTPUT:
  1889                                  	;	EIP (user) = callback (service) address
  1890                                  	;	CS (user) = UCODE
  1891                                  	;	EFLAGS (user) = flags before callback 	 
  1892                                  	;       ESP (user) = ESP-4 (user, before callback) 
  1893                                  	;	[ESP](user) = EIP (user) before callback
  1894                                  	;
  1895                                  	; Note: If CPU was in user mode while entering 
  1896                                  	;	the timer interrupt service routine,
  1897                                  	;	'IRET' will get return to callback routine
  1898                                  	;	immediately. If CPU was in system/kernel mode  
  1899                                  	;	'iret' will get return to system call and
  1900                                  	;	then, callback routine will be return address
  1901                                  	;	from system call. (User's callback/service code
  1902                                  	;	will be able to return to normal return address
  1903                                  	;	via an 'retn' at the end.) 
  1904                                  	;
  1905                                  	; Note(**): User's callback service code must be ended
  1906                                  	;	with a 'sysrele' sytstem call ! (09/01/2017)
  1907                                  	;
  1908                                  	;	For example:
  1909                                  	;
  1910                                  	;	timer_callback:
  1911                                  	;	    ...	 
  1912                                    	;	    inc	dword [time_counter]
  1913                                  	;	    ...
  1914                                  	;	    mov eax, 39 ; 'sysrele'
  1915                                  	;	    int 40h ; TRDOS 386 system call (interrupt)		
  1916                                  	;
  1917                                  	;
  1918                                  	;; Note(*): User's callback service code must preserve cpu 
  1919                                  	;;	flags if it has any instructions which changes
  1920                                  	;;	flags in the service code. (25/12/2016)
  1921                                  	;;
  1922                                  	;;	For example:
  1923                                  	;;
  1924                                  	;;	timer_callback:
  1925                                  	;;	    pushf ; save flags
  1926                                  	;;	    ; this instruction changes zero flag
  1927                                    	;;	    inc	dword [time_counter]
  1928                                  	;;	    popf ; restore flags
  1929                                  	;;	    retn ; return to normal user code
  1930                                  	;;		  (which is interrupted by the 
  1931                                  	;;		   timer interput) 	
  1932                                  	;;
  1933                                  
  1934                                  	; 15/01/2017
  1935 00000ABB 8B2D[5C030300]          	mov	ebp, [u.sp]; kernel's stack, points to EIP (user)
  1936 00000AC1 895D00                  	mov	[ebp], ebx
  1937 00000AC4 E95CFFFFFF              	jmp	timer_int_return
  1938                                  
  1939                                  	; 15/01/2017
  1940                                  	; 13/01/2017
  1941                                  	; 19/12/2016
  1942                                  	; 06/06/2016
  1943                                  	; 23/05/2016
  1944                                  	; 22/05/2016
  1945                                  	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
  1946                                  	; 26/02/2015
  1947                                  	; 07/09/2014
  1948                                  	; 25/08/2014
  1949                                  rtc_int:       ; Real Time Clock Interrupt (IRQ 8)
  1950                                  	; 22/05/2016
  1951 00000AC9 1E                      	push	ds ; ** ; 23/05/2016
  1952 00000ACA 50                      	push	eax ; *
  1953 00000ACB 66B81000                	mov	ax, KDATA
  1954 00000ACF 8ED8                    	mov	ds, ax
  1955                                  	;
  1956 00000AD1 8A25[AE8A0100]          	mov	ah, [RTC_2Hz] ;  2 Hz interrupt to 1 Hz function
  1957 00000AD7 80F401                  	xor	ah, 1
  1958 00000ADA 8825[AE8A0100]          	mov	[RTC_2Hz], ah ; 1 = 0.5 second, 0 = 1 second
  1959 00000AE0 753B                    	jnz	short rtc_int_return ; half second
  1960                                  	; 1 second
  1961                                  rtc_int_0:
  1962                                  	; 22/05/2016
  1963 00000AE2 58                      	pop	eax ; *
  1964                                  	;
  1965                                  	; 14/10/2015 ('timer_int')
  1966                                  	; Here, we are simulating system call entry (for task switch)
  1967                                  	; (If multitasking is enabled, 
  1968                                  	; 'clock' procedure may jump to 'sysrelease')
  1969                                  	;push	ds ; ** ; 23/05/2016
  1970 00000AE3 06                      	push	es
  1971 00000AE4 0FA0                    	push	fs
  1972 00000AE6 0FA8                    	push	gs
  1973 00000AE8 60                      	pushad  ; eax, ecx, edx, ebx, esp -before pushad-, ebp, esi, edi
  1974 00000AE9 66B91000                	mov     cx, KDATA
  1975                                          ;mov    ds, cx ; 06/06/2016
  1976 00000AED 8EC1                            mov     es, cx
  1977 00000AEF 8EE1                            mov     fs, cx
  1978 00000AF1 8EE9                            mov     gs, cx
  1979                                  	;
  1980 00000AF3 0F20D9                  	mov	ecx, cr3
  1981 00000AF6 890D[5C040300]          	mov	[cr3reg], ecx ; save current cr3 register value/content
  1982                                  	;
  1983 00000AFC 803D[D4030300]00        	cmp	byte [u.t_lock], 0 ; timer lock (callback) status ?
  1984 00000B03 7711                    	ja	short rtc_int_1	   ; yes
  1985                                  
  1986                                  	; 15/01/2017
  1987 00000B05 3B0D[308A0100]          	cmp 	ecx, [k_page_dir]
  1988 00000B0B 7409                    	je	short rtc_int_1
  1989                                  
  1990 00000B0D 8B0D[308A0100]          	mov	ecx, [k_page_dir]
  1991 00000B13 0F22D9                  	mov	cr3, ecx
  1992                                  rtc_int_1:
  1993                                  	; Timer event (kernel) functions must be performed with
  1994                                  	; 1 second intervals - TRDOS 386 (TRDOS v2.0) feature ! -
  1995                                   	;	
  1996                                  	; 25/08/2014
  1997 00000B16 E81A030000              	call	rtc_p  ; 19/05/2016 - major modification 
  1998                                  	
  1999                                  	; 23/05/2016
  2000 00000B1B 28E4                    	sub	ah, ah ; 0
  2001                                  	; 22/05/2016 - TRDOS 386 timer event modifications
  2002                                  rtc_int_return: ; 19/05/2016
  2003                                  	; 22/02/2015 - dsectpm.s
  2004                                  	; [ source: http://wiki.osdev.org/RTC ]
  2005                                  	; read status register C to complete procedure
  2006                                  	;(it is needed to get a next IRQ 8) 
  2007 00000B1D B00C                    	mov	al, 0Ch ; 
  2008 00000B1F E670                    	out	70h, al ; select register C
  2009 00000B21 90                      	nop
  2010 00000B22 E471                    	in	al, 71h ; just throw away contents
  2011                                  	; 22/02/2015
  2012 00000B24 B020                    	MOV	AL,EOI		; END OF INTERRUPT
  2013                                  	;CLI			; DISABLE INTERRUPTS TILL STACK CLEARED
  2014 00000B26 E6A0                    	OUT	INTB00,AL	; FOR CONTROLLER #2
  2015                                  
  2016                                  	; 23/05/2016
  2017 00000B28 B020                    	MOV	AL,EOI		; GET END OF INTERRUPT MASK
  2018 00000B2A FA                      	CLI			; DISABLE INTERRUPTS TILL STACK CLEARED
  2019 00000B2B E620                    	OUT	INTA00,AL	; END OF INTERRUPT TO 8259 - 1	
  2020                                  	;
  2021                                  	; 23/05/2016
  2022 00000B2D 20E4                    	and	ah, ah
  2023 00000B2F 0F84B7FEFFFF                    jz      rtc_int_2
  2024                                  	
  2025                                  	; ah = 1 (half second)
  2026 00000B35 58                      	pop	eax ; *
  2027 00000B36 1F                      	pop	ds  ; **
  2028 00000B37 CF                      	iretd
  2029                                  
  2030                                  ; ////////////////
  2031                                  
  2032                                  	; 28/08/2014
  2033                                  irq0:
  2034 00000B38 6A00                            push 	dword 0
  2035 00000B3A EB48                    	jmp	short which_irq
  2036                                  irq1:
  2037 00000B3C 6A01                            push 	dword 1
  2038 00000B3E EB44                    	jmp	short which_irq
  2039                                  irq2:
  2040 00000B40 6A02                            push 	dword 2
  2041 00000B42 EB40                    	jmp	short which_irq
  2042                                  irq3:
  2043                                  	; 20/11/2015
  2044                                  	; 24/10/2015
  2045 00000B44 2EFF15[DA2F0100]        	call	dword [cs:com2_irq3]
  2046 00000B4B 6A03                    	push 	dword 3
  2047 00000B4D EB35                    	jmp	short which_irq
  2048                                  irq4:
  2049                                  	; 20/11/2015
  2050                                  	; 24/10/2015
  2051 00000B4F 2EFF15[D62F0100]        	call	dword [cs:com1_irq4]
  2052 00000B56 6A04                            push 	dword 4
  2053 00000B58 EB2A                    	jmp	short which_irq
  2054                                  irq5:
  2055 00000B5A 6A05                            push 	dword 5
  2056 00000B5C EB26                    	jmp	short which_irq
  2057                                  irq6:
  2058 00000B5E 6A06                            push 	dword 6
  2059 00000B60 EB22                    	jmp	short which_irq
  2060                                  irq7:
  2061 00000B62 6A07                            push 	dword 7
  2062 00000B64 EB1E                    	jmp	short which_irq
  2063                                  irq8:
  2064 00000B66 6A08                            push 	dword 8
  2065 00000B68 EB1A                    	jmp	short which_irq
  2066                                  irq9:
  2067 00000B6A 6A09                            push 	dword 9
  2068 00000B6C EB16                    	jmp	short which_irq
  2069                                  irq10:
  2070 00000B6E 6A0A                            push 	dword 10
  2071 00000B70 EB12                    	jmp	short which_irq
  2072                                  irq11:
  2073 00000B72 6A0B                            push 	dword 11
  2074 00000B74 EB0E                    	jmp	short which_irq
  2075                                  irq12:
  2076 00000B76 6A0C                            push 	dword 12
  2077 00000B78 EB0A                    	jmp	short which_irq
  2078                                  irq13:
  2079 00000B7A 6A0D                            push 	dword 13
  2080 00000B7C EB06                    	jmp	short which_irq
  2081                                  irq14:
  2082 00000B7E 6A0E                            push 	dword 14
  2083 00000B80 EB02                    	jmp	short which_irq
  2084                                  irq15:
  2085 00000B82 6A0F                            push 	dword 15
  2086                                  	;jmp	short which_irq
  2087                                  
  2088                                  	; 22/01/2017
  2089                                  	; 19/10/2015
  2090                                  	; 29/08/2014
  2091                                  	; 21/08/2014
  2092                                  which_irq:
  2093 00000B84 870424                  	xchg	eax, [esp]  ; 28/08/2014
  2094 00000B87 53                      	push	ebx
  2095 00000B88 56                      	push	esi
  2096 00000B89 57                      	push	edi
  2097 00000B8A 1E                      	push 	ds
  2098 00000B8B 06                      	push 	es
  2099                                  	;
  2100 00000B8C 88C3                    	mov	bl, al
  2101                                  	;
  2102 00000B8E B810000000              	mov	eax, KDATA
  2103 00000B93 8ED8                    	mov	ds, ax
  2104 00000B95 8EC0                    	mov	es, ax
  2105                                  	; 19/10/2015
  2106 00000B97 FC                      	cld
  2107                                          ; 27/08/2014
  2108 00000B98 8105[384A0100]A000-             add     dword [scr_row], 0A0h
  2108 00000BA0 0000               
  2109                                  	;
  2110 00000BA2 B417                    	mov	ah, 17h	; blue (1) background, 
  2111                                  			; light gray (7) forecolor
  2112 00000BA4 8B3D[384A0100]                  mov     edi, [scr_row]
  2113 00000BAA B049                    	mov	al, 'I'
  2114 00000BAC 66AB                    	stosw
  2115 00000BAE B052                    	mov	al, 'R'
  2116 00000BB0 66AB                    	stosw
  2117 00000BB2 B051                    	mov	al, 'Q'
  2118 00000BB4 66AB                    	stosw
  2119 00000BB6 B020                    	mov	al, ' '
  2120 00000BB8 66AB                    	stosw
  2121 00000BBA 88D8                    	mov	al, bl
  2122 00000BBC 3C0A                    	cmp	al, 10
  2123 00000BBE 7208                    	jb	short ii1
  2124 00000BC0 B031                    	mov	al, '1'
  2125 00000BC2 66AB                    	stosw
  2126 00000BC4 88D8                    	mov	al, bl
  2127 00000BC6 2C0A                    	sub	al, 10
  2128                                  ii1:
  2129 00000BC8 0430                    	add	al, '0'
  2130 00000BCA 66AB                    	stosw
  2131 00000BCC B020                    	mov	al, ' '
  2132 00000BCE 66AB                    	stosw
  2133 00000BD0 B021                    	mov	al, '!'
  2134 00000BD2 66AB                    	stosw
  2135 00000BD4 B020                    	mov	al, ' '
  2136 00000BD6 66AB                    	stosw
  2137                                  	; 23/02/2015
  2138 00000BD8 80FB07                  	cmp	bl, 7 ; check for IRQ 8 to IRQ 15 
  2139 00000BDB 7604                    	jna	ii2
  2140                                  	; 22/01/2017
  2141 00000BDD B020                    	mov	al, 20h  ; END OF INTERRUPT COMMAND TO
  2142 00000BDF E6A0                    	out	0A0h, al ; the 2nd 8259
  2143                                  ii2:
  2144 00000BE1 B020                    	mov	al, 20h  ; END OF INTERRUPT COMMAND TO
  2145 00000BE3 E620                    	out	20h, al ; the 2nd 8259
  2146 00000BE5 E9CD010000              	jmp     iiret
  2147                                  	;
  2148                                  	; 22/08/2014
  2149                                  	;mov	al, 20h ; END OF INTERRUPT COMMAND TO 8259
  2150                                  	;out	20h, al	; 8259 PORT
  2151                                  	;
  2152                                  	;pop	es
  2153                                  	;pop	ds
  2154                                  	;pop	edi
  2155                                  	;pop	esi
  2156                                  	;pop	ebx
  2157                                  	;pop 	eax
  2158                                  	;iret
  2159                                  
  2160                                  	; 02/04/2015
  2161                                  	; 25/08/2014
  2162                                  exc0:
  2163 00000BEA 6A00                            push 	dword 0
  2164 00000BEC E990000000                      jmp     cpu_except
  2165                                  exc1:
  2166 00000BF1 6A01                            push 	dword 1
  2167 00000BF3 E989000000                      jmp     cpu_except
  2168                                  exc2:
  2169 00000BF8 6A02                            push 	dword 2
  2170 00000BFA E982000000                      jmp     cpu_except
  2171                                  exc3:
  2172 00000BFF 6A03                            push 	dword 3
  2173 00000C01 EB7E                            jmp     cpu_except
  2174                                  exc4:
  2175 00000C03 6A04                            push 	dword 4
  2176 00000C05 EB7A                            jmp     cpu_except
  2177                                  exc5:
  2178 00000C07 6A05                            push 	dword 5
  2179 00000C09 EB76                            jmp     cpu_except
  2180                                  exc6:
  2181 00000C0B 6A06                            push 	dword 6
  2182 00000C0D EB72                            jmp     cpu_except
  2183                                  exc7:
  2184 00000C0F 6A07                            push 	dword 7
  2185 00000C11 EB6E                            jmp     cpu_except
  2186                                  exc8:
  2187                                  	; [esp] = Error code
  2188 00000C13 6A08                            push 	dword 8
  2189 00000C15 EB5C                            jmp     cpu_except_en
  2190                                  exc9:
  2191 00000C17 6A09                            push 	dword 9
  2192 00000C19 EB66                            jmp     cpu_except
  2193                                  exc10:
  2194                                  	; [esp] = Error code
  2195 00000C1B 6A0A                            push 	dword 10
  2196 00000C1D EB54                            jmp     cpu_except_en
  2197                                  exc11:
  2198                                  	; [esp] = Error code
  2199 00000C1F 6A0B                            push 	dword 11
  2200 00000C21 EB50                            jmp     cpu_except_en
  2201                                  exc12:
  2202                                  	; [esp] = Error code
  2203 00000C23 6A0C                            push 	dword 12
  2204 00000C25 EB4C                            jmp     cpu_except_en
  2205                                  exc13:
  2206                                  	; [esp] = Error code
  2207 00000C27 6A0D                            push 	dword 13
  2208 00000C29 EB48                            jmp     cpu_except_en
  2209                                  exc14:
  2210                                  	; [esp] = Error code
  2211 00000C2B 6A0E                            push 	dword 14
  2212 00000C2D EB44                    	jmp	short cpu_except_en
  2213                                  exc15:
  2214 00000C2F 6A0F                            push 	dword 15
  2215 00000C31 EB4E                            jmp     cpu_except
  2216                                  exc16:
  2217 00000C33 6A10                            push 	dword 16
  2218 00000C35 EB4A                            jmp     cpu_except
  2219                                  exc17:
  2220                                  	; [esp] = Error code
  2221 00000C37 6A11                            push 	dword 17
  2222 00000C39 EB38                    	jmp	short cpu_except_en
  2223                                  exc18:
  2224 00000C3B 6A12                            push 	dword 18
  2225 00000C3D EB42                    	jmp	short cpu_except
  2226                                  exc19:
  2227 00000C3F 6A13                            push 	dword 19
  2228 00000C41 EB3E                    	jmp	short cpu_except
  2229                                  exc20:
  2230 00000C43 6A14                            push 	dword 20
  2231 00000C45 EB3A                    	jmp	short cpu_except
  2232                                  exc21:
  2233 00000C47 6A15                            push 	dword 21
  2234 00000C49 EB36                    	jmp	short cpu_except
  2235                                  exc22:
  2236 00000C4B 6A16                            push 	dword 22
  2237 00000C4D EB32                    	jmp	short cpu_except
  2238                                  exc23:
  2239 00000C4F 6A17                            push 	dword 23
  2240 00000C51 EB2E                    	jmp	short cpu_except
  2241                                  exc24:
  2242 00000C53 6A18                            push 	dword 24
  2243 00000C55 EB2A                    	jmp	short cpu_except
  2244                                  exc25:
  2245 00000C57 6A19                            push 	dword 25
  2246 00000C59 EB26                    	jmp	short cpu_except
  2247                                  exc26:
  2248 00000C5B 6A1A                            push 	dword 26
  2249 00000C5D EB22                    	jmp	short cpu_except
  2250                                  exc27:
  2251 00000C5F 6A1B                            push 	dword 27
  2252 00000C61 EB1E                    	jmp	short cpu_except
  2253                                  exc28:
  2254 00000C63 6A1C                            push 	dword 28
  2255 00000C65 EB1A                    	jmp	short cpu_except
  2256                                  exc29:
  2257 00000C67 6A1D                            push 	dword 29
  2258 00000C69 EB16                    	jmp	short cpu_except
  2259                                  exc30:
  2260 00000C6B 6A1E                            push 	dword 30
  2261 00000C6D EB04                    	jmp	short cpu_except_en
  2262                                  exc31:
  2263 00000C6F 6A1F                            push 	dword 31
  2264 00000C71 EB0E                            jmp     short cpu_except
  2265                                  
  2266                                  	; 19/10/2015
  2267                                  	; 19/09/2015
  2268                                  	; 01/09/2015
  2269                                  	; 28/08/2015
  2270                                  	; 28/08/2014
  2271                                  cpu_except_en:
  2272 00000C73 87442404                	xchg	eax, [esp+4] ; Error code
  2273 00000C77 36A3[78050300]          	mov	[ss:error_code], eax
  2274 00000C7D 58                      	pop	eax  ; Exception number
  2275 00000C7E 870424                  	xchg	eax, [esp]
  2276                                  		; eax = eax before exception
  2277                                  		; [esp] -> exception number
  2278                                  		; [esp+4] -> EIP to return
  2279                                  	; 22/01/2017
  2280                                  	; 19/10/2015
  2281                                  	; 19/09/2015
  2282                                  	; 01/09/2015
  2283                                  	; 28/08/2015
  2284                                  	; 29/08/2014
  2285                                  	; 28/08/2014
  2286                                  	; 25/08/2014
  2287                                  	; 21/08/2014
  2288                                  cpu_except:	; CPU Exceptions
  2289 00000C81 FC                      	cld
  2290 00000C82 870424                  	xchg	eax, [esp] 
  2291                                  		; eax = Exception number
  2292                                  		; [esp] = eax (before exception)	
  2293 00000C85 53                      	push	ebx
  2294 00000C86 56                      	push	esi
  2295 00000C87 57                      	push	edi
  2296 00000C88 1E                      	push 	ds
  2297 00000C89 06                      	push 	es
  2298                                  	; 28/08/2015
  2299 00000C8A 66BB1000                	mov	bx, KDATA
  2300 00000C8E 8EDB                    	mov	ds, bx
  2301 00000C90 8EC3                    	mov	es, bx
  2302 00000C92 0F20DB                  	mov	ebx, cr3
  2303 00000C95 53                      	push	ebx ; (*) page directory
  2304                                  	; 19/10/2015
  2305 00000C96 FC                      	cld
  2306                                  	; 25/03/2015
  2307 00000C97 8B1D[308A0100]          	mov	ebx, [k_page_dir]
  2308 00000C9D 0F22DB                  	mov	cr3, ebx
  2309                                  	; 28/08/2015
  2310 00000CA0 83F80E                  	cmp	eax, 0Eh ; 14, PAGE FAULT	
  2311 00000CA3 750F                    	jne	short cpu_except_nfp
  2312 00000CA5 E809520000              	call	page_fault_handler
  2313 00000CAA 21C0                    	and 	eax, eax
  2314 00000CAC 0F8401010000                    jz	iiretp ; 01/09/2015
  2315 00000CB2 B00E                    	mov	al, 0Eh ; 14
  2316                                  cpu_except_nfp:
  2317                                  	; 23/08/2016
  2318 00000CB4 803D[DA6F0000]03        	cmp	byte [CRT_MODE], 3
  2319 00000CBB 7409                    	je	short cpu_except_mode_3
  2320 00000CBD 50                      	push	eax
  2321 00000CBE B003                    	mov	al, 3
  2322 00000CC0 E8AB0E0000              	call	_set_mode
  2323 00000CC5 58                      	pop	eax
  2324                                  cpu_except_mode_3:
  2325                                  	; 02/04/2015
  2326 00000CC6 BB[13090000]            	mov	ebx, hang
  2327 00000CCB 875C241C                	xchg	ebx, [esp+28]
  2328                                  		; EIP (points to instruction which faults)
  2329                                  	  	; New EIP (hang)
  2330 00000CCF 891D[7C050300]          	mov	[FaultOffset], ebx
  2331 00000CD5 C744242008000000        	mov	dword [esp+32], KCODE ; kernel's code segment
  2332 00000CDD 814C242400020000        	or	dword [esp+36], 200h ; enable interrupts (set IF)
  2333                                  	;
  2334 00000CE5 88C4                    	mov	ah, al
  2335 00000CE7 240F                    	and	al, 0Fh
  2336 00000CE9 3C09                    	cmp	al, 9
  2337 00000CEB 7602                    	jna	short h1ok
  2338 00000CED 0407                    	add	al, 'A'-':'
  2339                                  h1ok:
  2340 00000CEF C0EC04                  	shr	ah, 4
  2341 00000CF2 80FC09                  	cmp	ah, 9
  2342 00000CF5 7603                    	jna	short h2ok
  2343 00000CF7 80C407                  	add	ah, 'A'-':'
  2344                                  h2ok:	
  2345 00000CFA 86E0                    	xchg 	ah, al	
  2346 00000CFC 66053030                	add	ax, '00'
  2347 00000D00 66A3[904C0100]          	mov	[excnstr], ax
  2348                                  	;
  2349                                  	; 29/08/2014
  2350 00000D06 A1[7C050300]            	mov	eax, [FaultOffset]
  2351 00000D0B 51                      	push	ecx
  2352 00000D0C 52                      	push	edx
  2353 00000D0D 89E3                    	mov	ebx, esp
  2354                                  	; 28/08/2015
  2355 00000D0F B910000000              	mov	ecx, 16	  ; divisor value to convert binary number
  2356                                  			  ; to hexadecimal string
  2357                                  	;mov	ecx, 10	    ; divisor to convert	
  2358                                  			    ; binary number to decimal string
  2359                                  b2d1:
  2360 00000D14 31D2                    	xor	edx, edx
  2361 00000D16 F7F1                    	div	ecx
  2362 00000D18 6652                    	push	dx
  2363 00000D1A 39C8                    	cmp	eax, ecx
  2364 00000D1C 73F6                    	jnb	short b2d1
  2365 00000D1E BF[9B4C0100]            	mov	edi, EIPstr ; EIP value
  2366                                  			    ; points to instruction which faults	
  2367                                  	; 28/08/2015
  2368 00000D23 89C2                    	mov	edx, eax
  2369                                  b2d2:
  2370                                  	;add	al, '0'
  2371 00000D25 8A82[27430000]          	mov	al, [edx+hexchrs]
  2372 00000D2B AA                      	stosb		    ; write hexadecimal digit to its place	
  2373 00000D2C 39E3                    	cmp	ebx, esp
  2374 00000D2E 7606                    	jna	short b2d3
  2375 00000D30 6658                    	pop	ax
  2376 00000D32 88C2                    	mov	dl, al
  2377 00000D34 EBEF                    	jmp	short b2d2
  2378                                  b2d3:
  2379 00000D36 B068                    	mov 	al, 'h' ; 28/08/2015
  2380 00000D38 AA                      	stosb
  2381 00000D39 B020                    	mov	al, 20h	    ; space
  2382 00000D3B AA                      	stosb
  2383 00000D3C 30C0                    	xor	al, al	    ; to do it an ASCIIZ string	
  2384 00000D3E AA                      	stosb
  2385                                  	;
  2386 00000D3F 5A                      	pop	edx
  2387 00000D40 59                      	pop	ecx
  2388                                  	;
  2389 00000D41 B44F                    	mov	ah, 4Fh	; red (4) background, 
  2390                                  			; white (F) forecolor
  2391 00000D43 BE[804C0100]            	mov	esi, exc_msg ; message offset
  2392                                  	;
  2393                                  	; 20/01/2017 (!cpu exception!)
  2394                                  	;
  2395 00000D48 8105[384A0100]A000-             add    dword [scr_row], 0A0h
  2395 00000D50 0000               
  2396 00000D52 8B3D[384A0100]                  mov    edi, [scr_row]
  2397                                  	;	
  2398 00000D58 C605[5B030300]00        	mov	byte [sysflg], 0  ; system mode
  2399 00000D5F FB                              sti
  2400                                  	;
  2401 00000D60 E8EDFBFFFF              	call 	printk
  2402                                  	;
  2403 00000D65 B410                    	mov	ah, 10h
  2404 00000D67 E881010000              	call	int16h ; getc
  2405                                  	;
  2406 00000D6C B003                    	mov	al, 3
  2407 00000D6E E8FD0D0000              	call	_set_mode
  2408                                  	;
  2409 00000D73 B801000000              	mov	eax, 1
  2410 00000D78 E916CD0000              	jmp	sysexit ; terminate process !!!
  2411                                  	
  2412                                  	; 22/01/2017
  2413                                  	; 18/04/2016
  2414                                  	; 28/08/2015
  2415                                  	; 23/02/2015
  2416                                  	; 20/08/2014
  2417                                  ignore_int:
  2418 00000D7D 50                      	push	eax
  2419 00000D7E 53                      	push	ebx ; 23/02/2015
  2420 00000D7F 56                      	push	esi
  2421 00000D80 57                      	push	edi
  2422 00000D81 1E                      	push 	ds
  2423 00000D82 06                      	push 	es
  2424                                  	; 18/04/2016
  2425 00000D83 66B81000                	mov	ax, KDATA
  2426 00000D87 8ED8                    	mov	ds, ax
  2427 00000D89 8EC0                    	mov	es, ax
  2428                                  	; 28/08/2015
  2429 00000D8B 0F20D8                  	mov	eax, cr3
  2430 00000D8E 50                      	push	eax ; (*) page directory
  2431                                  	;
  2432 00000D8F B467                    	mov	ah, 67h	; brown (6) background, 
  2433                                  			; light gray (7) forecolor
  2434 00000D91 BE[484B0100]            	mov	esi, int_msg ; message offset
  2435                                  piemsg:
  2436                                          ; 27/08/2014
  2437 00000D96 8105[384A0100]A000-             add     dword [scr_row], 0A0h
  2437 00000D9E 0000               
  2438 00000DA0 8B3D[384A0100]                  mov     edi, [scr_row]
  2439                                          ;
  2440 00000DA6 E8A7FBFFFF              	call 	printk
  2441                                  	;
  2442                                  	; 23/02/2015
  2443 00000DAB B020                    	mov	al, 20h  ; END OF INTERRUPT COMMAND TO
  2444 00000DAD E6A0                    	out	0A0h, al ; the 2nd 8259
  2445                                  	; 22/08/2014
  2446 00000DAF B020                    	mov	al, 20h ; END OF INTERRUPT COMMAND TO 8259
  2447 00000DB1 E620                    	out	20h, al	; 8259 PORT
  2448                                  iiretp: 
  2449                                  	; 22/01/2017
  2450                                  	; 01/09/2015
  2451                                  	; 28/08/2015
  2452 00000DB3 58                      	pop	eax ; (*) page directory
  2453 00000DB4 0F22D8                  	mov	cr3, eax
  2454                                  iiret:
  2455 00000DB7 07                      	pop	es
  2456 00000DB8 1F                      	pop	ds
  2457 00000DB9 5F                      	pop	edi
  2458 00000DBA 5E                      	pop	esi
  2459 00000DBB 5B                      	pop	ebx ; 29/08/2014
  2460 00000DBC 58                      	pop 	eax
  2461 00000DBD CF                      	iretd
  2462                                  
  2463                                  	; 23/05/2016
  2464                                  	; 22/08/2014
  2465                                  	; IBM PC/AT BIOS source code ----- 10/06/85 (bios.asm)
  2466                                  	; (INT 1Ah)
  2467                                  	;; Linux (v0.12) source code (main.c) by Linus Torvalds (1991)
  2468                                  time_of_day:
  2469 00000DBE E8DF5E0000              	call	UPD_IPR			; WAIT TILL UPDATE NOT IN PROGRESS
  2470 00000DC3 726F                            jc      short time_of_day_retn ; 23/05/2016
  2471 00000DC5 B000                    	mov	al, CMOS_SECONDS
  2472 00000DC7 E8F15E0000              	call	CMOS_READ
  2473 00000DCC A2[A08A0100]            	mov	[time_seconds], al 
  2474 00000DD1 B002                    	mov	al, CMOS_MINUTES
  2475 00000DD3 E8E55E0000              	call	CMOS_READ
  2476 00000DD8 A2[A18A0100]            	mov	[time_minutes], al 
  2477 00000DDD B004                    	mov	al, CMOS_HOURS
  2478 00000DDF E8D95E0000              	call	CMOS_READ
  2479 00000DE4 A2[A28A0100]                    mov     [time_hours], al
  2480 00000DE9 B006                    	mov	al, CMOS_DAY_WEEK 
  2481 00000DEB E8CD5E0000              	call	CMOS_READ
  2482 00000DF0 A2[A38A0100]            	mov	[date_wday], al
  2483 00000DF5 B007                     	mov	al, CMOS_DAY_MONTH
  2484 00000DF7 E8C15E0000              	call	CMOS_READ
  2485 00000DFC A2[A48A0100]            	mov	[date_day], al
  2486 00000E01 B008                    	mov	al, CMOS_MONTH
  2487 00000E03 E8B55E0000              	call	CMOS_READ
  2488 00000E08 A2[A58A0100]            	mov	[date_month], al
  2489 00000E0D B009                    	mov	al, CMOS_YEAR
  2490 00000E0F E8A95E0000              	call	CMOS_READ
  2491 00000E14 A2[A68A0100]            	mov	[date_year], al
  2492 00000E19 B032                    	mov	al, CMOS_CENTURY
  2493 00000E1B E89D5E0000              	call	CMOS_READ
  2494 00000E20 A2[A78A0100]            	mov	[date_century], al
  2495                                  	;
  2496 00000E25 B000                    	mov	al, CMOS_SECONDS
  2497 00000E27 E8915E0000              	call 	CMOS_READ
  2498 00000E2C 3A05[A08A0100]          	cmp	al, [time_seconds]
  2499 00000E32 758A                    	jne	short time_of_day
  2500                                  
  2501                                  time_of_day_retn:
  2502 00000E34 C3                      	retn
  2503                                  
  2504                                  	; 15/01/2017
  2505                                  	; 10/06/2016
  2506                                  	; 07/06/2016
  2507                                  	; 06/06/2016
  2508                                  	; 23/05/2016
  2509                                  rtc_p:
  2510 00000E35 B101                    	mov	cl, 1 ; 15/01/2017
  2511 00000E37 EB02                    	jmp	short rtc_p0
  2512                                  u_timer: 
  2513                                  	; Timer Events with 18.2 Hz Timer Ticks
  2514                                  	; (and also timer events with RTC seconds)
  2515 00000E39 28C9                    	sub	cl, cl ; mov cl, 0 ; 15/01/2017
  2516                                  rtc_p0:
  2517                                  	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
  2518                                  	; Major Modification:
  2519                                  	; Check and Perform Timer Events (for RTC)
  2520                                  	; 25/08/2014 - 07/09/2014
  2521                                  	; Retro UNIX 386 v1:
  2522                                   	; Print Real Time Clock content
  2523                                  	
  2524                                  	; 15/01/2017
  2525 00000E3B 880D[C0960100]          	mov	byte [priority], cl ; 0 or 1 (not 2)
  2526 00000E41 8A2D[C3960100]          	mov	ch, [timer_events]
  2527 00000E47 20ED                    	and	ch, ch
  2528 00000E49 7420                    	jz	short rtc_p3
  2529                                  
  2530 00000E4B BE[60040300]            	mov	esi, timer_set  ; beginning address of
  2531                                  				; timer events space
  2532                                  rtc_p1:
  2533 00000E50 8B06                    	mov	eax, [esi]	
  2534 00000E52 20C0                    	and	al, al ; 0 = free, >0 = process no.
  2535 00000E54 7416                    	jz	short rtc_p4
  2536                                  	;
  2537 00000E56 C1C810                  	ror	eax, 16
  2538                                  	; ah = response value, al = interrupt type
  2539                                  	; 15/01/2017
  2540                                  	; cl = interrupt source
  2541                                  	;       1 = RTC, 0 = PIT  	 	
  2542 00000E59 38C8                    	cmp	al, cl 
  2543 00000E5B 750A                    	jne	short rtc_p2 ; not as requested or undefined !
  2544 00000E5D 3C01                    	cmp	al, 1 ; 1 ; RTC interrupt ?
  2545 00000E5F 7410                    	je	short rtc_p5 ; yes, check for response
  2546                                  	; 06/06/2016 - 18.2 Hz Timer Ticks
  2547 00000E61 836E080A                	sub	dword [esi+8], 10 ; 1 tick = 10
  2548 00000E65 7613                    	jna	short rtc_p6  ; continue for responding
  2549                                  rtc_p2:
  2550                                  	; 15/01/2017 (cl -> ch)
  2551                                  	; 07/06/2016
  2552 00000E67 FECD                    	dec	ch    ; remain count of timer events	
  2553 00000E69 7501                    	jnz	short rtc_p4
  2554                                  rtc_p3:	 
  2555 00000E6B C3                      	retn
  2556                                  rtc_p4:	
  2557                                  	;cmp	esi, timer_set + 240 ; 15*16 (last event)
  2558                                  	;jnb	short rtc_p3 ; end of timer event space
  2559 00000E6C 83C610                  	add	esi, 16 ; next timer event
  2560 00000E6F EBDF                    	jmp	short rtc_p1
  2561                                  rtc_p5:	 
  2562                                  	; current timer count ; 06/06/2016 (182)
  2563 00000E71 816E08B6000000          	sub	dword [esi+8], 182 ; 1 second (10*18.2)
  2564 00000E78 77ED                    	ja	short rtc_p2  ; check for the next 
  2565                                  rtc_p6:	
  2566                                  	; it is the time of response! 
  2567 00000E7A 8B5E04                  	mov	ebx, [esi+4] ; set (count limit) value
  2568 00000E7D 895E08                  	mov	[esi+8], ebx ; reset count down value
  2569                                  			     ; to count limit
  2570                                  	; 19/12/2016
  2571                                  	; 10/12/2016 - timer callback modification
  2572 00000E80 8B7E0C                  	mov	edi, [esi+12] ; response (or callback) address	
  2573 00000E83 807E0100                	cmp	byte [esi+1], 0 ; >0 = callback
  2574 00000E87 762A                    	jna	short rtc_p8
  2575                                  
  2576                                  	; timer callback !
  2577 00000E89 0FB61E                  	movzx	ebx, byte [esi] ; process number (>0)
  2578 00000E8C 89D8                    	mov	eax, ebx
  2579 00000E8E C0E302                  	shl	bl, 2 ; *4
  2580 00000E91 89BB[0C010300]          	mov	[ebx+p.tcb-4], edi ; user's callback service addr
  2581 00000E97 3A05[B3030300]          	cmp	al, [u.uno]
  2582 00000E9D 7521                    	jne	short rtc_p9
  2583 00000E9F 893D[D0030300]          	mov	[u.tcb], edi
  2584                                  rtc_p7:
  2585                                  	; 15/01/2017
  2586 00000EA5 B002                    	mov	al, 2
  2587 00000EA7 A2[C0960100]            	mov	[priority], al ; 2
  2588                                  	; 10/01/2017
  2589                                  	;mov	byte [u.pri], 2
  2590 00000EAC A2[A9030300]            	mov	[u.pri], al ; 2
  2591 00000EB1 EBB4                    	jmp	short rtc_p2
  2592                                  rtc_p8:
  2593                                  	; response address is physical address of
  2594                                  	; the program's response (signal return) byte
  2595                                  	; 06/06/2016
  2596                                  	;mov	edi, [esi+12] ; response address
  2597 00000EB3 8827                    	mov	[edi], ah     ; response value 
  2598                                  	;
  2599 00000EB5 C1C010                  	rol	eax, 16
  2600                                  	; 15/01/2017
  2601 00000EB8 3A05[B3030300]          	cmp	al, [u.uno] ; running process ?
  2602 00000EBE 74E5                    	je	short rtc_p7
  2603                                  rtc_p9:
  2604                                  	; al = process number  ; 10/06/2016
  2605 00000EC0 B202                    	mov	dl, 2 ; priority, 2 = event (high)	
  2606 00000EC2 E8091E0100              	call	set_run_sequence ; 19/05/2016
  2607 00000EC7 EB9E                    	jmp	short rtc_p2 ; 10/06/2016
  2608                                  
  2609                                  ; Default IRQ 7 handler against spurious IRQs (from master PIC)
  2610                                  ; 25/02/2015 (source: http://wiki.osdev.org/8259_PIC)
  2611                                  default_irq7:
  2612 00000EC9 6650                    	push	ax
  2613 00000ECB B00B                    	mov	al, 0Bh  ; In-Service register
  2614 00000ECD E620                    	out	20h, al
  2615 00000ECF EB00                            jmp short $+2
  2616 00000ED1 EB00                    	jmp short $+2
  2617 00000ED3 E420                    	in	al, 20h
  2618 00000ED5 2480                    	and 	al, 80h ; bit 7 (is it real IRQ 7 or fake?)
  2619 00000ED7 7404                            jz      short irq7_iret ; Fake (spurious) IRQ, do not send EOI 
  2620 00000ED9 B020                            mov     al, 20h ; EOI
  2621 00000EDB E620                    	out	20h, al 
  2622                                  irq7_iret:
  2623 00000EDD 6658                    	pop	ax
  2624 00000EDF CF                      	iretd
  2625                                  	
  2626                                  bcd_to_ascii:
  2627                                  	; 25/08/2014
  2628                                  	; INPUT ->
  2629                                  	;	al = Packed BCD number
  2630                                  	; OUTPUT ->
  2631                                  	;	ax  = ASCII word/number
  2632                                  	;
  2633                                  	; Erdogan Tan - 1998 (proc_hex) - TRDOS.ASM (2004-2011)
  2634                                  	;
  2635 00000EE0 D410                    	db 0D4h,10h                     ; Undocumented inst. AAM
  2636                                  					; AH = AL / 10h
  2637                                  					; AL = AL MOD 10h
  2638 00000EE2 660D3030                	or ax,'00'                      ; Make it ASCII based
  2639                                  
  2640 00000EE6 86E0                            xchg ah, al 
  2641                                  	
  2642 00000EE8 C3                      	retn
  2643                                  
  2644                                  ; 15/12/2020
  2645                                  real_mem_16m_64k: 
  2646 00000EE9 0000                    	dw 0	; Real size of system memory (if > 16MB)
  2647                                  		; as number of 64K blocks - 256
  2648                                  		; (This is for saving real system memory
  2649                                  		; because if system memory is larger than
  2650                                  		; 3 GB and if a VESA VBE video bios
  2651                                  		; is detected, 'mem_16m_64K' may be
  2652                                  		; decreased to reserve LFB space 
  2653                                  		; at the end of system memory.)
  2654                                  		; Upper memory space from LFB base address
  2655                                  		; to 4GB will not be included by M.A.T.
  2656                                  def_LFB_addr:	
  2657 00000EEB 0000                    	dw 0 	; HW of default LFB addr (for mode 118h)	
  2658                                  	
  2659                                  
  2660                                  %include 'keyboard.s' ; 07/03/2015
  2661                              <1> ; ****************************************************************************
  2662                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.0 - keyboard.s
  2663                              <1> ; ----------------------------------------------------------------------------
  2664                              <1> ; Last Update: 15/01/2017
  2665                              <1> ; ----------------------------------------------------------------------------
  2666                              <1> ; Beginning: 17/01/2016
  2667                              <1> ; ----------------------------------------------------------------------------
  2668                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
  2669                              <1> ; ----------------------------------------------------------------------------
  2670                              <1> ; Turkish Rational DOS
  2671                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
  2672                              <1> ;
  2673                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
  2674                              <1> ; keyboard.inc (17/10/2015)
  2675                              <1> ;
  2676                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
  2677                              <1> ; ****************************************************************************
  2678                              <1> 
  2679                              <1> ; Retro UNIX 386 v1 Kernel - KEYBOARD.INC
  2680                              <1> ; Last Modification: 17/10/2015
  2681                              <1> ;		    (Keyboard Data is in 'KYBDATA.INC')	
  2682                              <1> ;
  2683                              <1> ; ///////// KEYBOARD FUNCTIONS (PROCEDURES) ///////////////
  2684                              <1> 
  2685                              <1> ; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
  2686                              <1> 
  2687                              <1> ; 03/12/2014
  2688                              <1> ; 26/08/2014
  2689                              <1> ; KEYBOARD I/O
  2690                              <1> ; (INT_16h - Retro UNIX 8086 v1 - U9.ASM, 30/06/2014)
  2691                              <1> 
  2692                              <1> ;NOTE: 'k0' to 'k7' are name of OPMASK registers.
  2693                              <1> ;	(The reason of using '_k' labels!!!) (27/08/2014)    
  2694                              <1> ;NOTE: 'NOT' keyword is '~' unary operator in NASM.
  2695                              <1> ;	('NOT LC_HC' --> '~LC_HC') (bit reversing operator)
  2696                              <1> 
  2697                              <1> int16h:	; 30/06/2015
  2698                              <1> ;getc:
  2699 00000EED 9C                  <1> 	pushfd	; 28/08/2014
  2700 00000EEE 0E                  <1> 	push 	cs
  2701 00000EEF E801000000          <1> 	call 	KEYBOARD_IO_1 ; getc_int
  2702 00000EF4 C3                  <1> 	retn	
  2703                              <1> 
  2704                              <1> getc_int:
  2705                              <1> 	; 28/02/2015
  2706                              <1> 	; 03/12/2014 (derivation from pc-xt-286 bios source code -1986-, 
  2707                              <1> 	;	      instead of pc-at bios - 1985-)
  2708                              <1> 	; 28/08/2014 (_k1d)
  2709                              <1> 	; 30/06/2014
  2710                              <1> 	; 03/03/2014
  2711                              <1> 	; 28/02/2014
  2712                              <1> 	; Derived from "KEYBOARD_IO_1" procedure of IBM "pc-xt-286" 
  2713                              <1> 	; rombios source code (21/04/1986)
  2714                              <1> 	;	 'keybd.asm', INT 16H, KEYBOARD_IO
  2715                              <1> 	;
  2716                              <1> 	; KYBD --- 03/06/86  KEYBOARD BIOS
  2717                              <1> 	;
  2718                              <1> 	;--- INT 16 H -----------------------------------------------------------------
  2719                              <1> 	; KEYBOARD I/O								      :
  2720                              <1> 	;	THESE ROUTINES PROVIDE READ KEYBOARD SUPPORT			      :
  2721                              <1> 	; INPUT									      :
  2722                              <1> 	;	(AH)= 00H  READ THE NEXT ASCII CHARACTER ENTERED FROM THE KEYBOARD,   :
  2723                              <1> 	;		   RETURN THE RESULT IN (AL), SCAN CODE IN (AH).              :
  2724                              <1> 	;		   THIS IS THE COMPATIBLE READ INTERFACE, EQUIVALENT TO THE   :
  2725                              <1> 	;                  STANDARD PC OR PCAT KEYBOARD				      :	
  2726                              <1> 	;-----------------------------------------------------------------------------:
  2727                              <1> 	;	(AH)= 01H  SET THE ZERO FLAG TO INDICATE IF AN ASCII CHARACTER IS     :
  2728                              <1> 	;		   AVAILABLE TO BE READ FROM THE KEYBOARD BUFFER.	      :
  2729                              <1> 	;		   (ZF)= 1 -- NO CODE AVAILABLE			              :
  2730                              <1> 	;		   (ZF)= 0 -- CODE IS AVAILABLE  (AX)= CHARACTER              :
  2731                              <1> 	;		   IF (ZF)= 0, THE NEXT CHARACTER IN THE BUFFER TO BE READ IS :
  2732                              <1> 	;		   IN (AX), AND THE ENTRY REMAINS IN THE BUFFER.              :
  2733                              <1> 	;		   THIS WILL RETURN ONLY PC/PCAT KEYBOARD COMPATIBLE CODES    :
  2734                              <1> 	;-----------------------------------------------------------------------------:	
  2735                              <1> 	;	(AH)= 02H  RETURN THE CURRENT SHIFT STATUS IN AL REGISTER             :
  2736                              <1> 	;		   THE BIT SETTINGS FOR THIS CODE ARE INDICATED IN THE        :
  2737                              <1> 	;		   EQUATES FOR @KB_FLAG		                              :
  2738                              <1> 	;-----------------------------------------------------------------------------:	
  2739                              <1> 	;	(AH)= 03H  SET TYPAMATIC RATE AND DELAY                               :
  2740                              <1> 	;	      (AL) = 05H                                                      :
  2741                              <1> 	;	      (BL) = TYPAMATIC RATE (BITS 5 - 7 MUST BE RESET TO 0)           :
  2742                              <1> 	;		       							      :
  2743                              <1> 	;                     REGISTER     RATE      REGISTER     RATE                :
  2744                              <1> 	;                      VALUE     SELECTED     VALUE     SELECTED              :
  2745                              <1> 	;                     --------------------------------------------            :
  2746                              <1> 	;			00H        30.0        10H        7.5                 :
  2747                              <1> 	;			01H        26.7        11H        6.7                 :
  2748                              <1> 	;			02H        24.0        12H        6.0                 :
  2749                              <1> 	;			03H        21.8        13H        5.5                 :
  2750                              <1> 	;			04H        20.0        14H        5.0                 :
  2751                              <1> 	;			05H        18.5        15H        4.6                 :
  2752                              <1> 	;			06H        17.1        16H        4.3                 :
  2753                              <1> 	;			07H        16.0        17H        4.0                 :
  2754                              <1> 	;			08H        15.0        18H        3.7                 :
  2755                              <1> 	;			09H        13.3        19H        3.3                 :
  2756                              <1> 	;			0AH        12.0        1AH        3.0                 :
  2757                              <1> 	;			0BH        10.9        1BH        2.7                 :
  2758                              <1>         ;			0CH        10.0        1CH        2.5                 :
  2759                              <1> 	;			0DH         9.2        1DH        2.3                 :
  2760                              <1> 	;			0EH         8.6        1EH        2.1                 :
  2761                              <1> 	;			0FH         8.0        1FH        2.0                 :
  2762                              <1> 	;									      :
  2763                              <1> 	;	      (BH) = TYPAMATIC DELAY  (BITS 2 - 7 MUST BE RESET TO 0)         :
  2764                              <1> 	;		       							      :
  2765                              <1> 	;                     REGISTER     DELAY                                      :
  2766                              <1> 	;                      VALUE       VALUE                                      :
  2767                              <1> 	;                     ------------------                                      :
  2768                              <1> 	;			00H        250 ms                                     :
  2769                              <1> 	;			01H        500 ms                                     :
  2770                              <1> 	;			02H        750 ms                                     :
  2771                              <1> 	;			03H       1000 ms                                     :
  2772                              <1> 	;-----------------------------------------------------------------------------:
  2773                              <1> 	;	(AH)= 05H  PLACE ASCII CHARACTER/SCAN CODE COMBINATION IN KEYBOARD    :
  2774                              <1> 	;		   BUFFER AS IF STRUCK FROM KEYBOARD                          :
  2775                              <1> 	;		   ENTRY:  (CL) = ASCII CHARACTER		              :
  2776                              <1> 	;		           (CH) = SCAN CODE                                   :
  2777                              <1> 	;		   EXIT:   (AH) = 00H = SUCCESSFUL OPERATION                  :
  2778                              <1> 	;		           (AL) = 01H = UNSUCCESSFUL - BUFFER FULL            :
  2779                              <1> 	;		   FLAGS:  CARRY IF ERROR                                     :
  2780                              <1> 	;-----------------------------------------------------------------------------:		
  2781                              <1> 	;	(AH)= 10H  EXTENDED READ INTERFACE FOR THE ENHANCED KEYBOARD,         :
  2782                              <1> 	;		   OTHERWISE SAME AS FUNCTION AH=0                            :
  2783                              <1> 	;-----------------------------------------------------------------------------:
  2784                              <1> 	;	(AH)= 11H  EXTENDED ASCII STATUS FOR THE ENHANCED KEYBOARD,           :
  2785                              <1> 	;		   OTHERWISE SAME AS FUNCTION AH=1                            :
  2786                              <1> 	;-----------------------------------------------------------------------------:	
  2787                              <1> 	;	(AH)= 12H  RETURN THE EXTENDED SHIFT STATUS IN AX REGISTER            :
  2788                              <1> 	;		   AL = BITS FROM KB_FLAG, AH = BITS FOR LEFT AND RIGHT       :
  2789                              <1> 	;		   CTL AND ALT KEYS FROM KB_FLAG_1 AND KB_FLAG_3              :
  2790                              <1> 	; OUTPUT					                              :
  2791                              <1> 	;	AS NOTED ABOVE, ONLY (AX) AND FLAGS CHANGED	                      :
  2792                              <1> 	;	ALL REGISTERS RETAINED		                                      :
  2793                              <1> 	;------------------------------------------------------------------------------
  2794                              <1> 
  2795                              <1> ; 15/01/2017
  2796                              <1> ; 14/01/2017
  2797                              <1> ; 02/01/2017
  2798                              <1> ; 29/05/2016
  2799                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  2800                              <1> int32h:  ; Keyboard BIOS
  2801                              <1> 
  2802                              <1> KEYBOARD_IO_1:	
  2803                              <1> 	;sti				; INTERRUPTS BACK ON
  2804                              <1> 	; 29/05/2016
  2805 00000EF5 80642408BE          <1>         and     byte [esp+8], 10111110b ; clear zero flag and cary flag
  2806                              <1> 	;
  2807 00000EFA 1E                  <1> 	push	ds			; SAVE CURRENT DS
  2808 00000EFB 53                  <1> 	push	ebx			; SAVE BX TEMPORARILY
  2809                              <1> 	;push	ecx			; SAVE CX TEMPORARILY
  2810 00000EFC 66BB1000            <1>         mov     bx, KDATA 
  2811 00000F00 8EDB                <1> 	mov	ds, bx			; PUT SEGMENT VALUE OF DATA AREA INTO DS
  2812                              <1> 
  2813                              <1> 	; 14/01/2017
  2814 00000F02 8B1C24              <1> 	mov	ebx, [esp]
  2815                              <1> 	;; 15/01/2017
  2816                              <1> 	; 02/01/2017
  2817                              <1> 	;;mov	byte [intflg], 32h	; keyboard interrupt 
  2818 00000F05 FB                  <1> 	sti
  2819                              <1> 	;
  2820                              <1> 
  2821 00000F06 08E4                <1> 	or	ah, ah			; CHECK FOR (AH)= 00H
  2822 00000F08 743A                <1> 	jz	short _K1		; ASCII_READ
  2823 00000F0A FECC                <1> 	dec	ah                      ; CHECK FOR (AH)= 01H
  2824 00000F0C 7453                <1>         jz      short _K2               ; ASCII_STATUS
  2825 00000F0E FECC                <1> 	dec	ah			; CHECK FOR (AH)= 02H
  2826 00000F10 0F8494000000        <1>         jz      _K3                     ; SHIFT STATUS
  2827 00000F16 FECC                <1> 	dec	ah			; CHECK FOR (AH)= 03H	
  2828 00000F18 0F8493000000        <1>         jz      _K300                   ; SET TYPAMATIC RATE/DELAY
  2829 00000F1E 80EC02              <1> 	sub	ah, 2			; CHECK FOR (AH)= 05H	
  2830 00000F21 0F84BC000000        <1>         jz      _K500                   ; KEYBOARD WRITE         
  2831                              <1> _KIO1:	
  2832 00000F27 80EC0B              <1> 	sub	ah, 11			; AH =  10H
  2833 00000F2A 740C                <1> 	jz	short _K1E		; EXTENDED ASCII READ
  2834 00000F2C FECC                <1> 	dec	ah			; CHECK FOR (AH)= 11H
  2835 00000F2E 7422                <1> 	jz	short _K2E		; EXTENDED_ASCII_STATUS
  2836 00000F30 FECC                <1> 	dec	ah			; CHECK FOR (AH)= 12H
  2837 00000F32 7458                <1> 	jz	short _K3E		; EXTENDED_SHIFT_STATUS
  2838                              <1> _KIO_EXIT:
  2839                              <1> 	; 02/01/2017
  2840 00000F34 FA                  <1> 	cli
  2841                              <1> 	;;mov	byte [intflg], 0 ;; 15/01/2017
  2842                              <1> 	;
  2843                              <1> 	;pop	ecx			; RECOVER REGISTER
  2844 00000F35 5B                  <1> 	pop	ebx			; RECOVER REGISTER
  2845 00000F36 1F                  <1> 	pop	ds			; RECOVER SEGMENT
  2846 00000F37 CF                  <1> 	iretd				; INVALID COMMAND, EXIT
  2847                              <1> 
  2848                              <1> 	;-----	ASCII CHARACTER
  2849                              <1> _K1E:	
  2850 00000F38 E8D3000000          <1> 	call	_K1S			; GET A CHARACTER FROM THE BUFFER (EXTENDED)
  2851 00000F3D E848010000          <1> 	call	_KIO_E_XLAT		; ROUTINE TO XLATE FOR EXTENDED CALLS
  2852 00000F42 EBF0                <1> 	jmp	short _KIO_EXIT         ; GIVE IT TO THE CALLER
  2853                              <1> _K1:	
  2854 00000F44 E8C7000000          <1> 	call	_K1S			; GET A CHARACTER FROM THE BUFFER
  2855 00000F49 E847010000          <1> 	call	_KIO_S_XLAT		; ROUTINE TO XLATE FOR STANDARD CALLS
  2856 00000F4E 72F4                <1> 	jc	short _K1		; CARRY SET MEANS TROW CODE AWAY
  2857                              <1> _K1A:
  2858 00000F50 EBE2                <1> 	jmp	short _KIO_EXIT         ; RETURN TO CALLER
  2859                              <1> 
  2860                              <1> 	;-----	ASCII STATUS
  2861                              <1> _K2E:	
  2862 00000F52 E804010000          <1> 	call	_K2S			; TEST FOR CHARACTER IN BUFFER (EXTENDED)
  2863 00000F57 7420                <1> 	jz	short _K2B		; RETURN IF BUFFER EMPTY
  2864 00000F59 9C                  <1> 	pushf				; SAVE ZF FROM TEST
  2865 00000F5A E82B010000          <1> 	call	_KIO_E_XLAT		; ROUTINE TO XLATE FOR EXTENDED CALLS
  2866 00000F5F EB17                <1> 	jmp	short _K2A	        ; GIVE IT TO THE CALLER
  2867                              <1> _K2:	
  2868 00000F61 E8F5000000          <1> 	call	_K2S			; TEST FOR CHARACTER IN BUFFER
  2869 00000F66 7411                <1> 	jz	short _K2B		; RETURN IF BUFFER EMPTY
  2870 00000F68 9C                  <1> 	pushf				; SAVE ZF FROM TEST
  2871 00000F69 E827010000          <1> 	call	_KIO_S_XLAT		; ROUTINE TO XLATE FOR STANDARD CALLS
  2872 00000F6E 7308                <1> 	jnc	short _K2A	        ; CARRY CLEAR MEANS PASS VALID CODE
  2873 00000F70 9D                  <1> 	popf				; INVALID CODE FOR THIS TYPE OF CALL
  2874 00000F71 E89A000000          <1> 	call	_K1S			; THROW THE CHARACTER AWAY
  2875 00000F76 EBE9                <1> 	jmp	short _K2		; GO LOOK FOR NEXT CHAR, IF ANY
  2876                              <1> _K2A:
  2877 00000F78 9D                  <1> 	popf				; RESTORE ZF FROM TEST
  2878                              <1> _K2B:
  2879                              <1> 	; 02/01/2017
  2880 00000F79 FA                  <1> 	cli
  2881                              <1> 	;; mov	byte [intflg], 0 ;; 15/01/2017
  2882                              <1> 	;
  2883                              <1> 	;pop	ecx			; RECOVER REGISTER
  2884 00000F7A 5B                  <1> 	pop	ebx			; RECOVER REGISTER
  2885 00000F7B 1F                  <1> 	pop	ds			; RECOVER SEGMENT
  2886                              <1> 	; (*) 29/05/2016
  2887                              <1> 	; (*) retf 4			; THROW AWAY (e)FLAGS
  2888 00000F7C 7208                <1> 	jc	short _k2d
  2889 00000F7E 7505                <1> 	jnz	short _k2c
  2890 00000F80 804C240840          <1> 	or	byte [esp+8], 01000000b	; set zero flag bit of eflags register
  2891                              <1> _k2c:
  2892 00000F85 CF                  <1> 	iretd
  2893                              <1> _k2d:
  2894                              <1> 	; 29/05/2016 -set carry flag on stack-
  2895                              <1> 	; [esp] = EIP
  2896                              <1> 	; [esp+4] = CS
  2897                              <1> 	; [esp+8] = E-FLAGS
  2898 00000F86 804C240801          <1> 	or	byte [esp+8], 1  ; set carry bit of eflags register
  2899                              <1> 	; [esp+12] = ESP (user)
  2900                              <1> 	; [esp+16] = SS (User)
  2901 00000F8B CF                  <1> 	iretd
  2902                              <1> 
  2903                              <1> 	
  2904                              <1> 	; (*) 29/05/2016 - 'ref 4' intruction causes to stack fault
  2905                              <1> 	; (OUTER-PRIVILEGE-LEVEL)
  2906                              <1> 	; INTEL 80386 PROGRAMMER'S REFERENCE MANUAL 1986
  2907                              <1> 	; // RETF instruction:
  2908                              <1> 	;
  2909                              <1> 	; IF OperandMode=32 THEN
  2910                              <1>  	;    Load CS:EIP from stack;
  2911                              <1>  	;    Set CS RPL to CPL;
  2912                              <1>  	;    Increment eSP by 8 plus the immediate offset if it exists;
  2913                              <1>  	;    Load SS:eSP from stack;
  2914                              <1>  	; ELSE (* OperandMode=16 *)
  2915                              <1>  	;    Load CS:IP from stack;
  2916                              <1>  	;    Set CS RPL to CPL;
  2917                              <1>  	;    Increment eSP by 4 plus the immediate offset if it exists;
  2918                              <1> 	;    Load SS:eSP from stack;
  2919                              <1>  	; FI;
  2920                              <1> 	;
  2921                              <1> 	; //
  2922                              <1> 
  2923                              <1> 	;-----	SHIFT STATUS
  2924                              <1> _K3E:                                   ; GET THE EXTENDED SHIFT STATUS FLAGS
  2925 00000F8C 8A25[A66F0000]      <1> 	mov	ah, [KB_FLAG_1]		; GET SYSTEM SHIFT KEY STATUS
  2926 00000F92 80E404              <1> 	and	ah, SYS_SHIFT		; MASK ALL BUT SYS KEY BIT
  2927                              <1> 	;mov	cl, 5			; SHIFT THEW SYSTEMKEY BIT OVER TO
  2928                              <1> 	;shl	ah, cl			; BIT 7 POSITION
  2929 00000F95 C0E405              <1>         shl	ah, 5
  2930 00000F98 A0[A66F0000]        <1> 	mov	al, [KB_FLAG_1]		; GET SYSTEM SHIFT STATES BACK
  2931 00000F9D 2473                <1> 	and	al, 01110011b		; ELIMINATE SYS SHIFT, HOLD_STATE AND INS_SHIFT
  2932 00000F9F 08C4                <1> 	or	ah, al                  ; MERGE REMAINING BITS INTO AH
  2933 00000FA1 A0[A86F0000]        <1> 	mov	al, [KB_FLAG_3]		; GET RIGHT CTL AND ALT
  2934 00000FA6 240C                <1> 	and	al, 00001100b		; ELIMINATE LC_E0 AND LC_E1
  2935 00000FA8 08C4                <1> 	or	ah, al			; OR THE SHIFT FLAGS TOGETHER
  2936                              <1> _K3:
  2937 00000FAA A0[A56F0000]        <1> 	mov	al, [KB_FLAG]		; GET THE SHIFT STATUS FLAGS
  2938                              <1> 	;jmp	short _KIO_EXIT		; RETURN TO CALLER
  2939 00000FAF EB83                <1> 	jmp	_KIO_EXIT
  2940                              <1> 
  2941                              <1> 	;-----	SET TYPAMATIC RATE AND DELAY
  2942                              <1> _K300:
  2943 00000FB1 3C05                <1> 	cmp	al, 5			; CORRECT FUNCTION CALL?
  2944                              <1> 	;jne	short _KIO_EXIT		; NO, RETURN
  2945 00000FB3 0F857BFFFFFF        <1>      	jne	_KIO_EXIT
  2946 00000FB9 F6C3E0              <1> 	test	bl, 0E0h		; TEST FOR OUT-OF-RANGE RATE
  2947 00000FBC 0F8572FFFFFF        <1>         jnz     _KIO_EXIT               ; RETURN IF SO
  2948 00000FC2 F6C7FC              <1> 	test	BH, 0FCh		; TEST FOR OUT-OF-RANGE DELAY
  2949 00000FC5 0F8569FFFFFF        <1>         jnz     _KIO_EXIT               ; RETURN IF SO
  2950 00000FCB B0F3                <1> 	mov	al, KB_TYPA_RD		; COMMAND FOR TYPAMATIC RATE/DELAY		
  2951 00000FCD E8DA060000          <1> 	call	SND_DATA		; SEND TO KEYBOARD	
  2952                              <1> 	;mov	cx, 5			; SHIFT COUNT
  2953                              <1> 	;shl	bh, cl			; SHIFT DELAY OVER
  2954 00000FD2 C0E705              <1> 	shl	bh, 5
  2955 00000FD5 88D8                <1> 	mov	al, bl			; PUT IN RATE
  2956 00000FD7 08F8                <1> 	or	al, bh			; AND DELAY
  2957 00000FD9 E8CE060000          <1> 	call	SND_DATA		; SEND TO KEYBOARD	
  2958 00000FDE E951FFFFFF          <1>         jmp     _KIO_EXIT               ; RETURN TO CALLER
  2959                              <1> 
  2960                              <1> 	;-----	WRITE TO KEYBOARD BUFFER
  2961                              <1> _K500:
  2962 00000FE3 56                  <1> 	push	esi			; SAVE SI (esi)
  2963 00000FE4 FA                  <1> 	cli				; 
  2964 00000FE5 8B1D[B66F0000]      <1>      	mov	ebx, [BUFFER_TAIL]	; GET THE 'IN TO' POINTER TO THE BUFFER
  2965 00000FEB 89DE                <1> 	mov	esi, ebx		; SAVE A COPY IN CASE BUFFER NOT FULL
  2966 00000FED E8D3000000          <1> 	call	_K4			; BUMP THE POINTER TO SEE IF BUFFER IS FULL
  2967 00000FF2 3B1D[B26F0000]      <1> 	cmp	ebx, [BUFFER_HEAD]	; WILL THE BUFFER OVERRUN IF WE STORE THIS?
  2968 00000FF8 740D                <1> 	je	short _K502		; YES - INFORM CALLER OF ERROR		
  2969 00000FFA 66890E              <1> 	mov	[esi], cx		; NO - PUT ASCII/SCAN CODE INTO BUFFER	
  2970 00000FFD 891D[B66F0000]      <1> 	mov	[BUFFER_TAIL], ebx	; ADJUST 'IN TO' POINTER TO REFLECT CHANGE
  2971 00001003 28C0                <1> 	sub	al, al			; TELL CALLER THAT OPERATION WAS SUCCESSFUL
  2972 00001005 EB02                <1> 	jmp	short _K504		; SUB INSTRUCTION ALSO RESETS CARRY FLAG
  2973                              <1> _K502:
  2974 00001007 B001                <1> 	mov	al, 01h			; BUFFER FULL INDICATION
  2975                              <1> _K504:
  2976 00001009 FB                  <1> 	sti				
  2977 0000100A 5E                  <1> 	pop	esi			; RECOVER SI (esi)
  2978 0000100B E924FFFFFF          <1>         jmp     _KIO_EXIT               ; RETURN TO CALLER WITH STATUS IN AL
  2979                              <1> 
  2980                              <1> 	;-----	READ THE KEY TO FIGURE OUT WHAT TO DO -----
  2981                              <1> _K1S:
  2982 00001010 FA                  <1> 	cli	; 03/12/2014
  2983 00001011 8B1D[B26F0000]      <1>         mov     ebx, [BUFFER_HEAD] 	; GET POINTER TO HEAD OF BUFFER
  2984 00001017 3B1D[B66F0000]      <1>         cmp     ebx, [BUFFER_TAIL] 	; TEST END OF BUFFER
  2985                              <1> 	;jne	short _K1U		; IF ANYTHING IN BUFFER SKIP INTERRUPT
  2986 0000101D 750F                <1> 	jne	short _k1x ; 03/12/2014
  2987                              <1> 	;
  2988                              <1> 	; 03/12/2014
  2989                              <1> 	; 28/08/2014
  2990                              <1> 	; PERFORM OTHER FUNCTION ?? here !
  2991                              <1> 	;; MOV	AX, 9002h		; MOVE IN WAIT CODE & TYPE
  2992                              <1> 	;; INT 	15H			; PERFORM OTHER FUNCTION
  2993                              <1> _K1T:                                   ; ASCII READ
  2994 0000101F FB                  <1> 	sti				; INTERRUPTS BACK ON DURING LOOP
  2995 00001020 90                  <1> 	nop				; ALLOW AN INTERRUPT TO OCCUR
  2996                              <1> _K1U:	
  2997 00001021 FA                  <1> 	cli				; INTERRUPTS BACK OFF
  2998 00001022 8B1D[B26F0000]      <1>         mov    	ebx, [BUFFER_HEAD] 	; GET POINTER TO HEAD OF BUFFER
  2999 00001028 3B1D[B66F0000]      <1>         cmp     ebx, [BUFFER_TAIL] 	; TEST END OF BUFFER
  3000                              <1> _k1x:
  3001 0000102E 53                  <1> 	push	ebx			; SAVE ADDRESS		
  3002 0000102F 9C                  <1> 	pushf				; SAVE FLAGS
  3003 00001030 E82F070000          <1> 	call	MAKE_LED		; GO GET MODE INDICATOR DATA BYTE
  3004 00001035 8A1D[A76F0000]      <1> 	mov	bl, [KB_FLAG_2] 	; GET PREVIOUS BITS
  3005 0000103B 30C3                <1> 	xor	bl, al			; SEE IF ANY DIFFERENT
  3006 0000103D 80E307              <1> 	and	bl, 07h	; KB_LEDS	; ISOLATE INDICATOR BITS
  3007 00001040 7406                <1> 	jz	short _K1V		; IF NO CHANGE BYPASS UPDATE
  3008 00001042 E8C9060000          <1> 	call	SND_LED1
  3009 00001047 FA                  <1> 	cli				; DISABLE INTERRUPTS
  3010                              <1> _K1V:
  3011 00001048 9D                  <1> 	popf				; RESTORE FLAGS
  3012 00001049 5B                  <1> 	pop	ebx			; RESTORE ADDRESS
  3013 0000104A 74D3                <1>         je      short _K1T              ; LOOP UNTIL SOMETHING IN BUFFER
  3014                              <1> 	;
  3015 0000104C 668B03              <1> 	mov	ax, [ebx] 		; GET SCAN CODE AND ASCII CODE
  3016 0000104F E871000000          <1>         call    _K4                     ; MOVE POINTER TO NEXT POSITION
  3017 00001054 891D[B26F0000]      <1>         mov     [BUFFER_HEAD], ebx      ; STORE VALUE IN VARIABLE
  3018 0000105A C3                  <1> 	retn				; RETURN
  3019                              <1> 
  3020                              <1> 	;-----	READ THE KEY TO SEE IF ONE IS PRESENT -----
  3021                              <1> _K2S:
  3022 0000105B FA                  <1> 	cli				; INTERRUPTS OFF
  3023 0000105C 8B1D[B26F0000]      <1>         mov     ebx, [BUFFER_HEAD]      ; GET HEAD POINTER
  3024 00001062 3B1D[B66F0000]      <1>         cmp     ebx, [BUFFER_TAIL]      ; IF EQUAL (Z=1) THEN NOTHING THERE
  3025 00001068 668B03              <1> 	mov	ax, [ebx]
  3026 0000106B 9C                  <1> 	pushf				; SAVE FLAGS
  3027 0000106C 6650                <1> 	push	ax			; SAVE CODE
  3028 0000106E E8F1060000          <1> 	call	MAKE_LED		; GO GET MODE INDICATOR DATA BYTE
  3029 00001073 8A1D[A76F0000]      <1> 	mov	bl, [KB_FLAG_2] 	; GET PREVIOUS BITS
  3030 00001079 30C3                <1> 	xor	bl, al			; SEE IF ANY DIFFERENT
  3031 0000107B 80E307              <1> 	and	bl, 07h ; KB_LEDS	; ISOLATE INDICATOR BITS
  3032 0000107E 7405                <1> 	jz	short _K2T		; IF NO CHANGE BYPASS UPDATE
  3033 00001080 E874060000          <1> 	call	SND_LED			; GO TURN ON MODE INDICATORS
  3034                              <1> _K2T:
  3035 00001085 6658                <1> 	pop	ax			; RESTORE CODE
  3036 00001087 9D                  <1> 	popf				; RESTORE FLAGS
  3037 00001088 FB                  <1> 	sti				; INTERRUPTS BACK ON
  3038 00001089 C3                  <1> 	retn				; RETURN
  3039                              <1> 
  3040                              <1> 	;-----	ROUTINE TO TRANSLATE SCAN CODE PAIRS FOR EXTENDED CALLS -----
  3041                              <1> _KIO_E_XLAT:
  3042 0000108A 3CF0                <1> 	cmp	al, 0F0h		; IS IT ONE OF THE FILL-INs?
  3043 0000108C 7506                <1> 	jne	short _KIO_E_RET	; NO, PASS IT ON
  3044 0000108E 08E4                <1>         or 	ah, ah			; AH = 0 IS SPECIAL CASE
  3045 00001090 7402                <1>         jz	short _KIO_E_RET        ; PASS THIS ON UNCHANGED
  3046 00001092 30C0                <1> 	xor	al, al			; OTHERWISE SET AL = 0
  3047                              <1> _KIO_E_RET:				
  3048 00001094 C3                  <1> 	retn				; GO BACK
  3049                              <1> 
  3050                              <1> 	;-----	ROUTINE TO TRANSLATE SCAN CODE PAIRS FOR STANDARD CALLS -----
  3051                              <1> _KIO_S_XLAT:
  3052 00001095 80FCE0              <1> 	cmp	ah, 0E0h		; IS IT KEYPAD ENTER OR / ?
  3053 00001098 750F                <1> 	jne	short _KIO_S2		; NO, CONTINUE
  3054 0000109A 3C0D                <1> 	cmp	al, 0Dh			; KEYPAD ENTER CODE?
  3055 0000109C 7408                <1>         je	short _KIO_S1		; YES, MASSAGE A BIT
  3056 0000109E 3C0A                <1> 	cmp	al, 0Ah			; CTRL KEYPAD ENTER CODE?
  3057 000010A0 7404                <1>         je	short _KIO_S1		; YES, MASSAGE THE SAME
  3058 000010A2 B435                <1> 	mov	ah, 35h			; NO, MUST BE KEYPAD /
  3059                              <1> _kio_ret: ; 03/12/2014
  3060 000010A4 F8                  <1> 	clc
  3061 000010A5 C3                  <1> 	retn
  3062                              <1> 	;jmp	short _KIO_USE		; GIVE TO CALLER
  3063                              <1> _KIO_S1:				
  3064 000010A6 B41C                <1> 	mov	ah, 1Ch			; CONVERT TO COMPATIBLE OUTPUT
  3065                              <1> 	;jmp	short _KIO_USE		; GIVE TO CALLER
  3066 000010A8 C3                  <1> 	retn
  3067                              <1> _KIO_S2:		
  3068 000010A9 80FC84              <1> 	cmp	ah, 84h			; IS IT ONE OF EXTENDED ONES?
  3069 000010AC 7715                <1> 	ja	short _KIO_DIS		; YES, THROW AWAY AND GET ANOTHER CHAR
  3070 000010AE 3CF0                <1> 	cmp	al, 0F0h		; IS IT ONE OF THE FILL-INs?
  3071 000010B0 7506                <1>         jne	short _KIO_S3		; NO, TRY LAST TEST
  3072 000010B2 08E4                <1> 	or	ah, ah			; AH = 0 IS SPECIAL CASE
  3073 000010B4 740C                <1>         jz	short _KIO_USE		; PASS THIS ON UNCHANGED
  3074 000010B6 EB0B                <1> 	jmp	short _KIO_DIS		; THROW AWAY THE REST
  3075                              <1> _KIO_S3:
  3076 000010B8 3CE0                <1> 	cmp	al, 0E0h		; IS IT AN EXTENSION OF A PREVIOUS ONE?
  3077                              <1> 	;jne	short _KIO_USE		; NO, MUST BE A STANDARD CODE
  3078 000010BA 75E8                <1> 	jne	short _kio_ret
  3079 000010BC 08E4                <1> 	or	ah, ah			; AH = 0 IS SPECIAL CASE
  3080 000010BE 7402                <1>         jz	short _KIO_USE		; JUMP IF AH = 0
  3081 000010C0 30C0                <1> 	xor	al, al			; CONVERT TO COMPATIBLE OUTPUT
  3082                              <1> 	;jmp	short _KIO_USE		; PASS IT ON TO CALLER
  3083                              <1> _KIO_USE:
  3084                              <1> 	;clc				; CLEAR CARRY TO INDICATE GOOD CODE
  3085 000010C2 C3                  <1> 	retn				; RETURN	
  3086                              <1> _KIO_DIS:
  3087 000010C3 F9                  <1> 	stc				; SET CARRY TO INDICATE DISCARD CODE
  3088 000010C4 C3                  <1> 	retn				; RETURN
  3089                              <1> 
  3090                              <1> 	;-----	INCREMENT BUFFER POINTER ROUTINE -----
  3091                              <1> _K4:    
  3092 000010C5 43                  <1> 	inc     ebx
  3093 000010C6 43                  <1> 	inc	ebx			; MOVE TO NEXT WORD IN LIST
  3094 000010C7 3B1D[AE6F0000]      <1>         cmp     ebx, [BUFFER_END] 	; AT END OF BUFFER?
  3095                              <1>         ;jne    short _K5               ; NO, CONTINUE
  3096 000010CD 7206                <1> 	jb	short _K5
  3097 000010CF 8B1D[AA6F0000]      <1>         mov     ebx, [BUFFER_START]     ; YES, RESET TO BUFFER BEGINNING
  3098                              <1> _K5:
  3099 000010D5 C3                  <1> 	retn
  3100                              <1> 
  3101                              <1> ; 20/02/2015
  3102                              <1> ; 05/12/2014
  3103                              <1> ; 26/08/2014
  3104                              <1> ; KEYBOARD (HARDWARE) INTERRUPT -  IRQ LEVEL 1
  3105                              <1> ; (INT_09h - Retro UNIX 8086 v1 - U9.ASM, 07/03/2014)
  3106                              <1> ;
  3107                              <1> ; Derived from "KB_INT_1" procedure of IBM "pc-at" 
  3108                              <1> ; rombios source code (06/10/1985)
  3109                              <1> ; 'keybd.asm', HARDWARE INT 09h - (IRQ Level 1)
  3110                              <1> 
  3111                              <1> ; EQUATES (IBM PC-XT-286 BIOS, 1986, 'POSQEQU.INC')
  3112                              <1> 
  3113                              <1> ;--------- 8042 COMMANDS -------------------------------------------------------
  3114                              <1> ENA_KBD		equ	0AEh		; ENABLE KEYBOARD COMMAND
  3115                              <1> DIS_KBD		equ	0ADh		; DISABLE KEYBOARD COMMAND
  3116                              <1> SHUT_CMD	equ	0FEh		; CAUSE A SHUTDOWN COMMAND
  3117                              <1> ;--------- 8042 KEYBOARD INTERFACE AND DIAGNOSTIC CONTROL REGISTERS ------------
  3118                              <1> STATUS_PORT	equ	064h		; 8042 STATUS PORT
  3119                              <1> INPT_BUF_FULL	equ	00000010b 	; 1 = +INPUT BUFFER FULL
  3120                              <1> PORT_A		equ	060h		; 8042 KEYBOARD SCAN CODE/CONTROL PORT
  3121                              <1> ;---------- 8042 KEYBOARD RESPONSE ---------------------------------------------
  3122                              <1> KB_ACK		equ	0FAh		; ACKNOWLEDGE PROM TRANSMISSION
  3123                              <1> KB_RESEND	equ	0FEh		; RESEND REQUEST
  3124                              <1> KB_OVER_RUN	equ	0FFh		; OVER RUN SCAN CODE
  3125                              <1> ;---------- KEYBOARD/LED COMMANDS ----------------------------------------------
  3126                              <1> KB_ENABLE	equ	0F4h		; KEYBOARD ENABLE
  3127                              <1> LED_CMD		equ	0EDh		; LED WRITE COMMAND
  3128                              <1> KB_TYPA_RD	equ	0F3h		; TYPAMATIC RATE/DELAY COMMAND
  3129                              <1> ;---------- KEYBOARD SCAN CODES ------------------------------------------------
  3130                              <1> NUM_KEY		equ	69		; SCAN CODE FOR	 NUMBER LOCK KEY
  3131                              <1> SCROLL_KEY	equ	70		; SCAN CODE FOR	 SCROLL LOCK KEY
  3132                              <1> ALT_KEY		equ	56		; SCAN CODE FOR	 ALTERNATE SHIFT KEY
  3133                              <1> CTL_KEY		equ	29		; SCAN CODE FOR	 CONTROL KEY
  3134                              <1> CAPS_KEY	equ	58		; SCAN CODE FOR	 SHIFT LOCK KEY
  3135                              <1> DEL_KEY		equ	83		; SCAN CODE FOR	 DELETE KEY
  3136                              <1> INS_KEY		equ	82		; SCAN CODE FOR	 INSERT KEY
  3137                              <1> LEFT_KEY	equ	42		; SCAN CODE FOR	 LEFT SHIFT
  3138                              <1> RIGHT_KEY	equ	54		; SCAN CODE FOR	 RIGHT SHIFT
  3139                              <1> SYS_KEY		equ	84		; SCAN CODE FOR	 SYSTEM KEY
  3140                              <1> ;---------- ENHANCED KEYBOARD SCAN CODES ---------------------------------------
  3141                              <1> ID_1		equ	0ABh		; 1ST ID CHARACTER FOR KBX
  3142                              <1> ID_2		equ	041h		; 2ND ID CHARACTER FOR KBX
  3143                              <1> ID_2A		equ	054h		; ALTERNATE 2ND ID CHARACTER FOR KBX
  3144                              <1> F11_M		equ	87		; F11 KEY MAKE
  3145                              <1> F12_M		equ	88		; F12 KEY MAKE
  3146                              <1> MC_E0		equ	224		; GENERAL MARKER CODE
  3147                              <1> MC_E1		equ	225		; PAUSE KEY MARKER CODE
  3148                              <1> ;---------- FLAG EQUATES WITHIN @KB_FLAG----------------------------------------
  3149                              <1> RIGHT_SHIFT	equ	00000001b	; RIGHT SHIFT KEY DEPRESSED
  3150                              <1> LEFT_SHIFT	equ	00000010b	; LEFT SHIFT KEY DEPRESSED
  3151                              <1> CTL_SHIFT	equ	00000100b	; CONTROL SHIFT KEY DEPRESSED
  3152                              <1> ALT_SHIFT	equ	00001000b	; ALTERNATE SHIFT KEY DEPRESSED
  3153                              <1> SCROLL_STATE	equ	00010000b	; SCROLL LOCK STATE IS ACTIVE
  3154                              <1> NUM_STATE	equ	00100000b	; NUM LOCK STATE IS ACTIVE
  3155                              <1> CAPS_STATE	equ	01000000b	; CAPS LOCK STATE IS ACTIVE
  3156                              <1> INS_STATE	equ	10000000b	; INSERT STATE IS ACTIVE
  3157                              <1> ;---------- FLAG EQUATES WITHIN	@KB_FLAG_1 -------------------------------------
  3158                              <1> L_CTL_SHIFT	equ	00000001b	; LEFT CTL KEY DOWN
  3159                              <1> L_ALT_SHIFT	equ	00000010b	; LEFT ALT KEY DOWN
  3160                              <1> SYS_SHIFT	equ	00000100b	; SYSTEM KEY DEPRESSED AND HELD
  3161                              <1> HOLD_STATE	equ	00001000b	; SUSPEND KEY HAS BEEN TOGGLED
  3162                              <1> SCROLL_SHIFT	equ	00010000b	; SCROLL LOCK KEY IS DEPRESSED
  3163                              <1> NUM_SHIFT	equ	00100000b	; NUM LOCK KEY IS DEPRESSED
  3164                              <1> CAPS_SHIFT	equ	01000000b	; CAPS LOCK KEY IS DEPRE55ED
  3165                              <1> INS_SHIFT	equ	10000000b	; INSERT KEY IS DEPRESSED
  3166                              <1> ;---------- FLAGS EQUATES WITHIN @KB_FLAG_2 -----------------------------------
  3167                              <1> KB_LEDS		equ	00000111b	; KEYBOARD LED STATE BITS
  3168                              <1> ;		equ	00000001b	; SCROLL LOCK INDICATOR
  3169                              <1> ;		equ	00000010b	; NUM LOCK INDICATOR
  3170                              <1> ;		equ	00000100b	; CAPS LOCK INDICATOR
  3171                              <1> ;		equ	00001000b	; RESERVED (MUST BE ZERO)
  3172                              <1> KB_FA		equ	00010000b	; ACKNOWLEDGMENT RECEIVED
  3173                              <1> KB_FE		equ	00100000b	; RESEND RECEIVED FLAG
  3174                              <1> KB_PR_LED	equ	01000000b	; MODE INDICATOR UPDATE
  3175                              <1> KB_ERR		equ	10000000b	; KEYBOARD TRANSMIT ERROR FLAG
  3176                              <1> ;----------- FLAGS EQUATES WITHIN @KB_FLAG_3 -----------------------------------
  3177                              <1> LC_E1		equ	00000001b	; LAST CODE WAS THE E1 HIDDEN CODE
  3178                              <1> LC_E0		equ	00000010b	; LAST CODE WAS THE E0 HIDDEN CODE
  3179                              <1> R_CTL_SHIFT	equ	00000100b	; RIGHT CTL KEY DOWN
  3180                              <1> R_ALT_SHIFT	equ	00001000b	; RIGHT ALT KEY DOWN
  3181                              <1> GRAPH_ON	equ	00001000b	; ALT GRAPHICS KEY DOWN (WT ONLY)	
  3182                              <1> KBX		equ	00010000b	; ENHANCED KEYBOARD INSTALLED
  3183                              <1> SET_NUM_LK	equ	00100000b	; FORCE NUM LOCK IF READ ID AND KBX
  3184                              <1> LC_AB		equ	01000000b	; LAST CHARACTER WAS FIRST ID CHARACTER
  3185                              <1> RD_ID		equ	10000000b	; DOING A READ ID (MUST BE BIT0)
  3186                              <1> ;
  3187                              <1> ;----------- INTERRUPT EQUATES -------------------------------------------------
  3188                              <1> EOI		equ	020h		; END OF INTERRUPT COMMAND TO 8259
  3189                              <1> INTA00		equ	020h		; 8259 PORT
  3190                              <1> 
  3191                              <1> 
  3192                              <1> kb_int:
  3193                              <1> 
  3194                              <1> ; 17/10/2015 ('ctrlbrk') 
  3195                              <1> ; 05/12/2014
  3196                              <1> ; 04/12/2014 (derived from pc-xt-286 bios source code -1986-)
  3197                              <1> ; 26/08/2014
  3198                              <1> ;
  3199                              <1> ; 03/06/86  KEYBOARD BIOS
  3200                              <1> ;
  3201                              <1> ;--- HARDWARE INT 09H -- (IRQ LEVEL 1) ------------------------------------------
  3202                              <1> ;										;
  3203                              <1> ;	KEYBOARD INTERRUPT ROUTINE						;
  3204                              <1> ;										;
  3205                              <1> ;--------------------------------------------------------------------------------
  3206                              <1> 
  3207                              <1> KB_INT_1:
  3208 000010D6 FB                  <1> 	sti				; ENABLE INTERRUPTS
  3209                              <1> 	;push	ebp
  3210 000010D7 50                  <1> 	push	eax
  3211 000010D8 53                  <1> 	push	ebx
  3212 000010D9 51                  <1> 	push	ecx
  3213 000010DA 52                  <1> 	push	edx
  3214 000010DB 56                  <1> 	push	esi
  3215 000010DC 57                  <1> 	push	edi
  3216 000010DD 1E                  <1> 	push	ds
  3217 000010DE 06                  <1> 	push	es
  3218 000010DF FC                  <1> 	cld				; FORWARD DIRECTION
  3219 000010E0 66B81000            <1> 	mov	ax, KDATA
  3220 000010E4 8ED8                <1> 	mov	ds, ax
  3221 000010E6 8EC0                <1> 	mov	es, ax
  3222                              <1> 	;
  3223                              <1> 	;-----	WAIT FOR KEYBOARD DISABLE COMMAND TO BE ACCEPTED
  3224 000010E8 B0AD                <1> 	mov	al, DIS_KBD		; DISABLE THE KEYBOARD COMMAND
  3225 000010EA E8A9050000          <1> 	call	SHIP_IT			; EXECUTE DISABLE
  3226 000010EF FA                  <1> 	cli				; DISABLE INTERRUPTS
  3227 000010F0 B900000100          <1> 	mov	ecx, 10000h		; SET MAXIMUM TIMEOUT
  3228                              <1> KB_INT_01:
  3229 000010F5 E464                <1> 	in	al, STATUS_PORT		; READ ADAPTER STATUS
  3230 000010F7 A802                <1> 	test	al, INPT_BUF_FULL	; CHECK INPUT BUFFER FULL STATUS BIT
  3231 000010F9 E0FA                <1> 	loopnz	KB_INT_01		; WAIT FOR COMMAND TO BE ACCEPTED
  3232                              <1> 	;
  3233                              <1> 	;-----	READ CHARACTER FROM KEYBOARD INTERFACE
  3234 000010FB E460                <1> 	in	al, PORT_A		; READ IN THE CHARACTER
  3235                              <1> 	;
  3236                              <1> 	;-----	SYSTEM HOOK INT 15H - FUNCTION 4FH (ON HARDWARE INT LEVEL 9H) 	
  3237                              <1> 	;MOV	AH, 04FH		; SYSTEM INTERCEPT - KEY CODE FUNCTION
  3238                              <1> 	;STC				; SET CY=1 (IN CASE OF IRET)
  3239                              <1> 	;INT	15H			; CASETTE CALL (AL)=KEY SCAN CODE
  3240                              <1> 	;				; RETURNS CY=1 FOR INVALID FUNCTION
  3241                              <1> 	;JC	KB_INT_02		; CONTINUE IF CARRY FLAG SET ((AL)=CODE)
  3242                              <1> 	;JMP	K26			; EXIT IF SYSTEM HANDLES SCAN CODE
  3243                              <1> 	;				; EXT HANDLES HARDWARE EOI AND ENABLE		
  3244                              <1> 	;
  3245                              <1> 	;-----	CHECK FOR A RESEND COMMAND TO KEYBOARD
  3246                              <1> KB_INT_02:				; 	  (AL)= SCAN CODE
  3247 000010FD FB                  <1> 	sti				; ENABLE INTERRUPTS AGAIN
  3248 000010FE 3CFE                <1> 	cmp	al, KB_RESEND		; IS THE INPUT A RESEND
  3249 00001100 7411                <1>         je      short KB_INT_4          ; GO IF RESEND
  3250                              <1> 	;
  3251                              <1> 	;-----	CHECK FOR RESPONSE TO A COMMAND TO KEYBOARD
  3252 00001102 3CFA                <1> 	cmp	al, KB_ACK		; IS THE INPUT AN ACKNOWLEDGE
  3253 00001104 751A                <1>         jne     short KB_INT_2          ; GO IF NOT
  3254                              <1> 	;
  3255                              <1> 	;-----	A COMMAND TO THE KEYBOARD WAS ISSUED
  3256 00001106 FA                  <1> 	cli				; DISABLE INTERRUPTS
  3257 00001107 800D[A76F0000]10    <1> 	or	byte [KB_FLAG_2], KB_FA ; INDICATE ACK RECEIVED
  3258 0000110E E97A020000          <1>         jmp     K26                     ; RETURN IF NOT (ACK RETURNED FOR DATA)
  3259                              <1> 	;
  3260                              <1> 	;-----	RESEND THE LAST BYTE
  3261                              <1> KB_INT_4:
  3262 00001113 FA                  <1> 	cli				; DISABLE INTERRUPTS
  3263 00001114 800D[A76F0000]20    <1> 	or	byte [KB_FLAG_2], KB_FE ; INDICATE RESEND RECEIVED
  3264 0000111B E96D020000          <1>         jmp     K26                     ; RETURN IF NOT ACK RETURNED FOR DATA)
  3265                              <1> 	;
  3266                              <1> ;-----	UPDATE MODE INDICATORS IF CHANGE IN STATE
  3267                              <1> KB_INT_2:
  3268 00001120 6650                <1> 	push 	ax			; SAVE DATA IN
  3269 00001122 E83D060000          <1> 	call	MAKE_LED		; GO GET MODE INDICATOR DATA BYTE
  3270 00001127 8A1D[A76F0000]      <1> 	mov	bl, [KB_FLAG_2] 	; GET PREVIOUS BITS
  3271 0000112D 30C3                <1> 	xor	bl, al			; SEE IF ANY DIFFERENT
  3272 0000112F 80E307              <1> 	and	bl, KB_LEDS		; ISOLATE INDICATOR BITS
  3273 00001132 7405                <1> 	jz	short UP0		; IF NO CHANGE BYPASS UPDATE
  3274 00001134 E8C0050000          <1> 	call	SND_LED			; GO TURN ON MODE INDICATORS
  3275                              <1> UP0:
  3276 00001139 6658                <1> 	pop	ax			; RESTORE DATA IN
  3277                              <1> ;------------------------------------------------------------------------
  3278                              <1> ;	START OF KEY PROCESSING						;
  3279                              <1> ;------------------------------------------------------------------------
  3280 0000113B 88C4                <1> 	mov	ah, al			; SAVE SCAN CODE IN AH ALSO
  3281                              <1> 	;
  3282                              <1> 	;-----	TEST FOR OVERRUN SCAN CODE FROM KEYBOARD
  3283 0000113D 3CFF                <1> 	cmp	al, KB_OVER_RUN		; IS THIS AN OVERRUN CHAR
  3284 0000113F 0F843F050000        <1>         je      K62			; BUFFER_FULL_BEEP
  3285                              <1> 	;
  3286                              <1> K16:	
  3287 00001145 8A3D[A86F0000]      <1> 	mov	bh, [KB_FLAG_3]		; LOAD FLAGS FOR TESTING
  3288                              <1> 	;
  3289                              <1> 	;-----	TEST TO SEE IF A READ_ID IS IN PROGRESS
  3290 0000114B F6C7C0              <1> 	test 	bh, RD_ID+LC_AB 	; ARE WE DOING A READ ID?
  3291 0000114E 7449                <1> 	jz	short NOT_ID		; CONTINUE IF NOT
  3292 00001150 7917                <1> 	jns	short TST_ID_2		; IS THE RD_ID FLAG ON?
  3293 00001152 3CAB                <1> 	cmp	al, ID_1		; IS THIS THE 1ST ID CHARACTER?
  3294 00001154 7507                <1> 	jne	short RST_RD_ID
  3295 00001156 800D[A86F0000]40    <1> 	or	byte [KB_FLAG_3], LC_AB ; INDICATE 1ST ID WAS OK
  3296                              <1> RST_RD_ID:
  3297 0000115D 8025[A86F0000]7F    <1> 	and	byte [KB_FLAG_3], ~RD_ID ; RESET THE READ ID FLAG
  3298                              <1>         ;jmp    short ID_EX		; AND EXIT
  3299 00001164 E924020000          <1> 	jmp	K26
  3300                              <1> 	;
  3301                              <1> TST_ID_2:
  3302 00001169 8025[A86F0000]BF    <1> 	and	byte [KB_FLAG_3], ~LC_AB ; RESET FLAG
  3303 00001170 3C54                <1> 	cmp	al, ID_2A		; IS THIS THE 2ND ID CHARACTER?
  3304 00001172 7419                <1>         je	short KX_BIT		; JUMP IF SO
  3305 00001174 3C41                <1> 	cmp	al, ID_2		; IS THIS THE 2ND ID CHARACTER?
  3306                              <1>         ;jne	short ID_EX		; LEAVE IF NOT
  3307 00001176 0F8511020000        <1> 	jne	K26
  3308                              <1> 	;
  3309                              <1> 	;-----	A READ ID SAID THAT IT WAS ENHANCED KEYBOARD
  3310 0000117C F6C720              <1> 	test	bh, SET_NUM_LK 		; SHOULD WE SET NUM LOCK?
  3311 0000117F 740C                <1>         jz      short KX_BIT		; EXIT IF NOT
  3312 00001181 800D[A56F0000]20    <1> 	or	byte [KB_FLAG], NUM_STATE ; FORCE NUM LOCK ON
  3313 00001188 E86C050000          <1> 	call	SND_LED			; GO SET THE NUM LOCK INDICATOR
  3314                              <1> KX_BIT:
  3315 0000118D 800D[A86F0000]10    <1> 	or	byte [KB_FLAG_3], KBX	; INDICATE ENHANCED KEYBOARD WAS FOUND
  3316 00001194 E9F4010000          <1> ID_EX:	jmp     K26			; EXIT
  3317                              <1> 	;
  3318                              <1> NOT_ID:
  3319 00001199 3CE0                <1> 	cmp	al, MC_E0		; IS THIS THE GENERAL MARKER CODE?
  3320 0000119B 750C                <1> 	jne	short TEST_E1
  3321 0000119D 800D[A86F0000]12    <1> 	or	byte [KB_FLAG_3], LC_E0+KBX ; SET FLAG BIT, SET KBX, AND
  3322                              <1> 	;jmp	short EXIT		; THROW AWAY THIS CODE
  3323 000011A4 E9EB010000          <1> 	jmp	K26A	
  3324                              <1> TEST_E1:	
  3325 000011A9 3CE1                <1> 	cmp	al, MC_E1		; IS THIS THE PAUSE KEY?
  3326 000011AB 750C                <1> 	jne	short NOT_HC
  3327 000011AD 800D[A86F0000]11    <1> 	or	byte [KB_FLAG_3], LC_E1+KBX ; SET FLAG BIT, SET KBX, AND
  3328 000011B4 E9DB010000          <1> EXIT:	jmp	K26A			; THROW AWAY THIS CODE
  3329                              <1> 	;
  3330                              <1> NOT_HC:
  3331 000011B9 247F                <1> 	and	al, 07Fh		; TURN OFF THE BREAK BIT
  3332 000011BB F6C702              <1> 	test	bh, LC_E0		; LAST CODE THE E0 MARKER CODE
  3333 000011BE 7414                <1> 	jz	short NOT_LC_E0		; JUMP IF NOT
  3334                              <1> 	;
  3335 000011C0 BF[926E0000]        <1> 	mov	edi, _K6+6		; IS THIS A SHIFT KEY?
  3336 000011C5 AE                  <1> 	scasb
  3337 000011C6 0F84C1010000        <1>         je      K26 ; K16B              ; YES, THROW AWAY & RESET FLAG
  3338 000011CC AE                  <1> 	scasb
  3339 000011CD 757C                <1> 	jne	short K16A		; NO, CONTINUE KEY PROCESSING
  3340                              <1> 	;jmp	short K16B		; YES, THROW AWAY & RESET FLAG
  3341 000011CF E9B9010000          <1> 	jmp	K26
  3342                              <1> 	;
  3343                              <1> NOT_LC_E0:
  3344 000011D4 F6C701              <1> 	test	bh, LC_E1		; LAST CODE THE E1 MARKER CODE?
  3345 000011D7 7435                <1> 	jz	short T_SYS_KEY		; JUMP IF NOT
  3346 000011D9 B904000000          <1> 	mov	ecx, 4			; LENGHT OF SEARCH
  3347 000011DE BF[906E0000]        <1> 	mov	edi, _K6+4		; IS THIS AN ALT, CTL, OR SHIFT?
  3348 000011E3 F2AE                <1> 	repne	scasb			; CHECK IT
  3349                              <1> 	;je	short EXIT		; THROW AWAY IF SO
  3350 000011E5 0F84A9010000        <1> 	je	K26A			
  3351                              <1> 	;
  3352 000011EB 3C45                <1> 	cmp	al, NUM_KEY		; IS IT THE PAUSE KEY?
  3353                              <1> 	;jne	short K16B		; NO, THROW AWAY & RESET FLAG
  3354 000011ED 0F859A010000        <1> 	jne	K26
  3355 000011F3 F6C480              <1> 	test	ah, 80h			; YES, IS IT THE BREAK OF THE KEY?
  3356                              <1> 	;jnz	short K16B		; YES, THROW THIS AWAY, TOO	
  3357 000011F6 0F8591010000        <1> 	jnz	K26
  3358                              <1>         ; 20/02/2015 
  3359 000011FC F605[A66F0000]08    <1> 	test	byte [KB_FLAG_1],HOLD_STATE ;  NO, ARE WE PAUSED ALREADY?
  3360                              <1> 	;jnz	short K16B		;  YES, THROW AWAY
  3361 00001203 0F8584010000        <1> 	jnz	K26
  3362 00001209 E9E1020000          <1> 	jmp     K39P                    ; NO, THIS IS THE REAL PAUSE STATE
  3363                              <1> 	;
  3364                              <1> 	;-----	TEST FOR SYSTEM KEY
  3365                              <1> T_SYS_KEY:
  3366 0000120E 3C54                <1> 	cmp	al, SYS_KEY		; IS IT THE SYSTEM KEY?
  3367 00001210 7539                <1> 	jnz	short K16A		; CONTINUE IF NOT
  3368                              <1> 	;
  3369 00001212 F6C480              <1> 	test	ah, 80h			; CHECK IF THIS A BREAK CODE
  3370 00001215 7524                <1> 	jnz	short K16C		; DO NOT TOUCH SYSTEM INDICATOR IF TRUE
  3371                              <1> 	;
  3372 00001217 F605[A66F0000]04    <1> 	test	byte [KB_FLAG_1], SYS_SHIFT ; SEE IF IN SYSTEM KEY HELD DOWN 
  3373                              <1>         ;jnz	short K16B		; IF YES, DO NOT PROCESS SYSTEM INDICATOR	
  3374 0000121E 0F8569010000        <1> 	jnz     K26			
  3375                              <1> 	;
  3376 00001224 800D[A66F0000]04    <1> 	or	byte [KB_FLAG_1], SYS_SHIFT ; INDICATE SYSTEM KEY DEPRESSED
  3377 0000122B B020                <1> 	mov	al, EOI			; END OF INTERRUPT COMMAND
  3378 0000122D E620                <1> 	out	20h, al ;out INTA00, al	; SEND COMMAND TO INTERRUPT CONTROL PORT
  3379                              <1> 					; INTERRUPT-RETURN-NO-EOI
  3380 0000122F B0AE                <1> 	mov	al, ENA_KBD		; INSURE KEYBOARD IS ENABLED
  3381 00001231 E862040000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
  3382                              <1> 	; !!! SYSREQ !!! function/system call (INTERRUPT) must be here !!!
  3383                              <1> 	;MOV	AL, 8500H		; FUNCTION VALUE FOR MAKE OF SYSTEM KEY
  3384                              <1> 	;STI				; MAKE SURE INTERRUPTS ENABLED
  3385                              <1> 	;INT	15H			; USER INTERRUPT	
  3386 00001236 E965010000          <1>         jmp     K27A                    ; END PROCESSING
  3387                              <1> 	;
  3388                              <1> ;K16B:	jmp	K26			; IGNORE SYSTEM KEY
  3389                              <1> 	;
  3390                              <1> K16C:
  3391 0000123B 8025[A66F0000]FB    <1> 	and	byte [KB_FLAG_1], ~SYS_SHIFT ; TURN OFF SHIFT KEY HELD DOWN
  3392 00001242 B020                <1> 	mov	al, EOI			; END OF INTERRUPT COMMAND
  3393 00001244 E620                <1> 	out	20h, al ;out INTA00, al ; SEND COMMAND TO INTERRUPT CONTROL PORT
  3394                              <1> 					; INTERRUPT-RETURN-NO-EOI
  3395                              <1> 	;MOV	AL, ENA_KBD		; INSURE KEYBOARD IS ENABLED
  3396                              <1> 	;CALL	SHIP_IT			; EXECUTE ENABLE
  3397                              <1> 	;
  3398                              <1> 	;MOV	AX, 8501H		; FUNCTION VALUE FOR BREAK OF SYSTEM KEY
  3399                              <1> 	;STI				; MAKE SURE INTERRUPTS ENABLED
  3400                              <1> 	;INT	15H			; USER INTERRUPT
  3401                              <1> 	;JMP	K27A			; INGONRE SYSTEM KEY				
  3402                              <1> 	;
  3403 00001246 E94E010000          <1> 	jmp     K27			; IGNORE SYSTEM KEY
  3404                              <1> 	;
  3405                              <1> 	;-----	TEST FOR SHIFT KEYS
  3406                              <1> K16A:
  3407 0000124B 8A1D[A56F0000]      <1> 	mov	bl, [KB_FLAG]		; PUT STATE FLAGS IN BL
  3408 00001251 BF[8C6E0000]        <1> 	mov	edi, _K6		; SHIFT KEY TABLE offset
  3409 00001256 B908000000          <1> 	mov	ecx, _K6L		; LENGTH
  3410 0000125B F2AE                <1> 	repne	scasb			; LOOK THROUGH THE TABLE FOR A MATCH
  3411 0000125D 88E0                <1> 	mov	al, ah			; RECOVER SCAN CODE
  3412 0000125F 0F8510010000        <1>         jne     K25                     ; IF NO MATCH, THEN SHIFT NOT FOUND
  3413                              <1> 	;
  3414                              <1> 	;------	SHIFT KEY FOUND
  3415                              <1> K17:
  3416 00001265 81EF[8D6E0000]      <1>         sub     edi, _K6+1              ; ADJUST PTR TO SCAN CODE MATCH
  3417 0000126B 8AA7[946E0000]      <1>        	mov     ah, [edi+_K7]       	; GET MASK INTO AH
  3418 00001271 B102                <1> 	mov	cl, 2			; SETUP COUNT FOR FLAG SHIFTS
  3419 00001273 A880                <1> 	test	al, 80h			; TEST FOR BREAK KEY
  3420 00001275 0F8596000000        <1>         jnz     K23                     ; JUMP OF BREAK
  3421                              <1> 	;
  3422                              <1> 	;-----	SHIFT MAKE FOUND, DETERMINE SET OR TOGGLE
  3423                              <1> K17C:
  3424 0000127B 80FC10              <1> 	cmp	ah, SCROLL_SHIFT
  3425 0000127E 732B                <1> 	jae	short K18		; IF SCROLL SHIFT OR ABOVE, TOGGLE KEY
  3426                              <1> 	;
  3427                              <1> 	;-----	PLAIN SHIFT KEY, SET SHIFT ON
  3428 00001280 0825[A56F0000]      <1> 	or	[KB_FLAG], ah		; TURN ON SHIFT BIT
  3429 00001286 A80C                <1>         test	al, CTL_SHIFT+ALT_SHIFT ; IS IT ALT OR CTRL?
  3430                              <1> 	;jnz	short K17D		; YES, MORE FLAGS TO SET
  3431 00001288 0F84FF000000        <1> 	jz	K26			; NO, INTERRUPT RETURN
  3432                              <1> K17D:
  3433 0000128E F6C702              <1> 	test	bh, LC_E0		; IS THIS ONE OF NEW KEYS?
  3434 00001291 740B                <1> 	jz 	short K17E		; NO, JUMP
  3435 00001293 0825[A86F0000]      <1> 	or	[KB_FLAG_3], ah		; SET BITS FOR RIGHT CTRL, ALT
  3436 00001299 E9EF000000          <1> 	jmp	K26			; INTERRUPT RETURN
  3437                              <1> K17E:
  3438 0000129E D2EC                <1> 	shr	ah, cl			; MOVE FLAG BITS TWO POSITIONS
  3439 000012A0 0825[A66F0000]      <1> 	or	[KB_FLAG_1], ah		; SET BITS FOR LEFT CTRL, ALT
  3440 000012A6 E9E2000000          <1> 	jmp	K26
  3441                              <1> 	;
  3442                              <1> 	;-----	TOGGLED SHIFT KEY, TEST FOR 1ST MAKE OR NOT
  3443                              <1> K18:					; SHIFT-TOGGLE
  3444 000012AB F6C304              <1> 	test	bl, CTL_SHIFT 		; CHECK CTL SHIFT STATE
  3445                              <1>         ;jz    	short K18A              ; JUMP IF NOT CTL STATE
  3446 000012AE 0F85C1000000        <1>         jnz     K25                     ; JUMP IF CTL STATE
  3447                              <1> K18A:
  3448 000012B4 3C52                <1> 	cmp	al, INS_KEY		; CHECK FOR INSERT KEY
  3449 000012B6 7524                <1> 	jne	short K22		; JUMP IF NOT INSERT KEY
  3450 000012B8 F6C308              <1> 	test	bl, ALT_SHIFT 		; CHECK FOR ALTERNATE SHIFT
  3451                              <1>       	;jz	short K18B		; JUMP IF NOT ALTERNATE SHIFT	
  3452 000012BB 0F85B4000000        <1>         jnz     K25                     ; JUMP IF ALTERNATE SHIFT
  3453                              <1> K18B:
  3454 000012C1 F6C702              <1> 	test	bh, LC_E0 ;20/02/2015	; IS THIS NEW INSERT KEY?
  3455 000012C4 7516                <1> 	jnz	short K22		; YES, THIS ONE'S NEVER A '0'
  3456                              <1> K19:	
  3457 000012C6 F6C320              <1> 	test	bl, NUM_STATE 		; CHECK FOR BASE STATE
  3458 000012C9 750C                <1> 	jnz	short K21		; JUMP IF NUM LOCK IS ON
  3459 000012CB F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; TEST FOR SHIFT STATE
  3460 000012CE 740C                <1> 	jz	short K22		; JUMP IF BASE STATE
  3461                              <1> K20:					; NUMERIC ZERO, NOT INSERT KEY
  3462 000012D0 88C4                <1> 	mov	ah, al			; PUT SCAN CODE BACK IN AH
  3463 000012D2 E99E000000          <1>         jmp     K25                     ; NUMERAL '0', STNDRD. PROCESSING
  3464                              <1> K21:					; MIGHT BE NUMERIC
  3465 000012D7 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT
  3466 000012DA 74F4                <1> 	jz	short K20		; IS NUMERIC, STD. PROC.
  3467                              <1> 	;
  3468                              <1> K22:					; SHIFT TOGGLE KEY HIT; PROCESS IT
  3469 000012DC 8425[A66F0000]      <1> 	test	ah, [KB_FLAG_1] 	; IS KEY ALREADY DEPRESSED
  3470 000012E2 0F85A5000000        <1>         jnz     K26                     ; JUMP IF KEY ALREADY DEPRESSED
  3471                              <1> K22A:
  3472 000012E8 0825[A66F0000]      <1>         or      [KB_FLAG_1], ah 	; INDICATE THAT THE KEY IS DEPRESSED
  3473 000012EE 3025[A56F0000]      <1> 	xor	[KB_FLAG], ah		; TOGGLE THE SHIFT STATE
  3474                              <1> 	;
  3475                              <1> 	;-----	TOGGLE LED IF CAPS, NUM  OR SCROLL KEY DEPRESSED
  3476 000012F4 F6C470              <1> 	test	ah, CAPS_SHIFT+NUM_SHIFT+SCROLL_SHIFT ; SHIFT TOGGLE?
  3477 000012F7 7409                <1> 	jz	short K22B		; GO IF NOT
  3478                              <1> 	;
  3479 000012F9 6650                <1> 	push	ax			; SAVE SCAN CODE AND SHIFT MASK
  3480 000012FB E8F9030000          <1> 	call	SND_LED			; GO TURN MODE INDICATORS ON
  3481 00001300 6658                <1> 	pop	ax			; RESTORE SCAN CODE
  3482                              <1> K22B:
  3483 00001302 3C52                <1> 	cmp	al, INS_KEY		; TEST FOR 1ST MAKE OF INSERT KEY
  3484 00001304 0F8583000000        <1>         jne     K26                     ; JUMP IF NOT INSERT KEY
  3485 0000130A 88C4                <1> 	mov	ah, al		        ; SCAN CODE IN BOTH HALVES OF AX
  3486 0000130C E999000000          <1>         jmp     K28                     ; FLAGS UPDATED, PROC. FOR BUFFER
  3487                              <1> 	;
  3488                              <1> 	;-----	BREAK SHIFT FOUND
  3489                              <1> K23:					; BREAK-SHIFT-FOUND
  3490 00001311 80FC10              <1> 	cmp	ah, SCROLL_SHIFT	; IS THIS A TOGGLE KEY
  3491 00001314 F6D4                <1> 	not	ah			; INVERT MASK
  3492 00001316 7355                <1> 	jae	short K24		; YES, HANDLE BREAK TOGGLE
  3493 00001318 2025[A56F0000]      <1> 	and	[KB_FLAG], ah		; TURN OFF SHIFT BIT
  3494 0000131E 80FCFB              <1> 	cmp	ah, ~CTL_SHIFT		; IS THIS ALT OR CTL?
  3495 00001321 7730                <1> 	ja	short K23D		; NO, ALL DONE
  3496                              <1> 	;
  3497 00001323 F6C702              <1> 	test	bh, LC_E0		; 2ND ALT OR CTL?
  3498 00001326 7408                <1> 	jz	short K23A		; NO, HANSLE NORMALLY
  3499 00001328 2025[A86F0000]      <1> 	and 	[KB_FLAG_3], ah		; RESET BIT FOR RIGHT ALT OR CTL
  3500 0000132E EB08                <1> 	jmp	short K23B		; CONTINUE
  3501                              <1> K23A:
  3502 00001330 D2FC                <1> 	sar	ah, cl			; MOVE THE MASK BIT TWO POSITIONS
  3503 00001332 2025[A66F0000]      <1> 	and	[KB_FLAG_1], ah		; RESET BIT FOR LEFT ALT AND CTL
  3504                              <1> K23B:
  3505 00001338 88C4                <1> 	mov	ah, al			; SAVE SCAN CODE
  3506 0000133A A0[A86F0000]        <1> 	mov	al, [KB_FLAG_3]		; GET RIGHT ALT & CTRL FLAGS
  3507 0000133F D2E8                <1> 	shr	al, cl			; MOVE TO BITS 1 & 0
  3508 00001341 0A05[A66F0000]      <1> 	or	al, [KB_FLAG_1]		; PUT IN LEFT ALT & CTL FLAGS
  3509 00001347 D2E0                <1> 	shl	al, cl			; MOVE BACK TO BITS 3 & 2
  3510 00001349 240C                <1> 	and	al, ALT_SHIFT+CTL_SHIFT ; FILTER OUT OTHER GARBAGE
  3511 0000134B 0805[A56F0000]      <1> 	or	[KB_FLAG], al		; PUT RESULT IN THE REAL FLAGS	
  3512 00001351 88E0                <1> 	mov	al, ah
  3513                              <1> K23D:
  3514 00001353 3CB8                <1> 	cmp	al, ALT_KEY+80h		; IS THIS ALTERNATE SHIFT RELEASE
  3515 00001355 7536                <1> 	jne	short K26		; INTERRUPT RETURN
  3516                              <1> 	;	
  3517                              <1> 	;-----	ALTERNATE SHIFT KEY RELEASED, GET THE VALUE INTO BUFFER
  3518 00001357 A0[A96F0000]        <1> 	mov	al, [ALT_INPUT]
  3519 0000135C B400                <1> 	mov	ah, 0			; SCAN CODE OF 0
  3520 0000135E 8825[A96F0000]      <1> 	mov	[ALT_INPUT], ah 	; ZERO OUT THE FIELD
  3521 00001364 3C00                <1> 	cmp	al, 0			; WAS THE INPUT = 0?
  3522 00001366 7425                <1> 	je	short K26		; INTERRUPT_RETURN
  3523                              <1>         ; 29/01/2016
  3524                              <1> 	;jmp     K61                    ; IT WASN'T, SO PUT IN BUFFER
  3525 00001368 E9D0020000          <1> 	jmp	_K60
  3526                              <1> 	;
  3527                              <1> K24:					; BREAK-TOGGLE
  3528 0000136D 2025[A66F0000]      <1> 	and	[KB_FLAG_1], ah 	; INDICATE NO LONGER DEPRESSED
  3529 00001373 EB18                <1> 	jmp	short K26		; INTERRUPT_RETURN
  3530                              <1> 	;
  3531                              <1> 	;-----	TEST FOR HOLD STATE
  3532                              <1> 					; AL, AH = SCAN CODE
  3533                              <1> K25:					; NO-SHIFT-FOUND
  3534 00001375 3C80                <1> 	cmp	al, 80h			; TEST FOR BREAK KEY
  3535 00001377 7314                <1> 	jae	short K26		; NOTHING FOR BREAK CHARS FROM HERE ON
  3536 00001379 F605[A66F0000]08    <1> 	test	byte [KB_FLAG_1], HOLD_STATE ; ARE WE IN HOLD STATE
  3537 00001380 7428                <1> 	jz	short K28		; BRANCH AROUND TEST IF NOT
  3538 00001382 3C45                <1> 	cmp	al, NUM_KEY
  3539 00001384 7407                <1> 	je	short K26		; CAN'T END HOLD ON NUM_LOCK
  3540 00001386 8025[A66F0000]F7    <1> 	and	byte [KB_FLAG_1], ~HOLD_STATE ; TURN OFF THE HOLD STATE BIT
  3541                              <1> 	;
  3542                              <1> K26:
  3543 0000138D 8025[A86F0000]FC    <1> 	and	byte [KB_FLAG_3], ~(LC_E0+LC_E1) ; RESET LAST CHAR H.C. FLAG
  3544                              <1> K26A:					; INTERRUPT-RETURN
  3545 00001394 FA                  <1> 	cli				; TURN OFF INTERRUPTS
  3546 00001395 B020                <1> 	mov	al, EOI			; END OF INTERRUPT COMMAND
  3547 00001397 E620                <1> 	out	20h, al	;out INTA00, al	; SEND COMMAND TO INTERRUPT CONTROL PORT
  3548                              <1> K27:					; INTERRUPT-RETURN-NO-EOI
  3549 00001399 B0AE                <1> 	mov	al, ENA_KBD		; INSURE KEYBOARD IS ENABLED
  3550 0000139B E8F8020000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
  3551                              <1> K27A:
  3552 000013A0 FA                  <1> 	cli				; DISABLE INTERRUPTS
  3553                              <1> 	;;mov	byte [intflg], 0 ; 07/01/2017 ;; 15/01/2017
  3554 000013A1 07                  <1> 	pop	es			; RESTORE REGISTERS
  3555 000013A2 1F                  <1> 	pop	ds
  3556 000013A3 5F                  <1> 	pop	edi
  3557 000013A4 5E                  <1> 	pop	esi
  3558 000013A5 5A                  <1> 	pop	edx
  3559 000013A6 59                  <1> 	pop	ecx
  3560 000013A7 5B                  <1> 	pop	ebx
  3561 000013A8 58                  <1> 	pop	eax
  3562                              <1> 	;pop	ebp
  3563 000013A9 CF                  <1> 	iretd				; RETURN
  3564                              <1> 
  3565                              <1> 	;-----	NOT IN	HOLD STATE
  3566                              <1> K28:					; NO-HOLD-STATE
  3567 000013AA 3C58                <1> 	cmp	al, 88			; TEST FOR OUT-OF-RANGE SCAN CODES
  3568 000013AC 77DF                <1> 	ja	short K26		; IGNORE IF OUT-OF-RANGE	
  3569                              <1> 	;
  3570 000013AE F6C308              <1> 	test	bl, ALT_SHIFT 		; ARE WE IN ALTERNATE SHIFT
  3571                              <1>         ;jz	short K28A		; IF NOT ALTERNATE
  3572 000013B1 0F84F1000000        <1>         jz      K38
  3573                              <1> 	;
  3574 000013B7 F6C710              <1> 	test	bh, KBX			; IS THIS THE ENCHANCED KEYBOARD?
  3575 000013BA 740D                <1> 	jz	short K29		; NO, ALT STATE IS REAL
  3576                              <1> 	 ;28/02/2015
  3577 000013BC F605[A66F0000]04    <1> 	test	byte [KB_FLAG_1], SYS_SHIFT ; YES, IS SYSREQ KEY DOWN?
  3578                              <1> 	;jz	short K29		;  NO, ALT STATE IS REAL
  3579 000013C3 0F85DF000000        <1> 	jnz	K38			; YES, THIS IS PHONY ALT STATE 
  3580                              <1>         ;				; DUE TO PRESSING SYSREQ	
  3581                              <1> ;K28A:	jmp	short K38
  3582                              <1> 	;
  3583                              <1> 	;-----	TEST FOR RESET KEY SEQUENCE (CTL ALT DEL)
  3584                              <1> K29:					; TEST-RESET
  3585 000013C9 F6C304              <1> 	test	bl, CTL_SHIFT 		; ARE WE IN CONTROL SHIFT ALSO?
  3586 000013CC 740B                <1> 	jz	short K31		; NO_RESET
  3587 000013CE 3C53                <1> 	cmp	al, DEL_KEY		; CTL-ALT STATE, TEST FOR DELETE KEY
  3588 000013D0 7507                <1> 	jne	short K31		; NO_RESET, IGNORE
  3589                              <1> 	;
  3590                              <1> 	;-----	CTL-ALT-DEL HAS BEEN FOUND
  3591                              <1>  	; 26/08/2014
  3592                              <1> cpu_reset:
  3593                              <1> 	; IBM PC/AT ROM BIOS source code - 10/06/85 (TEST4.ASM - PROC_SHUTDOWN)
  3594                              <1> 	; Send FEh (system reset command) to the keyboard controller.
  3595 000013D2 B0FE                <1> 	mov	al, SHUT_CMD		; SHUTDOWN COMMAND
  3596 000013D4 E664                <1> 	out	STATUS_PORT, al		; SEND TO KEYBOARD CONTROL PORT
  3597                              <1> khere:
  3598 000013D6 F4                  <1> 	hlt				; WAIT FOR 80286 RESET
  3599 000013D7 EBFD                <1> 	jmp 	short khere		; INSURE HALT
  3600                              <1> 
  3601                              <1> 	;
  3602                              <1> 	;-----	IN ALTERNATE SHIFT, RESET NOT FOUND
  3603                              <1> K31:					; NO-RESET
  3604 000013D9 3C39                <1> 	cmp	al, 57			; TEST FOR SPACE KEY
  3605 000013DB 7507                <1> 	jne	short K311		; NOT THERE
  3606 000013DD B020                <1> 	mov	al, ' '			; SET SPACE CHAR
  3607 000013DF E948020000          <1>         jmp     K57                     ; BUFFER_FILL
  3608                              <1> K311:
  3609 000013E4 3C0F                <1> 	cmp	al, 15			; TEST FOR TAB KEY
  3610 000013E6 7509                <1> 	jne	short K312		; NOT THERE
  3611 000013E8 66B800A5            <1> 	mov	ax, 0A500h		; SET SPECIAL CODE FOR ALT-TAB
  3612 000013EC E93B020000          <1>         jmp     K57                     ; BUFFER_FILL
  3613                              <1> K312:
  3614 000013F1 3C4A                <1> 	cmp	al, 74			; TEST FOR KEY PAD -
  3615 000013F3 0F84A2000000        <1>         je      K37B                    ; GO PROCESS
  3616 000013F9 3C4E                <1> 	cmp	al, 78			; TEST FOR KEY PAD +
  3617 000013FB 0F849A000000        <1>         je      K37B                    ; GO PROCESS
  3618                              <1> 	;
  3619                              <1> 	;-----	LOOK FOR KEY PAD ENTRY
  3620                              <1> K32:					; ALT-KEY-PAD
  3621 00001401 BF[686E0000]        <1> 	mov	edi, K30		; ALT-INPUT-TABLE offset
  3622 00001406 B90A000000          <1> 	mov	ecx, 10			; LOOK FOR ENTRY USING KEYPAD
  3623 0000140B F2AE                <1> 	repne	scasb			; LOOK FOR MATCH
  3624 0000140D 7525                <1> 	jne	short K33		; NO_ALT_KEYPAD
  3625 0000140F F6C702              <1> 	test	bh, LC_E0		; IS THIS ONE OF THE NEW KEYS?
  3626 00001412 0F858A000000        <1>         jnz     K37C                    ; YES, JUMP, NOT NUMPAD KEY
  3627 00001418 81EF[696E0000]      <1> 	sub	edi, K30+1		; DI NOW HAS ENTRY VALUE
  3628 0000141E A0[A96F0000]        <1> 	mov	al, [ALT_INPUT] 	; GET THE CURRENT BYTE
  3629 00001423 B40A                <1> 	mov	ah, 10			; MULTIPLY BY 10
  3630 00001425 F6E4                <1> 	mul	ah
  3631 00001427 6601F8              <1> 	add	ax, di			; ADD IN THE LATEST ENTRY
  3632 0000142A A2[A96F0000]        <1> 	mov	[ALT_INPUT], al 	; STORE IT AWAY
  3633                              <1> ;K32A:
  3634 0000142F E959FFFFFF          <1>         jmp     K26                     ; THROW AWAY THAT KEYSTROKE
  3635                              <1> 	;
  3636                              <1> 	;-----	LOOK FOR SUPERSHIFT ENTRY
  3637                              <1> K33:					; NO-ALT-KEYPAD
  3638 00001434 C605[A96F0000]00    <1>         mov     byte [ALT_INPUT], 0     ; ZERO ANY PREVIOUS ENTRY INTO INPUT
  3639 0000143B B91A000000          <1> 	mov	ecx, 26			; (DI),(ES) ALREADY POINTING
  3640 00001440 F2AE                <1> 	repne	scasb			; LOOK FOR MATCH IN ALPHABET
  3641 00001442 7450                <1> 	je	short K37A		; MATCH FOUND, GO FILLL THE BUFFER
  3642                              <1> 	;
  3643                              <1> 	;-----	LOOK FOR TOP ROW OF ALTERNATE SHIFT
  3644                              <1> K34:					; ALT-TOP-ROW
  3645 00001444 3C02                <1> 	cmp	al, 2			; KEY WITH '1' ON IT
  3646 00001446 7253                <1> 	jb	short K37B		; MUST BE ESCAPE
  3647 00001448 3C0D                <1> 	cmp	al, 13			; IS IT IN THE REGION
  3648 0000144A 7705                <1> 	ja	short K35		; NO, ALT SOMETHING ELSE
  3649 0000144C 80C476              <1> 	add	ah, 118			; CONVERT PSEUDO SCAN CODE TO RANGE
  3650 0000144F EB43                <1> 	jmp	short K37A		; GO FILL THE BUFFER
  3651                              <1> 	;
  3652                              <1> 	;-----	TRANSLATE ALTERNATE SHIFT PSEUDO SCAN CODES
  3653                              <1> K35:					; ALT-FUNCTION
  3654 00001451 3C57                <1> 	cmp	al, F11_M		; IS IT F11?	
  3655 00001453 7209                <1> 	jb	short K35A ; 20/02/2015	; NO, BRANCH
  3656 00001455 3C58                <1> 	cmp	al, F12_M		; IS IT F12?
  3657 00001457 7705                <1> 	ja	short K35A ; 20/02/2015	; NO, BRANCH
  3658 00001459 80C434              <1> 	add	ah, 52			; CONVERT TO PSEUDO SCAN CODE
  3659 0000145C EB36                <1> 	jmp	short K37A		; GO FILL THE BUFFER
  3660                              <1> K35A:
  3661 0000145E F6C702              <1> 	test	bh, LC_E0		; DO WE HAVE ONE OF THE NEW KEYS?
  3662 00001461 7422                <1> 	jz	short K37		; NO, JUMP
  3663 00001463 3C1C                <1> 	cmp	al, 28			; TEST FOR KEYPAD ENTER
  3664 00001465 7509                <1>         jne     short K35B              ; NOT THERE
  3665 00001467 66B800A6            <1> 	mov	ax, 0A600h		; SPECIAL CODE
  3666 0000146B E9BC010000          <1> 	jmp	K57			; BUFFER FILL
  3667                              <1> K35B:
  3668 00001470 3C53                <1> 	cmp	al, 83			; TEST FOR DELETE KEY
  3669 00001472 742E                <1> 	je	short K37C		; HANDLE WITH OTHER EDIT KEYS
  3670 00001474 3C35                <1> 	cmp	al, 53			; TEST FOR KEYPAD /
  3671                              <1> 	;jne	short K32A		; NOT THERE, NO OTHER E0 SPECIALS	
  3672 00001476 0F8511FFFFFF        <1>         jne     K26
  3673 0000147C 66B800A4            <1> 	mov	ax, 0A400h		; SPECIAL CODE
  3674 00001480 E9A7010000          <1> 	jmp	K57			; BUFFER FILL
  3675                              <1> K37:
  3676 00001485 3C3B                <1> 	cmp	al, 59			; TEST FOR FUNCTION KEYS (F1)
  3677 00001487 7212                <1>         jb      short K37B		; NO FN, HANDLE W/OTHER EXTENDED
  3678 00001489 3C44                <1> 	cmp	al, 68			; IN KEYPAD REGION?
  3679                              <1>         ;ja	short K32A		; IF SO, IGNORE
  3680 0000148B 0F87FCFEFFFF        <1>         ja      K26
  3681 00001491 80C42D              <1> 	add	ah, 45			; CONVERT TO PSEUDO SCAN CODE
  3682                              <1> K37A:
  3683 00001494 B000                <1> 	mov	al, 0			; ASCII CODE OF ZERO
  3684 00001496 E991010000          <1>         jmp     K57                     ; PUT IT IN THE BUFFER
  3685                              <1> K37B:
  3686 0000149B B0F0                <1> 	mov	al, 0F0h		; USE SPECIAL ASCII CODE
  3687 0000149D E98A010000          <1> 	jmp     K57                     ; PUT IT IN THE BUFFER
  3688                              <1> K37C:
  3689 000014A2 0450                <1> 	add	al, 80			; CONVERT SCAN CODE (EDIT KEYS)
  3690 000014A4 88C4                <1> 	mov	ah, al			; (SCAN CODE NOT IN AH FOR INSERT)
  3691 000014A6 EBEC                <1> 	jmp     short K37A              ; PUT IT IN THE BUFFER
  3692                              <1> 	;
  3693                              <1> 	;-----	NOT IN ALTERNATE SHIFT
  3694                              <1> K38:					; NOT-ALT-SHIFT
  3695                              <1> 					; BL STILL HAS SHIFT FLAGS
  3696 000014A8 F6C304              <1> 	test	bl, CTL_SHIFT 		; ARE WE IN CONTROL SHIFT?
  3697                              <1> 	;jnz	short K38A		; YES, START PROCESSING	
  3698 000014AB 0F84B0000000        <1>         jz      K44                     ; NOT-CTL-SHIFT
  3699                              <1> 	;
  3700                              <1> 	;-----	CONTROL SHIFT, TEST SPECIAL CHARACTERS
  3701                              <1> 	;-----	TEST FOR BREAK
  3702                              <1> K38A:
  3703 000014B1 3C46                <1> 	cmp	al, SCROLL_KEY		; TEST FOR BREAK
  3704 000014B3 7531                <1> 	jne	short K39		; JUMP, NO-BREAK
  3705 000014B5 F6C710              <1> 	test	bh, KBX			; IS THIS THE ENHANCED KEYBOARD?
  3706 000014B8 7405                <1> 	jz	short K38B		; NO, BREAK IS VALID	
  3707 000014BA F6C702              <1> 	test	bh, LC_E0		; YES, WAS LAST CODE AN E0?
  3708 000014BD 7427                <1> 	jz	short K39		; NO-BREAK, TEST FOR PAUSE	
  3709                              <1> K38B:
  3710 000014BF 8B1D[B26F0000]      <1> 	mov	ebx, [BUFFER_HEAD] 	; RESET BUFFER TO EMPTY
  3711 000014C5 891D[B66F0000]      <1> 	mov	[BUFFER_TAIL], ebx
  3712 000014CB C605[A46F0000]80    <1> 	mov	byte [BIOS_BREAK], 80h  ; TURN ON BIOS_BREAK BIT
  3713                              <1> 	;
  3714                              <1> 	;-----	ENABLE KEYBOARD
  3715 000014D2 B0AE                <1> 	mov	al, ENA_KBD		; ENABLE KEYBOARD
  3716 000014D4 E8BF010000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
  3717                              <1> 	;
  3718                              <1> 	; CTRL+BREAK code here !!!
  3719                              <1> 	;INT	1BH			; BREAK INTERRUPT VECTOR
  3720                              <1> 	; 17/10/2015	
  3721 000014D9 E812610000          <1> 	call	ctrlbrk ; control+break subroutine
  3722                              <1> 	;
  3723 000014DE 6629C0              <1> 	sub	ax, ax			; PUT OUT DUMMY CHARACTER
  3724 000014E1 E946010000          <1>         jmp     K57                     ; BUFFER_FILL
  3725                              <1> 	;
  3726                              <1> 	;-----	TEST FOR PAUSE
  3727                              <1> K39:					; NO_BREAK
  3728 000014E6 F6C710              <1> 	test	bh, KBX			; IS THIS THE ENHANCED KEYBOARD?
  3729 000014E9 7537                <1> 	jnz	short K41		; YES, THEN THIS CAN'T BE PAUSE	
  3730 000014EB 3C45                <1> 	cmp	al, NUM_KEY		; LOOK FOR PAUSE KEY
  3731 000014ED 7533                <1> 	jne	short K41		; NO-PAUSE
  3732                              <1> K39P:
  3733 000014EF 800D[A66F0000]08    <1> 	or	byte [KB_FLAG_1], HOLD_STATE ; TURN ON THE HOLD FLAG
  3734                              <1> 	;
  3735                              <1> 	;-----	ENABLE KEYBOARD
  3736 000014F6 B0AE                <1> 	mov	al, ENA_KBD		; ENABLE KEYBOARD
  3737 000014F8 E89B010000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
  3738                              <1> K39A:
  3739 000014FD B020                <1> 	mov	al, EOI			; END OF INTERRUPT TO CONTROL PORT
  3740 000014FF E620                <1> 	out	20h, al ;out INTA00, al	; ALLOW FURTHER KEYSTROKE INTERRUPTS
  3741                              <1> 	;
  3742                              <1> 	;-----	DURING PAUSE INTERVAL, TURN COLOR CRT BACK ON
  3743 00001501 803D[DA6F0000]07    <1>         cmp     byte [CRT_MODE], 7      ; IS THIS BLACK AND WHITE CARD
  3744 00001508 740A                <1>         je      short K40              	; YES, NOTHING TO DO
  3745 0000150A 66BAD803            <1> 	mov	dx, 03D8h		; PORT FOR COLOR CARD
  3746 0000150E A0[DB6F0000]        <1>         mov     al, [CRT_MODE_SET] 	; GET THE VALUE OF THE CURRENT MODE
  3747 00001513 EE                  <1> 	out	dx, al			; SET THE CRT MODE, SO THAT CRT IS ON
  3748                              <1> 	;
  3749                              <1> K40:					; PAUSE-LOOP
  3750 00001514 F605[A66F0000]08    <1>         test    byte [KB_FLAG_1], HOLD_STATE ; CHECK HOLD STATE FLAG
  3751 0000151B 75F7                <1> 	jnz	short K40		; LOOP UNTIL FLAG TURNED OFF
  3752                              <1> 	;
  3753 0000151D E977FEFFFF          <1>         jmp     K27                     ; INTERRUPT_RETURN_NO_EOI
  3754                              <1>         ;
  3755                              <1> 	;-----	TEST SPECIAL CASE KEY 55
  3756                              <1> K41:					; NO-PAUSE
  3757 00001522 3C37                <1> 	cmp	al, 55			; TEST FOR */PRTSC KEY
  3758 00001524 7513                <1> 	jne	short K42		; NOT-KEY-55
  3759 00001526 F6C710              <1> 	test	bh, KBX			; IS THIS THE ENHANCED KEYBOARD?
  3760 00001529 7405                <1> 	jz	short K41A		; NO, CTL-PRTSC IS VALID	
  3761 0000152B F6C702              <1> 	test	bh, LC_E0		; YES, WAS LAST CODE AN E0?
  3762 0000152E 7421                <1> 	jz	short K42B		; NO, TRANSLATE TO A FUNCTION
  3763                              <1> K41A:	
  3764 00001530 66B80072            <1> 	mov	ax, 114*256		; START/STOP PRINTING SWITCH
  3765 00001534 E9F3000000          <1>         jmp     K57                     ; BUFFER_FILL
  3766                              <1> 	;
  3767                              <1> 	;-----	SET UP TO TRANSLATE CONTROL SHIFT
  3768                              <1> K42:					; NOT-KEY-55
  3769 00001539 3C0F                <1> 	cmp	al, 15			; IS IT THE TAB KEY?
  3770 0000153B 7414                <1> 	je	short K42B		; YES, XLATE TO FUNCTION CODE
  3771 0000153D 3C35                <1> 	cmp	al, 53			; IS IT THE / KEY?
  3772 0000153F 750E                <1> 	jne	short K42A		; NO, NO MORE SPECIAL CASES	
  3773 00001541 F6C702              <1> 	test	bh, LC_E0		; YES, IS IT FROM THE KEY PAD?
  3774 00001544 7409                <1> 	jz	short K42A		; NO, JUST TRANSLATE
  3775 00001546 66B80095            <1> 	mov	ax, 9500h		; YES, SPECIAL CODE FOR THIS ONE
  3776 0000154A E9DD000000          <1> 	jmp	K57			; BUFFER FILL	
  3777                              <1> K42A: 
  3778                              <1> 	;;mov	ebx, _K8		; SET UP TO TRANSLATE CTL
  3779 0000154F 3C3B                <1> 	cmp	al, 59			; IS IT IN CHARACTER TABLE?
  3780                              <1>         ;jb	short K45F              ; YES, GO TRANSLATE CHAR
  3781                              <1> 	;;jb	K56 ; 20/02/2015
  3782                              <1> 	;;jmp	K64 ; 20/02/2015
  3783                              <1> K42B:
  3784 00001551 BB[9C6E0000]        <1> 	mov	ebx, _K8		; SET UP TO TRANSLATE CTL
  3785 00001556 0F82AE000000        <1> 	jb	K56 ;; 20/02/2015	
  3786 0000155C E9B9000000          <1> 	jmp	K64	
  3787                              <1>         ;
  3788                              <1> 	;-----	NOT IN CONTROL SHIFT
  3789                              <1> K44:					; NOT-CTL-SHIFT
  3790 00001561 3C37                <1> 	cmp	al, 55			; PRINT SCREEN KEY?
  3791 00001563 7528                <1> 	jne	short K45		; NOT PRINT SCREEN
  3792 00001565 F6C710              <1> 	test	bh, KBX			; IS THIS ENHANCED KEYBOARD?
  3793 00001568 7407                <1> 	jz	short K44A		; NO, TEST FOR SHIFT STATE	
  3794 0000156A F6C702              <1> 	test	bh, LC_E0		; YES, LAST CODE A MARKER?
  3795 0000156D 7507                <1> 	jnz	short K44B		; YES, IS PRINT SCREEN
  3796 0000156F EB41                <1> 	jmp	short K45C		; NO, TRANSLATE TO '*' CHARACTER
  3797                              <1> K44A:
  3798 00001571 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; NOT 101 KBD, SHIFT KEY DOWN?
  3799 00001574 743C                <1> 	jz	short K45C		; NO, TRANSLATE TO '*' CHARACTER
  3800                              <1> 	;
  3801                              <1> 	;-----	ISSUE INTERRUPT TO INDICATE PRINT SCREEN FUNCTION
  3802                              <1> K44B:
  3803 00001576 B0AE                <1> 	mov	al, ENA_KBD		; INSURE KEYBOARD IS ENABLED
  3804 00001578 E81B010000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
  3805 0000157D B020                <1> 	mov	al, EOI			; END OF CURRENT INTERRUPT
  3806 0000157F E620                <1> 	out	20h, al ;out INTA00, al	; SO FURTHER THINGS CAN HAPPEN
  3807                              <1> 	; Print Screen !!!		; ISSUE PRINT SCREEN INTERRUPT (INT 05h)
  3808                              <1> 	;PUSH 	BP			; SAVE POINTER
  3809                              <1> 	;INT 	5H			; ISSUE PRINT SCREEN INTERRUPT
  3810                              <1> 	;POP	BP			; RESTORE POINTER
  3811 00001581 8025[A86F0000]FC    <1>         and     byte [KB_FLAG_3], ~(LC_E0+LC_E1) ; ZERO OUT THESE FLAGS
  3812 00001588 E90CFEFFFF          <1>         jmp     K27                     ; GO BACK WITHOUT EOI OCCURRING
  3813                              <1> 	;
  3814                              <1> 	;-----	HANDLE IN-CORE KEYS
  3815                              <1> K45:					; NOT-PRINT-SCREEN
  3816 0000158D 3C3A                <1> 	cmp	al, 58			; TEST FOR IN-CORE AREA
  3817 0000158F 7734                <1> 	ja	short K46		; JUMP IF NOT
  3818 00001591 3C35                <1> 	cmp	al, 53			; IS THIS THE '/' KEY?
  3819 00001593 7505                <1> 	jne	short K45A		; NO, JUMP
  3820 00001595 F6C702              <1> 	test	bh, LC_E0		; WAS THE LAST CODE THE MARKER?
  3821 00001598 7518                <1> 	jnz	short K45C		; YES, TRANSLATE TO CHARACTER
  3822                              <1> K45A:
  3823 0000159A B91A000000          <1> 	mov	ecx, 26			; LENGHT OF SEARCH
  3824 0000159F BF[726E0000]        <1> 	mov	edi, K30+10		; POINT TO TABLE OF A-Z CHARS
  3825 000015A4 F2AE                <1> 	repne	scasb			; IS THIS A LETTER KEY?
  3826                              <1> 		; 20/02/2015
  3827 000015A6 7505                <1> 	jne	short K45B              ; NO, SYMBOL KEY
  3828                              <1> 	;
  3829 000015A8 F6C340              <1> 	test	bl, CAPS_STATE		; ARE WE IN CAPS_LOCK?
  3830 000015AB 750C                <1> 	jnz	short K45D		; TEST FOR SURE
  3831                              <1> K45B:
  3832 000015AD F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; ARE WE IN SHIFT STATE?
  3833 000015B0 750C                <1> 	jnz	short K45E		; YES, UPPERCASE
  3834                              <1> 					; NO, LOWERCASE
  3835                              <1> K45C:
  3836 000015B2 BB[F46E0000]        <1> 	mov	ebx, K10		; TRANSLATE TO LOWERCASE LETTERS
  3837 000015B7 EB51                <1> 	jmp	short K56	
  3838                              <1> K45D:					; ALMOST-CAPS-STATE
  3839 000015B9 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; CL ON. IS SHIFT ON, TOO?
  3840 000015BC 75F4                <1> 	jnz	short K45C		; SHIFTED TEMP OUT OF CAPS STATE
  3841                              <1> K45E:
  3842 000015BE BB[4C6F0000]        <1> 	mov	ebx, K11		; TRANSLATE TO UPPER CASE LETTERS
  3843 000015C3 EB45                <1> K45F:	jmp	short K56
  3844                              <1> 	;
  3845                              <1> 	;-----	TEST FOR KEYS F1 - F10
  3846                              <1> K46:					; NOT IN-CORE AREA
  3847 000015C5 3C44                <1> 	cmp	al, 68			; TEST FOR F1 - F10
  3848                              <1> 	;ja	short K47		; JUMP IF NOT
  3849                              <1> 	;jmp	short K53		; YES, GO DO FN KEY PROCESS			
  3850 000015C7 7635                <1> 	jna	short K53		
  3851                              <1> 	;
  3852                              <1> 	;-----	HANDLE THE NUMERIC PAD KEYS
  3853                              <1> K47:					; NOT F1 - F10
  3854 000015C9 3C53                <1> 	cmp	al, 83			; TEST NUMPAD KEYS
  3855 000015CB 772D                <1> 	ja	short K52		; JUMP IF NOT
  3856                              <1> 	;
  3857                              <1> 	;-----	KEYPAD KEYS, MUST TEST NUM LOCK FOR DETERMINATION
  3858                              <1> K48:
  3859 000015CD 3C4A                <1> 	cmp	al , 74			; SPECIAL CASE FOR MINUS
  3860 000015CF 74ED                <1> 	je	short K45E		; GO TRANSLATE
  3861 000015D1 3C4E                <1> 	cmp	al , 78			; SPECIAL CASE FOR PLUS
  3862 000015D3 74E9                <1> 	je	short K45E		; GO TRANSLATE
  3863 000015D5 F6C702              <1> 	test	bh, LC_E0		; IS THIS ONE OFTHE NEW KEYS?
  3864 000015D8 750A                <1> 	jnz	short K49		; YES, TRANSLATE TO BASE STATE
  3865                              <1> 	;		
  3866 000015DA F6C320              <1> 	test 	bl, NUM_STATE		; ARE WE IN NUM LOCK
  3867 000015DD 7514                <1> 	jnz	short K50		; TEST FOR SURE
  3868 000015DF F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; ARE WE IN SHIFT STATE?
  3869                              <1> 	;jnz	short K51		; IF SHIFTED, REALLY NUM STATE
  3870 000015E2 75DA                <1> 	jnz	short K45E
  3871                              <1> 	;
  3872                              <1> 	;-----	BASE CASE FOR KEYPAD
  3873                              <1> K49:					
  3874 000015E4 3C4C                <1> 	cmp	al, 76			; SPECIAL CASE FOR BASE STATE 5
  3875 000015E6 7504                <1> 	jne	short K49A		; CONTINUE IF NOT KEYPAD 5
  3876 000015E8 B0F0                <1> 	mov	al, 0F0h		; SPECIAL ASCII CODE	
  3877 000015EA EB40                <1> 	jmp	short K57		; BUFFER FILL
  3878                              <1> K49A:
  3879 000015EC BB[F46E0000]        <1> 	mov	ebx, K10		; BASE CASE TABLE	
  3880 000015F1 EB27                <1> 	jmp	short K64		; CONVERT TO PSEUDO SCAN
  3881                              <1> 	;
  3882                              <1> 	;-----	MIGHT BE NUM LOCK, TEST SHIFT STATUS
  3883                              <1> K50:					; ALMOST-NUM-STATE
  3884 000015F3 F6C303              <1>         test    bl, LEFT_SHIFT+RIGHT_SHIFT
  3885 000015F6 75EC                <1> 	jnz 	short K49		; SHIFTED TEMP OUT OF NUM STATE
  3886 000015F8 EBC4                <1> K51:	jmp	short K45E		; REALLY NUM STATE
  3887                              <1> 	;
  3888                              <1> 	;-----	TEST FOR THE NEW KEYS ON WT KEYBOARDS 
  3889                              <1> K52:					; NOT A NUMPAD KEY
  3890 000015FA 3C56                <1> 	cmp	al, 86			; IS IT THE NEW WT KEY?
  3891                              <1> 	;jne	short K53		; JUMP IF NOT
  3892                              <1> 	;jmp	short K45B		; HANDLE WITH REST OF LETTER KEYS
  3893 000015FC 74AF                <1> 	je	short K45B		
  3894                              <1> 	;
  3895                              <1> 	;-----	MUST BE F11 OR F12 
  3896                              <1> K53:					; F1 - F10 COME HERE, TOO
  3897 000015FE F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; TEST SHIFT STATE
  3898 00001601 74E1                <1> 	jz	short K49		; JUMP, LOWER CASE PSEUDO SC'S
  3899                              <1> 		; 20/02/2015 
  3900 00001603 BB[4C6F0000]        <1> 	mov	ebx, K11		; UPPER CASE PSEUDO SCAN CODES
  3901 00001608 EB10                <1> 	jmp	short K64		; TRANSLATE SCAN
  3902                              <1> 	;
  3903                              <1> 	;-----	TRANSLATE THE CHARACTER
  3904                              <1> K56:					; TRANSLATE-CHAR
  3905 0000160A FEC8                <1> 	dec	al			; CONVERT ORIGIN
  3906 0000160C D7                  <1> 	xlat    			; CONVERT THE SCAN CODE TO ASCII
  3907 0000160D F605[A86F0000]02    <1> 	test	byte [KB_FLAG_3], LC_E0	; IS THIS A NEW KEY?
  3908 00001614 7416                <1> 	jz	short K57		; NO, GO FILL BUFFER
  3909 00001616 B4E0                <1> 	mov	ah, MC_E0		; YES, PUT SPECIAL MARKER IN AH
  3910 00001618 EB12                <1> 	jmp	short K57		; PUT IT INTO THE BUFFER	
  3911                              <1> 	;
  3912                              <1> 	;-----	TRANSLATE SCAN FOR PSEUDO SCAN CODES
  3913                              <1> K64:					; TRANSLATE-SCAN-ORGD
  3914 0000161A FEC8                <1> 	dec	al			; CONVERT ORIGIN
  3915 0000161C D7                  <1>        	xlat    	                ; CTL TABLE SCAN
  3916 0000161D 88C4                <1> 	mov	ah, al			; PUT VALUE INTO AH
  3917 0000161F B000                <1> 	mov	al, 0			; ZERO ASCII CODE
  3918 00001621 F605[A86F0000]02    <1> 	test	byte [KB_FLAG_3], LC_E0	; IS THIS A NEW KEY?
  3919 00001628 7402                <1> 	jz	short K57		; NO, GO FILL BUFFER
  3920 0000162A B0E0                <1> 	mov	al, MC_E0		; YES, PUT SPECIAL MARKER IN AL
  3921                              <1> 	;
  3922                              <1> 	;-----	PUT CHARACTER INTO BUFFER
  3923                              <1> K57:					; BUFFER_FILL
  3924 0000162C 3CFF                <1> 	cmp	al, -1			; IS THIS AN IGNORE CHAR
  3925                              <1>         ;je	short K59		; YES, DO NOTHING WITH IT
  3926 0000162E 0F8459FDFFFF        <1> 	je      K26			; YES, DO NOTHING WITH IT
  3927 00001634 80FCFF              <1> 	cmp	ah, -1			; LOOK FOR -1 PSEUDO SCAN
  3928                              <1>         ;jne	short K61		; NEAR_INTERRUPT_RETURN
  3929 00001637 0F8450FDFFFF        <1> 	je      K26			; INTERRUPT_RETURN
  3930                              <1> ;K59:					; NEAR_INTERRUPT_RETURN
  3931                              <1> ;	jmp	K26			; INTERRUPT_RETURN
  3932                              <1> 
  3933                              <1> _K60: ; 29/01/2016
  3934 0000163D 80FC68              <1> 	cmp	ah, 68h	; ALT + F1 key
  3935 00001640 721F                <1> 	jb	short K61
  3936 00001642 80FC6F              <1> 	cmp	ah, 6Fh ; ALT + F8 key	
  3937 00001645 771A                <1> 	ja	short K61
  3938                              <1> 	;
  3939 00001647 8A1D[5E8A0100]      <1> 	mov	bl, [ACTIVE_PAGE]
  3940 0000164D 80C368              <1> 	add	bl, 68h
  3941 00001650 38E3                <1> 	cmp	bl, ah
  3942 00001652 740D                <1> 	je	short K61
  3943 00001654 6650                <1> 	push	ax
  3944 00001656 88E0                <1> 	mov	al, ah
  3945 00001658 2C68                <1> 	sub	al, 68h
  3946 0000165A E858090000          <1> 	call	set_active_page
  3947 0000165F 6658                <1> 	pop	ax
  3948                              <1> K61:					; NOT-CAPS-STATE
  3949 00001661 8B1D[B66F0000]      <1> 	mov	ebx, [BUFFER_TAIL] 	; GET THE END POINTER TO THE BUFFER
  3950 00001667 89DE                <1> 	mov	esi, ebx		; SAVE THE VALUE
  3951 00001669 E857FAFFFF          <1> 	call	_K4			; ADVANCE THE TAIL
  3952 0000166E 3B1D[B26F0000]      <1> 	cmp	ebx, [BUFFER_HEAD] 	; HAS THE BUFFER WRAPPED AROUND
  3953 00001674 740E                <1> 	je	short K62		; BUFFER_FULL_BEEP
  3954 00001676 668906              <1> 	mov	[esi], ax		; STORE THE VALUE
  3955 00001679 891D[B66F0000]      <1> 	mov	[BUFFER_TAIL], ebx 	; MOVE THE POINTER UP
  3956 0000167F E909FDFFFF          <1> 	jmp	K26
  3957                              <1> 	;;cli				; TURN OFF INTERRUPTS
  3958                              <1> 	;;mov	al, EOI			; END OF INTERRUPT COMMAND
  3959                              <1> 	;;out	INTA00, al		; SEND COMMAND TO INTERRUPT CONTROL PORT
  3960                              <1> 	;MOV	AL, ENA_KBD		; INSURE KEYBOARD IS ENABLED
  3961                              <1> 	;CALL	SHIP_IT			; EXECUTE ENABLE
  3962                              <1> 	;MOV	AX, 9102H		; MOVE IN POST CODE & TYPE
  3963                              <1> 	;INT	15H			; PERFORM OTHER FUNCTION
  3964                              <1> 	;;and	byte [KB_FLAG_3],~(LC_E0+LC_E1) ; RESET LAST CHAR H.C. FLAG
  3965                              <1> 	;JMP	K27A			; INTERRUPT_RETURN
  3966                              <1> 	;;jmp   K27                    
  3967                              <1> 	;
  3968                              <1> 	;-----	BUFFER IS FULL SOUND THE BEEPER
  3969                              <1> K62:
  3970 00001684 B020                <1> 	mov	al, EOI			; ENABLE INTERRUPT CONTROLLER CHIP
  3971 00001686 E620                <1> 	out	INTA00, al
  3972 00001688 66B9A602            <1> 	mov	cx, 678			; DIVISOR FOR 1760 HZ
  3973 0000168C B304                <1> 	mov	bl, 4			; SHORT BEEP COUNT (1/16 + 1/64 DELAY)
  3974 0000168E E86D0D0000          <1> 	call	beep			; GO TO COMMON BEEP HANDLER
  3975 00001693 E901FDFFFF          <1> 	jmp     K27			; EXIT   
  3976                              <1> 
  3977                              <1> SHIP_IT:
  3978                              <1> 	;---------------------------------------------------------------------------------
  3979                              <1> 	; SHIP_IT
  3980                              <1> 	;	THIS ROUTINES HANDLES TRANSMISSION OF COMMAND AND DATA BYTES
  3981                              <1> 	;	TO THE KEYBOARD CONTROLLER.
  3982                              <1> 	;---------------------------------------------------------------------------------
  3983                              <1> 	;
  3984 00001698 6650                <1> 	push	ax			; SAVE DATA TO SEND
  3985                              <1> 
  3986                              <1> 	;-----	WAIT FOR COMMAND TO ACCEPTED
  3987 0000169A FA                  <1> 	cli				; DISABLE INTERRUPTS TILL DATA SENT
  3988                              <1> 	; xor	ecx, ecx		; CLEAR TIMEOUT COUNTER
  3989 0000169B B900000100          <1> 	mov	ecx, 10000h			
  3990                              <1> S10:
  3991 000016A0 E464                <1> 	in	al, STATUS_PORT		; READ KEYBOARD CONTROLLER STATUS
  3992 000016A2 A802                <1> 	test	al, INPT_BUF_FULL	; CHECK FOR ITS INPUT BUFFER BUSY
  3993 000016A4 E0FA                <1> 	loopnz	S10			; WAIT FOR COMMAND TO BE ACCEPTED
  3994                              <1> 
  3995 000016A6 6658                <1> 	pop	ax			; GET DATA TO SEND
  3996 000016A8 E664                <1> 	out	STATUS_PORT, al		; SEND TO KEYBOARD CONTROLLER
  3997 000016AA FB                  <1> 	sti				; ENABLE INTERRUPTS AGAIN
  3998 000016AB C3                  <1> 	retn				; RETURN TO CALLER
  3999                              <1> 
  4000                              <1> SND_DATA:
  4001                              <1> 	; ---------------------------------------------------------------------------------
  4002                              <1> 	; SND_DATA
  4003                              <1> 	;	THIS ROUTINES HANDLES TRANSMISSION OF COMMAND AND DATA BYTES
  4004                              <1> 	;	TO THE KEYBOARD AND RECEIPT OF ACKNOWLEDGEMENTS. IT ALSO
  4005                              <1> 	;	HANDLES ANY RETRIES IF REQUIRED
  4006                              <1> 	; ---------------------------------------------------------------------------------
  4007                              <1> 	;
  4008 000016AC 6650                <1> 	push	ax			; SAVE REGISTERS
  4009 000016AE 6653                <1> 	push	bx
  4010 000016B0 51                  <1> 	push	ecx
  4011 000016B1 88C7                <1> 	mov	bh, al			; SAVE TRANSMITTED BYTE FOR RETRIES
  4012 000016B3 B303                <1> 	mov	bl, 3			; LOAD RETRY COUNT
  4013                              <1> SD0:
  4014 000016B5 FA                  <1> 	cli				; DISABLE INTERRUPTS
  4015 000016B6 8025[A76F0000]CF    <1> 	and	byte [KB_FLAG_2], ~(KB_FE+KB_FA) ; CLEAR ACK AND RESEND FLAGS
  4016                              <1> 	;
  4017                              <1> 	;-----	WAIT FOR COMMAND TO BE ACCEPTED
  4018 000016BD B900000100          <1> 	mov	ecx, 10000h		; MAXIMUM WAIT COUNT
  4019                              <1> SD5:
  4020 000016C2 E464                <1> 	in	al, STATUS_PORT		; READ KEYBOARD PROCESSOR STATUS PORT
  4021 000016C4 A802                <1> 	test	al, INPT_BUF_FULL	; CHECK FOR ANY PENDING COMMAND
  4022 000016C6 E0FA                <1> 	loopnz	SD5			; WAIT FOR COMMAND TO BE ACCEPTED
  4023                              <1> 	;
  4024 000016C8 88F8                <1> 	mov	al, bh			; REESTABLISH BYTE TO TRANSMIT
  4025 000016CA E660                <1> 	out	PORT_A, al		; SEND BYTE
  4026 000016CC FB                  <1> 	sti				; ENABLE INTERRUPTS
  4027                              <1> 	;mov	cx, 01A00h		; LOAD COUNT FOR 10 ms+
  4028 000016CD B9FFFF0000          <1> 	mov	ecx, 0FFFFh
  4029                              <1> SD1:
  4030 000016D2 F605[A76F0000]30    <1> 	test	byte [KB_FLAG_2], KB_FE+KB_FA ; SEE IF EITHER BIT SET
  4031 000016D9 750F                <1> 	jnz	short SD3		; IF SET, SOMETHING RECEIVED GO PROCESS
  4032 000016DB E2F5                <1> 	loop	SD1			; OTHERWISE WAIT
  4033                              <1> SD2:
  4034 000016DD FECB                <1> 	dec	bl			; DECREMENT RETRY COUNT
  4035 000016DF 75D4                <1> 	jnz	short SD0		; RETRY TRANSMISSION
  4036 000016E1 800D[A76F0000]80    <1> 	or	byte [KB_FLAG_2], KB_ERR ; TURN ON TRANSMIT ERROR FLAG
  4037 000016E8 EB09                <1> 	jmp	short SD4		; RETRIES EXHAUSTED FORGET TRANSMISSION
  4038                              <1> SD3:
  4039 000016EA F605[A76F0000]10    <1> 	test	byte [KB_FLAG_2], KB_FA ; SEE IF THIS IS AN ACKNOWLEDGE
  4040 000016F1 74EA                <1> 	jz	short SD2		; IF NOT, GO RESEND
  4041                              <1> SD4:	
  4042 000016F3 59                  <1> 	pop	ecx			; RESTORE REGISTERS
  4043 000016F4 665B                <1> 	pop	bx
  4044 000016F6 6658                <1> 	pop	ax
  4045 000016F8 C3                  <1> 	retn				; RETURN, GOOD TRANSMISSION
  4046                              <1> 
  4047                              <1> SND_LED:
  4048                              <1> 	; ---------------------------------------------------------------------------------
  4049                              <1> 	; SND_LED
  4050                              <1> 	;	THIS ROUTINES TURNS ON THE MODE INDICATORS.
  4051                              <1> 	;
  4052                              <1> 	;----------------------------------------------------------------------------------
  4053                              <1> 	;
  4054 000016F9 FA                  <1> 	cli				; TURN OFF INTERRUPTS
  4055 000016FA F605[A76F0000]40    <1> 	test	byte [KB_FLAG_2], KB_PR_LED ; CHECK FOR MODE INDICATOR UPDATE
  4056 00001701 755F                <1> 	jnz 	short SL1		; DON'T UPDATE AGAIN IF UPDATE UNDERWAY
  4057                              <1> 	;
  4058 00001703 800D[A76F0000]40    <1> 	or	byte [KB_FLAG_2], KB_PR_LED ; TURN ON UPDATE IN PROCESS
  4059 0000170A B020                <1> 	mov	al, EOI			; END OF INTERRUPT COMMAND
  4060 0000170C E620                <1> 	out	20h, al ;out INTA00, al	; SEND COMMAND TO INTERRUPT CONTROL PORT
  4061 0000170E EB11                <1> 	jmp	short SL0		; GO SEND MODE INDICATOR COMMAND
  4062                              <1> SND_LED1:
  4063 00001710 FA                  <1> 	cli				; TURN OFF INTERRUPTS
  4064 00001711 F605[A76F0000]40    <1> 	test	byte [KB_FLAG_2], KB_PR_LED ; CHECK FOR MODE INDICATOR UPDATE
  4065 00001718 7548                <1> 	jnz	short SL1		; DON'T UPDATE AGAIN IF UPDATE UNDERWAY
  4066                              <1> 	;
  4067 0000171A 800D[A76F0000]40    <1> 	or	byte [KB_FLAG_2], KB_PR_LED ; TURN ON UPDATE IN PROCESS
  4068                              <1> SL0:
  4069 00001721 B0ED                <1> 	mov	al, LED_CMD		; LED CMD BYTE
  4070 00001723 E884FFFFFF          <1> 	call	SND_DATA		; SEND DATA TO KEYBOARD
  4071 00001728 FA                  <1> 	cli
  4072 00001729 E836000000          <1> 	call	MAKE_LED		; GO FORM INDICATOR DATA BYTE
  4073 0000172E 8025[A76F0000]F8    <1> 	and	byte [KB_FLAG_2], 0F8h	; ~KB_LEDS ; CLEAR MODE INDICATOR BITS
  4074 00001735 0805[A76F0000]      <1> 	or	[KB_FLAG_2], al 	; SAVE PRESENT INDICATORS FOR NEXT TIME
  4075 0000173B F605[A76F0000]80    <1> 	test	byte [KB_FLAG_2], KB_ERR ; TRANSMIT ERROR DETECTED
  4076 00001742 750F                <1> 	jnz	short SL2		; IF SO, BYPASS SECOND BYTE TRANSMISSION
  4077                              <1> 	;
  4078 00001744 E863FFFFFF          <1> 	call	SND_DATA		; SEND DATA TO KEYBOARD
  4079 00001749 FA                  <1> 	cli				; TURN OFF INTERRUPTS
  4080 0000174A F605[A76F0000]80    <1> 	test	byte [KB_FLAG_2], KB_ERR ; TRANSMIT ERROR DETECTED
  4081 00001751 7408                <1> 	jz	short SL3		; IF NOT, DON'T SEND AN ENABLE COMMAND
  4082                              <1> SL2:
  4083 00001753 B0F4                <1> 	mov	al, KB_ENABLE		; GET KEYBOARD CSA ENABLE COMMAND
  4084 00001755 E852FFFFFF          <1> 	call	SND_DATA		; SEND DATA TO KEYBOARD
  4085 0000175A FA                  <1> 	cli				; TURN OFF INTERRUPTS
  4086                              <1> SL3:
  4087 0000175B 8025[A76F0000]3F    <1> 	and	byte [KB_FLAG_2], ~(KB_PR_LED+KB_ERR) ; TURN OFF MODE INDICATOR
  4088                              <1> SL1:					; UPDATE AND TRANSMIT ERROR FLAG
  4089 00001762 FB                  <1> 	sti				; ENABLE INTERRUPTS
  4090 00001763 C3                  <1> 	retn				; RETURN TO CALLER
  4091                              <1> 
  4092                              <1> MAKE_LED:
  4093                              <1> 	;---------------------------------------------------------------------------------
  4094                              <1> 	; MAKE_LED
  4095                              <1> 	;	THIS ROUTINES FORMS THE DATA BYTE NECESSARY TO TURN ON/OFF
  4096                              <1> 	;	THE MODE INDICATORS.
  4097                              <1> 	;---------------------------------------------------------------------------------
  4098                              <1> 	;
  4099                              <1> 	;push 	cx			; SAVE CX
  4100 00001764 A0[A56F0000]        <1> 	mov	al, [KB_FLAG]		; GET CAPS & NUM LOCK INDICATORS
  4101 00001769 2470                <1> 	and	al, CAPS_STATE+NUM_STATE+SCROLL_STATE ; ISOLATE INDICATORS
  4102                              <1> 	;mov	cl, 4			; SHIFT COUNT
  4103                              <1> 	;rol	al, cl			; SHIFT BITS OVER TO TURN ON INDICATORS
  4104 0000176B C0C004              <1> 	rol	al, 4 ; 20/02/2015
  4105 0000176E 2407                <1> 	and	al, 07h			; MAKE SURE ONLY MODE BITS ON
  4106                              <1> 	;pop	cx
  4107 00001770 C3                  <1> 	retn				; RETURN TO CALLER
  4108                              <1> 
  4109                              <1> ; % include 'kybdata.s'   ; KEYBOARD DATA
  4110                              <1> 
  4111                              <1> 
  4112                              <1> ; /// End Of KEYBOARD FUNCTIONS ///
  2661                                  
  2662                                  %include 'video.s' ; 07/03/2015
  2663                              <1> ; ****************************************************************************
  2664                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.3 - video.s
  2665                              <1> ; ----------------------------------------------------------------------------
  2666                              <1> ; Last Update: 07/03/2021
  2667                              <1> ; ----------------------------------------------------------------------------
  2668                              <1> ; Beginning: 16/01/2016
  2669                              <1> ; ----------------------------------------------------------------------------
  2670                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
  2671                              <1> ; ----------------------------------------------------------------------------
  2672                              <1> ; Turkish Rational DOS
  2673                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
  2674                              <1> ;
  2675                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
  2676                              <1> ; video.inc (13/08/2015)
  2677                              <1> ;
  2678                              <1> ; Derived from 'IBM PC-AT' BIOS source code (1985) 
  2679                              <1> ; ****************************************************************************
  2680                              <1> 
  2681                              <1> ; Retro UNIX 386 v1 Kernel - VIDEO.INC
  2682                              <1> ; Last Modification: 13/08/2015
  2683                              <1> ;		  (Video Data is in 'VIDATA.INC')
  2684                              <1> ;
  2685                              <1> ; ///////// VIDEO (CGA) FUNCTIONS ///////////////
  2686                              <1> 
  2687                              <1> ; 16/01/2016 (32 bit modifications, TRDOS386 - TRDOS v2.0, video.s)
  2688                              <1> ; INT 31H (TRDOS 386) = INT 10H (IBM PC/AT REAL MODE)
  2689                              <1> 
  2690                              <1> ; IBM PC-AT BIOS Source Code
  2691                              <1> ; TITLE VIDEO1 --- 06/10/85 VIDEO DISPLAY BIOS
  2692                              <1> 
  2693                              <1> _int10h:
  2694                              <1> 	; 23/03/2016
  2695                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  2696 00001771 9C                  <1> 	pushfd
  2697 00001772 0E                  <1> 	push	cs
  2698 00001773 E851000000          <1> 	call	VIDEO_IO_1
  2699 00001778 C3                  <1> 	retn
  2700                              <1> 
  2701                              <1> ;--- INT 10 H -------------------------------------------------------------------
  2702                              <1> ; VIDEO_IO									:
  2703                              <1> ;	THESE ROUTINES PROVIDE THE CRT DISPLAY INTERFACE			:
  2704                              <1> ;	THE FOLLOWING FUNCTIONS ARE PROVIDED:					:
  2705                              <1> ;										:
  2706                              <1> ;    (AH)= 00H	SET MODE (AL) CONTAINS MODE VALUE				:
  2707                              <1> ;		(AL) = 00H  40X25 BW MODE (POWER ON DEFAULT)			:
  2708                              <1> ;		(AL) = 01H  40X25 COLOR						:
  2709                              <1> ;		(AL) = 02H  80X25 BW						:
  2710                              <1> ;		(AL) = 03H  80X25 COLOR						:
  2711                              <1> ;		              GRAPHICS MODES					:
  2712                              <1> ;		(AL) = 04H  320X200 COLOR					:
  2713                              <1> ;		(AL) = 05H  320X200 BW MODE					:
  2714                              <1> ;		(AL) = 06H  640X200 BW MODE					:
  2715                              <1> ;		(AL) = 07H   80X25 MONOCHROME (USED INTERNAL TO VIDEO ONLY)	:
  2716                              <1> ;		*** NOTES -BW MODES OPERATE SAME AS COLOR MODES, BUT COLOR	:
  2717                              <1> ;		           BURST IS NOT ENABLED					:
  2718                              <1> ;		          -CURSOR IS NOT DISPLAYED IN GRAPHICS MODE		:
  2719                              <1> ;    (AH)= 01H	SET CURSOR TYPE							:
  2720                              <1> ;		(CH) = BITS 4-0 = START LINE FOR CURSOR				:
  2721                              <1> ;		       ** HARDWARE WILL ALWAYS CAUSE BLINK			:
  2722                              <1> ;		       ** SETTING BIT 5 OR 6 WILL CAUSE ERRATIC BLINKING	:
  2723                              <1> ;		          OR NO CURSOR AT ALL					:
  2724                              <1> ;		(CL) = BITS 4-0 = END LINE FOR CURSOR				:
  2725                              <1> ;    (AH)= 02H	SET CURSOR POSITION						:
  2726                              <1> ;		(DH,DL) = ROW,COLUMN  (00H,00H) IS UPPER LEFT			:
  2727                              <1> ;		(BH) = A PAGE NUMBER (MUST BE 00H FOR GRAPHICS MODES)		:
  2728                              <1> ;    (AH)= 03H	READ CURSOR POSITION						:
  2729                              <1> ;		(BH) = PAGE NUMBER (MUST BE 00H FOR GRAPHICS MODES)		:
  2730                              <1> ;		ON EXIT (DH,DL) = ROW,COLUMN OF CURRENT CURSOR			:
  2731                              <1> ;		        (CH,CL) = CURSOR MODE CURRENTLY SET			:
  2732                              <1> ;    (AH)= 04H	READ LIGHT PEN POSITION						:
  2733                              <1> ;		ON EXIT:							:
  2734                              <1> ;		(AH) = 00H -- LIGHT PEN SWITCH NOT DOWN/NOT TRIGGERED		:
  2735                              <1> ;		(AH) = 01H -- VALID LIGHT PEN VALUE IN REGISTERS		:
  2736                              <1> ;		        (DH,DL) = ROW,COLUMN OF CHARACTER LP POSITION		:
  2737                              <1> ;		        (CH) = RASTER LINE (0-199)				:
  2738                              <1> ;		        (BX) = PIXEL COLUMN (0-319,639)				:
  2739                              <1> ;    (AH)= 05H	SELECT ACTIVE DISPLAY PAGE (VALID ONLY FOR ALPHA MODES)		:
  2740                              <1> ;		(AL) = NEW PAGE VALUE (0-7 FOR MODES 0&1, 0-3 FOR MODES 2&3)	:
  2741                              <1> ;    (AH)= 06H	SCROLL ACTIVE PAGE UP						:
  2742                              <1> ;		(AL) = NUMBER OF LINES. ( LINES BLANKED AT BOTTOM OF WINDOW )	:
  2743                              <1> ;		        (AL) = 00H MEANS BLANK ENTIRE WINDOW			:
  2744                              <1> ;		(CH,CL) = ROW,COLUMN OF UPPER LEFT CORNER OF SCROLL		:
  2745                              <1> ;		(DH,DL) = ROW,COLUMN OF LOWER RIGHT CORNER OF SCROLL		:
  2746                              <1> ;		(BH) = ATTRIBUTE TO BE USED ON BLANK LINE			:
  2747                              <1> ;    (AH)= 07H	SCROLL ACTIVE PAGE DOWN						:
  2748                              <1> ;		(AL) = NUMBER OF LINES, INPUT LINES BLANKED AT TOP OF WINDOW	:
  2749                              <1> ;		        (AL) = 00H MEANS BLANK ENTIRE WINDOW			:
  2750                              <1> ;		(CH,CL) = ROW,COLUMN OF UPPER LEFT CORNER OF SCROLL		:
  2751                              <1> ;		(DH,DL) = ROW,COLUMN OF LOWER RIGHT CORNER OF SCROLL		:
  2752                              <1> ;		(BH) = ATTRIBUTE TO BE USED ON BLANK LINE			:
  2753                              <1> ;										:
  2754                              <1> ;   CHARACTER HANDLING ROUTINES							:
  2755                              <1> ;										:
  2756                              <1> ;    (AH)= 08H	READ ATTRIBUTE/CHARACTER AT CURRENT CURSOR POSITION		:
  2757                              <1> ;		(BH) = DISPLAY PAGE (VALID FOR ALPHA MODES ONLY)		:
  2758                              <1> ;		ON EXIT:							:
  2759                              <1> ;		(AL) = CHAR READ						:
  2760                              <1> ;		(AH) = ATTRIBUTE OF CHARACTER READ (ALPHA MODES ONLY)		:
  2761                              <1> ;    (AH)= 09H	WRITE ATTRIBUTE/CHARACTER AT CURRENT CURSOR POSITION		:
  2762                              <1> ;		(BH) = DISPLAY PAGE (VALID FOR ALPHA MODES ONLY)		:
  2763                              <1> ;		(CX) = COUNT OF CHARACTERS TO WRITE				:
  2764                              <1> ;		(AL) = CHAR TO WRITE						:
  2765                              <1> ;		(BL) = ATTRIBUTE OF CHARACTER (ALPHA)/COLOR OF CHAR (GRAPHICS)	:
  2766                              <1> ;		         SEE NOTE ON WRITE DOT FOR BIT 7 OF BL = 1.		:
  2767                              <1> ;    (AH) = 0AH	WRITE CHARACTER ONLY AT CURRENT CURSOR POSITION			:
  2768                              <1> ;		(BH) = DISPLAY PAGE (VALID FOR ALPHA MODES ONLY)		:
  2769                              <1> ;		(CX) = COUNT OF CHARACTERS TO WRITE				:
  2770                              <1> ;		(AL) = CHAR TO WRITE						:
  2771                              <1> ;		       NOTE: USE FUNCTION (AH)= 09H IN GRAPHICS MODES		:
  2772                              <1> ;	FOR READ/WRITE CHARACTER INTERFACE WHILE IN GRAPHICS MODE, THE		:
  2773                              <1> ;		CHARACTERS ARE FORMED FROM A CHARACTER GENERATOR IMAGE		:
  2774                              <1> ;		MAINTAINED IN THE SYSTEM ROM. ONLY THE 1ST 128 CHARS		:
  2775                              <1> ;		ARE CONTAINED THERE. TO READ/WRITE THE SECOND 128 CHARS,	:
  2776                              <1> ;		THE USER MUST INITIALIZE THE POINTER AT INTERRUPT 1FH		:
  2777                              <1> ;		(LOCATION 0007CH) TO POINT TO THE 1K BYTE TABLE CONTAINING	:
  2778                              <1> ;		THE CODE POINTS FOR THE SECOND 128 CHARS (128-255).		:
  2779                              <1> ;	FOR WRITE CHARACTER INTERFACE IN GRAPHICS MODE, THE REPLICATION FACTOR	:
  2780                              <1> ;		CONTAINED IN (CX) ON ENTRY WILL PRODUCE VALID RESULTS ONLY	:
  2781                              <1> ;		FOR CHARACTERS CONTAINED ON THE SAME ROW. CONTINUATION TO	:
  2782                              <1> ;		SUCCEEDING LINES WILL NOT PRODUCE CORRECTLY.			:
  2783                              <1> ;										:
  2784                              <1> ;    GRAPHICS INTERFACE								:
  2785                              <1> ;    (AH)= 0BH	SET COLOR PALETTE						:
  2786                              <1> ;		(BH) = PALETTE COLOR ID BEING SET (0-127)			:
  2787                              <1> ;		(BL) = COLOR VALUE TO BE USED WITH THAT COLOR ID		:
  2788                              <1> ;		       NOTE: FOR THE CURRENT COLOR CARD, THIS ENTRY POINT HAS	:
  2789                              <1> ;		               MEANING ONLY FOR 320X200 GRAPHICS.		:
  2790                              <1> ;		       COLOR ID = 0 SELECTS THE BACKGROUND COLOR (0-15)		:
  2791                              <1> ;		       COLOR ID = 1 SELECTS THE PALETTE TO BE USED:		:
  2792                              <1> ;		               0 = GREEN(1)/RED(2)/YELLOW(3)			:
  2793                              <1> ;		               1 = CYAN(1)/MAGENTA(2)/WHITE(3)			:
  2794                              <1> ;		       IN 40X25 OR 80X25 ALPHA MODES, THE VALUE SET FOR 	:
  2795                              <1> ;		               PALETTE COLOR 0 INDICATES THE BORDER COLOR	:
  2796                              <1> ;		               TO BE USED (VALUES 0-31, WHERE 16-31 SELECT	:
  2797                              <1> ;		               THE HIGH INTENSITY BACKGROUND SET.		:
  2798                              <1> ;    (AH)= 0CH	WRITE DOT							:
  2799                              <1> ;		(DX) = ROW NUMBER						:
  2800                              <1> ;		(CX) = COLUMN NUMBER						:
  2801                              <1> ;		(AL) = COLOR VALUE						:
  2802                              <1> ;		        IF BIT 7 OF AL = 1, THEN THE COLOR VALUE IS EXCLUSIVE	:
  2803                              <1> ;		        ORed WITH THE CURRENT CONTENTS OF THE DOT		:
  2804                              <1> ;    (AH)= ODH	READ DOT							:
  2805                              <1> ;		(DX) = ROW NUMBER						:
  2806                              <1> ;		(CX) = COLUMN NUMBER						:
  2807                              <1> ;		(AL) = RETURNS THE DOT READ					:
  2808                              <1> ;										:
  2809                              <1> ;    ASCII TELETYPE ROUTINE FOR OUTPUT						:
  2810                              <1> ;										:
  2811                              <1> ;    (AH)= 0EH	WRITE TELETYPE TO ACTIVE PAGE					:
  2812                              <1> ;		(AL) = CHAR TO WRITE						:
  2813                              <1> ;		(BL) = FOREGROUND COLOR IN GRAPHICS MODE			:
  2814                              <1> ;		NOTE -- SCREEN WIDTH IS CONTROLLED BY PREVIOUS MODE SET		:
  2815                              <1> ;    (AH)= 0FH	CURRENT VIDEO STATE						:
  2816                              <1> ;		RETURNS THE CURRENT VIDEO STATE					:
  2817                              <1> ;		(AL) = MODE CURRENTLY SET ( SEE (AH)=00H FOR EXPLANATION)	:
  2818                              <1> ;		(AH) = NUMBER OR CHARACTER COLUMNS ON SCREEN			:
  2819                              <1> ;		(BH) = CURRENT ACTIVE DISPLAY PAGE				:
  2820                              <1> ;    (AH)= 10H	RESERVED							:
  2821                              <1> ;    (AH)= 11H	RESERVED							:
  2822                              <1> ;    (AH)= 12H	RESERVED							:
  2823                              <1> ;    (AH)= 13H	WRITE STRING							:
  2824                              <1> ;			ES:BP  -  POINTER T0 STRING TO BE WRITTEN		:
  2825                              <1> ;			CX     -  LENGTH OF CHARACTER STRING TO WRITTEN		:
  2826                              <1> ;			DX     -  CURSOR POSITION FOR STRING TO BE WRITTEN	:
  2827                              <1> ;			BH     -  PAGE NUMBER					:
  2828                              <1> ;		(AL)= 00H	WRITE CHARACTER STRING				:
  2829                              <1> ;			BL     -  ATTRIBUTE					:
  2830                              <1> ;			STRING IS  <CHAR,CHAR, ... ,CHAR>			:
  2831                              <1> ;			CURSOR NOT MOVED					:
  2832                              <1> ;		(AL)= 01H	WRITE CHARACTER STRING AND MOVE CURSOR		:
  2833                              <1> ;			BL     -  ATTRIBUTE					:
  2834                              <1> ;			STRING IS  <CHAR,CHAR, ... ,CHAR>			:
  2835                              <1> ;			CURSOR MOVED						:
  2836                              <1> ;		(AL)= 02H	WRITE CHARACTER AND ATTRIBUTE STRING		:
  2837                              <1> ;			       (VALID FOR ALPHA MODES ONLY)			:
  2838                              <1> ;			STRING IS <CHAR,ATTR,CHAR,ATTR ..  ,CHAR,ATTR>		:
  2839                              <1> ;			CURSOR IS NOT MOVED					:
  2840                              <1> ;		(AL)= 03H WRITE CHARACTER AND ATTRIBUTE STRING AND MOVE CURSOR	:
  2841                              <1> ;			       (VALID FOR ALPHA MODES ONLY)			:
  2842                              <1> ;			STRING IS <CHAR,ATTR,CHAR,ATTR ..  ,CHAR,ATTR>		:
  2843                              <1> ;			CURSOR IS MOVED						:
  2844                              <1> ;		 NOTE:  CARRIAGE RETURN, LINE FEED, BACKSPACE, AND BELL ARE	:
  2845                              <1> ;		        TREATED AS COMMANDS RATHER THAN PRINTABLE CHARACTERS.	:
  2846                              <1> ;										:
  2847                              <1> ;	BX,CX,DX,SI,DI,BP,SP,DS,ES,SS PRESERVED DURING CALLS EXCEPT FOR		:
  2848                              <1> ;	BX,CX,DX RETURN VALUES ON FUNCTIONS 03H,04H,0DH AND 0FH. ON ALL CALLS	:
  2849                              <1> ;	AX IS MODIFIED.								:
  2850                              <1> ;--------------------------------------------------------------------------------
  2851                              <1> 
  2852 00001779 [2A1B0000]          <1> M1:	dd	SET_MODE	; TABLE OF ROUTINES WITHIN VIDEO I/O
  2853 0000177D [F71E0000]          <1> 	dd	SET_CTYPE
  2854 00001781 [2B1F0000]          <1> 	dd	SET_CPOS
  2855 00001785 [531F0000]          <1> 	dd	READ_CURSOR
  2856                              <1> 	;dd	VIDEO_RETURN	; READ_LPEN
  2857 00001789 [281B0000]          <1> 	dd	set_mode_ncm	; Set mode without clearing video memory
  2858 0000178D [991F0000]          <1> 	dd	ACT_DISP_PAGE
  2859 00001791 [2B200000]          <1> 	dd	SCROLL_UP
  2860 00001795 [55210000]          <1> 	dd	SCROLL_DOWN
  2861 00001799 [D5210000]          <1> 	dd	READ_AC_CURRENT
  2862 0000179D [32220000]          <1> 	dd	WRITE_AC_CURRENT
  2863 000017A1 [58220000]          <1> 	dd	WRITE_C_CURRENT
  2864 000017A5 [9D2B0000]          <1> 	dd	SET_COLOR
  2865 000017A9 [082C0000]          <1> 	dd	WRITE_DOT
  2866 000017AD [D32B0000]          <1> 	dd	READ_DOT
  2867 000017B1 [E8220000]          <1> 	dd	WRITE_TTY
  2868 000017B5 [101B0000]          <1> 	dd	VIDEO_STATE
  2869 000017B9 [9C360000]          <1> 	dd	vga_pal_funcs	; 10/08/2016 (TRDOS 386)
  2870 000017BD [15310000]          <1> 	dd	font_setup	; 10/07/2016 (TRDOS 386)
  2871 000017C1 [5F1B0000]          <1> 	dd	VIDEO_RETURN	; RESERVED
  2872 000017C5 [63240000]          <1> 	dd	WRITE_STRING	; 23/06/2016 (TRDOS 386)
  2873                              <1> M1L	EQU	$ - M1
  2874                              <1> 
  2875                              <1> ; 06/12/2020
  2876                              <1> ; 05/12/2020
  2877                              <1> ; 03/12/2020
  2878                              <1> ; 27/11/2020 - TRDOS 386 v2.0.3
  2879                              <1> ; 14/01/2017
  2880                              <1> ; 02/01/2017
  2881                              <1> ; 04/07/2016
  2882                              <1> ; 12/05/2016
  2883                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  2884                              <1> int31h:  ; Video BIOS
  2885                              <1> 
  2886                              <1> ; BH = Video page number
  2887                              <1> ; BL = Color/Attribute
  2888                              <1> ; AH = Function number
  2889                              <1> ; AL = Character
  2890                              <1> 
  2891                              <1> VIDEO_IO_1:
  2892                              <1> 	;sti				; INTERRUPTS BACK ON
  2893 000017C9 FC                  <1> 	cld				; SET DIRECTION FORWARD
  2894                              <1> 	
  2895                              <1> 	;cmp	ah, M1L/4		; TEST FOR WITHIN TABLE RANGE
  2896                              <1> 	;jnb	short M4		; BRANCH TO EXIT IF NOT A VALID COMMAND
  2897                              <1> 
  2898                              <1> 	; 26/11/2020
  2899 000017CA 80FC14              <1> 	cmp	ah, M1L/4
  2900 000017CD 7205                <1> 	jb	short VGA_func
  2901                              <1> 
  2902 000017CF 80FC4F              <1> 	cmp	ah, 4Fh
  2903 000017D2 7532                <1> 	jne	short M4 ; invalid !
  2904                              <1> 
  2905                              <1> VGA_func: ; 26/11/2020
  2906 000017D4 06                  <1> 	push	es ; *
  2907 000017D5 1E                  <1> 	push	ds ; **			; SAVE WORK AND PARAMETER REGISTERS
  2908                              <1> 
  2909                              <1> 	; 26/11/2020
  2910 000017D6 50                  <1> 	push	eax ; -
  2911                              <1> 	
  2912 000017D7 66B81000            <1> 	mov	ax, KDATA 		; POINT DS: TO DATA SEGMENT
  2913 000017DB 8ED8                <1> 	mov	ds, ax
  2914 000017DD 8EC0                <1> 	mov	es, ax
  2915                              <1> 
  2916                              <1> 	; 26/11/2020
  2917 000017DF 58                  <1> 	pop	eax ; +
  2918                              <1> 	;
  2919 000017E0 FB                  <1> 	sti
  2920 000017E1 80FC4F              <1> 	cmp	ah, 4Fh
  2921 000017E4 747A                <1> 	je	short VBE_func
  2922                              <1> 
  2923                              <1> 	; 04/12/2020
  2924 000017E6 A3[B8960100]        <1> 	mov	[video_eax], eax
  2925                              <1> 
  2926                              <1> 	; 21/12/2020
  2927 000017EB 803D[DA6F0000]FF    <1> 	cmp	byte [CRT_MODE], 0FFh	; Current mode is a VESA VBE mode ?
  2928 000017F2 7213                <1> 	jb	short VGA_func_std
  2929                              <1> 
  2930 000017F4 08E4                <1> 	or	ah, ah			; set mode ?
  2931 000017F6 750F                <1> 	jnz	short VGA_func_std	; no
  2932                              <1> 
  2933 000017F8 803D[5C090000]03    <1> 	cmp	byte [vbe3], 3		; (real) VESA VBE 3 video bios ?
  2934 000017FF 7506                <1> 	jne	short VGA_func_std	; no
  2935                              <1> 
  2936 00001801 E989010000          <1> 	jmp	vesa_vbe3_pmi
  2937                              <1> 
  2938                              <1> 	; 21/12/2020
  2939                              <1> M4:					; COMMAND NOT VALID
  2940 00001806 CF                  <1> 	iretd				; DO NOTHING IF NOT IN VALID RANGE
  2941                              <1> 
  2942                              <1> VGA_func_std:
  2943                              <1> 	; 06/12/2020
  2944                              <1> 	; 03/12/2020
  2945 00001807 80FC0F              <1> 	cmp	ah, 0Fh
  2946 0000180A 773D                <1> 	ja	short VGA_funcs_0	; only CGA funcs will be handled by	
  2947                              <1> 	; 06/12/2020			; vga bios firmware
  2948                              <1> 	; 03/12/2020			
  2949                              <1> 	;test	ah, 7Fh ; set mode ?
  2950                              <1> 	;;or	ah, ah			; only 'set mode' will be handled by
  2951                              <1> 	;jnz	short VGA_funcs_0	; vga bios firmware	
  2952                              <1> 	;jz	short vbe_pmi32_0
  2953                              <1> 
  2954                              <1> 	; 28/11/2020
  2955 0000180C 803D[1C120300]00    <1> 	cmp	byte [pmi32], 0		; 32 bit protected mode interface for
  2956 00001813 7634                <1> 	jna	short VGA_funcs_0	; video hardware's vga bios firmware
  2957                              <1> 					; ([pmi32] > 0 if it is activated)
  2958                              <1> 					; note:
  2959                              <1> 					; [vbe3] = 3 is required to activate
  2960                              <1> 	; 07/12/2020
  2961 00001815 20E4                <1> 	and	ah, ah ; is this set mode ?
  2962 00001817 7413                <1> 	jz	short vbe_pmi32_2 ; yes
  2963                              <1> 
  2964 00001819 80FC04              <1> 	cmp	ah, 04h	 ; set mode ('no clear memory' option)
  2965 0000181C 742B                <1> 	je	short VGA_funcs_0
  2966                              <1> 
  2967                              <1> 	; 07/12/2020
  2968 0000181E 803D[DA6F0000]07    <1> 	cmp	byte [CRT_MODE], 7 ; current mode > 7 ?
  2969 00001825 7622                <1> 	jna	short VGA_funcs_0  ; no	
  2970                              <1> 
  2971                              <1> 	; when mode 3 is active, 
  2972                              <1> 	; video bios functions are not redirected
  2973                              <1> 	; to VESA VBE3 PMI except 'set mode' function
  2974                              <1> 
  2975                              <1> vbe_pmi32_0:
  2976                              <1> 	; 06/12/2020
  2977                              <1> 	;or	ah, ah
  2978                              <1> 	;jnz	short vbe_pmi32_2
  2979                              <1> 	; ah = 0 ; 'set mode'
  2980                              <1> 	;cmp	al, 3 ; 80x25 text mode, 16 colors, default mode for MainProg
  2981                              <1> 	;jne	short vbe_pmi32_1
  2982                              <1> 	;cmp	byte [CRT_MODE], 3 ; If current video mode <> 3 and requested
  2983                              <1> 	;			; video mode is 3, use internal 'set mode';
  2984                              <1> 	;			; otherwise, use vesa vbe 3 bios's 'set mode'.
  2985                              <1> 	;jne	short VGA_funcs_0
  2986                              <1> vbe_pmi32_1:
  2987 00001827 E963010000          <1> 	jmp	vesa_vbe3_pmi
  2988                              <1> ;vbe_pmi32_2:
  2989                              <1> 	;cmp	ah, 04h ; set mode (no clear mem option)
  2990                              <1> 	;jne	short vbe_pmi32_1
  2991                              <1> 
  2992                              <1> vbe_pmi32_2:
  2993                              <1> 	; 07/12/2020
  2994 0000182C 803D[DA6F0000]07    <1> 	cmp	byte [CRT_MODE], 7 ; current mode > 7 ?
  2995 00001833 77F2                <1> 	ja	short vbe_pmi32_1  ; yes
  2996                              <1> 
  2997 00001835 3C07                <1> 	cmp	al, 7	; requested mode > 7 ?
  2998 00001837 7610                <1> 	jna	short VGA_funcs_0  ; no (CGA)
  2999                              <1> 
  3000 00001839 3C13                <1> 	cmp	al, 13h
  3001 0000183B 76EA                <1> 	jna	short vbe_pmi32_1
  3002                              <1> 
  3003 0000183D A880                <1> 	test	al, 80h
  3004 0000183F 7408                <1> 	jz	short VGA_funcs_0  ; unknown or special
  3005                              <1> 
  3006 00001841 3C87                <1> 	cmp	al, 87h	; requested mode > 7 ? 
  3007                              <1> 			; (with no clear mem ops)
  3008 00001843 7604                <1> 	jna	short VGA_funcs_0  ; no (CGA)
  3009                              <1> 
  3010 00001845 3C93                <1> 	cmp	al, 93h
  3011 00001847 76DE                <1> 	jna	short vbe_pmi32_1
  3012                              <1> 
  3013                              <1> 	; > 13h video modes are unknown or special
  3014                              <1>  	; they must be handled by kernel	
  3015                              <1> 
  3016                              <1> 	; CGA video modes will be handled by kernel
  3017                              <1> 
  3018                              <1> VGA_funcs_0:
  3019 00001849 52                  <1> 	push	edx ; ***
  3020 0000184A 51                  <1> 	push	ecx ; ****
  3021 0000184B 53                  <1> 	push	ebx ; *****
  3022 0000184C 56                  <1> 	push	esi ; ******
  3023 0000184D 57                  <1> 	push	edi ; *******
  3024 0000184E 55                  <1> 	push	ebp ; ********
  3025                              <1> 
  3026                              <1> 	;mov	[video_eax], eax ; 12/05/2016 
  3027 0000184F BF00800B00          <1> 	mov	edi, 0B8000h		; GET offset FOR COLOR CARD
  3028                              <1> 
  3029                              <1> 	; 23/03/2016
  3030 00001854 C0E402              <1> 	shl	ah, 2  ; dword		; TIMES 2 FOR WORD TABLE LOOKUP
  3031 00001857 0FB6F4              <1> 	movzx	esi, ah			; MOVE OFFSET INTO LOOK UP REGISTER (SI)
  3032                              <1> 	;mov	ah, [CRT_MODE]		; MOVE CURRENT MODE INTO (AH) REGISTER
  3033                              <1> 
  3034                              <1> 	;;15/01/2017
  3035                              <1> 	; 14/01/2017
  3036                              <1> 	; 02/01/2017
  3037                              <1> 	;;mov	byte [intflg], 31h  ; video interrupt
  3038                              <1> 	;sti ; 26/11/2020
  3039                              <1> 	;
  3040                              <1> 
  3041 0000185A FFA6[79170000]      <1> 	JMP	dword [esi+M1]		; GO TO SELECTED FUNCTION
  3042                              <1> 
  3043                              <1> VBE_func:
  3044                              <1> 	; 26/11/2020
  3045                              <1> 	;sti
  3046 00001860 55                  <1> 	push	ebp ; *** ; 27/11/2020	
  3047 00001861 56                  <1> 	push	esi ; **** 
  3048                              <1> 	
  3049                              <1> 	; Note:
  3050                              <1> 	; ebx, ecx, edx, edi, ebp registers
  3051                              <1> 	; must be saved by VBE functions and
  3052                              <1> 	; eax register must be set
  3053                              <1> 	; (according to VBE 3 standard)
  3054                              <1> 	; before return from this interrupt
  3055                              <1> 	; (every function must restore and set
  3056                              <1> 	; registers except esp, esi, es, ds)
  3057                              <1> 
  3058 00001862 803D[5C090000]02    <1> 	cmp	byte [vbe3], 2
  3059 00001869 7741                <1> 	ja	short VESA_VBE3_PMI_CALL ; VBE3 video bios ('PMID')
  3060                              <1> 	;je	short VBE_func_0  ; Bochs/Qemu/VirtualBox emulator
  3061 0000186B 726A                <1> 	jb	short VBE_unknown ; invalid ([vbe3] = 0)
  3062                              <1> 
  3063                              <1> 	;jmp	VESA_VBE3_PMI_CALL
  3064                              <1> 
  3065                              <1> VBE_func_0:	
  3066                              <1> 	; Bochs/Plex86 VGAbios VBE extension
  3067                              <1> 	; (TRDOS 386 v2.0.3 can use VBE graphics modes on emulators)
  3068                              <1> 	; BOCHS/QEMU/VIRTUALBOX
  3069                              <1>  
  3070 0000186D 8A25[5D090000]      <1> 	mov	ah, [vbe2bios]
  3071 00001873 80FCC0              <1> 	cmp	ah, 0C0h		
  3072 00001876 725F                <1> 	jb	short VBE_unknown 	
  3073 00001878 80FCC5              <1> 	cmp	ah, 0C5h
  3074 0000187B 775A                <1> 	ja	short VBE_unknown
  3075                              <1> 
  3076                              <1> 	; TRDOS 386 is running on BOCHS or QEMU
  3077 0000187D B44F                <1> 	mov	ah, 4Fh
  3078                              <1> VBE_func_1:
  3079 0000187F 0FB6F0              <1> 	movzx	esi, al ; VESA VBE function number
  3080 00001882 66C1E602            <1> 	shl	si, 2 ; dword
  3081 00001886 6683FE14            <1> 	cmp	si, N1L
  3082 0000188A 734B                <1> 	jnb	short VBE_unknown
  3083                              <1> 	;sti
  3084                              <1> 	
  3085 0000188C FF96[98180000]      <1> 	call	dword [esi+N1] ; call VBE function
  3086                              <1> 		
  3087                              <1> 	;jmp	short VBE_bios_return
  3088                              <1> 
  3089                              <1> VBE_bios_return:
  3090 00001892 FA                  <1> 	cli
  3091 00001893 5E                  <1> 	pop	esi ; ****
  3092 00001894 5D                  <1> 	pop	ebp ; *** ; 27/11/2020
  3093 00001895 07                  <1> 	pop	es  ; **
  3094 00001896 1F                  <1> 	pop	ds  ; *
  3095 00001897 CF                  <1> 	iretd
  3096                              <1> 
  3097                              <1> 	; 26/11/2020
  3098                              <1> N1:
  3099 00001898 [FB180000]          <1> 	dd	vbe_biosfn_return_ctrl_info
  3100 0000189C [283A0000]          <1> 	dd	vbe_biosfn_return_mode_info
  3101 000018A0 [E33A0000]          <1> 	dd	vbe_biosfn_set_mode
  3102 000018A4 [B33B0000]          <1> 	dd	vbe_biosfn_return_current_mode
  3103 000018A8 [D23B0000]          <1> 	dd	vbe_biosfn_save_restore_state
  3104                              <1> 	;dd	vbe_biosfn_display_window_ctrl
  3105                              <1> 	;dd	vbe_biosfn_set_get_log_scanline
  3106                              <1> 	;dd	vbe_biosfn_set_get_disp_start
  3107                              <1> 	;dd	vbe_biosfn_set_get_dac_pal_frm
  3108                              <1> 	;dd	vbe_biosfn_set_get_palette_data
  3109                              <1> 	
  3110                              <1> N1L	EQU	$ - N1
  3111                              <1> 
  3112                              <1> 
  3113                              <1> VESA_VBE3_PMI_CALL: ; VESA VBE video bios (firmware) functions
  3114                              <1> 		    ; by using VESA VBE3 Protected Mode Interface
  3115                              <1> 	
  3116                              <1> 	; 29/11/2020
  3117                              <1> 	; 26/11/2020 - TRDOS 386 v2.0.3 video.s
  3118                              <1> 
  3119                              <1> 	; We are here because..
  3120                              <1> 	; 'PMID' has been verified by TRDOS 386 v2.0.3 kernel.
  3121                              <1> 	; (Otherwise bochs/plex86 compatible VBE functions and
  3122                              <1> 	;  modes would be used on BOCHS/QEMU/VIRTUALBOX emulators
  3123                              <1> 	;  or only standard/old VGA graphics modes would be used.)
  3124                              <1> 
  3125                              <1> 	; (TRDOS 386 v2.0.3 can use VESA VBE graphics modes if
  3126                              <1> 	;  the video bios is full compatible with VBE3 standard) 
  3127                              <1> 
  3128                              <1> 	; 29/11/2020
  3129                              <1> 
  3130 000018AC 0FB6F0              <1> 	movzx	esi, al ; VESA VBE 3 function number
  3131 000018AF 66C1E602            <1> 	shl	si, 2 ; dword
  3132 000018B3 6683FE14            <1> 	cmp	si, P1L
  3133 000018B7 731E                <1> 	jnb	short VBE_unknown
  3134                              <1> 	;sti
  3135                              <1> 
  3136 000018B9 57                  <1> 	push	edi ; *****
  3137                              <1> 		
  3138 000018BA FF96[C3180000]      <1> 	call	dword [esi+P1] ; call VBE 3 function
  3139                              <1> 
  3140 000018C0 5F                  <1> 	pop	edi ; *****
  3141                              <1> 		
  3142 000018C1 EBCF                <1> 	jmp	short VBE_bios_return
  3143                              <1> 
  3144                              <1> P1:
  3145 000018C3 [DD180000]          <1> 	dd	vbe3_pmfn_return_ctrl_info
  3146 000018C7 [01190000]          <1> 	dd	vbe3_pmfn_return_mode_info
  3147 000018CB [3E190000]          <1> 	dd	vbe3_pmfn_set_mode
  3148 000018CF [39190000]          <1> 	dd	vbe3_pmfn_return_current_mode
  3149 000018D3 [301A0000]          <1> 	dd	vbe3_pmfn_save_restore_state
  3150                              <1> 	;dd	vbe3_pmfn_display_window_ctrl
  3151                              <1> 	;dd	vbe3_pmfn_set_get_log_scanline
  3152                              <1> 	;dd	vbe3_pmfn_set_get_disp_start
  3153                              <1> 	;dd	vbe3_pmfn_set_get_dac_pal_frm
  3154                              <1> 	;dd	vbe3_pmfn_set_get_palette_data
  3155                              <1> 	;dd	vbe3_pmfn_return_pmi ; invalid for TRDOS 386 v2
  3156                              <1> 	;dd	vbe3_pmfn_set_get_pixel_clock
  3157                              <1> 	
  3158                              <1> P1L	EQU	$ - P1
  3159                              <1> 
  3160                              <1> ;	; 29/11/2020
  3161                              <1> ;	mov	edi, VBE3MODEINFOBLOCK >> 4 ; / 16
  3162                              <1> ;	
  3163                              <1> ;	cmp	al, 04h
  3164                              <1> ;	jb	short vbe3_pm_f ; function: 4F00h to 4F03h
  3165                              <1> ;	ja	short vbe3_pmi_f5B ; function: 4F05h to 4F0Bh
  3166                              <1> ;
  3167                              <1> ;	; check buffer length (must be <= 2048 bytes)
  3168                              <1> ;
  3169                              <1> ;	and	dl, dl ; 0
  3170                              <1> ;	jz	short vbe3_pm_f 
  3171                              <1> ;		       ; Return Save/Restore State buffer size
  3172                              <1> ;
  3173                              <1> ;	push	ebx  ; buffer address
  3174                              <1> ;	push	edx  ; function: save (01h) or restore (02h)
  3175                              <1> ;	call	
  3176                              <1> ;
  3177                              <1> ;vbe3_pm_f03:
  3178                              <1> ;	cmp	al, 2
  3179                              <1> ;	ja	short vbe3_pm_f ; function 4F03h
  3180                              <1> ;	jb	short vbe3_pm_f1
  3181                              <1> ;
  3182                              <1> ;
  3183                              <1> ;vbe3_pm_f1:
  3184                              <1> ;	
  3185                              <1> ;
  3186                              <1> ;vbe3_pmi_f5B:
  3187                              <1> ;	cmp	al, 09h
  3188                              <1> ;	jna	short vbe3_pm_f ; funcs 05h to 09h are usable 
  3189                              <1> ;	
  3190                              <1> ;	cmp	al, 0Bh ; Get/Set pixel clock, last function
  3191                              <1> ;	jne	short VBE_unknown 
  3192                              <1> ;			; (do not use 'uncertain' functions
  3193                              <1> ;			; because of system-user buff transfers)
  3194                              <1> ;vbe3_pm_f:
  3195                              <1> ;	mov	byte [vbe3_pm_fn], al	; set
  3196                              <1> ;	; prepare 16 bit pm segments & registers for pmi call 
  3197                              <1> ;	call	VESA_VBE3_PM_FUNCTION
  3198                              <1> ;
  3199                              <1> ;
  3200                              <1> 
  3201                              <1> 	; 26/11/2020
  3202                              <1> VBE_unknown:
  3203 000018D7 66B80001            <1> 	mov	ax, 0100h  ; ah = 1 : Function call failed	
  3204                              <1> 			   ; al = 0 : Function is not supported	
  3205                              <1> 	
  3206 000018DB EBB5                <1> 	jmp	short VBE_bios_return
  3207                              <1> 
  3208                              <1> vbe3_pmfn_return_ctrl_info:
  3209                              <1> 	; 12/12/2020
  3210                              <1> 	;
  3211                              <1> 	; VBE function 4F00h - Return VBE Controller Information
  3212                              <1> 	;
  3213                              <1> 	; Input:
  3214                              <1> 	;      EDI = Pointer to buffer in which to place
  3215                              <1> 	;	     VbeInfoBlock structure
  3216                              <1> 	;
  3217                              <1> 	;	AX = 4F00h
  3218                              <1> 	; Output:
  3219                              <1> 	;	AX = VBE return status
  3220                              <1> 	;	     AX = 004Fh -> succeeded
  3221                              <1> 	;	     AX <> 004Fh -> failed
  3222                              <1> 	; 
  3223                              <1> 	; Modified registers: eax (+ edi for kernel's own call)
  3224                              <1> 
  3225                              <1> 	; NOTE: TRDOS 386 v2 (v2.0.3) kernel calls this function
  3226                              <1> 	; during startup while cpu is in real mode
  3227                              <1> 	; (by using int 10h, 4F02h) and saves VbeInfoBlock at
  3228                              <1> 	; VBE3INFOBLOCK address (97E00h for TRDOS 386 v2.0.3).
  3229                              <1> 	;	
  3230                              <1> 	; So...
  3231                              <1> 	; This VBE function is adjusted to return/move same info
  3232                              <1> 	; from VBE3INFOBLOCK to user's buffer in EDI.
  3233                              <1> 
  3234                              <1> 	; int 31h (int 10h) entrance
  3235                              <1> 
  3236 000018DD 21FF                <1> 	and	edi, edi
  3237 000018DF 7424                <1> 	jz	short vbe3_func_fail ; invalid buffer address !
  3238                              <1> 
  3239                              <1> ;_vbe3_pmfn_return_ctrl_info:		
  3240                              <1> 	;or	edi, edi
  3241                              <1> 	;jnz	short _vbe_biosfn_return_ctrl_info
  3242                              <1> 	;
  3243                              <1> 	;; this option may not be necessary - 12/12/2020
  3244                              <1> 	;
  3245                              <1> 	;; edi = 0, kernel forces to get ctrl info again
  3246                              <1> 	;;	   by using VESA VBE3 video bios's pmi
  3247                              <1> 	;
  3248                              <1> 	;;push	edi
  3249                              <1> 	;; far call to VESA VBE3 PMI 
  3250                              <1> 	;;mov	ax, 4F00h ; Return VBE Controller Info
  3251                              <1> 	;mov	edi, VBE3INFOBLOCK-VBE3SAVERESTOREBLOCK
  3252                              <1> 	;; ES selector base address = VBE3SAVERESTOREBLOCK 
  3253                              <1> 	;call	int10h_32bit_pmi
  3254                              <1> 	;;pop	edi
  3255                              <1> 	;mov	edi, VBE3INFOBLOCK ; retn to the kernel sub
  3256                              <1> 	;cmp	ax, 004Fh
  3257                              <1> 	;je	short vbe_ctrl_info_retn
  3258                              <1> 	;stc	
  3259                              <1> 	;retn
  3260                              <1> 
  3261                              <1> _vbe_biosfn_return_ctrl_info:
  3262 000018E1 57                  <1> 	push	edi
  3263 000018E2 51                  <1> 	push	ecx
  3264 000018E3 BE007E0900          <1> 	mov	esi, VBE3INFOBLOCK
  3265 000018E8 B900020000          <1> 	mov	ecx, 512
  3266 000018ED E872020100          <1> 	call	transfer_to_user_buffer
  3267 000018F2 59                  <1> 	pop	ecx
  3268 000018F3 5F                  <1> 	pop	edi
  3269 000018F4 720F                <1> 	jc	short vbe3_func_fail
  3270                              <1> 
  3271 000018F6 31C0                <1> 	xor	eax, eax
  3272 000018F8 B04F                <1> 	mov	al, 4Fh ; successful
  3273                              <1> ;vbe_ctrl_info_retn:
  3274 000018FA C3                  <1> 	retn
  3275                              <1> 
  3276                              <1> vbe_biosfn_return_ctrl_info:
  3277                              <1> 	; 12/12/2020
  3278                              <1> 	;
  3279                              <1> 	; VBE function 4F00h - Return VBE Controller Information
  3280                              <1> 	;
  3281                              <1> 	; Input:
  3282                              <1> 	;      EDI = Pointer to buffer in which to place
  3283                              <1> 	;	     VbeInfoBlock structure
  3284                              <1> 	;
  3285                              <1> 	;	AX = 4F00h
  3286                              <1> 	; Output:
  3287                              <1> 	;	AX = VBE return status
  3288                              <1> 	;	     AX = 004Fh -> succeeded
  3289                              <1> 	;	     AX <> 004Fh -> failed   
  3290                              <1> 	; 
  3291                              <1> 	; Modified registers: eax
  3292                              <1> 
  3293 000018FB 21FF                <1> 	and	edi, edi
  3294 000018FD 7406                <1> 	jz	short vbe3_func_fail ; invalid buffer addr !
  3295 000018FF EBE0                <1> 	jmp	short _vbe_biosfn_return_ctrl_info 
  3296                              <1> 
  3297                              <1> vbe3_pmfn_return_mode_info:
  3298                              <1> 	; 21/12/2020
  3299                              <1> 	; 12/12/2020
  3300                              <1> 	;
  3301                              <1> 	; VBE function 4F01h - Return VBE Mode Information
  3302                              <1> 	;
  3303                              <1> 	; Input:
  3304                              <1> 	;	CX = Mode number (VESA VBE mode number)
  3305                              <1> 	;      EDI = Pointer to ModeInfoBlock structure
  3306                              <1> 	;	     (256 bytes) -User's buffer address-
  3307                              <1> 	;      EDI = 0 -> kernel call
  3308                              <1> 	;		  (do not transfer ModeInfoBlock
  3309                              <1> 	;		  to user's buffer address)
  3310                              <1> 	;	AX = 4F01h	
  3311                              <1> 	; Output:
  3312                              <1> 	;	AX = VBE return status
  3313                              <1> 	;	     AX = 004Fh -> succeeded
  3314                              <1> 	;	     AX <> 004Fh -> failed   
  3315                              <1> 	; 
  3316                              <1> 	; Modified registers: eax, esi, edi
  3317                              <1> 
  3318                              <1> 	; int 31h (int 10h) entrance
  3319                              <1> 	
  3320 00001901 09FF                <1> 	or	edi, edi
  3321 00001903 7506                <1> 	jnz	short _vbe3_pmfn_return_mode_info
  3322                              <1> 
  3323                              <1> vbe3_func_fail:
  3324 00001905 B84F010000          <1> 	mov	eax, 014Fh ; ah = 1 : Function call failed
  3325                              <1> 			   ; al = 4Fh : Function is supported
  3326 0000190A C3                  <1> 	retn
  3327                              <1> 	
  3328                              <1> 	; jump from '_vbe_biosfn_return_mode_info' 
  3329                              <1> _vbe3_pmfn_return_mode_info:
  3330 0000190B 57                  <1> 	push	edi
  3331                              <1> 
  3332                              <1> 	;; clear vbe3 'mode info block' buffer
  3333                              <1> 	;push	ecx
  3334                              <1> 	;xor	eax, eax
  3335                              <1> 	;mov	ecx, 256/4
  3336                              <1> 	;mov	edi, VBE3MODEINFOBLOCK
  3337                              <1> 	;rep	stosd
  3338                              <1> 	;pop	ecx
  3339                              <1> 
  3340                              <1> 	; far call to VESA VBE3 PMI 
  3341                              <1> 	;mov	ax, 4F01h ; Return VBE Mode Information
  3342 0000190C BF00060000          <1> 	mov	edi, VBE3MODEINFOBLOCK-VBE3SAVERESTOREBLOCK
  3343                              <1> 	; ES selector base address = VBE3SAVERESTOREBLOCK 
  3344 00001911 E8FC000000          <1> 	call	int10h_32bit_pmi
  3345                              <1> 
  3346 00001916 5F                  <1> 	pop	edi
  3347                              <1> 
  3348                              <1> 	;cmp	ax, 004Fh
  3349                              <1> 	;jne	short vbe3_func_retn  ; failed !
  3350                              <1> 
  3351 00001917 21FF                <1> 	and	edi, edi
  3352                              <1> 	;jz	short vbe3_func_success
  3353                              <1> 	; 21/12/2020
  3354 00001919 741D                <1> 	jz	short vbe3_func_retn
  3355                              <1> 
  3356 0000191B 6683F84F            <1> 	cmp	ax, 004Fh
  3357 0000191F 7517                <1> 	jne	short vbe3_func_retn  ; failed !
  3358                              <1> 
  3359 00001921 51                  <1> 	push	ecx
  3360 00001922 BE007C0900          <1> 	mov	esi, VBE3MODEINFOBLOCK		
  3361 00001927 B900010000          <1> 	mov	ecx, 256
  3362 0000192C E833020100          <1> 	call	transfer_to_user_buffer
  3363 00001931 59                  <1> 	pop	ecx
  3364 00001932 72D1                <1> 	jc	short vbe3_func_fail
  3365                              <1> 
  3366 00001934 31C0                <1> 	xor	eax, eax
  3367 00001936 B04F                <1> 	mov	al, 4Fh ; successful
  3368                              <1> vbe3_func_success:
  3369                              <1> vbe3_func_retn:	
  3370 00001938 C3                  <1> 	retn
  3371                              <1> 
  3372                              <1> vbe3_pmfn_return_current_mode:
  3373                              <1> 	; 12/12/2020
  3374                              <1> 	;
  3375                              <1> 	; VBE function 4F03h - Return Current VBE Mode
  3376                              <1> 	;
  3377                              <1> 	; Input:
  3378                              <1> 	;	none (AX = 4F03h)
  3379                              <1> 	; Output:
  3380                              <1> 	;	AX = VBE return status
  3381                              <1> 	;	     AX = 004Fh -> succeeded
  3382                              <1> 	;	     AX <> 004Fh -> failed
  3383                              <1> 	;	BX = Current VBE mode
  3384                              <1> 	;	  bit 0-13 = Mode number
  3385                              <1> 	;	  bit 14 = 0 Windowed frame buffer model
  3386                              <1> 	;	         = 1 Linear frame buffer model
  3387                              <1> 	;	  bit 15 
  3388                              <1> 	;	      = 0 Memory cleared at last mode set
  3389                              <1> 	;	      = 1 Memory not cleared at last mode set
  3390                              <1> 	; 
  3391                              <1> 	; Modified registers: eax, ebx
  3392                              <1> 
  3393                              <1> 	; int 31h (int 10h) entrance
  3394                              <1> 	
  3395                              <1> 	; far call to VESA VBE3 PMI 
  3396                              <1> 
  3397                              <1> 	;mov	eax, 4F03h ; Return Current VBE Mode
  3398                              <1> vbe3_pmfn_far_call:
  3399                              <1> 	; ES selector base address = VBE3SAVERESTOREBLOCK 
  3400                              <1> 	;call	int10h_32bit_pmi
  3401                              <1> 	;retn
  3402 00001939 E9D4000000          <1> 	jmp	int10h_32bit_pmi
  3403                              <1> 
  3404                              <1> vbe3_pmfn_set_mode:
  3405                              <1> 	; 22/12/2020
  3406                              <1> 	; 21/12/2020
  3407                              <1> 	; 12/12/2020
  3408                              <1> 	;
  3409                              <1> 	; VBE function 4F02h - Set VBE Mode
  3410                              <1> 	;
  3411                              <1> 	; Input:
  3412                              <1> 	;	BX = Desired Mode to set
  3413                              <1> 	;	  bit 0-13 = Mode number
  3414                              <1> 	;	  bit 14 = 0 Windowed frame buffer model
  3415                              <1> 	;	         = 1 Linear frame buffer model
  3416                              <1> 	;	  bit 15 
  3417                              <1> 	;	      = 0 Memory cleared at last mode set
  3418                              <1> 	;	      = 1 Memory not cleared at last mode set
  3419                              <1> 	; Output:
  3420                              <1> 	;	AX = VBE return status
  3421                              <1> 	;	     AX = 004Fh -> succeeded
  3422                              <1> 	;	     AX <> 004Fh -> failed
  3423                              <1> 	; 
  3424                              <1> 	; Modified registers: eax, ebx, esi (21/12/2020)
  3425                              <1> 
  3426                              <1> 	; int 31h (int 10h) entrance
  3427                              <1> 
  3428                              <1> 	; 22/12/2020 (VESA VBE3 feature)
  3429                              <1> 	; BX bit 11 is flag for
  3430                              <1> 	;	user specified CRTC values for refresh rate
  3431                              <1> 	; 'test bh, 8'
  3432                              <1> 	; if bit 11 is set, EDI points to 'CRTCInfoBlock'
  3433                              <1> 
  3434                              <1> 	; 22/12/2020
  3435                              <1> 	;; test bx for VBE video mode
  3436                              <1> 	;test	bh, 1
  3437                              <1> 	;jnz	short vbe3_sm_0
  3438                              <1> 
  3439                              <1> 	;; use internal VBE mode set procedure
  3440                              <1> 	;; for non-vbe (std VGA/CGA) modes
  3441                              <1> 	;
  3442                              <1> 	;; (it is useful -as 4F02h function- 
  3443                              <1> 	;;  to jump 'vbe_biosfn_set_mode'
  3444                              <1> 	;;  instead of direct jump to '_set_mode')
  3445                              <1> 	;; ((eliminates additional push-pops and settings))
  3446                              <1>  
  3447                              <1> 	;jmp	vbe_biosfn_set_mode	
  3448                              <1> 
  3449                              <1> vbe3_sm_0: 
  3450                              <1> 	;;push	ds  ; *
  3451                              <1> 	;;push	es  ; **
  3452                              <1> 	;;push	ebp ; ***
  3453                              <1> 	;;push	esi ; **** 
  3454                              <1> 	
  3455                              <1> 	; Fit bx to VESA VBE2 type mode setting
  3456                              <1> 	; (bx bit 11 is used for custom CRTC values in VBE3)
  3457                              <1> 	; clear bit 9 to 11 (clear bh bit 1 to bit 3)
  3458                              <1> 
  3459                              <1> 	; 22/12/2020
  3460 0000193E 57                  <1> 	push	edi ; *****
  3461 0000193F F6C708              <1> 	test	bh, 8	; Use user specified CRTC values
  3462 00001942 7530                <1> 	jnz	short vbe3_sm_3  ; for refresh rate
  3463                              <1> vbe3_sm_4:
  3464 00001944 80E7C1              <1> 	and	bh, 0C1h ; use bit 15, 14, 8 only (for bh)
  3465                              <1> 	;mov	[vbe_mode_x], bh
  3466                              <1> 
  3467 00001947 803D[DA6F0000]03    <1> 	cmp	byte [CRT_MODE], 3 ; is current mode 03h ?
  3468 0000194E 7509                <1> 	jne	short vbe3_sm_1    ; no
  3469                              <1> 
  3470                              <1> 	; save mode 03h video pages and cursor positions
  3471 00001950 57                  <1> 	push	edi ; **!***	
  3472 00001951 51                  <1> 	push	ecx ; ******
  3473                              <1> 	;push	esi
  3474                              <1> 	
  3475 00001952 E8CE040000          <1> 	call	save_mode3_multiscreen
  3476                              <1> 	
  3477                              <1> 	;pop	esi
  3478 00001957 59                  <1> 	pop	ecx ; ******
  3479 00001958 5F                  <1> 	pop	edi ; **!***
  3480                              <1> vbe3_sm_1:
  3481                              <1> 	; ax = 4F02h
  3482                              <1> 	; bx = video mode number (vbe2 type)
  3483 00001959 E8B4000000          <1> 	call	int10h_32bit_pmi 
  3484                              <1> 			; call to far call to VBE3 PMI
  3485                              <1> 
  3486 0000195E 6683F84F            <1> 	cmp	ax, 004Fh ; succeeded ?
  3487 00001962 750E                <1> 	jne	short vbe3_sm_2
  3488                              <1> 	; set current mode byte/sign to extended (SVGA) mode
  3489 00001964 C605[DA6F0000]FF    <1> 	mov	byte [CRT_MODE], 0FFh ; VESA VBE mode
  3490                              <1> 	; set current VBE mode word to bx input
  3491 0000196B 66891D[1E120300]    <1> 	mov	[video_mode], bx
  3492                              <1> vbe3_sm_2:
  3493                              <1> 	; 22/12/2020
  3494 00001972 5F                  <1> 	pop	edi ; ***** 
  3495 00001973 C3                  <1> 	retn
  3496                              <1> 
  3497                              <1> vbe3_sm_3:
  3498                              <1> 	; 22/12/2020
  3499                              <1> 	; copy user's CRTCInfoBlock to the buffer
  3500 00001974 51                  <1> 	push	ecx
  3501 00001975 89FE                <1> 	mov	esi, edi
  3502 00001977 BF807D0900          <1> 	mov	edi, VBE3CRTCINFOBLOCK
  3503 0000197C B940000000          <1> 	mov	ecx, 64
  3504 00001981 E828020100          <1> 	call	transfer_from_user_buffer
  3505 00001986 59                  <1> 	pop	ecx
  3506                              <1> 	; set offset (es base addr is VBE3SAVERESTOREBLOCK) 
  3507 00001987 81EF00760900        <1> 	sub	edi, VBE3SAVERESTOREBLOCK
  3508 0000198D EBB5                <1> 	jmp	short vbe3_sm_4
  3509                              <1> 	
  3510                              <1> vesa_vbe3_pmi:
  3511                              <1> 	; 12/12/2020
  3512                              <1> 	; 08/12/2020
  3513                              <1> 	; 07/12/2020
  3514                              <1> 	; 05/12/2020, 06/12/2020
  3515                              <1> 	; 03/12/2020, 04/12/2020
  3516                              <1> 	; 28/11/2020 (TRDOS 386 v2.0.3)
  3517                              <1> 	; VGA BIOS functions via
  3518                              <1> 	; VESA VBE3 Protected Mode Inface
  3519                              <1> 	; [vbe3] = 3 and [pmi32] > 0
  3520                              <1> 
  3521                              <1> 	; 04/12/2020
  3522                              <1> 	; Only 'set mode' will be redirected to vbe3 video bios
  3523                              <1> 	; (by setting mode 3 multiscreen paraters before and after) 
  3524                              <1> 
  3525                              <1> 	; 06/12/2020
  3526 0000198F 20E4                <1> 	and	ah, ah	; 0 = set mode function
  3527 00001991 7402                <1> 	jz	short vbe3_pmi_0
  3528 00001993 EB76                <1> 	jmp	vbe3_pmi_9 
  3529                              <1> 
  3530                              <1> vbe3_pmi_0:
  3531                              <1> 	; 07/12/2020
  3532 00001995 88C4                <1> 	mov	ah, al
  3533 00001997 80E480              <1> 	and	ah, 80h ; 0 or 80h
  3534 0000199A 30E0                <1> 	xor	al, ah ; 8?h -> 0?h
  3535                              <1> 
  3536                              <1> 	;cmp	al, 13h ; mode number above 13h is returned
  3537                              <1> 	;jna	short vbe3_pmi_1
  3538                              <1> 	;		; back to default code due to uncertainty
  3539                              <1> 	; 		; (>13h is not std for all svga bioses)
  3540                              <1> 	;jmp	VGA_funcs_0
  3541                              <1> vbe3_pmi_1:
  3542                              <1> 	; 07/12/2020
  3543                              <1> 	; Possible cases for VBE3 (PMI, ah=0) set mode:
  3544                              <1> 	; current mode > 07h and requested mode: any 
  3545                              <1> 	; current mode <= 07h and requested mode > 07h
  3546                              <1> 
  3547                              <1> 	; 06/12/2020
  3548 0000199C 8825[C7960100]      <1> 	mov	byte [noclearmem], ah ; 0 or 80h
  3549                              <1> 	; check current video mode if it is 03h
  3550 000019A2 803D[DA6F0000]03    <1> 	cmp	byte [CRT_MODE], 3 ; current mode
  3551 000019A9 750B                <1> 	jne	short vbe3_pmi_3
  3552                              <1> 	; 07/12/2020
  3553                              <1> 	; check new video mode if it is 03h also
  3554                              <1> 	;cmp	al, 3
  3555                              <1> 	;jne	short vbe3_pmi_2
  3556                              <1> 	;mov	byte [p_crt_mode], 80h 	; clear video memory
  3557                              <1> 	;jmp	short vbe3_pmi_5
  3558                              <1> vbe3_pmi_2:
  3559                              <1> 	; case 1:
  3560                              <1> 	; Current mode is 03h and new mode is not 03h
  3561                              <1> 
  3562                              <1> 	; save video pages and cursor positions
  3563 000019AB 56                  <1> 	push	esi
  3564 000019AC 57                  <1> 	push	edi
  3565 000019AD 51                  <1> 	push	ecx
  3566                              <1> 
  3567                              <1> 	; 12/12/2020
  3568                              <1> 	;mov	esi, 0B8000h ; mode 3 video memory
  3569                              <1> 	;mov	edi, 98000h  ; backup location
  3570                              <1> 	;mov	ecx, (0B8000h-0B0000h)/4
  3571                              <1> 	;rep	movsd
  3572                              <1> 	;
  3573                              <1> 	;mov	byte [p_crt_mode], 3 ; previous mode, backup sign
  3574                              <1> 	;xchg	cl, [ACTIVE_PAGE]
  3575                              <1> 	;mov	[p_crt_page], cl  ; save as previous active page
  3576                              <1> 	;
  3577                              <1> 	;; save cursor positions
  3578                              <1> 	;mov	esi, CURSOR_POSN
  3579                              <1> 	;mov	edi, cursor_pposn ; cursor positions backup
  3580                              <1> 	;mov	cl, 4
  3581                              <1> 	;rep	movsd
  3582                              <1> 
  3583                              <1> 	; 12/12/2020
  3584 000019AE E872040000          <1> 	call	save_mode3_multiscreen
  3585                              <1> 
  3586 000019B3 59                  <1> 	pop	ecx
  3587 000019B4 5F                  <1> 	pop	edi
  3588 000019B5 5E                  <1> 	pop	esi
  3589                              <1> vbe3_pmi_3:
  3590                              <1> 	; 08/12/2020
  3591                              <1> 	; 07/12/2020
  3592                              <1> 	; case 3 or case 4
  3593 000019B6 A2[DA6F0000]        <1> 	mov	[CRT_MODE], al
  3594 000019BB 3C03                <1> 	cmp	al, 3
  3595 000019BD 7407                <1> 	je	short vbe3_pmi_4
  3596                              <1> 	; case 4:
  3597                              <1> 	; Current mode is not 03h and also new mode is not 03h
  3598 000019BF 800D[C5960100]80    <1> 	or	byte [p_crt_mode], 80h  ; 83h (case 1 -> case 4)
  3599                              <1> 	;jmp	short vbe3_pmi_5
  3600                              <1> vbe3_pmi_4:
  3601                              <1> 	; case 3:
  3602                              <1> 	;
  3603                              <1> 	; Current mode is not 03h and new mode is 03h
  3604                              <1> 
  3605                              <1> ;vbe3_pmi_5:
  3606                              <1> 	;mov	[CRT_MODE], al
  3607                              <1> 
  3608 000019C6 E847000000          <1> 	call	int10h_32bit_pmi	
  3609                              <1> 
  3610 000019CB 803D[DA6F0000]03    <1> 	cmp	byte [CRT_MODE], 3  ; new video mode
  3611                              <1> 	;jne	vbe3_pmi_8	; video mode <> 03h
  3612 000019D2 7532                <1> 	jne	short vbe3_pmi_8	
  3613                              <1> 
  3614                              <1> 	;push	eax ; 04/12/2020
  3615 000019D4 53                  <1> 	push	ebx
  3616 000019D5 51                  <1> 	push	ecx
  3617 000019D6 52                  <1> 	push	edx
  3618 000019D7 57                  <1> 	push	edi ; 03/12/2020
  3619                              <1> 
  3620                              <1> 	; 12/12/2020
  3621 000019D8 56                  <1> 	push	esi
  3622 000019D9 E87A040000          <1> 	call	restore_mode3_multiscreen
  3623 000019DE 5E                  <1> 	pop	esi
  3624                              <1> 	; AL = active video page
  3625                              <1> 
  3626                              <1> 	; 12/12/2020
  3627                              <1> 	;mov	al, [p_crt_page] ; previous mode 3 active page
  3628                              <1> 	;
  3629                              <1> 	;;test	byte [p_crt_mode], 7Fh ; 83h or 80h or 03h
  3630                              <1> 	;;jz	short vbe3_pmi_6 ; do not restore video pages
  3631                              <1> 	;			 ; clear current video page
  3632                              <1> 	;; case 3
  3633                              <1> 	;
  3634                              <1> 	;; ([p_crt_mode] = 03h)
  3635                              <1> 	;
  3636                              <1> 	;; New video mode is 3 while current video mode is not 3
  3637                              <1> 	;; (multi screen) video pages will be restored from 098000h
  3638                              <1> 	;
  3639                              <1> 	;; restore video pages and cursor positions
  3640                              <1> 	;
  3641                              <1> 	;mov	[ACTIVE_PAGE], al ; current mode 3 active page
  3642                              <1> 	;
  3643                              <1> 	;push	esi
  3644                              <1> 	;
  3645                              <1> 	;; restore video pages
  3646                              <1> 	;mov	esi, 98000h
  3647                              <1> 	;mov	edi, 0B8000h
  3648                              <1> 	;;mov	ecx, 2000h
  3649                              <1> 	;mov	cx, 2000h ; 8K dwords (32K)
  3650                              <1> 	;rep	movsd
  3651                              <1> 	;
  3652                              <1> 	;mov	[p_crt_mode], cl ; reset ('case 3' end condition)
  3653                              <1> 	;
  3654                              <1> 	;; restore cursor positions
  3655                              <1> 	;mov	esi, cursor_pposn
  3656                              <1> 	;mov	edi, CURSOR_POSN
  3657                              <1> 	;;mov	ecx, 4	; restore all cursor positions (16 bytes)
  3658                              <1> 	;mov	cl, 4
  3659                              <1> 	;rep 	movsd
  3660                              <1> 	;
  3661                              <1> 	;pop	esi
  3662                              <1> 	;
  3663                              <1> 	;; 07/12/2020
  3664                              <1> 	;; restore CRT_START according to ACTIVE_PAGE
  3665                              <1> 	;mov	[CRT_START], cx ; 0
  3666                              <1> 	;
  3667                              <1> 	;; check active page and set it again if it is not 0
  3668                              <1> 	;or	al, al
  3669                              <1> 	;jz	short vbe3_pmi_7
  3670                              <1> 	;
  3671                              <1> 	;mov	cl, al
  3672                              <1> ;vbe3_pmi_5:
  3673                              <1> 	;add	word [CRT_START], 4096
  3674                              <1> 	;dec	cl
  3675                              <1> 	;jnz	short vbe3_pmi_5
  3676                              <1> 
  3677 000019DF B405                <1> 	mov	ah, 05h ; set current video page
  3678                              <1> 	;al = video page
  3679 000019E1 E82C000000          <1> 	call	int10h_32bit_pmi
  3680                              <1> 	
  3681                              <1> 	; check current cursor position & set it again if not 0,0
  3682                              <1> 	;movzx	ebx, byte [ACTIVE_PAGE]
  3683 000019E6 0FB6D8              <1> 	movzx	ebx, al
  3684 000019E9 D0E3                <1> 	shl	bl, 1
  3685 000019EB 81C3[4E8A0100]      <1> 	add	ebx, CURSOR_POSN
  3686 000019F1 668B13              <1> 	mov	dx, [ebx]
  3687 000019F4 6621D2              <1> 	and	dx, dx		
  3688 000019F7 7409                <1> 	jz	short vbe3_pmi_7
  3689                              <1> 	
  3690                              <1> 	;dx = cursor position (dl = column, dh = row)
  3691                              <1> 	;mov	bh, [ACTIVE_PAGE] ; 06/12/2020
  3692 000019F9 88C7                <1> 	mov	bh, al
  3693 000019FB B402                <1> 	mov	ah, 02h ; set cursor position
  3694 000019FD E810000000          <1> 	call	int10h_32bit_pmi
  3695                              <1> 	
  3696                              <1> 	;jmp	short vbe3_pmi_7
  3697                              <1> 
  3698                              <1> ;vbe3_pmi_6:
  3699                              <1> ;	; 07/12/2020
  3700                              <1> ;	; case 1, previous mode is 03h, current mode is 03h
  3701                              <1> ;	; 03/12/2020
  3702                              <1> ;	cmp	byte [noclearmem], 0
  3703                              <1> ;	jna	short vbe3_pmi_7 ; do not clear memory
  3704                              <1> ;	; clear video page
  3705                              <1> ;	mov	ecx, 1024 ; 4096/4
  3706                              <1> ;	mov	eax, 07200720h
  3707                              <1> ;	mov	edi, 0B8000h ; [crt_base]
  3708                              <1> ;	add	di, [CRT_START]
  3709                              <1> ;	rep	stosd	; FILL THE REGEN BUFFER WITH BLANKS
  3710                              <1> 
  3711                              <1> vbe3_pmi_7:
  3712 00001A02 5F                  <1> 	pop	edi
  3713 00001A03 5A                  <1> 	pop	edx
  3714 00001A04 59                  <1> 	pop	ecx
  3715 00001A05 5B                  <1> 	pop	ebx
  3716                              <1> 	;pop	eax ; 04/12/2020
  3717                              <1> vbe3_pmi_8:
  3718                              <1> 	; 04/12/2020
  3719                              <1> 	;(TRDOS 386 v2.0.3, INT 31h, ah=0 return)
  3720 00001A06 31C0                <1> 	xor	eax, eax  ; eax = 0 -> succesful
  3721                              <1> vesa_vbe3_pmi_retn:
  3722 00001A08 07                  <1> 	pop	es  ; **
  3723 00001A09 1F                  <1> 	pop	ds  ; *
  3724 00001A0A CF                  <1> 	iretd
  3725                              <1> 
  3726                              <1> vbe3_pmi_9:
  3727                              <1> 	; 06/12/2020 
  3728                              <1> 	;cmp	ah, 10h ; Set/Get Palette Registers
  3729                              <1> 	;jnb	short vbe3_pmi_10
  3730                              <1> 	; 05/12/2020
  3731 00001A0B E802000000          <1> 	call	int10h_32bit_pmi
  3732 00001A10 EBF6                <1> 	jmp	short vesa_vbe3_pmi_retn
  3733                              <1> 
  3734                              <1> ;vbe3_pmi_10:
  3735                              <1> 	; 06/12/2020
  3736                              <1> 	;jmp	VGA_funcs_0
  3737                              <1> 
  3738                              <1> int10h_32bit_pmi:
  3739                              <1> 	; 03/12/2020
  3740                              <1> 	; 28/11/2020
  3741                              <1> 	; calling standard VGA Bios (INT 10h) functions
  3742                              <1> 	; by using 32 bit protected mode interface of
  3743                              <1> 	; VESA VBE3 Video Bios (with 'PMID' signature)
  3744                              <1> 
  3745                              <1> 	; 03/12/2020
  3746                              <1> 	; eax, ebx, ecx, edx, edi will be used by vbios pmi
  3747                              <1> 	; (esi and ebp will not be used) 
  3748                              <1> 
  3749                              <1> 	; 03/12/2020
  3750 00001A12 56                  <1> 	push	esi
  3751 00001A13 C1E010              <1> 	shl	eax, 16  ; move function number (ax) to hw
  3752 00001A16 8B35[24120300]      <1> 	mov	esi, [pmid_addr] ; linear address of
  3753                              <1> 				 ; PMInfo.Entrypoint pointer
  3754                              <1> 	;mov	ax, [esi+PMInfo.EntryPoint]	
  3755 00001A1C 668B06              <1> 	mov	ax, [esi]	 
  3756 00001A1F C1C010              <1> 	rol	eax, 16 ; move PM entry address to hw
  3757                              <1> 			; and move function number to lw (ax)
  3758 00001A22 5E                  <1> 	pop	esi
  3759                              <1> 
  3760                              <1> 	; top of stack: ; (*)
  3761                              <1> 	; return (the caller) address of "int10h_32bit_pmi"
  3762                              <1> 
  3763 00001A23 E97BEDFFFF          <1> 	jmp	_VBE3PMI_fcall ; will return to the caller (*)
  3764                              <1> 
  3765                              <1> _vbe3_pmfn_srs_8:
  3766                              <1> 	; 17/01/2021
  3767 00001A28 31DB                <1> 	xor 	ebx, ebx ; points to VBE3SAVERESTOREBLOCK
  3768                              <1> _vbe3_pmfn_srs_9: ; 24/01/2021
  3769 00001A2A 66B8044F            <1> 	mov	ax, 4F04h
  3770 00001A2E EBE2                <1> 	jmp	short int10h_32bit_pmi
  3771                              <1> 
  3772                              <1> vbe3_pmfn_save_restore_state:
  3773                              <1> 	; 24/01/2021
  3774                              <1> 	; 23/01/2021
  3775                              <1> 	; 16/01/2021, 17/01/2021
  3776                              <1> 	; 14/01/2021
  3777                              <1> 	;
  3778                              <1> 	; VBE function 4F04h - Save/Restore Video State
  3779                              <1> 	;
  3780                              <1> 	; Input:
  3781                              <1> 	;	DL = sub function
  3782                              <1> 	;	CL = requested state
  3783                              <1> 	;      EBX = pointer to buffer (if DL<>00h)
  3784                              <1> 	;	AX = 4F04h 
  3785                              <1> 	; Output:
  3786                              <1> 	;	AX = 004Fh (successful)
  3787                              <1> 	;	AH > 0 -> error
  3788                              <1> 	;	BX = Number of 64-byte blocks 
  3789                              <1> 	;	     to hold the state buffer (if DL=00h)
  3790                              <1> 
  3791                              <1> 	; Modified registers: eax, ebx, esi, edi
  3792                              <1> 	
  3793 00001A30 21DB                <1> 	and	ebx, ebx ; user's buffer address
  3794 00001A32 750A                <1> 	jnz	short _vbe3_pmfn_save_restore_state
  3795                              <1> 
  3796 00001A34 08D2                <1> 	or	dl, dl
  3797 00001A36 740C                <1> 	jz	short _vbe3_pmfn_srs_0
  3798                              <1> 
  3799                              <1> 	; function failed
  3800                              <1> 	;;mov	eax, 0100h
  3801                              <1> 	;sub	eax, eax
  3802                              <1> 	;inc	ah  ; eax = 0100h
  3803                              <1> 	;retn
  3804                              <1> 	; 16/01/2021
  3805                              <1> _vbe3_pmfn_srs_fail:
  3806 00001A38 B84F010000          <1> 	mov	eax, 014Fh ; ah = 1 : Function call failed
  3807                              <1> 			   ; al = 4Fh : Function is supported
  3808                              <1> _vbe3_srs_retn:
  3809 00001A3D C3                  <1> 	retn
  3810                              <1> 
  3811                              <1> _vbe3_pmfn_save_restore_state:
  3812 00001A3E 20D2                <1> 	and	dl, dl
  3813 00001A40 7559                <1> 	jnz	short _vbe3_pmfn_srs_2
  3814                              <1> _vbe3_pmfn_srs:
  3815 00001A42 31DB                <1> 	xor	ebx, ebx
  3816                              <1> _vbe3_pmfn_srs_0:
  3817                              <1> 	; 24/01/2021
  3818 00001A44 83F90F              <1> 	cmp	ecx, 0Fh
  3819                              <1> 	;ja	short _vbe3_pmfn_srs_1
  3820 00001A47 77EF                <1> 	ja	short _vbe3_pmfn_srs_fail 
  3821                              <1> 
  3822                              <1> 	; !!! CLEAR CL BIT 2 !!! 
  3823                              <1> 	; (when bit 2 is set, function causes cpu exception)
  3824                              <1> 	; BIOS data will not be saved and restored
  3825                              <1> 	; (to prevent protected mode page fault error)
  3826 00001A49 80E1FD              <1> 	and	cl, ~2 ; and cl, not 2
  3827                              <1> 	
  3828                              <1> 	; 24/01/2021
  3829                              <1> 	;mov	bl, 1
  3830 00001A4C FEC3                <1> 	inc	bl ; = 1
  3831 00001A4E 66D3E3              <1> 	shl	bx, cl 
  3832 00001A51 66231D[28120300]    <1> 	and	bx, [vbe3stbsflags]
  3833 00001A58 7416                <1> 	jz	short _vbe3_pmfn_srs_1
  3834                              <1> 	;mov	bx, cx
  3835 00001A5A 89CB                <1> 	mov	ebx, ecx ; <= 15
  3836 00001A5C D0E3                <1> 	shl	bl, 1 ; 0, 2, 8 .. 30
  3837 00001A5E 668B9B[833C0000]    <1> 	mov	bx, [vbestatebufsize+ebx]
  3838 00001A65 89DF                <1> 	mov	edi, ebx
  3839                              <1> 	; edi = state buffer size in bytes
  3840 00001A67 66C1EB06            <1> 	shr	bx, 6 ; / 64
  3841 00001A6B 66B84F00            <1> 	mov	ax, 4Fh
  3842 00001A6F C3                  <1> 	retn
  3843                              <1> _vbe3_pmfn_srs_1:
  3844                              <1> 	; ax = 4F04h
  3845                              <1> 	;call	int10h_32bit_pmi
  3846                              <1> 	; 24/01/2021
  3847                              <1> 	;call	_vbe3_pmfn_srs_8
  3848                              <1> 	; ebx = 0
  3849 00001A70 E8B5FFFFFF          <1> 	call	_vbe3_pmfn_srs_9	
  3850 00001A75 6683F84F            <1> 	cmp	ax, 004Fh
  3851 00001A79 75C2                <1> 	jne	short _vbe3_srs_retn
  3852                              <1> 	; 24/01/2021
  3853                              <1> 	;cmp	ecx, 0Fh
  3854                              <1> 	;ja	short _vbe3_srs_retn
  3855                              <1> 	; 24/01/2021
  3856                              <1> 	;mov	ax, 1
  3857 00001A7B B001                <1> 	mov	al, 1
  3858 00001A7D 66D3E0              <1> 	shl	ax, cl		
  3859 00001A80 660905[28120300]    <1> 	or	[vbe3stbsflags], ax ; set flag for state option
  3860                              <1> 	; 23/01/2021
  3861 00001A87 89DF                <1> 	mov	edi, ebx
  3862 00001A89 89C8                <1> 	mov	eax, ecx
  3863 00001A8B D0E0                <1> 	shl	al, 1
  3864 00001A8D 66C1E706            <1> 	shl	di, 6 ; * 64
  3865 00001A91 6689B8[833C0000]    <1> 	mov	[vbestatebufsize+eax], di
  3866                              <1> 				; save buf size for option 
  3867                              <1> 	;xchg	edi, ebx
  3868                              <1> 	; edi = state buffer size in bytes
  3869 00001A98 B04F                <1> 	mov	al, 4Fh
  3870 00001A9A C3                  <1> 	retn
  3871                              <1> 
  3872                              <1> _vbe3_pmfn_srs_2:
  3873                              <1> 	; 24/01/2021
  3874                              <1> 	; !!! CLEAR CL BIT 2 !!! 
  3875                              <1> 	; (when bit 2 is set, function causes cpu exception)
  3876                              <1> 	; BIOS data will not be saved and restored
  3877                              <1> 	; (to prevent protected mode page fault error)
  3878                              <1> 
  3879 00001A9B F6C1FD              <1> 	test	cl, ~2 ; test cl, not 2
  3880 00001A9E 7498                <1> 	jz	short _vbe3_pmfn_srs_fail
  3881                              <1> 
  3882 00001AA0 80FA02              <1> 	cmp	dl, 2
  3883 00001AA3 7748                <1> 	ja	short _vbe3_pmfn_srs_5
  3884                              <1> 
  3885                              <1> 	;and	cl, ~2 ; and cl, not 2
  3886                              <1> 
  3887 00001AA5 53                  <1> 	push	ebx ; * ; buffer address
  3888                              <1> 	; save or restore state
  3889                              <1> 	; (get required buffer size at first)
  3890 00001AA6 52                  <1> 	push	edx ; **
  3891 00001AA7 28D2                <1> 	sub	dl, dl ; 0
  3892 00001AA9 E894FFFFFF          <1> 	call	_vbe3_pmfn_srs
  3893 00001AAE 5A                  <1> 	pop	edx ; **
  3894                              <1> 	; 24/01/2021
  3895 00001AAF 5B                  <1> 	pop	ebx ; *
  3896 00001AB0 08E4                <1> 	or	ah, ah
  3897 00001AB2 7538                <1> 	jnz	short _vbe3_pmfn_srs_4 ; error
  3898                              <1> 
  3899                              <1> 	; edi = buffer size in bytes
  3900 00001AB4 81FF00080000        <1> 	cmp	edi, 2048
  3901 00001ABA 772B                <1> 	ja	short _vbe3_pmfn_srs_3
  3902                              <1> 
  3903 00001ABC 80FA01              <1> 	cmp	dl, 1
  3904 00001ABF 7531                <1> 	jne	short _vbe3_pmfn_srs_6 ; restore state
  3905                              <1> 	
  3906                              <1> 	; save video state
  3907                              <1> 	;xor 	ebx, ebx ; points to VBE3SAVERESTOREBLOCK
  3908                              <1> 	;mov	ax, 4F04h
  3909                              <1> 	;call	int10h_32bit_pmi
  3910                              <1> 
  3911                              <1> 	; 24/01/2021
  3912 00001AC1 E842000000          <1> 	call	_vbe3_pmfn_srs_7
  3913                              <1> 	
  3914 00001AC6 6683F84F            <1> 	cmp	ax, 004Fh
  3915 00001ACA 7520                <1> 	jne	short _vbe3_pmfn_srs_4
  3916                              <1> 
  3917 00001ACC 09DB                <1> 	or	ebx, ebx  ; kernel ('sysvideo') ?
  3918 00001ACE 741C                <1> 	jz	short _vbe3_pmfn_srs_4 ; yes
  3919                              <1> 
  3920                              <1> 	; the caller is user
  3921 00001AD0 51                  <1> 	push	ecx ; *
  3922 00001AD1 89F9                <1> 	mov	ecx, edi ; state buffer size
  3923 00001AD3 BE00760900          <1> 	mov	esi, VBE3SAVERESTOREBLOCK ; source
  3924                              <1> 					; (vbe3 pmi buff)
  3925 00001AD8 89DF                <1> 	mov	edi, ebx	; destination (user buff)
  3926 00001ADA E885000100          <1> 	call	transfer_to_user_buffer
  3927 00001ADF 59                  <1> 	pop	ecx ; *
  3928 00001AE0 7205                <1> 	jc	short _vbe3_pmfn_srs_3
  3929                              <1> 
  3930 00001AE2 29C0                <1> 	sub	eax, eax
  3931 00001AE4 B04F                <1> 	mov	al, 4Fh
  3932 00001AE6 C3                  <1> 	retn
  3933                              <1> 
  3934                              <1> 	; 24/01/2021
  3935                              <1> _vbe3_pmfn_srs_3:
  3936 00001AE7 B84F010000          <1> 	mov	eax, 014Fh
  3937                              <1> _vbe3_pmfn_srs_4:
  3938 00001AEC C3                  <1> 	retn
  3939                              <1> _vbe3_pmfn_srs_5:
  3940 00001AED 31C0                <1> 	xor	eax, eax
  3941 00001AEF FEC4                <1> 	inc	ah
  3942                              <1> 	; eax = 0100h, function is not supported
  3943 00001AF1 C3                  <1> 	retn
  3944                              <1> 
  3945                              <1> _vbe3_pmfn_srs_6:
  3946                              <1> 	; restore video state
  3947                              <1> 	; 24/01/2021
  3948                              <1> 	;pop	ebx ; *
  3949                              <1> 	; 23/01/2021
  3950 00001AF2 09DB                <1> 	or	ebx, ebx ; 0 ?	
  3951 00001AF4 7412                <1> 	jz	short _vbe3_pmfn_srs_7 ; 'sysvideo' call
  3952                              <1> 	; 24/01/2021
  3953                              <1> 	;jz	_vbe3_pmfn_srs_8
  3954 00001AF6 89DE                <1> 	mov	esi, ebx
  3955                              <1> 	; esi = user's video state buffer
  3956 00001AF8 51                  <1> 	push	ecx ; *
  3957 00001AF9 89F9                <1> 	mov	ecx, edi ; state buffer size
  3958 00001AFB BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; destination
  3959                              <1> 					; (vbe3 pmi buff)
  3960                              <1> 	;mov	esi, ebx	; source (user buff)
  3961 00001B00 E8A9000100          <1> 	call	transfer_from_user_buffer
  3962 00001B05 59                  <1> 	pop	ecx ; *
  3963 00001B06 72DF                <1> 	jc	short _vbe3_pmfn_srs_3
  3964                              <1> _vbe3_pmfn_srs_7:
  3965 00001B08 53                  <1> 	push	ebx ; *
  3966                              <1> 	; restore video state
  3967                              <1> 	;xor 	ebx, ebx ; points to VBE3SAVERESTOREBLOCK
  3968                              <1> 	;mov	ax, 4F04h
  3969                              <1> 	;call	int10h_32bit_pmi
  3970                              <1> 	; 17/01/2021
  3971 00001B09 E81AFFFFFF          <1> 	call	_vbe3_pmfn_srs_8
  3972 00001B0E 5B                  <1> 	pop	ebx ; *
  3973 00001B0F C3                  <1> 	retn
  3974                              <1> 
  3975                              <1> VIDEO_STATE:
  3976                              <1> 	; 26/06/2016
  3977                              <1> 	; 12/05/2016
  3978                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  3979                              <1> 
  3980                              <1> ;---------------------------------------------------
  3981                              <1> ; VIDEO STATE
  3982                              <1> ;  RETURNS THE CURRENT VIDEO STATE IN AX
  3983                              <1> ;  AH = NUMBER OF COLUMNS ON THE SCREEN
  3984                              <1> ;  AL = CURRENT VIDEO MODE
  3985                              <1> ;  BH = CURRENT ACTIVE PAGE
  3986                              <1> ;---------------------------------------------------
  3987                              <1> 
  3988 00001B10 8A25[DC6F0000]      <1> 	mov	ah, [CRT_COLS]	; GET NUMBER OF COLUMNS
  3989 00001B16 A0[DA6F0000]        <1> 	mov	al, [CRT_MODE]	; CURRENT MODE
  3990                              <1> 	;movzx	esi, al
  3991                              <1> 	;mov	ah, [esi+M6] 
  3992                              <1> 	; BH = active page
  3993 00001B1B 8A3D[5E8A0100]      <1> 	mov	bh, [ACTIVE_PAGE] ; GET CURRENT ACTIVE PAGE
  3994 00001B21 FA                  <1> 	cli	; 02/01/2017
  3995 00001B22 5D                  <1> 	pop	ebp		; RECOVER REGISTERS
  3996 00001B23 5F                  <1> 	pop	edi
  3997 00001B24 5E                  <1> 	pop	esi
  3998 00001B25 59                  <1> 	pop	ecx		; DISCARD SAVED BX
  3999 00001B26 EB41                <1> 	jmp	short M15	; RETURN TO CALLER
  4000                              <1> 
  4001                              <1> set_mode_ncm:
  4002                              <1> 	; 17/11/2020 (TRDOS 386 v2.0.3)
  4003                              <1> 	; 04/07/2016 - TRDOS 386 (TRDOS v2.0)
  4004                              <1> 	; set mode without clearing the video memory
  4005                              <1> 	; (ony for graphics modes)
  4006                              <1> 
  4007                              <1> 	;cmp	al, 7 ; IBM PC CGA modes
  4008                              <1> 	;jna	short SET_MODE ; normal function (clear)
  4009                              <1> 	;; do not clear memory
  4010                              <1> 	;;mov	[noclearmem], al ; > 0
  4011                              <1> 	;mov	byte [noclearmem], 80h ; 17/11/2020
  4012                              <1> 	;call	_set_mode
  4013                              <1> 	;mov	byte [noclearmem], 0
  4014                              <1>         ;jmp     short VIDEO_RETURN
  4015                              <1> 
  4016                              <1> 	; 17/11/2020 (TRDOS v2.0.3)
  4017 00001B28 0C80                <1> 	or	al, 80h ; not clear memory option
  4018                              <1> 
  4019                              <1> 	; 05/12/2020
  4020                              <1> 	; 27/11/2020
  4021                              <1> 	; 17/11/2020
  4022                              <1> 	; 08/08/2016, 10/08/2016
  4023                              <1> 	; 29/07/2016, 30/07/2016
  4024                              <1> 	; 25/07/2016, 26/07/2016, 27/07/2016
  4025                              <1> 	; 02/07/2016, 18/07/2016, 23/07/2016
  4026                              <1> 	; 24/06/2016, 26/06/2016
  4027                              <1> 	; 29/05/2016 - TRDOS 386 (TRDOS v2.0)
  4028                              <1> SET_MODE:
  4029                              <1> 	; For 32 bit TRDOS and Retro UNIX 386:
  4030                              <1> 	;	valid video mode: 03h only!
  4031                              <1> 	;	(VGA modes will be selected with another routine)
  4032                              <1> 	;
  4033                              <1> 	; set_txt_mode ; 80*25 (16 fore colors, 8 back colors)
  4034                              <1> 
  4035                              <1> 	; 27/11/2020
  4036                              <1> 	
  4037                              <1> 	; Check if current mode is 
  4038                              <1> 	; Bochs/Plex86 VBE graphics mode
  4039 00001B2A 803D[DA6F0000]FF    <1> 	cmp	byte [CRT_MODE], 0FFh ; VESA VBE graphics mode
  4040 00001B31 7220                <1> 	jb	short _set_mode_      ; signature  	
  4041                              <1> 				      ; VBE mode number is in	 
  4042                              <1> 				      ; [video_mode] bit 0to8
  4043 00001B33 88C3                <1> 	mov	bl, al ; save video mode
  4044 00001B35 E89D240000          <1> 	call	dispi_get_enable
  4045 00001B3A 50                  <1> 	push	eax ; save current VBE dispi status 
  4046                              <1> 	; Disable Bochs/Plex86 VBE dispi
  4047                              <1> 	;mov	ax, 0 ; VBE_DISPI_DISABLED 
  4048 00001B3B 31C0                <1> 	xor	eax, eax ; 0 
  4049 00001B3D E869240000          <1> 	call	dispi_set_enable
  4050 00001B42 88D8                <1> 	mov	al, bl ; restore video mode
  4051 00001B44 E827000000          <1> 	call	_set_mode
  4052 00001B49 58                  <1> 	pop	eax ; restore current VBE dispi status 
  4053 00001B4A 7313                <1> 	jnc	short VIDEO_RETURN
  4054                              <1> 	; ! unimplemented or invalid video mode number !
  4055                              <1> 	; VBE dispi must be enabled again
  4056                              <1> 	; (return to run on current VBE graphics mode)
  4057                              <1> 	;;mov	al, [video_mode+1] ; bit 8 to 15
  4058                              <1> 	;;and	al, 0C0h ; isolate bit 14 and bit 15 
  4059                              <1> 	;;or	al, 1 ; VBE_DISPI_ENABLED
  4060 00001B4C E85A240000          <1> 	call	dispi_set_enable
  4061 00001B51 EB07                <1> 	jmp	short _video_func_err
  4062                              <1> 
  4063                              <1> _set_mode_:
  4064                              <1> 	; VGA bios (non-VBE) 'setmode' procedure
  4065                              <1> 
  4066                              <1> 	; 26/11/2020 (TRDOS v2.0.3)
  4067                              <1> 	
  4068                              <1> ;------------------------------------------------------
  4069                              <1> ; SET MODE					      :
  4070                              <1> ;	THIS ROUTINE INITIALIZES THE ATTACHMENT TO    :
  4071                              <1> ;	THE SELECTED MODE, THE SCREEN IS BLANKED.     :
  4072                              <1> ; INPUT						      :
  4073                              <1> ;	(AL) - MODE SELECTED (RANGE 0-7)	      :
  4074                              <1> ; OUTPUT					      :
  4075                              <1> ;	NONE					      :
  4076                              <1> ;------------------------------------------------------
  4077                              <1> 
  4078 00001B53 E818000000          <1> 	call	_set_mode ; 24/06/2016 (set_txt_mode)
  4079                              <1> 	; 26/11/2020
  4080 00001B58 7305                <1> 	jnc	short VIDEO_RETURN
  4081                              <1> 
  4082                              <1> 	; 26/11/2020
  4083                              <1> _video_func_err:
  4084 00001B5A 31C0                <1> 	xor	eax, eax ; function call failed
  4085 00001B5C 48                  <1> 	dec	eax  ; 0FFFFFFFFh ; - 1	
  4086 00001B5D EB05                <1> 	jmp	short _video_return	
  4087                              <1> 
  4088                              <1> ; 12/05/2016
  4089                              <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  4090                              <1> 
  4091                              <1> ;-----	NORMAL RETURN FROM ALL VIDEO RETURNS
  4092                              <1> 
  4093                              <1> VIDEO_RETURN:
  4094 00001B5F A1[B8960100]        <1> 	mov	eax, [video_eax] ; 12/05/2016
  4095                              <1> _video_return:
  4096 00001B64 FA                  <1> 	cli ; 02/01/2017
  4097 00001B65 5D                  <1> 	pop	ebp ; ******** ; 26/11/2020
  4098 00001B66 5F                  <1> 	pop	edi ; *******
  4099 00001B67 5E                  <1> 	pop	esi ; ******
  4100 00001B68 5B                  <1> 	pop	ebx ; *****
  4101                              <1> M15:	; VIDEO_RETURN_C
  4102                              <1> 	;;15/01/2017
  4103                              <1> 	; 02/01/2017
  4104                              <1> 	;;mov	byte [intflg], 0
  4105                              <1> 	;
  4106 00001B69 59                  <1> 	pop	ecx ; **** ; 26/11/2020
  4107 00001B6A 5A                  <1> 	pop	edx ; ***
  4108 00001B6B 1F                  <1> 	pop	ds  ; **
  4109 00001B6C 07                  <1> 	pop	es  ; *	; RECOVER SEGMENTS
  4110 00001B6D CF                  <1> 	iretd		; ALL DONE
  4111                              <1> 
  4112                              <1> set_txt_mode:
  4113                              <1> 	
  4114                              <1> 	; 29/07/2016
  4115                              <1> 	; 27/06/2016
  4116 00001B6E B003                <1> 	mov	al, 3 ; 26/11/2020 (bit 7 = 0)
  4117                              <1> 
  4118                              <1> 	; 17/11/2020 (TRDOS v2.0.3)
  4119                              <1> 	;mov	byte [noclearmem], 0
  4120                              <1> 
  4121                              <1> ; 10/08/2016
  4122                              <1> ; 08/08/2016
  4123                              <1> ; 30/07/2016
  4124                              <1> ; 29/07/2016
  4125                              <1> ; 25/07/2016, 26/07/2016, 27/07/2016
  4126                              <1> ; 07/07/2016, 18/07/2016, 23/07/2016
  4127                              <1> ; 02/07/2016, 03/07/2016, 04/07/2016
  4128                              <1> ; 26/06/2016
  4129                              <1> ; 24/06/2016 (set_txt_mode -> _set_mode)
  4130                              <1> ; 17/06/2016
  4131                              <1> ; 29/05/2016
  4132                              <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  4133                              <1> 
  4134                              <1> _set_mode:
  4135                              <1> 	; 12/12/2020
  4136                              <1> 	; 26/11/2020
  4137                              <1> 	; call from 'biosfn_set_video_mode'
  4138                              <1> 	;	(bochs/plex86 video bios code)
  4139                              <1> 	; call from 'SET_MODE'
  4140                              <1> 	;	(TRDOS 386 v2 default, IBM PC/AT rom bios code)
  4141                              <1> 	; continue from 'set_txt_mode'	
  4142                              <1> 
  4143                              <1> 	; INPUT:
  4144                              <1> 	;	al = VGA video mode
  4145                              <1> 	; RETURN:
  4146                              <1> 	;	cf = 1 -> video mode not implemented
  4147                              <1> 	;	cf = 0 -> OK
  4148                              <1> 	;
  4149                              <1> 	; Modified registers: eax, bx, ecx, esi, edi, (ebp)
  4150                              <1> 
  4151                              <1> 	; 17/11/2020 (TRDOS v2.0.3)
  4152                              <1> 	; no clear memory option 
  4153                              <1> 	; (from mode number byte bit 7)
  4154 00001B70 88C4                <1> 	mov	ah, al
  4155 00001B72 80E480              <1> 	and	ah, 80h
  4156                              <1> 	;mov	[noclearmem], al
  4157 00001B75 8825[C7960100]      <1> 	mov	[noclearmem], ah
  4158                              <1> 	;and	al, 7Fh ; clear bit 7
  4159                              <1> 	;;xor	[noclearmem], al ; clear bit 0 to 6
  4160                              <1> 	; 26/11/2020
  4161 00001B7B 30E0                <1> 	xor	al, ah ; and al, 7Fh
  4162                              <1> 
  4163                              <1> 	; 19/11/2020
  4164                              <1> 
  4165                              <1> 	; Video mode 03h action principle:
  4166                              <1> 	;
  4167                              <1> 	; for case 1:
  4168                              <1> 	; Current mode is 03h and next/requested mode is not 03h
  4169                              <1> 	;	- save mode (set mode 03h flag)
  4170                              <1> 	;	- save 8 video pages (which are will be restored)	
  4171                              <1> 	;	- save active page number (which will be reactivated)
  4172                              <1> 	;	- set active page to 0 always (no multi screen)
  4173                              <1> 	;	- save 8 cursor positions (which will be restored)
  4174                              <1> 	; 	- use 'noclearmem' option
  4175                              <1> 	;	[p_crt_mode] = 0 -> 03h 
  4176                              <1> 	;
  4177                              <1> 	; for case 2:
  4178                              <1> 	; Current mode is 03h and next/requested mode is also 03h
  4179                              <1> 	;	- clear active video page if 'noclearmem' is not set
  4180                              <1> 	;	[p_crt_mode] = 0 -> 80h -> 0
  4181                              <1> 	;
  4182                              <1> 	; for case 3:
  4183                              <1> 	; Current mode is not 03h and next/requested mode is 03h
  4184                              <1> 	;	- restore video pages (8 video pages were saved)	
  4185                              <1> 	;	- restore active page number (which were saved)
  4186                              <1> 	;	- restore 8 cursor positions (which were saved)
  4187                              <1> 	;	- reset/clear mode 03h flag
  4188                              <1> 	;	[p_crt_mode] = 03h -> 0
  4189                              <1> 	;
  4190                              <1> 	; for case 4:
  4191                              <1> 	; Current mode is not 03h and next/requested mode is not 03h
  4192                              <1> 	; 	- use 'noclearmem' option
  4193                              <1> 	;	- set active page to 0 always
  4194                              <1> 	;	[p_crt_mode] = 03h -> 83h -> 03h
  4195                              <1> 	;
  4196                              <1> 	; initial (boot time) values:
  4197                              <1> 	;	[p_crt_mode] = 0 ("there isn't a page backup, yet")
  4198                              <1> 	;	  [CRT_MODE] = 3 (kernel's starting mode)
  4199                              <1> 
  4200                              <1> 	; 26/11/2020
  4201 00001B7D 3C03                <1> 	cmp	al, 03h	    ; mode 3, 80x25 text, 16 colors
  4202 00001B7F 7515                <1> 	jne	short _sm_0 ; (default mode for TRDOS 386 mainprog)
  4203                              <1> 
  4204                              <1> 	; case 2 or case 3
  4205                              <1> 
  4206                              <1> 	; check current video mode if it is 03h
  4207 00001B81 08E4                <1> 	or	ah, ah ; 80h or 0 ('noclearmem' option)
  4208 00001B83 7521                <1> 	jnz	short _sm_1 ; do not clear display page
  4209                              <1>  	
  4210                              <1> 	; 26/11/2020
  4211                              <1> 	; Note:
  4212                              <1> 	; [CRT_MODE] = 0FFh for VESA VBE video modes
  4213                              <1> 	; [video_mode] = standard VGA and VESA VBE video modes
  4214                              <1> 	
  4215 00001B85 3805[DA6F0000]      <1> 	cmp	[CRT_MODE], al	; 03h
  4216 00001B8B 7520                <1> 	jne	short _sm_2	; case 3 ([p_crt_mode] = 03h)
  4217                              <1> 
  4218                              <1> 	; case 2
  4219                              <1> 
  4220                              <1> 	; [p_crt_mode] = 0
  4221                              <1> 
  4222                              <1> 	; 19/11/2020
  4223                              <1> 	; If '_set_mode' procedure is called for video mode 3
  4224                              <1> 	;     while video mode is 3, video page will be cleared
  4225                              <1> 	;     and cursor position of video page will be reset.	 
  4226                              <1> 
  4227                              <1> 	; clear display page
  4228 00001B8D C605[C5960100]80    <1> 	mov	byte [p_crt_mode], 80h ; clear page sign
  4229 00001B94 EB1C                <1> 	jmp	short _sm_3	; bypass save video page routine
  4230                              <1> _sm_0:
  4231                              <1> 	; case 1 or case 4
  4232                              <1> 
  4233                              <1> 	; 05/12/2020
  4234 00001B96 803D[DA6F0000]03    <1> 	cmp	byte [CRT_MODE], 3 ; is current mode 03h?
  4235 00001B9D 7507                <1> 	jne	short _sm_1	; case 4 ; [p_crt_mode] = 03h
  4236                              <1> 	
  4237                              <1> 	; case 1
  4238                              <1> 	; [p_crt_mode] = 0
  4239                              <1> 
  4240                              <1> 	; 19/11/2020
  4241                              <1> 	; If '_set_mode' procedure is called for a video mode
  4242                              <1> 	;     except video mode 3 while current video mode
  4243                              <1> 	;     is 3, all video pages of mode 3 will be copied 
  4244                              <1> 	;     to 98000h address as backup, before mode change.
  4245                              <1> 	
  4246                              <1> _sm_save_pm:
  4247                              <1> 	; 12/12/2020
  4248                              <1> 	;; 03/07/2016
  4249                              <1> 	;; save video pages
  4250                              <1> 	;mov	esi, 0B8000h
  4251                              <1> 	;mov	edi, 98000h ; 30/07/2016
  4252                              <1> 	;mov	ecx, (0B8000h-0B0000h)/4
  4253                              <1> 	;rep	movsd
  4254                              <1> 
  4255                              <1> 	;mov	byte [p_crt_mode], 3 ; previous mode, backup sign
  4256                              <1> 	;; 26/11/2020
  4257                              <1> 	;xchg	cl, [ACTIVE_PAGE]
  4258                              <1> 	;mov	[p_crt_page], cl  ; save as previous active page
  4259                              <1> 	;
  4260                              <1> 	;; save cursor positions
  4261                              <1> 	;mov	esi, CURSOR_POSN
  4262                              <1> 	;mov	edi, cursor_pposn ; cursor positions backup
  4263                              <1> 	;mov	cl, 4
  4264                              <1> 	;rep	movsd
  4265                              <1> 
  4266                              <1> 	; 12/12/2020
  4267 00001B9F E881020000          <1> 	call	save_mode3_multiscreen
  4268                              <1> 
  4269                              <1> 	; 29/07/2016
  4270                              <1> 	;;mov	[ACTIVE_PAGE], cl ; 0
  4271                              <1> 	;xchg	cl, [ACTIVE_PAGE]
  4272                              <1> 	;mov	[p_crt_page], cl  ; previous page (for mode 3)
  4273                              <1> 	
  4274                              <1> 	; [ACTIVE_PAGE] = 0 
  4275                              <1> 	
  4276 00001BA4 EB07                <1> 	jmp	short _sm_2	; case 1 - 19/11/2020
  4277                              <1> _sm_1:
  4278                              <1> 	; 26/11/2020
  4279                              <1> 	; 19/11/2020
  4280                              <1> 	
  4281                              <1> 	; case 4
  4282 00001BA6 800D[C5960100]80    <1> 	or	byte [p_crt_mode], 80h 
  4283                              <1> 				; here [p_crt_mode] must be 83h
  4284                              <1> 				;	  (for case 4)
  4285                              <1> 				; (because video mode 03h
  4286                              <1> 				; was changed before as in case 1)
  4287                              <1> 
  4288                              <1> _sm_2:	; case 4 (jump to _sm_2) - 19/11/2020 
  4289                              <1> 
  4290                              <1> 	; 19/11/2020
  4291                              <1> 	; case 3
  4292                              <1> 	; If '_set_mode' procedure is called for video mode 3
  4293                              <1> 	;     while video mode is not 3 and if there is video
  4294                              <1> 	;     page backup for video mode 3, all (of 8) mode 3
  4295                              <1> 	;     video pages will be restored from 98000h.
  4296                              <1> 
  4297 00001BAD A2[DA6F0000]        <1> 	mov	[CRT_MODE], al  ; save mode in global variable
  4298                              <1> _sm_3:
  4299                              <1> 	; 30/07/2016
  4300                              <1> 	; 26/07/2016
  4301                              <1> 	; 25/07/2016
  4302                              <1> 	; set_mode_vga:
  4303                              <1> 	; 18/07/2016
  4304                              <1> 	; 14/07/2016
  4305                              <1> 	; 09/07/2016
  4306                              <1> 	; 04/07/2016
  4307                              <1> 	; 03/07/2016 (TRDOS 386 = TRDOS v2.0)
  4308                              <1> 	; /// video mode 13h ///
  4309                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4310                              <1> 	; vgabios-0.7a (2011)
  4311                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4312                              <1> 	; 'vgabios.c', 'vgatables.h'
  4313                              <1> 	;
  4314                              <1> 	; Oracle VirtualBox 5.0.24 VGABios Source Code
  4315                              <1> 	; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
  4316                              <1> 	;
  4317 00001BB2 88C4                <1> 	mov	ah, al
  4318 00001BB4 B910000000          <1> 	mov	ecx, vga_mode_count
  4319 00001BB9 BE[F66F0000]        <1> 	mov	esi, vga_modes
  4320 00001BBE 31DB                <1> 	xor	ebx, ebx
  4321                              <1> _sm_4:
  4322 00001BC0 AC                  <1> 	lodsb
  4323 00001BC1 38C4                <1> 	cmp	ah, al
  4324 00001BC3 7406                <1> 	je	short _sm_5
  4325 00001BC5 FEC3                <1> 	inc	bl
  4326 00001BC7 E2F7                <1> 	loop	_sm_4
  4327                              <1> 
  4328                              <1> 	; UNIMPLEMENTED VIDEO MODE !
  4329                              <1> 	;xor	eax, eax
  4330                              <1>         ;mov	[video_eax], eax ; 0
  4331                              <1> 
  4332                              <1> 	; 26/11/2020
  4333 00001BC9 F9                  <1> 	stc	; unimplemented video mode ! (cf=1)
  4334                              <1> 
  4335 00001BCA C3                  <1> 	retn
  4336                              <1> 
  4337                              <1> ;-----	eBX POINTS TO CORRECT ROW OF INITIALIZATION TABLE
  4338                              <1> 
  4339                              <1> _sm_5: 	; 25/07/2016
  4340                              <1> 	;mov	esi, ebx
  4341                              <1> 	;add	esi, vga_memmodel
  4342                              <1> 	;mov	al, [esi]
  4343                              <1> 	; 19/11/2020
  4344 00001BCB 8A83[46700000]      <1> 	mov	al, [ebx+vga_memmodel]
  4345 00001BD1 A2[DE960100]        <1> 	mov	[VGA_MTYPE], al
  4346                              <1> 
  4347 00001BD6 89DF                <1> 	mov	edi, ebx
  4348 00001BD8 81C7[56700000]      <1> 	add	edi, vga_dac_s 	
  4349 00001BDE C0E302              <1> 	shl	bl, 2 ; byte -> dword
  4350 00001BE1 81C3[06700000]      <1> 	add	ebx, vga_mode_tbl_ptr
  4351                              <1> 
  4352                              <1> 	;mov	dword [VGA_BASE], 0B8000h
  4353                              <1> 	;cmp	ah, 0Dh ; [CRT_MODE]
  4354                              <1> 	;jb	short M9 
  4355                              <1> 	;mov	dword [VGA_BASE], 0A0000h
  4356                              <1> ;M9:
  4357 00001BE7 8B33                <1> 	mov	esi, [ebx]
  4358 00001BE9 89F3                <1> 	mov	ebx, esi
  4359 00001BEB 83C614              <1> 	add	esi, vga_p_cm_pos ; ebx + 20
  4360 00001BEE 668B06              <1> 	mov	ax, [esi]       ; get the cursor mode from the table
  4361 00001BF1 66A3[F36F0000]      <1> 	mov	[CURSOR_MODE], ax ; save cursor mode (initial value)
  4362                              <1> 	; al = 6, ah = 7
  4363                              <1> 	; al = 0Dh, ah = 0Eh ; 25/07/2016
  4364 00001BF7 E8A8020000          <1> 	call	cursor_shape_fix
  4365                              <1> 	; al = 14, ah = 15 (If [CHAR_HEIGHT] = 16)
  4366 00001BFC 668906              <1> 	mov	[esi], ax
  4367                              <1> 
  4368 00001BFF 56                  <1> 	push	esi ; *	
  4369                              <1> 
  4370 00001C00 8A25[E16F0000]      <1> 	mov	ah, [VGA_MODESET_CTL]
  4371 00001C06 80E408              <1> 	and	ah, 8 ; default palette loading ?
  4372 00001C09 7524                <1> 	jnz	short _sm_6
  4373 00001C0B 66BAC603            <1> 	mov	dx, 3C6h ; VGAREG_PEL_MASK (DAC mask register)
  4374 00001C0F B0FF                <1> 	mov	al, 0FFh ; PEL mask
  4375 00001C11 EE                  <1> 	out	dx, al
  4376 00001C12 8A27                <1> 	mov	ah, [edi] ; DAC model (selection number)
  4377 00001C14 E87E100000          <1> 	call	load_dac_palette
  4378                              <1> 	; ecx = 0
  4379 00001C19 F605[E16F0000]02    <1> 	test	byte [VGA_MODESET_CTL], 2 ; gray scale summing
  4380 00001C20 740D                <1> 	jz	short _sm_6
  4381 00001C22 53                  <1> 	push	ebx
  4382 00001C23 29DB                <1> 	sub	ebx, ebx ; sub bl, bl
  4383 00001C25 66B90001            <1>         mov     cx, 256 
  4384 00001C29 E8BC100000          <1> 	call	gray_scale_summing
  4385 00001C2E 5B                  <1> 	pop	ebx	
  4386                              <1> _sm_6:
  4387                              <1> 	; Reset Attribute Ctl flip-flop
  4388 00001C2F 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  4389 00001C33 EC                  <1>  	in	al, dx
  4390                              <1> 	; Set Attribute Ctl
  4391 00001C34 89DE                <1> 	mov	esi, ebx ; addr of params tbl for selected mode
  4392 00001C36 83C623              <1> 	add	esi, 35  ; actl regs
  4393 00001C39 30E4                <1> 	xor	ah, ah ; 0
  4394 00001C3B 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  4395                              <1> _sm_7:
  4396 00001C3F 88E0                <1> 	mov	al, ah
  4397 00001C41 EE                  <1> 	out	dx, al ; index
  4398 00001C42 AC                  <1> 	lodsb
  4399                              <1> 	; DX = 3C0h = VGAREG_ACTL_WRITE_DATA
  4400 00001C43 EE                  <1> 	out	dx, al ; value
  4401 00001C44 FEC4                <1> 	inc	ah
  4402 00001C46 80FC14              <1> 	cmp	ah, 20 ; number of actl registers
  4403 00001C49 72F4                <1> 	jb	short _sm_7
  4404                              <1> 	;
  4405 00001C4B 88E0                <1> 	mov	al, ah ; 20
  4406 00001C4D EE                  <1> 	out	dx, al ; index
  4407 00001C4E 28C0                <1> 	sub	al, al ; 0
  4408 00001C50 EE                  <1> 	out	dx, al ; value
  4409                              <1> 	;
  4410                              <1> 	; Set Sequencer Ctl
  4411 00001C51 89DE                <1> 	mov	esi, ebx ; addr of params tbl for selected mode
  4412 00001C53 83C605              <1> 	add	esi, 5 ; sequ regs
  4413                              <1> 	;
  4414 00001C56 66BAC403            <1> 	mov	dx, 3C4h  ; VGAREG_SEQU_ADDRESS
  4415 00001C5A EE                  <1> 	out	dx, al ; 0
  4416 00001C5B 6642                <1> 	inc	dx ; 3C5h ; VGAREG_SEQU_DATA
  4417 00001C5D B003                <1> 	mov	al, 3
  4418 00001C5F EE                  <1> 	out	dx, al
  4419 00001C60 B401                <1> 	mov	ah, 1	
  4420                              <1> _sm_8:
  4421 00001C62 88E0                <1> 	mov	al, ah
  4422                              <1> 	;mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  4423 00001C64 664A                <1> 	dec	dx
  4424 00001C66 EE                  <1> 	out	dx, al ; index
  4425 00001C67 AC                  <1> 	lodsb
  4426 00001C68 6642                <1> 	inc	dx ; 3C5h ; VGAREG_SEQU_DATA
  4427 00001C6A EE                  <1> 	out	dx, al
  4428 00001C6B 80FC04              <1> 	cmp	ah, 4 ; number of sequ regs
  4429 00001C6E 7304                <1> 	jnb	short _sm_9		
  4430 00001C70 FEC4                <1> 	inc	ah 
  4431 00001C72 EBEE                <1> 	jmp	short _sm_8
  4432                              <1> _sm_9:
  4433                              <1> 	; Set Grafx Ctl
  4434 00001C74 89DE                <1> 	mov	esi, ebx ; addr of params tbl for selected mode
  4435 00001C76 83C637              <1> 	add	esi, 55 ; grdc regs
  4436 00001C79 30E4                <1> 	xor	ah, ah ; 0
  4437                              <1> _sm_10:
  4438 00001C7B 88E0                <1> 	mov	al, ah
  4439 00001C7D 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4440 00001C81 EE                  <1> 	out	dx, al	
  4441 00001C82 AC                  <1> 	lodsb
  4442 00001C83 6642                <1> 	inc	dx ; 3CFh ; VGAREG_GRDC_DATA
  4443 00001C85 EE                  <1> 	out	dx, al
  4444 00001C86 FEC4                <1> 	inc	ah
  4445 00001C88 80FC09              <1> 	cmp	ah, 9 ; number of grdc regs
  4446 00001C8B 72EE                <1> 	jb	short _sm_10
  4447                              <1> 	;
  4448                              <1> 	; Disable CRTC write protection
  4449 00001C8D 66BAD403            <1> 	mov	dx, 3D4h  ; VGAREG_VGA_CRTC_ADDRESS
  4450                              <1> 	;mov	al, 11h
  4451                              <1> 	;our	dx, al
  4452                              <1> 	;inc	dx
  4453                              <1> 	;sub	al, al
  4454                              <1> 	;out	dx, al
  4455 00001C91 66B81100            <1> 	mov	ax, 11h
  4456 00001C95 66EF                <1> 	out	dx, ax
  4457 00001C97 89DE                <1> 	mov	esi, ebx ; addr of params tbl for selected mode
  4458 00001C99 83C60A              <1> 	add	esi, 10 ; crtc regs
  4459                              <1> 	; ah = 0
  4460                              <1> _sm_11:
  4461 00001C9C 88E0                <1> 	mov	al, ah
  4462                              <1> 	; dx = 3D4h = VGAREG_VGA_CRTC_ADDRESS
  4463 00001C9E EE                  <1> 	out	dx, al ; index
  4464 00001C9F AC                  <1> 	lodsb
  4465 00001CA0 6642                <1> 	inc	dx  ; VGAREG_VGA_CRTC_ADDRESS + 1
  4466 00001CA2 EE                  <1> 	out	dx, al ; value
  4467 00001CA3 80FC18              <1> 	cmp	ah, 24 ; number of crtc registers - 1
  4468 00001CA6 7306                <1> 	jnb	short _sm_12
  4469 00001CA8 FEC4                <1> 	inc	ah
  4470 00001CAA 664A                <1> 	dec	dx ; 3D4h
  4471 00001CAC EBEE                <1> 	jmp	short _sm_11
  4472                              <1> _sm_12:
  4473                              <1> 	; Set the misc register
  4474 00001CAE 66BACC03            <1> 	mov	dx, 3CCh ; VGAREG_READ_MISC_OUTPUT
  4475 00001CB2 8A4309              <1> 	mov	al, [ebx+9] ; misc reg
  4476 00001CB5 EE                  <1> 	out	dx, al
  4477                              <1> 	;
  4478                              <1> 	; Enable video
  4479 00001CB6 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  4480 00001CBA B020                <1> 	mov	al, 20h  
  4481 00001CBC EE                  <1>         out     dx, al   ; set bit 5 to 1
  4482 00001CBD 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  4483 00001CC1 EC                  <1> 	in	al, dx
  4484                              <1> 	;
  4485                              <1> 	; 17/11/2020
  4486                              <1> 	;cmp	byte [noclearmem], 0
  4487                              <1>         ;ja	short _sm_15
  4488                              <1> 
  4489 00001CC2 F605[C7960100]80    <1> 	test	byte [noclearmem], 80h
  4490 00001CC9 7540                <1> 	jnz	short _sm_15	
  4491                              <1> 
  4492                              <1> 	; 29/07/2016
  4493 00001CCB 31C0                <1> 	xor	eax, eax
  4494 00001CCD B900400000          <1> 	mov	ecx, 4000h ; 16K words (32K)
  4495 00001CD2 803D[DE960100]02    <1> 	cmp     byte [VGA_MTYPE], 2  ; CTEXT, MTEXT, CGA
  4496 00001CD9 7715                <1> 	ja	short _sm_14    ; no ? (0A0000h)
  4497 00001CDB BF00800B00          <1> 	mov	edi, 0B8000h
  4498 00001CE0 7409                <1> 	je	short _sm_13	; CGA graphics mode
  4499                              <1> 	; 08/08/2016
  4500 00001CE2 A3[DA960100]        <1> 	mov	[VGA_INT43H], eax ; 0 ; default font 
  4501 00001CE7 66B82007            <1> 	mov	ax, 0720h	; CGA text mode
  4502                              <1> _sm_13:
  4503 00001CEB F366AB              <1> 	rep	stosw
  4504 00001CEE EB1B                <1> 	jmp	short _sm_15
  4505                              <1> 
  4506                              <1> _sm_14:
  4507 00001CF0 BF00000A00          <1> 	mov	edi, 0A0000h
  4508                              <1> 	; ecx = 16384 dwords (64K)
  4509 00001CF5 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  4510 00001CF9 B002                <1> 	mov	al, 2
  4511 00001CFB EE                  <1> 	out	dx, al
  4512                              <1> 	;mov	dx, 3C5h ; VGAREG_SEQU_DATA
  4513 00001CFC 6642                <1> 	inc	dx
  4514 00001CFE EC                  <1> 	in	al, dx ; mmask
  4515 00001CFF 6650                <1> 	push	ax
  4516 00001D01 B00F                <1> 	mov	al, 0Fh ; all planes
  4517 00001D03 EE                  <1> 	out	dx, al
  4518 00001D04 30C0                <1> 	xor	al, al ; 0
  4519 00001D06 F3AB                <1> 	rep	stosd	; ecx = 163684 (64K)
  4520 00001D08 6658                <1> 	pop	ax
  4521 00001D0A EE                  <1> 	out	dx, al  ; mmask
  4522                              <1> _sm_15:
  4523                              <1> 	; ebx = addr of params tbl for selected mode
  4524                              <1> 	; 10/08/2016
  4525 00001D0B 668B03              <1> 	mov	ax, [ebx] ; num of columns, 'twidth'
  4526 00001D0E A2[DC6F0000]        <1> 	mov	[CRT_COLS], al
  4527                              <1> 	;; 26/07/2016
  4528                              <1> 	;; CRTC_ADDRESS = 3D4h (always)
  4529                              <1> 	;mov	ah, [ebx+1] ; num of rows, 'theightm1'
  4530 00001D13 FEC4                <1> 	inc	ah ; 09/07/2016
  4531 00001D15 8825[E26F0000]      <1> 	mov	[VGA_ROWS], ah
  4532                              <1> 	; 10/08/2016
  4533 00001D1B 8A4302              <1> 	mov	al, [ebx+2]
  4534 00001D1E A2[DE6F0000]        <1> 	mov	[CHAR_HEIGHT], al 
  4535                              <1> 	; 29/07/2016
  4536                              <1> 	; length of regen buffer in bytes
  4537 00001D23 668B4B03            <1> 	mov	cx, [ebx+3] ; 'slength_l'
  4538 00001D27 66890D[C8960100]    <1> 	mov	[CRT_LEN], cx
  4539                              <1> 	;
  4540                              <1> 	; 27/07/2016
  4541 00001D2E 30E4                <1> 	xor	ah, ah
  4542 00001D30 A0[5E8A0100]        <1> 	mov	al, [ACTIVE_PAGE] ; may be > 0 for mode 3
  4543                              <1> 	;mul	word [CRT_LEN] ; 4096 for mode 3
  4544 00001D35 66F7E1              <1> 	mul	cx ; 29/07/2016
  4545 00001D38 66A3[4C8A0100]      <1> 	mov	[CRT_START], ax
  4546                              <1> 	;
  4547 00001D3E B060                <1> 	mov	al, 60h
  4548                              <1> 	;cmp	byte [noclearmem], 0
  4549                              <1> 	;jna	short _sm_16
  4550                              <1> 	;add	al, 80h
  4551 00001D40 0A05[C7960100]      <1> 	or	al, [noclearmem] ; 17/11/2020
  4552                              <1> _sm_16:
  4553 00001D46 A2[DF6F0000]        <1> 	mov	[VGA_VIDEO_CTL], al
  4554 00001D4B C605[E06F0000]F9    <1> 	mov	byte [VGA_SWITCHES], 0F9h
  4555 00001D52 8025[E16F0000]7F    <1> 	and	byte [VGA_MODESET_CTL], 7Fh
  4556                              <1> 
  4557 00001D59 5E                  <1> 	pop	esi ; *
  4558                              <1> 
  4559                              <1> 	; 26/07/2016
  4560                              <1> 	; 07/07/2016
  4561 00001D5A 668B0D[F36F0000]    <1> 	mov	cx, [CURSOR_MODE] ; restore cursor mode (initial value)
  4562 00001D61 66870E              <1> 	xchg	cx, [esi] ; cl = start line, ch = end line
  4563                              <1> 			  ; reset to initial value
  4564 00001D64 86E9                <1> 	xchg 	ch, cl  ; ch = start line, cl = end line  
  4565 00001D66 66890D[F36F0000]    <1> 	mov	[CURSOR_MODE], cx ; save (fixed) cursor mode
  4566                              <1> 
  4567                              <1> 	; 27/07/2016
  4568 00001D6D 803D[DE960100]02    <1> 	cmp	byte [VGA_MTYPE], 2 ; CTEXT, MTEXT
  4569 00001D74 7317                <1> 	jnb	short _sm_17
  4570                              <1> 
  4571                              <1> 	; Set cursor shape
  4572                              <1> 	;mov	cx, 0607h
  4573                              <1> 	;call	_set_ctype
  4574                              <1> 
  4575                              <1> 	; 29/07/2016
  4576 00001D76 B40A                <1> 	mov	ah, 10	; 6845 register for cursor set
  4577 00001D78 E84D060000          <1> 	call	m16	; output cx register
  4578                              <1> 	
  4579                              <1> 	; 25/07/2016
  4580 00001D7D 803D[DA6F0000]03    <1>         cmp     byte [CRT_MODE], 03h
  4581 00001D84 7507                <1> 	jne	short _sm_17
  4582                              <1> 	; 26/07/2016
  4583                              <1> 
  4584 00001D86 A0[5E8A0100]        <1> 	mov	al, [ACTIVE_PAGE]
  4585 00001D8B EB0B                <1> 	jmp	short _sm_18
  4586                              <1> _sm_17:
  4587                              <1> 	; Set cursor pos for page 0..7
  4588                              <1> 	;sub	ax, ax ; eax = 0
  4589 00001D8D 29C0                <1> 	sub	eax, eax ; 17/11/2020
  4590 00001D8F BF[4E8A0100]        <1> 	mov	edi, CURSOR_POSN
  4591 00001D94 AB                  <1> 	stosd	
  4592 00001D95 AB                  <1> 	stosd
  4593 00001D96 AB                  <1> 	stosd
  4594 00001D97 AB                  <1> 	stosd
  4595                              <1> 	;; Set active page 0
  4596                              <1> 	;mov	[ACTIVE_PAGE], al ; 0
  4597                              <1> _sm_18:
  4598                              <1> 	; 29/07/2016
  4599 00001D98 803D[DE960100]02    <1> 	cmp	byte [VGA_MTYPE], 2 ; CTEXT, MTEXT
  4600 00001D9F 737F                <1>         jnb	_sm_23
  4601                              <1> 
  4602                              <1> 	;cmp	byte [CHAR_HEIGHT], 16
  4603                              <1> 	;je	short _sm_19
  4604                              <1> 
  4605                              <1>  	;; copy and activate 8x16 font
  4606                              <1> 	
  4607                              <1> 	; 26/07/2016
  4608 00001DA1 B004                <1> 	mov	al, 04h
  4609                              <1> 	;sub	bl, bl
  4610                              <1> 	; AX = 1104H ; Load ROM 8x16 Character Set
  4611                              <1> 	; (BL = font block to load (EGA: 0-3; VGA: 0-7))
  4612 00001DA3 E8E8160000          <1> 	call	load_text_8_16_pat
  4613                              <1> 
  4614                              <1> 	; video_func_1103h:
  4615                              <1> 	; biosfn_set_text_block_specifier:
  4616                              <1> 	; BL = font block selector code	
  4617                              <1> 	; NOTE: TRDOS 386 only uses and sets font block 0
  4618                              <1> 	; (It is as BL = 0 for TRDOS 386)
  4619 00001DA8 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  4620                              <1> 	;;mov	ah, bl
  4621                              <1> 	;sub	ah, ah ; 0
  4622                              <1> 	;mov	al, 03h
  4623                              <1> 	; 19/11/2020
  4624 00001DAC 66B80300            <1> 	mov	ax, 03h
  4625 00001DB0 66EF                <1> 	out	dx, ax
  4626                              <1> _sm_19:
  4627                              <1> 	; 29/07/2016
  4628                              <1> 	; 26/07/2016
  4629                              <1> 	; 24/06/2016
  4630                              <1> 	;mov	edi, 0B8000h
  4631                              <1> 	;mov	cx, 4000h ; 16K words (32K)
  4632                              <1> 	;
  4633 00001DB2 30C0                <1> 	xor	al, al
  4634 00001DB4 3805[C5960100]      <1>         cmp     [p_crt_mode], al ; 0 
  4635 00001DBA 7705                <1>         ja      short _sm_20 ; 03h, 80h or 83h
  4636                              <1> 
  4637                              <1> 	; case 1 - 19/11/2020
  4638                              <1> 	;
  4639                              <1> 	; If [pc_crt_mode] = 0, that means, previous mode is 03h
  4640                              <1> 	; and current mode is not 03h (case 1)
  4641                              <1> 
  4642                              <1> 	; 30/07/2016
  4643                              <1> 	; 24/06/2016
  4644                              <1> 	; TRDOS 386 (TRDOS v2) 'set mode' modification
  4645                              <1> 	; (for multiscreen feature):
  4646                              <1> 	; If '_set_mode' procedure is called for video mode 3
  4647                              <1> 	;     while video mode is 3, video page will be cleared
  4648                              <1> 	;     and cursor position of video page will be reset.
  4649                              <1> 	; If '_set_mode' procedure is called for a video mode
  4650                              <1> 	;     except video mode 3, while current video mode
  4651                              <1> 	;     is 3, all video pages of mode 3 will be copied 
  4652                              <1> 	;     to 98000h address as backup, before mode change.
  4653                              <1> 	; If '_set_mode' procedure is called for video mode 3
  4654                              <1> 	;     while video mode is not 3 and if there is video
  4655                              <1> 	;     page backup for video mode 3, all (of 8) mode 3
  4656                              <1> 	;     video pages will be restored from 98000h.
  4657                              <1> 
  4658                              <1> 	; 19/11/2020
  4659                              <1> 	;mov	[ACTIVE_PAGE], al ; 0
  4660                              <1> 
  4661                              <1> 	; Here,
  4662                              <1> 	; video memory already cleared if [noclearmem] <> 80h
  4663                              <1> 	
  4664                              <1> 	;mov	ax, 0720h
  4665                              <1> 	;mov	cx, 4000h ; 16K words (32K)
  4666                              <1> 	;mov	edi, 0B8000h
  4667                              <1> 	;rep	stosw
  4668                              <1> 	;sub	al, al
  4669                              <1> 	
  4670                              <1> 	;jmp	short _sm_23
  4671                              <1> 
  4672                              <1> 	; Set hardware side for the new active video page
  4673                              <1>  
  4674 00001DBC E9FB010000          <1> 	jmp	_set_active_page ; 19/11/2020	
  4675                              <1> 
  4676                              <1> _sm_20:
  4677                              <1> 	; 19/11/2020
  4678                              <1> 	; case 2 or case 3 or case 4 - 19/11/2020
  4679                              <1> 	
  4680                              <1> 	; 19/11/2020
  4681 00001DC1 803D[DA6F0000]03    <1> 	cmp	byte [CRT_MODE], 3  ; new video mode
  4682 00001DC8 754F                <1> 	jne	short _sm_22 ; al = 0 (& video mode <> 03h)
  4683                              <1> 			     ; case 4 - 19/11/2020
  4684                              <1> 			     ; ([p_crt_mode] = 83h)
  4685                              <1> 
  4686                              <1> 	; case 2 or case 3 - 19/11/2020	
  4687                              <1> 
  4688                              <1> 	;movzx	ebx, byte [ACTIVE_PAGE]
  4689                              <1> 	; 19/11/2020
  4690 00001DCA A0[C6960100]        <1> 	mov	al, [p_crt_page] ; previous mode 3 active page
  4691                              <1> 	;movzx	ebx, al
  4692                              <1> 	;shl	bl, 1 ; * 2
  4693                              <1> 	;add	ebx, CURSOR_POSN
  4694                              <1> 
  4695                              <1> 	; 29/07/2016
  4696 00001DCF F605[C5960100]7F    <1> 	test    byte [p_crt_mode], 7Fh ; 83h or 80h or 03h
  4697 00001DD6 740F                <1> 	jz	short _sm_21	; do not restore video pages
  4698                              <1> 				; case 2 - 19/11/2020 
  4699                              <1> 	; case 3 - 19/11/2020
  4700                              <1> 
  4701                              <1> 	; ([p_crt_mode] = 03h)
  4702                              <1> 
  4703                              <1> 	; New video mode is 3 while current video mode is not 3
  4704                              <1> 	; (multi screen) video pages will be restored from 098000h
  4705                              <1> 
  4706                              <1> 	; 19/11/2020
  4707 00001DD8 A2[5E8A0100]        <1> 	mov	[ACTIVE_PAGE], al ; current mode 3 active page
  4708                              <1> 
  4709                              <1> 	; 12/12/2020
  4710                              <1> 	;; restore video pages
  4711                              <1> 	;mov	esi, 98000h ; 30/07/2016 
  4712                              <1> 	;mov	edi, 0B8000h
  4713                              <1> 	;mov	cx, 2000h ; 8K dwords (32K)
  4714                              <1> 	;rep	movsd
  4715                              <1> 	;
  4716                              <1> 	;; 19/11/2020
  4717                              <1> 	;mov	[p_crt_mode], cl ; reset ('case 3' end condition)
  4718                              <1> 	;
  4719                              <1> 	;; restore cursor positions
  4720                              <1> 	;mov	esi, cursor_pposn
  4721                              <1> 	;mov	edi, CURSOR_POSN
  4722                              <1> 	;;mov	ecx, 4	; restore all cursor positions (16 bytes)
  4723                              <1> 	;mov	cl, 4
  4724                              <1> 	;rep 	movsd
  4725                              <1> 	
  4726                              <1> 	; 12/12/2020
  4727 00001DDD E89C000000          <1> 	call	_restore_mode3_multiscreen
  4728                              <1> 
  4729                              <1> 	;jmp	short _sm_23 ; do not clear current video pages
  4730                              <1> 
  4731                              <1> 	; 19/11/2020
  4732 00001DE2 E9D5010000          <1> 	jmp	_set_active_page
  4733                              <1> 
  4734                              <1> _sm_21:
  4735                              <1> 	; 19/11/2020
  4736                              <1> 	; case 2 
  4737                              <1> 	;
  4738                              <1> 	; ([p_crt_mode] = 80h)
  4739                              <1> 	;
  4740                              <1> 	; User has requested to set video mode 3 again while
  4741                              <1> 	; current video mode is 3.. that means, set mode 03h
  4742                              <1> 	; parameters again and clear video page.
  4743                              <1> 	; ('noclearmem' option effects the result) 
  4744                              <1> 	
  4745                              <1> 	; 19/11/2020
  4746 00001DE7 F605[C7960100]80    <1> 	test	byte [noclearmem], 80h
  4747 00001DEE 7529                <1> 	jnz	short _sm_22	; 'do not clear video memory'
  4748                              <1> 				; continue with current text
  4749                              <1> 				; (user's option/choice) 
  4750                              <1> 	; clear video page
  4751                              <1> 	;mov	cx, [CRT_LEN] ; 4096
  4752                              <1> 	;shr	cx, 1 ; 2048 ; 16/11/2020
  4753 00001DF0 66B82007            <1> 	mov	ax, 0720h
  4754                              <1> 	; 26/11/2020
  4755 00001DF4 B900080000          <1> 	mov	ecx, 2048 ; 4096/2
  4756 00001DF9 BF00800B00          <1> 	mov	edi, 0B8000h ; [crt_base]
  4757 00001DFE 66033D[4C8A0100]    <1> 	add	di, [CRT_START]
  4758 00001E05 F366AB              <1> 	rep	stosw	; FILL THE REGEN BUFFER WITH BLANKS
  4759                              <1> 	;
  4760                              <1> 	; 19/11/2020
  4761 00001E08 A0[5E8A0100]        <1> 	mov	al, [ACTIVE_PAGE] ; 0 to 7 (for video mode 3)
  4762 00001E0D 0FB6D8              <1> 	movzx	ebx, al
  4763 00001E10 D0E3                <1> 	shl	bl, 1
  4764 00001E12 66898B[4E8A0100]    <1> 	mov	[ebx+CURSOR_POSN], cx ; reset cursor position
  4765                              <1> _sm_22:
  4766                              <1> 	;mov	[p_crt_mode], al ; 0 ; reset
  4767                              <1> 	; 19/11/2020
  4768                              <1> 	;and	byte [p_crt_mode], 3 ; 83h -> 3, 80h -> 0  
  4769 00001E19 8025[C5960100]7F    <1> 	and	byte [p_crt_mode], 7Fh ; 83h -> 3, 80h -> 0
  4770                              <1> _sm_23:
  4771                              <1> 	; al = video page number
  4772                              <1> 	; [CRT_LEN] = length of regen buffer in bytes
  4773                              <1> 	;call	_set_active_page
  4774                              <1> 	; 16/11/2020
  4775 00001E20 E997010000          <1> 	jmp	_set_active_page
  4776                              <1> 
  4777                              <1> ;-----	NORMAL RETURN FROM ALL VIDEO RETURNS
  4778                              <1> 	;retn
  4779                              <1> 
  4780                              <1> save_mode3_multiscreen:
  4781                              <1> 	; 12/12/2020 (TRDOS v2.0.3)
  4782                              <1> 	; save mode 03h video pages and cursor positions
  4783                              <1> 	;
  4784                              <1> 	; Modified registers: ecx (=0), esi, edi
  4785                              <1> 	
  4786                              <1> 	; 12/12/2020
  4787                              <1> 	; moved here from '_set_mode'	
  4788                              <1> 	; 03/07/2016
  4789                              <1> 	; save video pages
  4790 00001E25 BE00800B00          <1> 	mov	esi, 0B8000h
  4791 00001E2A BF00800900          <1> 	mov	edi, 98000h ; 30/07/2016
  4792 00001E2F B900200000          <1> 	mov	ecx, (0B8000h-0B0000h)/4
  4793 00001E34 F3A5                <1> 	rep	movsd
  4794                              <1> 	
  4795 00001E36 C605[C5960100]03    <1> 	mov	byte [p_crt_mode], 3 ; previous mode, backup sign
  4796                              <1> 	; 26/11/2020
  4797 00001E3D 860D[5E8A0100]      <1> 	xchg	cl, [ACTIVE_PAGE]
  4798 00001E43 880D[C6960100]      <1> 	mov	[p_crt_page], cl  ; save as previous active page
  4799                              <1> 	
  4800                              <1> 	; save cursor positions
  4801 00001E49 BE[4E8A0100]        <1> 	mov	esi, CURSOR_POSN
  4802 00001E4E BF[CA960100]        <1> 	mov	edi, cursor_pposn ; cursor positions backup
  4803 00001E53 B104                <1> 	mov	cl, 4
  4804 00001E55 F3A5                <1> 	rep	movsd
  4805 00001E57 C3                  <1> 	retn
  4806                              <1> 
  4807                              <1> restore_mode3_multiscreen:
  4808                              <1> 	; 12/12/2020 (TRDOS v2.0.3)
  4809                              <1> 	; restore mode 03h video pages and cursor positions
  4810                              <1> 	;
  4811                              <1> 	; Input:
  4812                              <1> 	;    settings from the last 'save_mode3_multiscreen'
  4813                              <1> 	;
  4814                              <1> 	; Output: 
  4815                              <1> 	;    AL = active video page = [ACTIVE_PAGE]
  4816                              <1> 	;
  4817                              <1> 	; Modified registers: al, ecx (=0), esi, edi
  4818                              <1> 
  4819 00001E58 A0[C6960100]        <1> 	mov	al, [p_crt_page] ; previous mode 3 active page
  4820 00001E5D A2[5E8A0100]        <1> 	mov	[ACTIVE_PAGE], al ; current mode 3 active page
  4821                              <1> 
  4822                              <1> 	; 12/12/2020
  4823                              <1> 	; moved here from 'vesa_vbe3_pmi'	
  4824                              <1> 
  4825                              <1> 	; 07/12/2020
  4826                              <1> 	; restore CRT_START according to ACTIVE_PAGE
  4827                              <1> 	;mov	[CRT_START], cx ; 0
  4828                              <1> 	; 12/12/2020
  4829 00001E62 66C705[4C8A0100]00- <1> 	mov	word [CRT_START], 0
  4829 00001E6A 00                  <1>
  4830                              <1> 
  4831                              <1> 	; check active page and set it again if it is not 0
  4832 00001E6B 08C0                <1> 	or	al, al
  4833                              <1> 	;;jz	short vbe3_pmi_7
  4834                              <1> 	;jz	short _restore_mode3_multiscreen
  4835 00001E6D 740F                <1> 	jz	short r_m3_ms_1
  4836 00001E6F 88C1                <1> 	mov	cl, al
  4837                              <1> ;vbe3_pmi_5:
  4838                              <1> r_m3_ms_0:
  4839 00001E71 668105[4C8A0100]00- <1> 	add	word [CRT_START], 4096
  4839 00001E79 10                  <1>
  4840 00001E7A FEC9                <1> 	dec	cl
  4841                              <1> 	;jnz	short vbe3_pmi_5
  4842 00001E7C 75F3                <1> 	jnz	short r_m3_ms_0
  4843                              <1> r_m3_ms_1:
  4844                              <1> 	; 12/12/2020
  4845                              <1> 	; moved here from '_set_mode'	
  4846                              <1> _restore_mode3_multiscreen:
  4847                              <1> 	; Modified registers: ecx, esi, edi
  4848                              <1> 
  4849                              <1> 	; restore video pages
  4850 00001E7E BE00800900          <1> 	mov	esi, 98000h ; 30/07/2016 
  4851 00001E83 BF00800B00          <1> 	mov	edi, 0B8000h
  4852                              <1> 	;mov	cx, 2000h ; 8K dwords (32K)
  4853 00001E88 B900200000          <1> 	mov	ecx, 2000h
  4854 00001E8D F3A5                <1> 	rep	movsd
  4855                              <1> 
  4856                              <1> 	; 19/11/2020
  4857 00001E8F 880D[C5960100]      <1> 	mov	[p_crt_mode], cl ; reset ('case 3' end condition)
  4858                              <1> 
  4859                              <1> 	; restore cursor positions
  4860 00001E95 BE[CA960100]        <1> 	mov	esi, cursor_pposn
  4861 00001E9A BF[4E8A0100]        <1> 	mov	edi, CURSOR_POSN
  4862                              <1> 	;mov	ecx, 4	; restore all cursor positions (16 bytes)
  4863 00001E9F B104                <1> 	mov	cl, 4
  4864 00001EA1 F3A5                <1> 	rep 	movsd
  4865 00001EA3 C3                  <1> 	retn
  4866                              <1> 
  4867                              <1> cursor_shape_fix:
  4868                              <1> 	; 07/07/2016
  4869                              <1> 	; (Cursor start and cursor end line values -6,7-
  4870                              <1> 	; will be fixed depending on character height)
  4871                              <1> 	;
  4872                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4873                              <1> 	; vgabios-0.7a (2011)
  4874                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4875                              <1> 	; 'vgabios.c', ' biosfn_set_cursor_shape (CH,CL)'
  4876                              <1> 	;
  4877                              <1> 	; INPUT ->
  4878                              <1> 	;	AL = cursor start line (=6)
  4879                              <1> 	;	AH = cursor end line (=7)
  4880                              <1> 	; OUTPUT ->
  4881                              <1> 	;	AL = cursor start line (=14)
  4882                              <1> 	;	AH = cursor end line (=15)
  4883                              <1> 	;
  4884                              <1> 	;; if((modeset_ctl&0x01)&&(cheight>8)&&(CL<8)&&(CH<0x20))
  4885                              <1> 
  4886                              <1> 	;test	byte [VGA_MODESET_CTL], 1 ; VGA active
  4887                              <1> 	;jz	short csf_3
  4888 00001EA4 803D[DE6F0000]08    <1> 	cmp	byte [CHAR_HEIGHT], 8
  4889 00001EAB 7649                <1> 	jna	short csf_3
  4890 00001EAD 80FC08              <1> 	cmp	ah, 8
  4891 00001EB0 7344                <1> 	jnb	short csf_3
  4892 00001EB2 3C20                <1> 	cmp	al, 20h
  4893 00001EB4 7340                <1> 	jnb	short csf_3
  4894                              <1> 	;
  4895 00001EB6 6650                <1> 	push	ax
  4896                              <1> 	; {
  4897                              <1>    	; if(CL!=(CH+1))	
  4898 00001EB8 FEC0                <1> 	inc	al
  4899 00001EBA 38C4                <1> 	cmp	ah, al   ; ah != al + 1
  4900 00001EBC 740F                <1>         je      short csf_1
  4901                              <1> 	; CH = ((CH+1) * cheight / 8) -1;
  4902 00001EBE 8A25[DE6F0000]      <1> 	mov	ah, [CHAR_HEIGHT]
  4903 00001EC4 F6E4                <1> 	mul	ah
  4904 00001EC6 C0E803              <1> 	shr	al, 3 ; / 8
  4905 00001EC9 FEC8                <1> 	dec	al ; - 1
  4906 00001ECB EB0E                <1> 	jmp	short csf_2 
  4907                              <1> csf_1: 	
  4908                              <1>  	; }
  4909                              <1>    	; else		; ah = al + 1
  4910                              <1>     	; {
  4911 00001ECD FEC4                <1> 	inc	ah	; ah = ah + 1   
  4912                              <1> 	; CH = ((CL+1) * cheight / 8) - 2;
  4913 00001ECF A0[DE6F0000]        <1> 	mov	al, [CHAR_HEIGHT]
  4914 00001ED4 F6E4                <1> 	mul	ah
  4915 00001ED6 C0E803              <1> 	shr	al, 3 ; / 8
  4916 00001ED9 2C02                <1> 	sub	al, 2 ; - 2
  4917                              <1> 	; al = 14 (if [CHAR_HEIGHT] = 16)
  4918                              <1> csf_2:
  4919 00001EDB 880424              <1> 	mov	[esp], al
  4920 00001EDE 8A642401            <1> 	mov	ah, [esp+1]
  4921                              <1> 	; CL = ((CL+1) * cheight / 8) - 1;
  4922 00001EE2 FEC4                <1> 	inc	ah 
  4923 00001EE4 A0[DE6F0000]        <1> 	mov	al, [CHAR_HEIGHT]
  4924 00001EE9 F6E4                <1> 	mul	ah
  4925 00001EEB C0E803              <1> 	shr	al, 3 ; / 8
  4926 00001EEE FEC8                <1> 	dec	al ; - 1
  4927 00001EF0 88442401            <1> 	mov	[esp+1], al
  4928                              <1> 	; ah = 15 (if [CHAR_HEIGHT] = 16)
  4929                              <1> 	;
  4930 00001EF4 6658                <1> 	pop	ax
  4931                              <1> csf_3:
  4932 00001EF6 C3                  <1> 	retn
  4933                              <1> 
  4934                              <1> SET_CTYPE:
  4935                              <1> 	; 12/09/2016
  4936                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  4937 00001EF7 803D[DA6F0000]07    <1> 	cmp	byte [CRT_MODE], 7
  4938 00001EFE 0F875BFCFFFF        <1> 	ja	VIDEO_RETURN ; 12/09/2016
  4939 00001F04 E805000000          <1> 	call	_set_ctype
  4940 00001F09 E951FCFFFF          <1>         jmp     VIDEO_RETURN
  4941                              <1> 
  4942                              <1> _set_ctype:
  4943                              <1> 	; 02/09/2014 (Retro UNIX 386 v1)
  4944                              <1> 	;
  4945                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  4946                              <1> 
  4947                              <1> 	; (CH) = BITS 4-0 = START LINE FOR CURSOR
  4948                              <1> 	;  ** HARDWARE WILL ALWAYS CAUSE BLINK
  4949                              <1> 	;  ** SETTING BIT 5 OR 6 WILL CAUSE ERRATIC BLINKING
  4950                              <1> 	;     OR NO CURSOR AT ALL
  4951                              <1> 	; (CL) = BITS 4-0 = END LINE FOR CURSOR
  4952                              <1> 
  4953                              <1> ;------------------------------------------------
  4954                              <1> ; SET_CTYPE
  4955                              <1> ;	THIS ROUTINE SETS THE CURSOR VALUE
  4956                              <1> ; INPUT
  4957                              <1> ;	(CX) HAS CURSOR VALUE CH-START LINE, CL-STOP LINE
  4958                              <1> ; OUTPUT	
  4959                              <1> ;	NONE
  4960                              <1> ;------------------------------------------------
  4961                              <1> 
  4962                              <1> 	; 07/07/2016
  4963                              <1> 	; Fixing cursor start and stop line depending on
  4964                              <1> 	; current character height (=16)
  4965                              <1> 	; (Note: Default/initial values are 6 and 7.
  4966                              <1> 	; If set values are 6 (start) & 7 (stop) and 
  4967                              <1> 	; [CHAR_HEIGHT] = 16 :
  4968                              <1> 	; After fixing, start line will be 14, stop line
  4969                              <1> 	; will be 15.)
  4970 00001F0E 6689C8              <1> 	mov	ax, cx
  4971 00001F11 86C4                <1> 	xchg	al, ah
  4972                              <1> 	; AL = start line, AH = stop line
  4973 00001F13 E88CFFFFFF          <1> 	call	cursor_shape_fix
  4974                              <1> 	; AL = start line (fixed), AH = stop line (fixed)
  4975 00001F18 6689C1              <1> 	mov	cx, ax
  4976 00001F1B 86E9                <1> 	xchg	ch, cl
  4977                              <1> 	; CH = start line (fixed), CL = stop line (fixed)
  4978                              <1> 	;
  4979 00001F1D B40A                <1> 	mov	ah, 10	; 6845 register for cursor set
  4980 00001F1F 66890D[F36F0000]    <1> 	mov	[CURSOR_MODE], cx ; save in data area
  4981                              <1> 	;call	m16	; output cx register
  4982                              <1> 	;retn
  4983 00001F26 E99F040000          <1>         jmp     m16
  4984                              <1> 
  4985                              <1> SET_CPOS:
  4986                              <1> 	; 12/09/2016
  4987                              <1> 	; 07/07/2016
  4988                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  4989 00001F2B 80FF07              <1> 	cmp	bh, 7 ; video page > 7 ; 07/07/2016
  4990 00001F2E 0F872BFCFFFF        <1> 	ja	VIDEO_RETURN
  4991                              <1> 	;
  4992 00001F34 803D[DA6F0000]07    <1> 	cmp	byte [CRT_MODE], 7
  4993 00001F3B 770A                <1> 	ja	short vga_set_cpos ; 12/09/2016	
  4994 00001F3D E85D040000          <1> 	call	_set_cpos
  4995 00001F42 E918FCFFFF          <1>         jmp     VIDEO_RETURN
  4996                              <1> 
  4997                              <1> vga_set_cpos:
  4998                              <1> 	; 12/09/2016
  4999                              <1> 	; 09/07/2016
  5000                              <1> 	; set cursor position
  5001                              <1> 	; NOTE: Hardware cursor position will not be set
  5002                              <1> 	;   in any VGA modes (>7)
  5003                              <1> 	;   But, cursor position will be saved into
  5004                              <1> 	;   [CURSOR_POSN].
  5005                              <1> 	;   TRDOS 386 (TRDOS v2.0) uses only one page
  5006                              <1> 	;   (page 0) for all graphics modes.
  5007                              <1> 
  5008 00001F47 668915[4E8A0100]    <1> 	mov	[CURSOR_POSN], dx ; save cursor pos for pg 0
  5009                              <1> 	; 04/08/2016
  5010                              <1> 	;mov	bh, [ACTIVE_PAGE] ; = 0
  5011                              <1> 	;call	_set_cpos
  5012 00001F4E E90CFCFFFF          <1> 	jmp     VIDEO_RETURN
  5013                              <1> 
  5014                              <1> READ_CURSOR:
  5015                              <1> 	; 12/09/2016
  5016                              <1> 	; 07/07/2016
  5017                              <1> 	; 12/05/2016
  5018                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  5019                              <1> 	;
  5020                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  5021                              <1> 
  5022                              <1> ;------------------------------------------------------
  5023                              <1> ; READ_CURSOR
  5024                              <1> ;	THIS ROUTINE READS THE CURRENT CURSOR VALUE FROM THE
  5025                              <1> ;	845, FORMATS IT, AND SENDS IT BACK TO THE CALLER
  5026                              <1> ; INPUT
  5027                              <1> ;	BH - PAGE OF CURSOR
  5028                              <1> ; OUTPUT
  5029                              <1> ;	DX - ROW, COLUMN OF THE CURRENT CURSOR POSITION
  5030                              <1> ;	CX - CURRENT CURSOR MODE
  5031                              <1> ;------------------------------------------------------
  5032                              <1> 
  5033                              <1> 	; BH = Video page number (0 to 7)
  5034                              <1> 
  5035                              <1> 	; 07/07/2016
  5036 00001F53 80FF07              <1> 	cmp	bh, 7 ; video page > 7 (invalid)
  5037 00001F56 7606                <1> 	jna	short read_cursor_1
  5038                              <1> 	; invalid video page (input) 
  5039 00001F58 31C9                <1> 	xor	ecx, ecx ; 0
  5040 00001F5A 31D2                <1> 	xor	edx, edx ; 0
  5041 00001F5C EB15                <1> 	jmp	short read_cursor_2
  5042                              <1> read_cursor_1:
  5043                              <1> 	; 12/09/2016
  5044 00001F5E 803D[DA6F0000]07    <1> 	cmp	byte [CRT_MODE], 7 ; vga mode
  5045 00001F65 7727                <1> 	ja	short vga_get_cpos
  5046                              <1> 	;
  5047 00001F67 E815000000          <1> 	call	get_cpos
  5048 00001F6C 0FB70D[F36F0000]    <1> 	movzx	ecx, word [CURSOR_MODE]
  5049                              <1> read_cursor_2:
  5050 00001F73 5D                  <1> 	pop	ebp
  5051 00001F74 5F                  <1> 	pop	edi
  5052 00001F75 5E                  <1> 	pop	esi
  5053 00001F76 5B                  <1> 	pop	ebx
  5054 00001F77 58                  <1> 	pop	eax  ; DISCARD SAVED CX AND DX
  5055 00001F78 58                  <1> 	pop	eax
  5056 00001F79 A1[B8960100]        <1> 	mov	eax, [video_eax] ; 12/05/2016
  5057                              <1> 	;;15/01/2017
  5058                              <1> 	;;mov	byte [intflg], 0 ; 07/01/2017
  5059 00001F7E 1F                  <1> 	pop	ds
  5060 00001F7F 07                  <1> 	pop	es
  5061 00001F80 CF                  <1> 	iretd
  5062                              <1> 
  5063                              <1> get_cpos:
  5064                              <1> 	; 12/05/2016
  5065                              <1> 	; 16/01/2016
  5066                              <1> 	; BH = Video page number (0 to 7)
  5067                              <1> 	;
  5068 00001F81 D0E7                <1> 	shl	bh, 1 ; WORD OFFSET
  5069 00001F83 0FB6F7              <1> 	movzx	esi, bh 
  5070 00001F86 0FB796[4E8A0100]    <1> 	movzx	edx, word [esi+CURSOR_POSN]
  5071 00001F8D C3                  <1> 	retn
  5072                              <1> 
  5073                              <1> vga_get_cpos:
  5074                              <1> 	; 12/09/2016
  5075                              <1> 	; get cursor position (vga)
  5076 00001F8E 0FB715[4E8A0100]    <1> 	movzx	edx, word [CURSOR_POSN] ; cursor pos for pg 0
  5077 00001F95 31C9                <1> 	xor	ecx, ecx ; Cursor Mode = 0 (invalid)
  5078 00001F97 EBDA                <1> 	jmp     short read_cursor_2
  5079                              <1> 
  5080                              <1> ACT_DISP_PAGE:
  5081                              <1> 	; 07/07/2016
  5082                              <1> 	; 26/06/2016
  5083                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  5084                              <1> 	;
  5085                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  5086                              <1> 	;
  5087                              <1> ;-----------------------------------------------------
  5088                              <1> ; ACT_DISP_PAGE
  5089                              <1> ;	THIS ROUTINE SETS THE ACTIVE DISPLAY PAGE, ALLOWING
  5090                              <1> ;	THE FULL USE OF THE MEMORY SET ASIDE FOR THE VIDEO ATTACHMENT
  5091                              <1> ; INPUT
  5092                              <1> ;	AL HAS THE NEW ACTIVE DISPLAY PAGE
  5093                              <1> ; OUTPUT
  5094                              <1> ;	THE 6845 IS RESET TO DISPLAY THAT PAGE
  5095                              <1> ;-----------------------------------------------------
  5096                              <1> 	; 07/07/2016
  5097 00001F99 3C07                <1> 	cmp	al, 7	; > 7 = invalid video page number
  5098                              <1> 	;ja	VIDEO_RETURN
  5099 00001F9B 7715                <1>         ja	short adp_2 ; 18/11/2020
  5100                              <1> 	;cmp	byte [CRT_MODE], 3
  5101                              <1> 	;je	short adp_1
  5102                              <1> 	; 18/11/2020
  5103 00001F9D 8A25[DA6F0000]      <1> 	mov	ah, [CRT_MODE]
  5104 00001FA3 80FC03              <1> 	cmp	ah, 3
  5105 00001FA6 7605                <1> 	jna	short adp_1 ; mode 01h, 00h (01h), 02h (03h), 03h
  5106 00001FA8 80FC07              <1> 	cmp	ah, 7	    ; mode 07h (03h)
  5107 00001FAB 7505                <1> 	jne	short adp_2
  5108                              <1> 	;and 	al, al
  5109                              <1>         ;jnz	VIDEO_RETURN
  5110                              <1> 	;;sub	al, al ; 0 ; force to page 0
  5111                              <1> adp_1:	
  5112 00001FAD E805000000          <1> 	call	set_active_page
  5113                              <1> adp_2:
  5114 00001FB2 E9A8FBFFFF          <1>         jmp     VIDEO_RETURN
  5115                              <1> 
  5116                              <1> set_active_page:   ; tty_sw
  5117                              <1> 	; 09/12/2017
  5118                              <1> 	; 26/07/2016
  5119                              <1> 	; 26/06/2016
  5120                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  5121                              <1> 	; 30/06/2015
  5122                              <1> 	; 04/03/2014  (act_disp_page --> tty_sw)
  5123                              <1> 	; 10/12/2013
  5124                              <1> 	; 04/12/2013
  5125                              <1> 	;
  5126 00001FB7 A2[5E8A0100]        <1> 	mov	[ACTIVE_PAGE], al ; save active page value ; [ptty]
  5127                              <1> _set_active_page:
  5128                              <1> 	; 27/06/2015
  5129 00001FBC 0FB6D8              <1> 	movzx	ebx, al
  5130                              <1> 	;
  5131                              <1> 	;cbw	; 07/09/2014 (ah=0)
  5132 00001FBF 28E4                <1> 	sub	ah, ah ; 09/12/2017
  5133 00001FC1 66F725[C8960100]    <1> 	mul	word [CRT_LEN]  ; get saved length of regen buffer
  5134                              <1> 				; display page times regen length
  5135                              <1> 	; 10/12/2013
  5136 00001FC8 66A3[4C8A0100]      <1> 	mov	[CRT_START], ax ; save start address for later
  5137 00001FCE 6689C1              <1> 	mov	cx, ax ; start address to cx
  5138                              <1> _M16:
  5139                              <1> 	;sar	cx, 1
  5140 00001FD1 66D1E9              <1> 	shr	cx, 1	; divide by 2 for 6845 handling
  5141 00001FD4 B40C                <1> 	mov	ah, 12	; 6845 register for start address
  5142 00001FD6 E8EF030000          <1> 	call	m16
  5143                              <1> 	;sal	bx, 1
  5144                              <1> 	; 01/09/2014
  5145 00001FDB D0E3                <1> 	shl	bl, 1	; *2 for word offset
  5146 00001FDD 81C3[4E8A0100]      <1> 	add	ebx, CURSOR_POSN
  5147 00001FE3 668B13              <1> 	mov	dx, [ebx] ; get cursor for this page
  5148                              <1> 	; 16/01/2016
  5149                              <1> 	;call	m18
  5150                              <1> 	;retn
  5151 00001FE6 E9CB030000          <1> 	jmp	m18
  5152                              <1> 
  5153                              <1> position:
  5154                              <1> 	; 24/06/2016
  5155                              <1> 	; 12/05/2016 - TRDOS 386 (TRDOS v2.0)
  5156                              <1> 	; 27/06/2015
  5157                              <1> 	; 02/09/2014
  5158                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  5159                              <1> 	; 04/12/2013 (Retro UNIX 8086 v1)
  5160                              <1> 	;
  5161                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  5162                              <1> 	;
  5163                              <1> ;-----------------------------------------
  5164                              <1> ; POSITION
  5165                              <1> ;	THIS SERVICE ROUTINE CALCULATES THE REGEN BUFFER ADDRESS
  5166                              <1> ;	OF A CHARACTER IN THE ALPHA MODE
  5167                              <1> ; INPUT
  5168                              <1> ;	AX = ROW, COLUMN POSITION
  5169                              <1> ; OUTPUT
  5170                              <1> ;	AX = OFFSET OF CHAR POSITION IN REGEN BUFFER
  5171                              <1> ;-----------------------------------------
  5172                              <1> 
  5173                              <1> 	; DX = ROW, COLUMN POSITION
  5174 00001FEB 0FB605[DC6F0000]    <1> 	movzx	eax, byte [CRT_COLS] ; 24/06/2016
  5175 00001FF2 F6E6                <1> 	mul	dh	 ; row value
  5176 00001FF4 30F6                <1> 	xor	dh, dh   ; 0	
  5177 00001FF6 6601D0              <1> 	add	ax, dx	 ; add column value to the result
  5178 00001FF9 66D1E0              <1> 	shl	ax, 1	; * 2 for attribute bytes
  5179                              <1> 		; EAX = AX = OFFSET OF CHAR POSITION IN REGEN BUFFER 
  5180 00001FFC C3                  <1> 	retn
  5181                              <1> 
  5182                              <1> find_position:
  5183                              <1> 	; 24/06/2016
  5184                              <1> 	; 12/05/2016 - TRDOS 386 (TRDOS v2.0)
  5185                              <1> 	; 27/06/2015
  5186                              <1> 	; 07/09/2014
  5187                              <1> 	; 02/09/2014
  5188                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  5189                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  5190                              <1> 
  5191 00001FFD 0FB6CF              <1> 	movzx	ecx, bh ; video page number
  5192 00002000 89CE                <1> 	mov	esi, ecx
  5193 00002002 66D1E6              <1> 	shl	si, 1
  5194 00002005 668B96[4E8A0100]    <1> 	mov	dx, [esi+CURSOR_POSN]
  5195 0000200C 740C                <1> 	jz	short p21
  5196 0000200E 6631F6              <1> 	xor	si, si
  5197                              <1> p20:
  5198 00002011 660335[C8960100]    <1> 	add	si, [CRT_LEN] ; 24/06/2016
  5199                              <1> 	;add	si, 80*25*2 ; add length of buffer for one page
  5200 00002018 E2F7                <1> 	loop	p20
  5201                              <1> p21:
  5202 0000201A 6621D2              <1> 	and	dx, dx
  5203 0000201D 7407                <1> 	jz	short p22
  5204 0000201F E8C7FFFFFF          <1> 	call 	position ; determine location in regen in page
  5205 00002024 01C6                <1> 	add	esi, eax ; add location to start of regen page
  5206                              <1> p22:	
  5207                              <1> 	;mov	dx, [addr_6845] ; get base address of active display
  5208                              <1> 	;mov	dx, 03D4h ; I/O address of color card
  5209                              <1> 	;add	dx, 6	; point at status port
  5210 00002026 66BADA03            <1> 	mov	dx, 03DAh ; status port
  5211                              <1> 	; cx = 0
  5212 0000202A C3                  <1> 	retn
  5213                              <1> 
  5214                              <1> SCROLL_UP:
  5215                              <1> 	; 07/07/2016
  5216                              <1> 	; 26/06/2016
  5217                              <1> 	; 12/05/2016
  5218                              <1> 	; 30/01/2016
  5219                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  5220                              <1> 	; 07/09/2014
  5221                              <1> 	; 02/09/2014
  5222                              <1> 	; 01/09/2014 (Retro UNIX 386 v1 - beginning)
  5223                              <1> 	; 04/04/2014
  5224                              <1> 	; 04/12/2013
  5225                              <1> 	;
  5226                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  5227                              <1> 	;
  5228                              <1> ;----------------------------------------------
  5229                              <1> ; SCROLL UP
  5230                              <1> ;	THIS ROUTINE MOVES A BLOCK OF CHARACTERS UP
  5231                              <1> ;	ON THE SCREEN
  5232                              <1> ; INPUT
  5233                              <1> ;	(AH) = CURRENT CRT MODE
  5234                              <1> ;	(AL) = NUMBER OF ROWS TO SCROLL
  5235                              <1> ;	(CX) = ROW/COLUMN OF UPPER LEFT CORNER
  5236                              <1> ;	(DX) = ROW/COLUMN OF LOWER RIGHT CORNER
  5237                              <1> ;	(BH) = ATTRIBUTE TO BE USED ON BLANKED LINE
  5238                              <1> ;	(DS) = DATA SEGMENT
  5239                              <1> ;	(ES) = REGEN BUFFER SEGMENT
  5240                              <1> ; OUTPUT
  5241                              <1> ;	NONE -- THE REGEN BUFFER IS MODIFIED
  5242                              <1> ;--------------------------------------------
  5243                              <1> 
  5244                              <1> 	; 07/07/2016
  5245 0000202B 38F5                <1> 	cmp	ch, dh
  5246 0000202D 0F872CFBFFFF        <1> 	ja	VIDEO_RETURN
  5247 00002033 38D1                <1> 	cmp	cl, dl
  5248 00002035 0F8724FBFFFF        <1> 	ja	VIDEO_RETURN
  5249                              <1> 	;
  5250 0000203B E805000000          <1> 	call	_scroll_up
  5251 00002040 E91AFBFFFF          <1>         jmp     VIDEO_RETURN
  5252                              <1> 
  5253                              <1> _scroll_up:  ; from 'write_tty'
  5254                              <1> 	;
  5255                              <1> 	; cl = left upper column
  5256                              <1> 	; ch = left upper row
  5257                              <1> 	; dl = right lower column
  5258                              <1> 	; dh = right lower row
  5259                              <1> 	;
  5260                              <1> 	; al = line count 
  5261                              <1> 	; bl = attribute to be used on blanked line
  5262                              <1> 	; bh = video page number (0 to 7)
  5263                              <1> 
  5264 00002045 E89C000000          <1> 	call	test_line_count ; 16/01/2016
  5265                              <1> 
  5266 0000204A 8A25[DA6F0000]      <1> 	mov	ah, [CRT_MODE] ; current video mode
  5267                              <1> 	;;cmp	byte [CRT_MODE], 4
  5268                              <1> 	;cmp	ah, 4 ; 07/07/2016
  5269                              <1> 	;jnb	GRAPHICS_UP ; 26/06/2016
  5270                              <1> 	; 18/11/2020
  5271 00002050 80FC04              <1> 	cmp	ah, 4
  5272 00002053 720A                <1>  	jb	short n0	
  5273 00002055 80FC07              <1> 	cmp	ah, 7 ; TEST FOR BW CARD 
  5274                              <1> 		      ;	(80x25 text, mono)
  5275 00002058 7405                <1> 	je	short n0 ; same with mode 3 for TRDOS 386
  5276 0000205A E942050000          <1> 	jmp	GRAPHICS_UP
  5277                              <1> n0:
  5278                              <1> 	; 07/07/2016
  5279 0000205F 80FF07              <1> 	cmp	bh, 7 ; video page number
  5280 00002062 7606                <1> 	jna	short n1
  5281 00002064 8A3D[5E8A0100]      <1> 	mov	bh, [ACTIVE_PAGE]
  5282                              <1> n1:
  5283 0000206A 88DC                <1> 	mov	ah, bl ; attribute
  5284 0000206C 6650                <1> 	push	ax ; *
  5285                              <1> 	;mov 	esi, [CRT_BASE]
  5286 0000206E BE00800B00          <1>         mov     esi, 0B8000h  
  5287 00002073 3A3D[5E8A0100]      <1>         cmp     bh, [ACTIVE_PAGE]
  5288 00002079 750B                <1> 	jne	short n2
  5289                              <1> 	;
  5290 0000207B 66A1[4C8A0100]      <1>         mov     ax, [CRT_START]
  5291 00002081 6601C6              <1>         add     si, ax
  5292 00002084 EB11                <1>         jmp     short n4
  5293                              <1> n2:
  5294 00002086 20FF                <1>         and     bh, bh
  5295 00002088 740D                <1> 	jz	short n4
  5296 0000208A 88F8                <1> 	mov	al, bh
  5297                              <1> n3:
  5298 0000208C 660335[C8960100]    <1>         add	si, [CRT_LEN]
  5299 00002093 FEC8                <1>         dec	al
  5300 00002095 75F5                <1> 	jnz	short n3
  5301                              <1> n4:	
  5302 00002097 E85D000000          <1> 	call	scroll_position ; 16/01/2016
  5303 0000209C 7420                <1>         jz      short n6 
  5304                              <1> 
  5305 0000209E 01CE                <1>         add     esi, ecx ; from address for scroll
  5306 000020A0 88F5                <1> 	mov	ch, dh  ; #rows in block
  5307 000020A2 28C5                <1> 	sub	ch, al	; #rows to be moved
  5308                              <1> n5:
  5309 000020A4 E894000000          <1> 	call	n10 ; 16/01/2016
  5310                              <1> 	
  5311 000020A9 51                  <1>         push	ecx
  5312 000020AA 0FB60D[DC6F0000]    <1> 	movzx	ecx, byte [CRT_COLS] 
  5313 000020B1 00C9                <1> 	add	cl, cl
  5314 000020B3 01CE                <1>         add	esi, ecx  ; next line
  5315 000020B5 01CF                <1>         add	edi, ecx
  5316 000020B7 59                  <1> 	pop	ecx
  5317                              <1> 
  5318 000020B8 FECD                <1> 	dec	ch	 ; count of lines to move
  5319 000020BA 75E8                <1> 	jnz	short n5 ; row loop
  5320                              <1> 	; ch = 0
  5321 000020BC 88C6                <1> 	mov	dh, al	 ; #rows
  5322                              <1> n6:
  5323                              <1> 	; attribute in ah
  5324 000020BE B020                <1> 	mov	al, ' '	 ; fill with blanks
  5325                              <1> n7:
  5326 000020C0 E885000000          <1> 	call	n11 ; 16/01/2016
  5327                              <1> 
  5328 000020C5 8A0D[DC6F0000]      <1> 	mov	cl, [CRT_COLS]
  5329 000020CB 00C9                <1> 	add	cl, cl
  5330 000020CD 01CF                <1>         add	edi, ecx
  5331                              <1> 
  5332 000020CF FECE                <1> 	dec	dh
  5333 000020D1 75ED                <1> 	jnz	short n7
  5334                              <1> n16:
  5335 000020D3 3A3D[5E8A0100]      <1> 	cmp	bh, [ACTIVE_PAGE]
  5336 000020D9 750A                <1> 	jne	short n8
  5337                              <1> 	
  5338                              <1> 	;cmp	byte [CRT_MODE], 7 ; is this the black and white card
  5339                              <1> 	;je	short n8	   ; if so, skip the mode reset
  5340                              <1> 
  5341 000020DB A0[DB6F0000]        <1> 	mov	al, [CRT_MODE_SET] ; get the value of mode set
  5342 000020E0 66BAD803            <1> 	mov	dx, 03D8h ; always set color card port
  5343 000020E4 EE                  <1> 	out	dx, al
  5344                              <1> n8:
  5345 000020E5 C3                  <1> 	retn
  5346                              <1> 
  5347                              <1> test_line_count:
  5348                              <1> 	; 12/05/2016
  5349                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  5350                              <1> 	; 07/09/2014 (scroll_up)
  5351 000020E6 08C0                <1> 	or	al, al
  5352 000020E8 740E                <1> 	jz	short al_set2
  5353 000020EA 6652                <1> 	push	dx
  5354 000020EC 28EE                <1> 	sub	dh, ch  ; subtract upper row from lower row number
  5355 000020EE FEC6                <1> 	inc	dh	; adjust difference by 1
  5356 000020F0 38C6                <1> 	cmp	dh, al 	; line count = amount of rows in window?
  5357 000020F2 7502                <1> 	jne	short al_set1 ; if not the we're all set
  5358 000020F4 30C0                <1> 	xor	al, al	; otherwise set al to zero
  5359                              <1> al_set1:
  5360 000020F6 665A                <1> 	pop	dx
  5361                              <1> al_set2:
  5362 000020F8 C3                  <1> 	retn
  5363                              <1> 
  5364                              <1> scroll_position:
  5365                              <1> 	; 26/06/2016
  5366                              <1> 	; 30/01/2016
  5367                              <1>         ; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  5368                              <1> 	; 07/09/2014 (scroll_up)
  5369                              <1> 
  5370 000020F9 6652                <1> 	push	dx
  5371 000020FB 6689CA              <1> 	mov	dx, cx	; now, upper left position in DX
  5372 000020FE E8E8FEFFFF          <1> 	call	position
  5373 00002103 01C6                <1> 	add	esi, eax
  5374 00002105 89F7                <1> 	mov	edi, esi
  5375 00002107 665A                <1> 	pop	dx	; lower right position in DX
  5376 00002109 6629CA              <1> 	sub	dx, cx
  5377 0000210C FEC6                <1> 	inc	dh	; dh = #rows 
  5378 0000210E FEC2                <1> 	inc	dl	; dl = #cols in block
  5379 00002110 59                  <1> 	pop	ecx 	; return address
  5380 00002111 6658                <1> 	pop	ax	; * ; al = line count, ah = attribute
  5381 00002113 51                  <1> 	push	ecx	; return address
  5382 00002114 0FB7C8              <1> 	movzx	ecx, ax
  5383 00002117 8A25[DC6F0000]      <1> 	mov	ah, [CRT_COLS]
  5384 0000211D F6E4                <1> 	mul	ah	; determine offset to from address
  5385 0000211F 6601C0              <1> 	add	ax, ax  ; *2 for attribute byte
  5386                              <1> 	;
  5387 00002122 6650                <1> 	push	ax	; offset 
  5388 00002124 6652                <1> 	push	dx
  5389                              <1> 	;
  5390                              <1> 	; 04/04/2014
  5391 00002126 66BADA03            <1> 	mov	dx, 3DAh ; guaranteed to be color card here	
  5392                              <1> n9:                      ; wait_display_enable
  5393 0000212A EC                  <1>         in      al, dx   ; get port
  5394 0000212B A808                <1> 	test	al, RVRT ; wait for vertical retrace	
  5395 0000212D 74FB                <1> 	jz	short n9 ; wait_display_enable
  5396 0000212F B025                <1> 	mov	al, 25h
  5397 00002131 B2D8                <1> 	mov	dl, 0D8h ; address control port
  5398 00002133 EE                  <1> 	out	dx, al	; turn off video during vertical retrace
  5399 00002134 665A                <1> 	pop	dx	; #rows, #cols
  5400 00002136 6658                <1>        	pop	ax	; offset
  5401 00002138 6691                <1> 	xchg	ax, cx	; 
  5402                              <1> 	; ecx = offset, al = line count, ah = attribute
  5403                              <1> 	;
  5404 0000213A 08C0                <1> 	or	al, al
  5405 0000213C C3                  <1> 	retn
  5406                              <1> n10:
  5407                              <1> 	; Move rows
  5408 0000213D 88D1                <1> 	mov	cl, dl	; get # of cols to move
  5409 0000213F 56                  <1> 	push	esi
  5410 00002140 57                  <1> 	push	edi	; save start address
  5411                              <1> n10r:
  5412 00002141 66A5                <1> 	movsw		; move that line on screen
  5413 00002143 FEC9                <1> 	dec	cl
  5414 00002145 75FA                <1>         jnz     short n10r
  5415 00002147 5F                  <1> 	pop	edi
  5416 00002148 5E                  <1> 	pop	esi	; recover addresses
  5417 00002149 C3                  <1> 	retn
  5418                              <1> n11:
  5419                              <1> 	; Clear rows
  5420                              <1>                 	; dh =  #rows
  5421 0000214A 88D1                <1>         mov	cl, dl	; get # of cols to clear
  5422 0000214C 57                  <1>         push    edi     ; save address
  5423                              <1> n11r:
  5424 0000214D 66AB                <1>         stosw           ; store fill character
  5425 0000214F FEC9                <1> 	dec	cl
  5426 00002151 75FA                <1>         jnz     short n11r
  5427 00002153 5F                  <1>         pop     edi     ; recover address
  5428 00002154 C3                  <1> 	retn
  5429                              <1> 
  5430                              <1> SCROLL_DOWN:
  5431                              <1> 	; 07/07/2016
  5432                              <1> 	; 27/06/2016
  5433                              <1> 	; 26/06/2016
  5434                              <1> 	; 12/05/2016
  5435                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  5436                              <1> 	;
  5437                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  5438                              <1> 
  5439                              <1> ;------------------------------------------
  5440                              <1> ; SCROLL DOWN
  5441                              <1> ;	THIS ROUTINE MOVES THE CHARACTERS WITHIN A DEFINED
  5442                              <1> ;	BLOCK DOWN ON THE SCREEN, FILLING THE TOP LINES
  5443                              <1> ;	WITH A DEFINED CHARACTER
  5444                              <1> ; INPUT
  5445                              <1> ;	(AH) = CURRENT CRT MODE
  5446                              <1> ;	(AL) = NUMBER OF LINES TO SCROLL
  5447                              <1> ;	(CX) = UPPER LEFT CORNER OF RECION
  5448                              <1> ;	(DX) = LOWER RIGHT CORNER OF REGION
  5449                              <1> ;	(BH) = FILL CHARACTER
  5450                              <1> ;	(DS) = DATA SEGMENT
  5451                              <1> ;	(ES) = REGEN SEGMENT
  5452                              <1> ; OUTPUT
  5453                              <1> ;	NONE -- SCREEN IS SCROLLED
  5454                              <1> ;------------------------------------------
  5455                              <1> 
  5456                              <1> 	; 07/07/2016
  5457 00002155 38F5                <1> 	cmp	ch, dh
  5458                              <1> 	;ja	VIDEO_RETURN
  5459 00002157 7709                <1> 	ja	short _s_d_retn ; 18/11/2020
  5460 00002159 38D1                <1> 	cmp	cl, dl
  5461                              <1> 	;ja	VIDEO_RETURN
  5462 0000215B 7705                <1> 	ja	short _s_d_retn ; 18/11/2020
  5463                              <1> 	;
  5464 0000215D E805000000          <1> 	call	_scroll_down
  5465                              <1> _s_d_retn:
  5466 00002162 E9F8F9FFFF          <1>         jmp     VIDEO_RETURN
  5467                              <1> 
  5468                              <1> _scroll_down: ; 27/06/2016
  5469                              <1> 
  5470                              <1> 	; cl = left upper column
  5471                              <1> 	; ch = left upper row
  5472                              <1> 	; dl = right lower column
  5473                              <1> 	; dh = right lower row
  5474                              <1> 	;
  5475                              <1> 	; al = line count 
  5476                              <1> 	; bl = attribute to be used on blanked line
  5477                              <1> 	; bh = video page number (0 to 7)
  5478                              <1> 
  5479                              <1> 	; !!!!
  5480 00002167 FD                  <1> 	std		; DIRECTION FOR SCROLL DOWN
  5481                              <1> 	; !!!!
  5482 00002168 E879FFFFFF          <1> 	call	test_line_count ; 16/01/2016
  5483                              <1> 	
  5484 0000216D 8A25[DA6F0000]      <1> 	mov	ah, [CRT_MODE] ; current video mode
  5485                              <1> 	;;cmp	byte [CRT_MODE], 4
  5486                              <1> 	;cmp	ah, 4 ; 07/07/2016
  5487                              <1> 	;jnb	GRAPHICS_DOWN ; 26/06/2016
  5488                              <1> 	; 18/11/2020
  5489 00002173 80FC04              <1> 	cmp	ah, 4
  5490 00002176 720A                <1>  	jb	short _n0	
  5491 00002178 80FC07              <1> 	cmp	ah, 7 ; TEST FOR BW CARD 
  5492                              <1> 		      ;	(80x25 text, mono)
  5493 0000217B 7405                <1> 	je	short _n0 ; same with mode 3 for TRDOS 386
  5494 0000217D E903080000          <1> 	jmp	GRAPHICS_DOWN
  5495                              <1> _n0:
  5496                              <1> 	; 07/07/2016
  5497 00002182 80FF07              <1> 	cmp	bh, 7 ; video page number
  5498 00002185 7606                <1> 	jna	short n12
  5499 00002187 8A3D[5E8A0100]      <1> 	mov	bh, [ACTIVE_PAGE]
  5500                              <1> 	;
  5501                              <1> n12:			; CONTINUE_DOWN
  5502 0000218D 88DC                <1> 	mov	ah, bl
  5503 0000218F 6650                <1> 	push	ax	; * ; save attribute in ah
  5504 00002191 6689D0              <1> 	mov	ax, dx	; LOWER RIGHT CORNER
  5505 00002194 E860FFFFFF          <1> 	call	scroll_position	; GET REGEN LOCATION
  5506 00002199 741F                <1> 	jz	short n14
  5507 0000219B 29CE                <1> 	sub	esi, ecx  ; SI IS FROM ADDRESS
  5508 0000219D 88F5                <1> 	mov	ch, dh  ; #rows in block
  5509 0000219F 28C5                <1> 	sub	ch, al	; #rows to be moved
  5510                              <1> n13:
  5511 000021A1 E897FFFFFF          <1> 	call	n10	; MOVE ONE ROW
  5512                              <1> 
  5513 000021A6 51                  <1> 	push	ecx
  5514 000021A7 8A0D[DC6F0000]      <1> 	mov	cl, [CRT_COLS] 
  5515 000021AD 00C9                <1> 	add	cl, cl
  5516 000021AF 29CE                <1>         sub	esi, ecx  ; next line
  5517 000021B1 29CF                <1>         sub	edi, ecx
  5518 000021B3 59                  <1>         pop	ecx
  5519                              <1> 	
  5520 000021B4 FECD                <1> 	dec	ch	 ; count of lines to move
  5521 000021B6 75E9                <1> 	jnz	short n13 ; row loop
  5522                              <1> 	; ch = 0
  5523 000021B8 88C6                <1> 	mov	dh, al	 ; #rows
  5524                              <1> n14:
  5525                              <1> 	; attribute in ah
  5526 000021BA B020                <1> 	mov	al, ' '	 ; fill with blanks
  5527                              <1> n15:
  5528 000021BC E889FFFFFF          <1> 	call	n11 ; 16/01/2016
  5529                              <1> 
  5530 000021C1 8A0D[DC6F0000]      <1> 	mov	cl, [CRT_COLS]
  5531 000021C7 00C9                <1> 	add	cl, cl
  5532 000021C9 29CF                <1>         sub	edi, ecx
  5533                              <1>         
  5534 000021CB FECE                <1> 	dec	dh
  5535 000021CD 75ED                <1> 	jnz	short n15
  5536                              <1> 	;
  5537                              <1> 	; 18/11/2020
  5538 000021CF FC                  <1> 	cld	; clear direction flag	
  5539                              <1> 	;
  5540 000021D0 E9FEFEFFFF          <1> 	jmp	n16 ; 27/06/2016
  5541                              <1> 
  5542                              <1> ;	cmp	bh, [ACTIVE_PAGE]
  5543                              <1> ;	jne	short n16
  5544                              <1> ;
  5545                              <1> ;	;cmp	byte [CRT_MODE], 7	; is this the black and white card
  5546                              <1> ;	;je	short n16		; if so, skip the mode reset
  5547                              <1> ;
  5548                              <1> ;	mov	al, [CRT_MODE_SET] ; get the value of mode set
  5549                              <1> ;	mov	dx, 03D8h ; always set color card port
  5550                              <1> ;	out	dx, al
  5551                              <1> ;n16:
  5552                              <1> ;	; !!!!
  5553                              <1> ;	cld		; Clear direction flag !
  5554                              <1> ;	; !!!!
  5555                              <1> ;	retn
  5556                              <1> 
  5557                              <1> READ_AC_CURRENT:
  5558                              <1> 	; 08/07/2016
  5559                              <1> 	; 26/06/2016
  5560                              <1> 	; 12/05/2016
  5561                              <1> 	; 18/01/2016
  5562                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  5563                              <1> 	;
  5564                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  5565                              <1> 	;
  5566                              <1> 	; 08/07/2016
  5567 000021D5 803D[DA6F0000]07    <1>         cmp     byte [CRT_MODE], 7 ; 6!?
  5568 000021DC 7607                <1> 	jna	short read_ac_c
  5569 000021DE 31C0                <1> 	xor	eax, eax
  5570 000021E0 E97FF9FFFF          <1>         jmp     _video_return 
  5571                              <1> read_ac_c:
  5572 000021E5 E805000000          <1> 	call	_read_ac_current
  5573                              <1> 	; 12/05/2016
  5574                              <1>         ;jmp     VIDEO_RETURN
  5575 000021EA E975F9FFFF          <1> 	jmp	_video_return
  5576                              <1> 
  5577                              <1> ;------------------------------------------------------------------------
  5578                              <1> ; READ_AC_CURRENT							:
  5579                              <1> ;	THIS ROUTINE READS THE ATTRIBUTE AND CHARACTER AT THE CURRENT	:
  5580                              <1> ;	CURSOR POSITION AND RETURNS THEM TO THE CALLER			:
  5581                              <1> ; INPUT									:
  5582                              <1> ;	(AH) = CURRENT CRT MODE						:
  5583                              <1> ;	(BH) = DISPLAY PAGE ( ALPHA MODES ONLY )			:
  5584                              <1> ;	(DS) = DATA SEGMENT						:
  5585                              <1> ;	(ES) = REGEN SEGMENT						:
  5586                              <1> ; OUTPUT								:
  5587                              <1> ;	(AL) = CHARACTER READ						:
  5588                              <1> ;	(AH) = ATTRIBUTE READ						:
  5589                              <1> ;------------------------------------------------------------------------
  5590                              <1> 
  5591                              <1> _read_ac_current:
  5592                              <1> 	; 26/06/2016
  5593                              <1> 	; 12/05/2016 
  5594                              <1> 	; 18/01/2016
  5595                              <1> 
  5596 000021EF 8A25[DA6F0000]      <1> 	mov	ah, [CRT_MODE] ; current video mode	
  5597 000021F5 80FC04              <1> 	cmp	ah, 4
  5598 000021F8 720A                <1>  	jb	short p10
  5599                              <1> 	; 18/11/2020
  5600                              <1> 	;cmp	byte [CRT_MODE], 4
  5601                              <1> 	;jnb	GRAPHICS_READ ; 26/06/2016
  5602                              <1> 
  5603 000021FA 80FC07              <1> 	cmp	ah, 7 ; TEST FOR BW CARD (80x25 monochrome text)
  5604 000021FD 7405                <1> 	je	short p10	 ; same with mode 3 in TRDOS 386
  5605 000021FF E9D7080000          <1> 	jmp	GRAPHICS_READ
  5606                              <1> p10:
  5607 00002204 E8F4FDFFFF          <1> 	call	find_position	; GET REGEN LOCATION AND PORT ADDRESS
  5608                              <1> 	;
  5609                              <1> 	; esi = regen location
  5610                              <1> 	; dx = status port
  5611                              <1> 	;
  5612                              <1> 
  5613                              <1> 	; 18/11/2020
  5614                              <1> 	; convert display mode to a zero value 
  5615                              <1> 	; for 80 column color mode
  5616                              <1> 	;mov	ah, [CRT_MODE]	
  5617                              <1> 	;sub	ah, 2
  5618                              <1> 	;shr	ah, 1
  5619                              <1> 	;jnz	short p13
  5620                              <1> 
  5621                              <1> 	; 05/12/2020
  5622                              <1> 	; 18/11/2020 (TRDOS 386 v2.0.3)
  5623                              <1> 	;xor	bl, bl	; 0
  5624 00002209 803D[DA6F0000]03    <1> 	cmp	byte [CRT_MODE], 03h ; 80x25 color text
  5625                              <1> 	;je	short p11    ; Note: Only mode 03h and mode 01h are
  5626                              <1> 	;inc	bl	; 1  ;       in use by TRDOS 386 as text modes	
  5627                              <1> 	;jmp	short p14    ;       (07h, 00h and 02h are redirected)		
  5628 00002210 7516                <1> 	jne	short p13
  5629                              <1> 
  5630                              <1> 	; 05/12/2020
  5631 00002212 3A3D[5E8A0100]      <1> 	cmp     bh, [ACTIVE_PAGE]
  5632 00002218 750E                <1> 	jne	short p13 
  5633                              <1> 
  5634                              <1> 	; WAIT FOR HORIZONTAL RETRACE OR VERTICAL RETRACE IF COLOR 80
  5635                              <1> p11:
  5636 0000221A FB                  <1> 	sti		; enable interrupts first
  5637                              <1> 	; 05/12/2020
  5638 0000221B 90                  <1> 	nop
  5639                              <1> 	; 18/11/2020
  5640                              <1> 	;or	bl, bl
  5641                              <1> 	;jnz	short p13 ; mode 01h (and mode 00h) - 40x25 color text
  5642 0000221C FA                  <1> 	cli 		; block interrupts for single loop
  5643 0000221D EC                  <1> 	in	al, dx	; get status from the adapter
  5644 0000221E A801                <1> 	test	al, RHRZ ; is horizontal retrace low
  5645 00002220 75F8                <1> 	jnz	short p11 ; wait until it is
  5646                              <1> p12:			;  wait for either retrace high
  5647 00002222 EC                  <1> 	in	al, dx ; get status again
  5648 00002223 A809                <1> 	test	al, RVRT+RHRZ ; is horizontal or vertical retrace high
  5649 00002225 74FB                <1> 	jz	short p12 ; wait until either retrace active
  5650                              <1> ;p14:
  5651 00002227 FB                  <1> 	sti
  5652                              <1> p13:
  5653 00002228 81C600800B00        <1> 	add	esi, 0B8000h 
  5654 0000222E 668B06              <1> 	mov	ax, [esi]
  5655                              <1> 
  5656 00002231 C3                  <1> 	retn	; 18/01/2016
  5657                              <1> 
  5658                              <1> WRITE_AC_CURRENT:
  5659                              <1> 	; 08/07/2016
  5660                              <1> 	; 26/06/2016
  5661                              <1> 	; 24/06/2016
  5662                              <1> 	; 12/05/2016
  5663                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  5664                              <1> 	;
  5665                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  5666                              <1> 	;
  5667                              <1> ;----------------------------------------------------------------
  5668                              <1> ; WRITE_AC_CURRENT						:
  5669                              <1> ;	THTS ROUTINE WRITES THE ATTRIBUTE AND CHARACTER		:
  5670                              <1> ;	AT THE CURRENT CURSOR POSITION				:
  5671                              <1> ; INPUT								:
  5672                              <1> ;	(AH) = CURRENT CRT MODE					:
  5673                              <1> ;	(BH) = DISPLAY PAGE					:
  5674                              <1> ;	(CX) = COUNT OF CHARACTERS TO WRITE			:
  5675                              <1> ;	(AL) = CHAR TO WRITE					:
  5676                              <1> ;	(BL) = ATTRIBUTE OF CHAR TO WRITE			:
  5677                              <1> ;	(DS) = DATA SEGMENT					:
  5678                              <1> ;	(ES) = REGEN SEGMENT					:
  5679                              <1> ; OUTPUT							:
  5680                              <1> ;	DISPLAY REGEN BUFFER UPDATED				:
  5681                              <1> ;----------------------------------------------------------------
  5682                              <1> 
  5683                              <1> 	; 08/07/2016
  5684 00002232 803D[DA6F0000]07    <1> 	cmp	byte [CRT_MODE], 7 ; 6!?
  5685 00002239 760A                <1> 	jna	short write_ac_c
  5686                              <1> 
  5687 0000223B E8110B0000          <1> 	call	vga_write_char_attr
  5688 00002240 E91AF9FFFF          <1> 	jmp     VIDEO_RETURN	
  5689                              <1> 
  5690                              <1> write_ac_c:
  5691 00002245 E834000000          <1> 	call	_write_c_current
  5692                              <1> 
  5693 0000224A 0FB6F7              <1> 	movzx	esi, bh ; video page number (0 to 7)	
  5694 0000224D 889E[E36F0000]      <1> 	mov	[esi+chr_attrib], bl ; color/attribute
  5695                              <1> 
  5696 00002253 E907F9FFFF          <1>         jmp     VIDEO_RETURN
  5697                              <1> 
  5698                              <1> WRITE_C_CURRENT:
  5699                              <1> 	; 08/07/2016
  5700                              <1> 	; 26/06/2016
  5701                              <1> 	; 12/05/2016
  5702                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  5703                              <1> 	;
  5704                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  5705                              <1> 	;
  5706                              <1> ;----------------------------------------------------------------
  5707                              <1> ; WRITE_C_CURRENT						:
  5708                              <1> ;	THIS ROUTINE WRITES THE CHARACTER AT			:
  5709                              <1> ;	THE CURRENT CURSOR POSITION, ATTRIBUTE UNCHANGED	:
  5710                              <1> ; INPUT								:
  5711                              <1> ;	(AH) = CURRENT CRT MODE					:
  5712                              <1> ;	(BH) = DISPLAY PAGE					:
  5713                              <1> ;	(CX) = COUNT OF CHARACTERS TO WRITE			:
  5714                              <1> ;	(AL) = CHAR TO WRITE					:
  5715                              <1> ;	(DS) = DATA SEGMENT					:
  5716                              <1> ;	(ES) = REGEN SEGMENT					:
  5717                              <1> ; OUTPUT							:
  5718                              <1> ;	DISPLAY REGEN BUFFER UPDATED				:
  5719                              <1> ;----------------------------------------------------------------
  5720                              <1> 
  5721                              <1> 	; 08/07/2016
  5722 00002258 803D[DA6F0000]07    <1> 	cmp	byte [CRT_MODE], 7 ; 6!?
  5723 0000225F 760A                <1> 	jna	short write_c_c
  5724                              <1> 
  5725 00002261 E8EB0A0000          <1> 	call	vga_write_char_only
  5726 00002266 E9F4F8FFFF          <1> 	jmp     VIDEO_RETURN	
  5727                              <1> 
  5728                              <1> write_c_c:
  5729                              <1> 	;and	bh, 7 ; video page number (<= 7)
  5730 0000226B 0FB6F7              <1> 	movzx	esi, bh	
  5731 0000226E 8A9E[E36F0000]      <1> 	mov	bl, [esi+chr_attrib]
  5732                              <1> 
  5733 00002274 E805000000          <1> 	call	_write_c_current
  5734 00002279 E9E1F8FFFF          <1>         jmp     VIDEO_RETURN
  5735                              <1> 
  5736                              <1> _write_c_current:  ; from 'write_tty'
  5737                              <1> 	; 18/11/2020
  5738                              <1> 	; 26/06/2016
  5739                              <1> 	; 24/06/2016
  5740                              <1> 	; 12/05/2016
  5741                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  5742                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  5743                              <1> 	; 18/01/2014
  5744                              <1> 	; 04/12/2013
  5745                              <1> 	;
  5746                              <1> 	; VIDEO.ASM - 06/10/85 VIDEO DISPLAY BIOS
  5747                              <1> 
  5748                              <1> 	; 18/11/2020
  5749 0000227E 8A25[DA6F0000]      <1> 	mov	ah, [CRT_MODE] ; current video mode	
  5750 00002284 80FC04              <1> 	cmp	ah, 4
  5751 00002287 720A                <1>  	jb	short p40
  5752                              <1> 	
  5753                              <1> 	;cmp	byte [CRT_MODE], 4
  5754                              <1>         ;jnb	GRAPHICS_WRITE ; 26/06/2016
  5755                              <1> 
  5756 00002289 80FC07              <1> 	cmp	ah, 7 ; TEST FOR BW CARD
  5757 0000228C 7405                <1> 	je	short p40
  5758 0000228E E998070000          <1> 	jmp	GRAPHICS_WRITE
  5759                              <1> p40:
  5760                              <1> 	; al = character
  5761                              <1> 	; bl = color/attribute
  5762                              <1> 	; bh = video page
  5763                              <1> 	; cx = count of characters to write
  5764 00002293 6652                <1> 	push	dx
  5765 00002295 88DC                <1> 	mov	ah, bl  ; color/attribute (12/05/2016)
  5766 00002297 6650                <1> 	push	ax	; save character & attribute/color
  5767 00002299 6651                <1> 	push	cx
  5768 0000229B E85DFDFFFF          <1> 	call 	find_position  ; get regen location and port address
  5769 000022A0 6659                <1> 	pop	cx
  5770                              <1> 	; esi = regen location
  5771                              <1> 	; dx = status port
  5772                              <1> 	;
  5773 000022A2 81C600800B00        <1> 	add	esi, 0B8000h ; 30/08/2014 (crt_base) 
  5774                              <1> 	;
  5775                              <1> 	; 18/11/2020
  5776                              <1> 	; convert display mode to a zero value 
  5777                              <1> 	; for 80 column color mode
  5778                              <1> 	;mov	ah, [CRT_MODE]	
  5779                              <1> 	;sub	ah, 2
  5780                              <1> 	;shr	ah, 1
  5781                              <1> 	;jnz	short p44    ; 26/06/2016
  5782                              <1> 
  5783                              <1> 	; 05/12/2020
  5784                              <1> 	; 18/11/2020 (TRDOS 386 v2.0.3)
  5785                              <1> 	;xor	bl, bl	; 0
  5786 000022A8 803D[DA6F0000]03    <1> 	cmp	byte [CRT_MODE], 03h ; 80x25 color text
  5787                              <1> 	;je	short p41    ; Note: Only mode 03h and mode 01h are
  5788                              <1> 	;inc	bl	; 1  ;       in use by TRDOS 386 as text modes	
  5789                              <1> 	;jmp	short p43    ;       (07h, 00h and 02h are redirected)			
  5790                              <1> 	; 05/12/2020
  5791 000022AF 751A                <1> 	jne	short p44
  5792                              <1> p46:
  5793                              <1> 	; 05/12/2020
  5794 000022B1 3A3D[5E8A0100]      <1> 	cmp     bh, [ACTIVE_PAGE]
  5795 000022B7 7512                <1> 	jne	short p44
  5796                              <1> 
  5797                              <1> 	; WAIT FOR HORIZONTAL RETRACE OR VERTICAL RETRACE IF COLOR 80
  5798                              <1> p41:
  5799                              <1> 	; 05/12/2020
  5800 000022B9 FB                  <1> 	sti		; enable interrupts first
  5801 000022BA 90                  <1> 	nop
  5802                              <1> 	; 18/11/2020
  5803                              <1> 	;or	bl, bl
  5804                              <1> 	;jnz	short p44 ; mode 01h (and mode 00h) - 40x25 color text
  5805 000022BB FA                  <1> 	cli 		; block interrupts for single loop
  5806 000022BC EC                  <1> 	in	al, dx	; get status from the adapter
  5807 000022BD A808                <1> 	test	al, RVRT ; check for vertical retrace first
  5808 000022BF 7509                <1> 	jnz	short p43 ; Do fast write now if vertical retrace
  5809 000022C1 A801                <1> 	test	al, RHRZ ; is horizontal retrace low
  5810 000022C3 75F4                <1> 	jnz	short p41 ; wait until it is
  5811                              <1> p42:			;  wait for either retrace high
  5812 000022C5 EC                  <1> 	in	al, dx ; get status again
  5813 000022C6 A809                <1> 	test	al, RVRT+RHRZ ; is horizontal or vertical retrace high
  5814 000022C8 74FB                <1> 	jz	short p42 ; wait until either retrace active
  5815                              <1> p43:	
  5816 000022CA FB                  <1> 	sti
  5817                              <1> p44:
  5818 000022CB 668B0424            <1> 	mov	ax, [esp] ; restore the character (al) & attribute (ah)
  5819 000022CF 668906              <1> 	mov	[esi], ax
  5820                              <1> 
  5821 000022D2 6649                <1> 	dec	cx
  5822 000022D4 740D                <1> 	jz	short p45
  5823                              <1> 
  5824 000022D6 46                  <1> 	inc	esi
  5825 000022D7 46                  <1> 	inc	esi
  5826                              <1> 
  5827                              <1> 	; 05/12/2020
  5828 000022D8 803D[DA6F0000]03    <1> 	cmp	byte [CRT_MODE], 03h
  5829 000022DF 75EA                <1> 	jne	short p44
  5830                              <1> 	;jmp	short p41
  5831 000022E1 EBCE                <1> 	jmp	short p46
  5832                              <1> p45:	
  5833 000022E3 6658                <1> 	pop	ax
  5834 000022E5 665A                <1> 	pop	dx
  5835 000022E7 C3                  <1> 	retn
  5836                              <1> 
  5837                              <1> ; 09/07/2016
  5838                              <1> ; 26/06/2016
  5839                              <1> ; 24/06/2016
  5840                              <1> ; 12/05/2016
  5841                              <1> ; 18/01/2016
  5842                              <1> ; 16/01/2016 - TRDOS 386 (TRDOS v2.0)
  5843                              <1> ; 30/06/2015
  5844                              <1> ; 27/06/2015
  5845                              <1> ; 11/03/2015
  5846                              <1> ; 02/09/2014
  5847                              <1> ; 30/08/2014
  5848                              <1> ; VIDEO FUNCTIONS
  5849                              <1> ; (write_tty - Retro UNIX 8086 v1 - U9.ASM, 01/02/2014)
  5850                              <1> 
  5851                              <1> WRITE_TTY:
  5852                              <1> 	; 09/12/2017
  5853                              <1> 	; 09/07/2016
  5854                              <1> 	; 01/07/2016
  5855                              <1> 	; 26/06/2016
  5856                              <1> 	; 24/06/2016
  5857                              <1> 	; 13/05/2016
  5858                              <1> 	; 12/05/2016
  5859                              <1> 	; 30/01/2016
  5860                              <1> 	; 18/01/2016
  5861                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  5862                              <1> 	; 13/08/2015
  5863                              <1> 	; 02/09/2014
  5864                              <1> 	; 30/08/2014 (Retro UNIX 386 v1 - beginning)
  5865                              <1> 	; 01/02/2014 (Retro UNIX 8086 v1 - last update)
  5866                              <1> 	; 03/12/2013 (Retro UNIX 8086 v1 - beginning)	
  5867                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX, ESI, EDI)
  5868                              <1> 	;
  5869                              <1> 	; INPUT -> AL = Character to be written
  5870                              <1> 	;	   BL = Color (Forecolor, Backcolor)
  5871                              <1> 	;	   BH = Video Page (0 to 7)
  5872                              <1> 
  5873                              <1> 	; 09/07/2016
  5874 000022E8 803D[DA6F0000]07    <1>         cmp     byte [CRT_MODE], 7
  5875 000022EF 760A                <1> 	jna 	short write_tty_cga
  5876                              <1> 
  5877 000022F1 E8460D0000          <1> 	call	vga_write_teletype
  5878 000022F6 E964F8FFFF          <1> 	jmp	VIDEO_RETURN
  5879                              <1> 
  5880                              <1> write_tty_cga:
  5881                              <1> 	; 13/05/2016
  5882                              <1> 	;call	_write_tty
  5883                              <1> 	; 01/07/2016
  5884 000022FB E818000000          <1> 	call	_write_tty_m3
  5885 00002300 E95AF8FFFF          <1> 	jmp	VIDEO_RETURN
  5886                              <1> 
  5887                              <1> RVRT	equ	00001000b	; VIDEO VERTICAL RETRACE BIT
  5888                              <1> RHRZ	equ	00000001b	; VIDEO HORIZONTAL RETRACE BIT
  5889                              <1> 
  5890                              <1> ; Derived from "WRITE_TTY" procedure of IBM "pc-at" rombios source code
  5891                              <1> ; (06/10/1985), 'video.asm', INT 10H, VIDEO_IO
  5892                              <1> ;
  5893                              <1> ; 06/10/85  VIDEO DISPLAY BIOS
  5894                              <1> ;
  5895                              <1> ;--- WRITE_TTY ------------------------------------------------------------------
  5896                              <1> ;										:
  5897                              <1> ;   THIS INTERFACE PROVIDES A TELETYPE LIKE INTERFACE TO THE			:
  5898                              <1> ;   VIDEO CARDS. THE INPUT CHARACTER IS WRITTEN TO THE CURRENT			:
  5899                              <1> ;   CURSOR POSITION, AND THE CURSOR IS MOVED TO THE NEXT POSITION.		:
  5900                              <1> ;   IF THE CURSOR LEAVES THE LAST COLUMN OF THE FIELD, THE COLUMN		:
  5901                              <1> ;   IS SET TO ZERO, AND THE ROW VALUE IS INCREMENTED. IF THE ROW		:
  5902                              <1> ;   ROW VALUE LEAVES THE FIELD, THE CURSOR IS PLACED ON THE LAST ROW,		:
  5903                              <1> ;   FIRST COLUMN, AND THE ENTIRE SCREEN IS SCROLLED UP ONE LINE.		:
  5904                              <1> ;   WHEN THE SCREEN IS SCROLLED UP, THE ATTRIBUTE FOR FILLING THE		:
  5905                              <1> ;   NEWLY BLANKED LINE IS READ FROM THE CURSOR POSITION ON THE PREVIOUS		:
  5906                              <1> ;   LINE BEFORE THE SCROLL, IN CHARACTER MODE. IN GRAPHICS MODE,		:
  5907                              <1> ;   THE 0 COLOR IS USED.							:
  5908                              <1> ;   ENTRY --									:
  5909                              <1> ;     (AH) = CURRENT CRT MODE							:
  5910                              <1> ;     (AL) = CHARACTER TO BE WRITTEN						:
  5911                              <1> ;	    NOTE THAT BACK SPACE, CARRIAGE RETURN, BELL AND LINE FEED ARE	:
  5912                              <1> ;	    HANDLED AS COMMANDS RATHER THAN AS DISPLAY GRAPHICS CHARACTERS	:
  5913                              <1> ;     (BL) = FOREGROUND COLOR FOR CHAR WRITE IF CURRENTLY IN A GRAPHICS MODE	:
  5914                              <1> ;   EXIT -- 									:
  5915                              <1> ;     ALL REGISTERS SAVED							:
  5916                              <1> ;--------------------------------------------------------------------------------
  5917                              <1> 
  5918                              <1> ; 18/11/2020 (TRDOS 386 v2.0.3)
  5919                              <1> ; 09/12/2017
  5920                              <1> ; 08/07/2016
  5921                              <1> ; 26/06/2016
  5922                              <1> ; 24/06/2016
  5923                              <1> _write_tty:
  5924                              <1> 	; 13/05/2016
  5925                              <1> 	; --- 18/11/2020 ---
  5926                              <1> 	; NOTE:
  5927                              <1> 	; Only kernel calls "_write_tty" procedure...
  5928                              <1> 	; TRDOS 386 v2 kernel uses video mode 3 for displaying
  5929                              <1> 	; (some error) messages and also mainprog command interpreter
  5930                              <1> 	; (in kernel) uses "_write_tty".
  5931                              <1> 	; So, here video mode must be set to 3 if it is not 3.
  5932                              <1>  
  5933 00002305 FA                  <1> 	cli	; disable interrupts
  5934                              <1> 	;
  5935                              <1> 	; 01/09/2014
  5936 00002306 803D[DA6F0000]03    <1> 	cmp	byte [CRT_MODE], 3
  5937 0000230D 7409                <1> 	je	short _write_tty_m3
  5938                              <1> 	;
  5939                              <1> set_mode_3:
  5940 0000230F 53                  <1> 	push	ebx
  5941 00002310 50                  <1> 	push	eax
  5942                              <1> 	;call	_set_mode
  5943                              <1> 	; 18/11/2020 
  5944 00002311 E858F8FFFF          <1> 	call	set_txt_mode  ; set video mode to 03h 
  5945 00002316 58                  <1> 	pop	eax
  5946 00002317 5B                  <1> 	pop	ebx
  5947                              <1> 	;
  5948                              <1> _write_tty_m3: ; 24/06/2016 (m3 -> _write_tty_m3)
  5949 00002318 0FB6F7              <1> 	movzx 	esi, bh ; 12/05/2016
  5950 0000231B 66D1E6              <1> 	shl	si, 1
  5951 0000231E 81C6[4E8A0100]      <1> 	add	esi, CURSOR_POSN
  5952 00002324 668B16              <1> 	mov	dx, [esi]
  5953                              <1> 	;
  5954                              <1> 	; dx now has the current cursor position
  5955                              <1> 	;
  5956 00002327 3C0D                <1> 	cmp	al, 0Dh	; CR	; is it carriage return or control character
  5957 00002329 763E                <1> 	jbe	short u8
  5958                              <1> 	;
  5959                              <1> 	; write the char to the screen
  5960                              <1> u0:	
  5961                              <1> 	; al = character
  5962                              <1> 	; bl = attribute/color
  5963                              <1> 	; bh = video page number (0 to 7)
  5964                              <1> 	;
  5965 0000232B 66B90100            <1> 	mov	cx, 1  ; 24/06/2016
  5966                              <1> 	; cx = count of characters to write
  5967                              <1> 	;
  5968 0000232F E84AFFFFFF          <1> 	call	_write_c_current ; 16/01/2015
  5969                              <1> 	;
  5970                              <1> 	; position the cursor for next char
  5971 00002334 FEC2                <1> 	inc	dl		; next column
  5972 00002336 3A15[DC6F0000]      <1> 	cmp	dl, [CRT_COLS]  ; test for column overflow 
  5973 0000233C 7561                <1>         jne     _set_cpos
  5974 0000233E B200                <1> 	mov	dl, 0		; column = 0
  5975                              <1> u10:				; (line feed found)
  5976 00002340 80FE18              <1> 	cmp	dh, 25-1 	; check for last row
  5977 00002343 7220                <1> 	jb 	short u6
  5978                              <1> 	;
  5979                              <1> 	; scroll required
  5980                              <1> u1:	
  5981                              <1> 	; SET CURSOR POSITION (04/12/2013)
  5982 00002345 E855000000          <1> 	call	_set_cpos
  5983                              <1> 	;
  5984                              <1> 	; determine value to fill with during scroll
  5985                              <1> u2:
  5986                              <1> 	; bh = video page number
  5987                              <1> 	;
  5988 0000234A E8A0FEFFFF          <1> 	call	_read_ac_current ; 18/01/2016
  5989                              <1> 	;
  5990                              <1> 	; al = character, ah = attribute
  5991                              <1> 	; bh = video page number
  5992                              <1> 	; 18/11/2020
  5993 0000234F 88E3                <1> 	mov	bl, ah ; color/attribute 	
  5994                              <1> u3:
  5995                              <1> 	;;mov	ax, 0601h 	; scroll one line
  5996                              <1> 	;;sub	cx, cx		; upper left corner
  5997                              <1> 	;;mov	dh, 25-1 	; lower right row
  5998                              <1> 	;;;mov	dl, [CRT_COLS]
  5999                              <1> 	;mov	dl, 80		; lower right column	
  6000                              <1> 	;;dec	dl
  6001                              <1> 	;;mov	dl, 79
  6002                              <1> 
  6003                              <1> 	;;call	scroll_up	; 04/12/2013
  6004                              <1> 	;;; 11/03/2015
  6005                              <1> 	; 02/09/2014
  6006                              <1> 	;;;mov	cx, [crt_ulc] ; Upper left corner  (0000h)
  6007                              <1> 	;;;mov	dx, [crt_lrc] ; Lower right corner (184Fh)
  6008                              <1> 	; 11/03/2015
  6009 00002351 6629C9              <1> 	sub	cx, cx
  6010                              <1> 	;mov	dx, 184Fh ; dl = 79 (column), dh = 24 (row)
  6011                              <1> 	; 18/11/2020
  6012 00002354 B618                <1> 	mov	dh, 25-1
  6013 00002356 8A15[DC6F0000]      <1> 	mov	dl, [CRT_COLS]
  6014 0000235C FECA                <1> 	dec	dl
  6015                              <1> 	;
  6016 0000235E B001                <1> 	mov	al, 1		; scroll 1 line up
  6017                              <1> 		; ah = attribute
  6018                              <1> 	;mov	bl, al ; 12/05/2016
  6019 00002360 E9E0FCFFFF          <1> 	jmp	_scroll_up	; 16/01/2016
  6020                              <1> ;u4:
  6021                              <1> 	;;int	10h		; video-call return
  6022                              <1> 				; scroll up the screen
  6023                              <1> 				; tty return
  6024                              <1> ;u5:
  6025                              <1> 	;retn			; return to the caller
  6026                              <1> 
  6027                              <1> u6:				; set-cursor-inc
  6028 00002365 FEC6                <1> 	inc	dh		; next row
  6029                              <1> 				; set cursor
  6030                              <1> ;u7:					
  6031                              <1> 	;;mov	ah, 02h
  6032                              <1> 	;;jmp	short u4 	; establish the new cursor
  6033                              <1> 	;call	_set_cpos
  6034                              <1> 	;jmp 	short u5
  6035 00002367 EB36                <1> 	jmp     _set_cpos
  6036                              <1> 
  6037                              <1> 	; check for control characters
  6038                              <1> u8:
  6039 00002369 7432                <1> 	je	short u9
  6040 0000236B 3C0A                <1> 	cmp	al, 0Ah		; is it a line feed (0Ah)
  6041 0000236D 74D1                <1> 	je	short u10
  6042 0000236F 3C07                <1> 	cmp	al, 07h 	; is it a bell
  6043 00002371 747E                <1> 	je	short u11
  6044 00002373 3C08                <1> 	cmp	al, 08h		; is it a backspace
  6045                              <1> 	;jne	short u0
  6046 00002375 741E                <1> 	je	short bs	; 12/12/2013
  6047                              <1> 	; 12/12/2013 (tab stop)
  6048 00002377 3C09                <1> 	cmp	al, 09h		; is it a tab stop
  6049 00002379 75B0                <1> 	jne	short u0
  6050 0000237B 88D0                <1> 	mov	al, dl
  6051                              <1> 	;cbw
  6052 0000237D 30E4                <1> 	xor	ah, ah ; 09/12/2017
  6053 0000237F B108                <1> 	mov	cl, 8
  6054 00002381 F6F1                <1> 	div	cl
  6055 00002383 28E1                <1> 	sub	cl, ah
  6056                              <1> ts:
  6057                              <1> 	; 02/09/2014
  6058                              <1> 	; 01/09/2014
  6059                              <1> 	;mov	al, 20h
  6060                              <1> tsloop:
  6061 00002385 6651                <1> 	push	cx
  6062                              <1> 	; 18/11/2020
  6063                              <1> 	;push	ax
  6064                              <1> 	;;mov	bh, [ACTIVE_PAGE]
  6065                              <1> 	; 05/12/2020
  6066                              <1> 	;push	bx
  6067 00002387 B020                <1> 	mov	al, 20h ; al = space (blank) 
  6068                              <1> 			; bl = color/attribute
  6069 00002389 E88AFFFFFF          <1> 	call	_write_tty_m3 ; 24/06/2016 (m3 -> _write_tty_m3)
  6070                              <1> 	; 05/12/2020
  6071                              <1> 	; bx is preserved in '_write_tty_m3'
  6072                              <1> 	; 18/11/2020
  6073                              <1> 	;pop	bx  ; BL = color/attribute, Bh = video page 
  6074                              <1> 	;pop	ax  ; AL = character
  6075 0000238E 6659                <1> 	pop	cx
  6076 00002390 FEC9                <1> 	dec	cl
  6077 00002392 75F1                <1> 	jnz	short tsloop
  6078 00002394 C3                  <1> 	retn
  6079                              <1> bs:	
  6080                              <1> 	; back space found
  6081                              <1> 
  6082 00002395 08D2                <1> 	or	dl, dl 		; is it already at start of line
  6083                              <1> 	;je	short u7 	; set_cursor
  6084 00002397 7406                <1> 	jz	short _set_cpos
  6085 00002399 664A                <1> 	dec	dx     		; no -- just move it back
  6086                              <1> 	;jmp	short u7
  6087 0000239B EB02                <1> 	jmp	short _set_cpos
  6088                              <1> 
  6089                              <1> 	; carriage return found
  6090                              <1> u9:
  6091 0000239D B200                <1> 	mov	dl, 0 		; move to first column
  6092                              <1> 	;jmp	short u7
  6093                              <1> 	;jmp	short _set_cpos ; 30/01/2016
  6094                              <1> 
  6095                              <1> 	; line feed found
  6096                              <1> ;u10:
  6097                              <1> ;	cmp	dh, 25-1 	; bottom of screen
  6098                              <1> ;	jne	short u6 	; no, just set the cursor
  6099                              <1> ;       jmp     u1              ; yes, scroll the screen
  6100                              <1> 
  6101                              <1> _set_cpos:
  6102                              <1> 	; 12/05/2016 - TRDOS 386 (TRDOS v2.0)
  6103                              <1> 	; 27/06/2015
  6104                              <1> 	; 01/09/2014
  6105                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  6106                              <1> 	;
  6107                              <1> 	; 04/12/2013 - 12/12/2013 (Retro UNIX 8086 v1) 
  6108                              <1> 	;
  6109                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  6110                              <1> 	;
  6111                              <1> ;----------------------------------------------
  6112                              <1> ; SET_CPOS
  6113                              <1> ;	THIS ROUTINE SETS THE CURRENT CURSOR POSITION TO THE
  6114                              <1> ;	NEW X-Y VALUES PASSED
  6115                              <1> ; INPUT
  6116                              <1> ;	DX - ROW,COLUMN OF NEW CURSOR
  6117                              <1> ;	BH - DISPLAY PAGE OF CURSOR
  6118                              <1> ; OUTPUT
  6119                              <1> ;	CURSOR ID SET AT 6845 IF DISPLAY PAGE IS CURRENT DISPLAY
  6120                              <1> ;----------------------------------------------
  6121                              <1> 	;
  6122 0000239F BE[4E8A0100]        <1> 	mov	esi, CURSOR_POSN
  6123 000023A4 0FB6C7              <1>         movzx   eax, bh	; BH = video page number
  6124                              <1> ;	or	al, al
  6125                              <1> ;	jz	short _set_cpos_0
  6126 000023A7 D0E0                <1>         shl     al, 1   ; word offset
  6127 000023A9 01C6                <1>         add     esi, eax
  6128                              <1> ;_set_cpos_0:
  6129 000023AB 668916              <1> 	mov	[esi], dx ; save the pointer
  6130 000023AE 383D[5E8A0100]      <1> 	cmp	[ACTIVE_PAGE], bh
  6131 000023B4 7532                <1> 	jne	short m17
  6132                              <1> 	;call	m18	; CURSOR SET
  6133                              <1> ;m17:			; SET_CPOS_RETURN
  6134                              <1> 	; 01/09/2014
  6135                              <1> ;	retn
  6136                              <1> 		; DX  = row/column
  6137                              <1> m18:
  6138 000023B6 E830FCFFFF          <1> 	call	position ; determine location in regen buffer	
  6139 000023BB 668B0D[4C8A0100]    <1> 	mov	cx, [CRT_START]
  6140 000023C2 6601C1              <1> 	add	cx, ax  ; add char position in regen buffer
  6141                              <1> 			; to the start address (offset) for this page
  6142 000023C5 66D1E9              <1> 	shr	cx, 1	; divide by 2 for char only count
  6143 000023C8 B40E                <1> 	mov	ah, 14	; register number for cursor
  6144                              <1> 	;call	m16	; output value to the 6845	
  6145                              <1> 	;retn
  6146                              <1> 
  6147                              <1> 	;-----	THIS ROUTINE OUTPUTS THE CX REGISTER
  6148                              <1> 	;	TO THE 6845 REGISTERS NAMED IN (AH)
  6149                              <1> m16:
  6150 000023CA FA                  <1> 	cli
  6151                              <1> 	;mov	dx, [addr_6845] ; address register
  6152 000023CB 66BAD403            <1> 	mov 	dx, 03D4h ; I/O address of color card
  6153 000023CF 88E0                <1> 	mov	al, ah	; get value
  6154 000023D1 EE                  <1> 	out	dx, al	; register set
  6155 000023D2 6642                <1> 	inc	dx	; data register
  6156 000023D4 EB00                <1> 	jmp	$+2	; i/o delay
  6157 000023D6 88E8                <1> 	mov	al, ch	; data
  6158 000023D8 EE                  <1> 	out	dx, al	
  6159 000023D9 664A                <1> 	dec	dx	
  6160 000023DB 88E0                <1> 	mov	al, ah
  6161 000023DD FEC0                <1> 	inc	al	; point to other data register
  6162 000023DF EE                  <1> 	out	dx, al	; set for second register
  6163 000023E0 6642                <1> 	inc	dx
  6164 000023E2 EB00                <1> 	jmp	$+2	; i/o delay
  6165 000023E4 88C8                <1> 	mov	al, cl	; second data value
  6166 000023E6 EE                  <1> 	out	dx, al
  6167 000023E7 FB                  <1> 	sti
  6168                              <1> m17:
  6169 000023E8 C3                  <1> 	retn
  6170                              <1> 
  6171                              <1> _beep:
  6172                              <1> 	; 12/02/2021 (TRDOS v2.0.3)
  6173 000023E9 FA                  <1> 	cli
  6174 000023EA E811000000          <1> 	call	beep
  6175 000023EF FB                  <1> 	sti
  6176 000023F0 C3                  <1> 	retn
  6177                              <1> 
  6178                              <1> beeper: 
  6179                              <1> 	; 04/08/2016
  6180                              <1> 	; 12/05/2016 - TRDOS 386 (TRDOS v2.0)
  6181                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  6182                              <1> 	; 18/01/2014
  6183                              <1> 	; 03/12/2013
  6184                              <1> 	; bell found
  6185                              <1> u11:
  6186 000023F1 FB                  <1> 	sti
  6187 000023F2 3A3D[5E8A0100]      <1> 	cmp	bh, [ACTIVE_PAGE]
  6188 000023F8 7553                <1> 	jne	short u12	; Do not sound the beep 
  6189                              <1> 				; if it is not written on the active page
  6190                              <1> beeper_gfx: ; 04/08/2016
  6191 000023FA 66B93305            <1> 	mov	cx, 1331 	; divisor for 896 hz tone
  6192 000023FE B31F                <1> 	mov	bl, 31		; set count for 31/64 second for beep
  6193                              <1> 	;call	beep		; sound the pod bell
  6194                              <1> 	;jmp	short u5 	; tty_return
  6195                              <1> 	;retn
  6196                              <1> 	
  6197                              <1> TIMER	equ 	040h   		; 8254 TIMER - BASE ADDRESS
  6198                              <1> PORT_B	equ	061h		; PORT B READ/WRITE DIAGNOSTIC REGISTER
  6199                              <1> GATE2	equ	00000001b	; TIMER 2 INPUT CATE CLOCK BIT
  6200                              <1> SPK2	equ	00000010b	; SPEAKER OUTPUT DATA ENABLE BIT
  6201                              <1> 
  6202                              <1> beep:
  6203                              <1> 	; 12/02/2021
  6204                              <1> 	; 07/02/2015
  6205                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  6206                              <1> 	; 18/01/2014
  6207                              <1> 	; 03/12/2013
  6208                              <1> 	;
  6209                              <1> 	; TEST4.ASM - 06/10/85  POST AND BIOS UTILITY ROUTINES
  6210                              <1> 	;
  6211                              <1> 	; ROUTINE TO SOUND THE BEEPER USING TIMER 2 FOR TONE
  6212                              <1> 	;
  6213                              <1> 	; ENTRY:
  6214                              <1> 	;    (BL) = DURATION COUNTER ( 1 FOR 1/64 SECOND )
  6215                              <1> 	;    (CX) = FREQUENCY DIVISOR (1193180/FREQUENCY) (1331 FOR 886 HZ)
  6216                              <1> 	; EXIT:				:
  6217                              <1> 	;    (AX),(BL),(CX) MODIFIED.
  6218                              <1> 
  6219 00002400 9C                  <1> 	pushfd  ; 18/01/2014	; save interrupt status
  6220 00002401 FA                  <1> 	cli			; block interrupts during update
  6221 00002402 B0B6                <1> 	mov	al, 10110110b	; select timer 2, lsb, msb binary
  6222 00002404 E643                <1> 	out	TIMER+3, al 	; write timer mode register
  6223 00002406 EB00                <1> 	jmp	$+2		; I/O delay
  6224 00002408 88C8                <1> 	mov	al, cl		; divisor for hz (low)
  6225 0000240A E642                <1> 	out	TIMER+2,AL	; write timer 2 count - lsb
  6226 0000240C EB00                <1> 	jmp	$+2		; I/O delay
  6227 0000240E 88E8                <1> 	mov	al, ch		; divisor for hz (high)
  6228 00002410 E642                <1> 	out	TIMER+2, al	; write timer 2 count - msb
  6229 00002412 E461                <1> 	in	al, PORT_B	; get current setting of port
  6230 00002414 88C4                <1> 	mov	ah, al		; save that setting
  6231 00002416 0C03                <1> 	or	al, GATE2+SPK2	; gate timer 2 and turn speaker on
  6232 00002418 E661                <1> 	out	PORT_B, al	; and restore interrupt status
  6233                              <1> 	; 12/02/2021
  6234 0000241A 9D                  <1> 	popfd	; 18/01/2014
  6235                              <1> 	;sti
  6236                              <1> g7:				; 1/64 second per count (bl)
  6237 0000241B B90B040000          <1> 	mov	ecx, 1035	; delay count for 1/64 of a second
  6238 00002420 E829000000          <1> 	call	waitf		; go to beep delay 1/64 count
  6239 00002425 FECB                <1> 	dec	bl		; (bl) length count expired?
  6240 00002427 75F2                <1> 	jnz	short g7	; no - continue beeping speaker
  6241                              <1> 	;
  6242 00002429 9C                  <1> 	pushfd	; 12/02/2021	; save interrupt status
  6243 0000242A FA                  <1> 	cli  	; 18/01/2014	; block interrupts during update
  6244 0000242B E461                <1> 	in	al, PORT_B	; get current port value
  6245                              <1>         ;or      al, not (GATE2+SPK2) ; isolate current speaker bits in case
  6246 0000242D 0CFC                <1>         or      al, ~(GATE2+SPK2)
  6247 0000242F 20C4                <1>         and	ah, al		; someone turned them off during beep
  6248 00002431 88E0                <1> 	mov	al, ah		; recover value of port
  6249                              <1>         ;or      al, not (GATE2+SPK2) ; force speaker data off
  6250 00002433 0CFC                <1> 	or 	al, ~(GATE2+SPK2) ; isolate current speaker bits in case
  6251 00002435 E661                <1> 	out	PORT_B, al	; and stop speaker timer
  6252 00002437 9D                  <1> 	popfd	; 12/02/2021		; restore interrupt flag state
  6253                              <1> 	;sti
  6254 00002438 B90B040000          <1> 	mov	ecx, 1035	; force 1/64 second delay (short)
  6255 0000243D E80C000000          <1> 	call	waitf		; minimum delay between all beeps
  6256 00002442 9C                  <1> 	pushfd			; save interrupt status
  6257 00002443 FA                  <1> 	cli			; block interrupts during update
  6258 00002444 E461                <1> 	in	al, PORT_B	; get current port value in case
  6259 00002446 2403                <1> 	and	al, GATE2+SPK2	; someone turned them on
  6260 00002448 08E0                <1> 	or	al, ah		; recover value of port_b
  6261 0000244A E661                <1> 	out	PORT_B, al	; restore speaker status
  6262 0000244C 9D                  <1> 	popfd			; restore interrupt flag state
  6263                              <1> u12:	
  6264 0000244D C3                  <1> 	retn
  6265                              <1> 
  6266                              <1> REFRESH_BIT equ	00010000b 	; REFRESH TEST BIT
  6267                              <1> 
  6268                              <1> WAITF:
  6269                              <1> waitf:
  6270                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  6271                              <1> 	; 03/12/2013
  6272                              <1> 	;
  6273                              <1> ;	push ax			; save work register (ah)
  6274                              <1> ;waitf1:
  6275                              <1> 				; use timer 1 output bits
  6276                              <1> ;	in	al, PORT_B	; read current counter output status
  6277                              <1> ;	and	al, REFRESH_BIT	; mask for refresh determine bit
  6278                              <1> ;	cmp	al, ah		; did it just change
  6279                              <1> ;	je	short waitf1	; wait for a change in output line
  6280                              <1> ;	;
  6281                              <1> ;	mov	ah, al		; save new lflag state
  6282                              <1> ;	loop	waitf1		; decrement half cycles till count end
  6283                              <1> ;	;
  6284                              <1> ;	pop	ax		; restore (ah)
  6285                              <1> ;	retn			; return (cx)=0
  6286                              <1> 
  6287                              <1> ; 06/02/2015 (unix386.s <-- dsectrm2.s)
  6288                              <1> ; 17/12/2014 (dsectrm2.s)
  6289                              <1> ; WAITF
  6290                              <1> ; /// IBM PC-XT Model 286 System BIOS Source Code - Test 4 - 06/10/85 ///
  6291                              <1> ;
  6292                              <1> ;---WAITF-----------------------------------------------------------------------
  6293                              <1> ;	FIXED TIME WAIT ROUTINE (HARDWARE CONTROLLED - NOT PROCESSOR)
  6294                              <1> ; ENTRY:
  6295                              <1> ;	(CX) =	COUNT OF 15.085737 MICROSECOND INTERVALS TO WAIT
  6296                              <1> ;	      	MEMORY REFRESH TIMER 1 OUTPUT USED AS REFERENCE
  6297                              <1> ; EXIT:
  6298                              <1> ;	       	AFTER (CX) TIME COUNT (PLUS OR MINUS 16 MICROSECONDS)
  6299                              <1> ;	(CX) = 0	
  6300                              <1> ;-------------------------------------------------------------------------------
  6301                              <1> 
  6302                              <1> ; Refresh period: 30 micro seconds (15-80 us)
  6303                              <1> ; (16/12/2014 - AWARDBIOS 1999 - ATORGS.ASM, WAIT_REFRESH)
  6304                              <1> 
  6305                              <1> ;WAITF:					; DELAY FOR (CX)*15.085737 US
  6306 0000244E 6650                <1> 	PUSH	AX			; SAVE WORK REGISTER (AH)
  6307                              <1> 	; 16/12/2014
  6308                              <1> 	;shr	cx, 1			; convert to count of 30 micro seconds
  6309 00002450 D1E9                <1> 	shr	ecx, 1	; 21/02/2015
  6310                              <1> ;17/12/2014	
  6311                              <1> ;WAITF1:
  6312                              <1> ;	IN	AL, PORT_B   ;061h	; READ CURRENT COUNTER OUTPUT STATUS
  6313                              <1> ;	AND	AL, REFRESH_BIT	;00010000b ; MASK FOR REFRESH DETERMINE BIT
  6314                              <1> ;	CMP	AL, AH			; DID IT JUST CHANGE
  6315                              <1> ;	JE	short WAITF1		; WAIT FOR A CHANGE IN OUTPUT LINE
  6316                              <1> ;	MOV	AH, AL			; SAVE NEW FLAG STATE
  6317                              <1> ;	LOOP	WAITF1			; DECREMENT HALF CYCLES TILL COUNT END
  6318                              <1> 	;
  6319                              <1> 	; 17/12/2014
  6320                              <1> 	;
  6321                              <1> 	; Modification from 'WAIT_REFRESH' procedure of AWARD BIOS - 1999
  6322                              <1> 	;
  6323                              <1> ;WAIT_REFRESH:  Uses port 61, bit 4 to have CPU speed independent waiting.
  6324                              <1> ;   	INPUT:  CX = number of refresh periods to wait
  6325                              <1> ;     	       (refresh periods = 1 per 30 microseconds on most machines)
  6326                              <1> WR_STATE_0:
  6327 00002452 E461                <1> 	IN	AL,PORT_B		; IN AL,SYS1
  6328 00002454 A810                <1> 	TEST	AL,010H
  6329 00002456 74FA                <1> 	JZ	SHORT WR_STATE_0
  6330                              <1> WR_STATE_1:
  6331 00002458 E461                <1> 	IN	AL,PORT_B		; IN AL,SYS1
  6332 0000245A A810                <1> 	TEST	AL,010H
  6333 0000245C 75FA                <1> 	JNZ	SHORT WR_STATE_1
  6334 0000245E E2F2                <1>         LOOP    WR_STATE_0
  6335                              <1> 	;
  6336 00002460 6658                <1> 	POP	AX			; RESTORE (AH)
  6337 00002462 C3                  <1> 	RETn				; (CX) = 0
  6338                              <1> 
  6339                              <1> ; 09/07/2016
  6340                              <1> ; 01/07/2016
  6341                              <1> ; 24/06/2016
  6342                              <1> ; 23/06/2016 - TRDOS 386 (TRDOS v2.0)
  6343                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  6344                              <1> ;-------------------------------------------------------------------------------
  6345                              <1> ; WRITE_STRING								       :
  6346                              <1> ;	THIS ROUTINE WRITES A STRING OF CHARACTERS TO THE CRT.		       :
  6347                              <1> ; INPUT 								       :
  6348                              <1> ;	(AL) = WRITE STRING COMMAND  0 - 3				       :
  6349                              <1> ;	(BH) = DISPLAY PAGE (ACTIVE PAGE)				       :
  6350                              <1> ;	(CX) = COUNT OF CHARACTERS TO WRITE, IF (CX) = 0 THEN RETURN	       :
  6351                              <1> ;	(DX) = CURSOR POSITION FOR START OF STRING WRITE		       :
  6352                              <1> ;	(BL) = ATTRIBUTE OF CHARACTER TO WRITE IF (AL) = 0  OR	(AL) = 1       :
  6353                              <1> ;	(eBP) = SOURCE STRING OFFSET					       :
  6354                              <1> ; OUTPUT								       :
  6355                              <1> ;	NONE								       :
  6356                              <1> ;-------------------------------------------------------------------------------
  6357                              <1> 
  6358                              <1> ; AL = 00h: Assign all characters the attribute in BL; do not update cursor
  6359                              <1> ; AL = 01h: Assign all characters the attribute in BL; update cursor
  6360                              <1> ; AL = 02h: Use attributes in string; do not update cursor
  6361                              <1> ; AL = 03h: Use attributes in string; update cursor
  6362                              <1> 
  6363                              <1> WRITE_STRING:
  6364                              <1> 	; 12/09/2016
  6365                              <1> 	; 09/07/2016
  6366                              <1> 	;cmp	byte [CRT_MODE], 7 ; 6?!
  6367                              <1> 	;ja	VIDEO_RETURN		; not a valid function for VGA modes
  6368                              <1> 	;
  6369 00002463 A2[C4960100]        <1> 	mov	[w_str_cmd], al		; save (AL) command
  6370 00002468 3C04                <1> 	CMP	AL, 4			; TEST FOR INVALID WRITE STRING OPTION
  6371 0000246A 0F83EFF6FFFF        <1> 	JNB	VIDEO_RETURN		; IF OPTION INVALID THEN RETURN
  6372                              <1> 
  6373                              <1>         ;JCXZ   VIDEO_RETURN            ; IF ZERO LENGTH STRING THEN RETURN
  6374                              <1> 
  6375 00002470 67E362              <1>         jcxz    P55			; 01/07/2016
  6376                              <1> 
  6377                              <1> 	; 01/07/2016
  6378                              <1> 	;and	ecx, 0FFFFh
  6379                              <1> 	; ECX = byte count
  6380                              <1> 	;push	ecx
  6381 00002473 89EE                <1> 	mov	esi, ebp ; user buffer
  6382 00002475 BF00000700          <1> 	mov	edi, Cluster_Buffer  ; system buffer
  6383 0000247A E82FF70000          <1> 	call	transfer_from_user_buffer
  6384                              <1> 	;pop	ecx
  6385 0000247F 0F82DAF6FFFF        <1> 	jc	VIDEO_RETURN
  6386                              <1> 	; ecx = transfer (byte) count = character count
  6387 00002485 BD00000700          <1> 	mov	ebp, Cluster_Buffer
  6388                              <1> 	; 12/09/2016
  6389 0000248A 803D[DA6F0000]07    <1> 	cmp	byte [CRT_MODE], 7 ; 6?!
  6390 00002491 0F87A1000000        <1> 	ja	vga_write_string
  6391                              <1> 	;
  6392 00002497 0FB6F7              <1> 	movzx	esi, bh			; GET CURRENT CURSOR PAGE
  6393 0000249A 66D1E6              <1> 	SAL	SI, 1			; CONVERT TO PAGE OFFSET  (SI= PAGE)
  6394                              <1> 	; *****
  6395 0000249D 66FFB6[4E8A0100]    <1> 	PUSH	word [eSI+CURSOR_POSN]	; SAVE CURRENT CURSOR POSITION IN STACK
  6396                              <1> 
  6397                              <1> 	;MOV	AX,0200H		; SET NEW CURSOR POSITION
  6398                              <1> 	;INT	10H
  6399                              <1> P50next:	
  6400 000024A4 51                  <1> 	push	ecx ; ****
  6401 000024A5 53                  <1> 	push	ebx ; *** ; 18/11/2020
  6402 000024A6 56                  <1> 	push	esi ; **
  6403 000024A7 52                  <1> 	push	edx ; *
  6404 000024A8 E8F2FEFFFF          <1> 	call	_set_cpos
  6405                              <1> P50:
  6406 000024AD 8A4500              <1> 	MOV	AL, [eBP]		; GET CHARACTER FROM INPUT STRING
  6407 000024B0 45                  <1> 	INC	eBP			; BUMP POINTER TO CHARACTER
  6408                              <1> 
  6409                              <1> ;-----	TEST FOR SPECIAL CHARACTER'S
  6410                              <1> 
  6411 000024B1 3C08                <1> 	CMP	AL, 08H			; IS IT A BACKSPACE
  6412 000024B3 7410                <1> 	JE	short P51		; BACK_SPACE
  6413 000024B5 3C0D                <1> 	CMP	AL, 0Dh ; CR		; IS IT CARRIAGE RETURN
  6414 000024B7 740C                <1> 	JE	short P51		; CAR_RET
  6415 000024B9 3C0A                <1> 	CMP	AL, 0Ah ; LF		; IS IT A LINE FEED
  6416 000024BB 7408                <1> 	JE	short P51		; LINE_FEED
  6417                              <1> 	; 18/11/2020
  6418 000024BD 3C09                <1> 	cmp	al, 09h			; is it a tab stop
  6419 000024BF 7404                <1> 	je	short P51
  6420                              <1> 	;
  6421 000024C1 3C07                <1> 	CMP	AL, 07h			; IS IT A BELL
  6422 000024C3 7515                <1> 	JNE	short P52		; IF NOT THEN DO WRITE CHARACTER
  6423                              <1> P51:
  6424                              <1> 	;MOV	AH,0EH			; TTY_CHARACTER_WRITE
  6425                              <1> 	;INT	10H			; WRITE TTY CHARACTER TO THE CRT
  6426                              <1> 	
  6427 000024C5 E84EFEFFFF          <1> 	call	_write_tty_m3
  6428                              <1> 
  6429 000024CA 5A                  <1> 	pop	edx ; *
  6430 000024CB 5E                  <1> 	pop	esi ; **
  6431                              <1> 
  6432 000024CC 668B96[4E8A0100]    <1> 	MOV	DX, [eSI+CURSOR_POSN]	; GET CURRENT CURSOR POSITION
  6433 000024D3 EB44                <1> 	JMP	SHORT P54		; SET CURSOR POSITION AND CONTINUE
  6434                              <1> P55:
  6435 000024D5 E985F6FFFF          <1> 	JMP	VIDEO_RETURN
  6436                              <1> P52:
  6437 000024DA 66B90100            <1> 	MOV	CX, 1			; SET CHARACTER WRITE AMOUNT TO ONE
  6438 000024DE 803D[C4960100]02    <1> 	CMP	byte [w_str_cmd], 2	; IS THE ATTRIBUTE IN THE STRING
  6439 000024E5 7204                <1> 	JB	short P53		; IF NOT THEN SKIP
  6440 000024E7 8A5D00              <1> 	MOV	BL, [eBP]		; ELSE GET NEW ATTRIBUTE
  6441 000024EA 45                  <1> 	INC	eBP			; BUMP STRING POINTER
  6442                              <1> P53:
  6443                              <1> 	;MOV	AH,09H			; GOT_CHARACTER
  6444                              <1> 	;INT	10H			; WRITE CHARACTER TO THE CRT
  6445                              <1> 
  6446 000024EB E88EFDFFFF          <1> 	call	_write_c_current
  6447                              <1> 	
  6448 000024F0 5A                  <1> 	pop	edx ; *	
  6449                              <1> 
  6450                              <1> 	; 05/12/2020
  6451                              <1> 	; bx is preserved in '_write_c_current'
  6452                              <1> 	; 18/11/2020
  6453                              <1> 	;mov	ebx, [esp+4]	; ***
  6454                              <1> 
  6455 000024F1 0FB6F7              <1> 	movzx	esi, bh ; video page number (0 to 7)	
  6456 000024F4 889E[E36F0000]      <1> 	mov	[esi+chr_attrib], bl ; color/attribute
  6457                              <1> 
  6458 000024FA FEC2                <1> 	INC	DL			; INCREMENT COLUMN COUNTER
  6459 000024FC 3A15[DC6F0000]      <1> 	CMP	DL, [CRT_COLS]		; IF COLS ARE WITHIN RANGE FOR THIS MODE
  6460                              <1> 	;JB	short P54		;    THEN GO TO COLUMNS SET
  6461 00002502 7214                <1> 	jb	short P56 ; 05/12/2020
  6462 00002504 FEC6                <1> 	INC	DH			; BUMP ROW COUNTER BY ONE
  6463 00002506 28D2                <1> 	SUB	DL, DL			; SET COLUMN COUNTER TO ZERO
  6464 00002508 80FE19              <1> 	CMP	DH, 25			; IF ROWS ARE LESS THAN 25 THEN
  6465                              <1> 	;JB	short P54		; GO TO ROWS_COLUMNS_SET
  6466 0000250B 720B                <1> 	jb	short P56 ; 05/12/2020
  6467                              <1> 
  6468                              <1> 	; 18/11/2020
  6469                              <1> 	;MOV	AX,0E0AH		; ELSE SCROLL SCREEN
  6470                              <1> 	;INT	10H			; RESET ROW COUNTER TO 24
  6471                              <1> 
  6472                              <1> 	; 18/11/2020
  6473 0000250D B00A                <1> 	mov	al, 0Ah	; line feed
  6474                              <1> 
  6475 0000250F E804FEFFFF          <1> 	call	_write_tty_m3
  6476                              <1> 	
  6477 00002514 66BA0018            <1> 	mov	dx, 1800h		; Column = 0, Row = 24
  6478                              <1> P56:	
  6479                              <1> 	; 05/12/2020
  6480                              <1> 	; 18/11/2020
  6481 00002518 5E                  <1> 	pop	esi ; **
  6482                              <1> P54:					; ROW_COLUMNS_SET
  6483                              <1> 	;MOV	AX,0200H		; SET NEW CURSOR POSITION COMMAND
  6484                              <1> 	;INT	10H			; ESTABLISH NEW CURSOR POSITION
  6485                              <1> 
  6486                              <1> 	; 18/11/2020
  6487 00002519 5B                  <1> 	pop	ebx ; ***
  6488 0000251A 59                  <1> 	pop	ecx ; ****
  6489                              <1> 
  6490                              <1> 	;LOOP	P50			; DO IT ONCE MORE UNTIL (CX) = ZERO
  6491 0000251B 6649                <1> 	dec	cx
  6492 0000251D 7585                <1> 	jnz	short P50next
  6493                              <1> 
  6494 0000251F 665A                <1> 	POP	DX  ; *****		; RESTORE OLD CURSOR COORDINATES
  6495                              <1> 	
  6496 00002521 F605[C4960100]01    <1> 	test	byte [w_str_cmd], 1	; IF CURSOR WAS NOT TO BE MOVED
  6497 00002528 0F8531F6FFFF        <1> 	JNZ	VIDEO_RETURN		; THEN EXIT WITHOUT RESETTING OLD VALUE
  6498                              <1> 	
  6499                              <1> 	;MOV	AX,0200H		; ELSE RESTORE OLD CURSOR POSITION
  6500                              <1> 	;INT	10H
  6501                              <1> 					; DONE - EXIT WRITE STRING
  6502 0000252E E86CFEFFFF          <1> 	call	_set_cpos
  6503 00002533 E927F6FFFF          <1> 	JMP	VIDEO_RETURN		; RETURN TO CALLER
  6504                              <1> 
  6505                              <1> vga_write_string:
  6506                              <1> 	; 12/09/2016 - TRDOS 386 (TRDOS v2.0)
  6507                              <1> 	;
  6508                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  6509                              <1> 	; vgabios-0.7a (2011)
  6510                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  6511                              <1> 	; 'vgabios.c', ' biosfn_write_string'
  6512                              <1> 
  6513                              <1> 	; INPUT 								  :
  6514                              <1> 	;	(AL) = WRITE STRING COMMAND  0 - 3				  :
  6515                              <1> 	;	(BH) = DISPLAY PAGE (ACTIVE PAGE)				  :
  6516                              <1> 	;	(CX) = COUNT OF CHARACTERS TO WRITE, IF (CX) = 0 THEN RETURN	  :
  6517                              <1> 	;	(DX) = CURSOR POSITION FOR START OF STRING WRITE		  :
  6518                              <1> 	;	(BL) = ATTRIBUTE OF CHARACTER TO WRITE IF (AL) = 0  OR	(AL) = 1  :
  6519                              <1> 	;	(eBP) = SOURCE STRING OFFSET					  :
  6520                              <1> 	; OUTPUT								  :
  6521                              <1> 	;	NONE								  :
  6522                              <1> 	;-------------------------------------------------------------------------;
  6523                              <1> 
  6524                              <1> 	; AL = 00h: Assign all characters the attribute in BL; do not update cursor
  6525                              <1> 	; AL = 01h: Assign all characters the attribute in BL; update cursor
  6526                              <1> 	; AL = 02h: Use attributes in string; do not update cursor
  6527                              <1> 	; AL = 03h: Use attributes in string; update cursor
  6528                              <1> 	
  6529                              <1> 	; biosfn_write_string(GET_AL(),GET_BH(),GET_BL(),CX,GET_DH(),GET_DL(),ES,BP);
  6530                              <1> 	; static void biosfn_write_string (flag,page,attr,count,row,col,seg,offset) 
  6531                              <1> 
  6532                              <1> 	; // Read curs info for the page
  6533                              <1>  	; biosfn_get_cursor_pos(page,&dummy,&oldcurs);
  6534                              <1> 	; bh = video page = 0
  6535                              <1> 	;movzx	esi, word [CURSOR_POSN] ; current cursor position for video page 0
  6536                              <1> 	
  6537                              <1> 	; // if row=0xff special case : use current cursor position
  6538                              <1> 	; if(row==0xff)
  6539                              <1> 	;  {col=oldcurs&0x00ff;
  6540                              <1> 	;   row=(oldcurs&0xff00)>>8;
  6541                              <1> 	;  }
  6542                              <1> 
  6543                              <1> 	;mov	al, [w_str_cmd]
  6544                              <1> 
  6545 00002538 80FEFF              <1> 	cmp	dh, 0FFh
  6546 0000253B 7407                <1> 	je	short vga_wstr_1 ; user current cursor position
  6547                              <1> vga_wstr_0:
  6548                              <1> 	; set cursor position
  6549 0000253D 668915[4E8A0100]    <1> 	mov	[CURSOR_POSN], dx ; save cursor pos for pg 0
  6550                              <1> vga_wstr_1:
  6551 00002544 66FF35[4E8A0100]    <1> 	push	word [CURSOR_POSN] ; *
  6552                              <1> 
  6553                              <1> 	; ebp = string offset in system buffer (user buffer was copied to)
  6554                              <1> 	
  6555                              <1> 	; while(count--!=0)
  6556                              <1> 	;  {
  6557                              <1> 	;   car=read_byte(seg,offset++);
  6558                              <1> 	;   if((flag&0x02)!=0)
  6559                              <1> 	;    attr=read_byte(seg,offset++);
  6560                              <1> 	;    biosfn_write_teletype(car,page,attr,WITH_ATTR);
  6561                              <1> 	;  }
  6562                              <1> 
  6563                              <1> 	;push	eax ; **
  6564                              <1> 	;test	al, 2
  6565 0000254B F605[C4960100]02    <1> 	test	byte [w_str_cmd], 2
  6566 00002552 751D                <1> 	jnz	short vga_wstr_3
  6567 00002554 881D[5F8A0100]      <1> 	mov	[ccolor], bl
  6568                              <1> vga_wstr_2:
  6569 0000255A 51                  <1> 	push	ecx
  6570 0000255B 8A4500              <1> 	mov	al, [ebp]
  6571 0000255E E8D90A0000          <1> 	call	vga_write_teletype
  6572 00002563 59                  <1> 	pop	ecx
  6573 00002564 6649                <1> 	dec	cx
  6574 00002566 741E                <1> 	jz	short vga_wstr_4
  6575 00002568 45                  <1> 	inc	ebp
  6576 00002569 8A1D[5F8A0100]      <1> 	mov	bl, [ccolor]
  6577 0000256F EBE9                <1> 	jmp	short vga_wstr_2
  6578                              <1> vga_wstr_3:
  6579 00002571 51                  <1> 	push	ecx
  6580 00002572 8A4500              <1> 	mov	al, [ebp]
  6581 00002575 45                  <1> 	inc	ebp
  6582 00002576 8A5D00              <1> 	mov	bl, [ebp]
  6583 00002579 E8BE0A0000          <1> 	call	vga_write_teletype
  6584 0000257E 59                  <1> 	pop	ecx
  6585 0000257F 6649                <1> 	dec	cx
  6586 00002581 7403                <1> 	jz	short vga_wstr_4
  6587 00002583 45                  <1> 	inc	ebp
  6588 00002584 EBEB                <1> 	jmp	short vga_wstr_3
  6589                              <1> vga_wstr_4:
  6590                              <1> 	; // Set back curs pos 
  6591                              <1> 	; if((flag&0x01)==0)
  6592                              <1> 	;  biosfn_set_cursor_pos(page,oldcurs);
  6593                              <1> 	; }
  6594                              <1> 	;pop	eax ; **
  6595 00002586 665A                <1> 	pop	dx ; word [CURSOR_POSN] ; *
  6596                              <1> 	;test	al, 1
  6597 00002588 F605[C4960100]01    <1> 	test	byte [w_str_cmd], 1
  6598 0000258F 0F85CAF5FFFF        <1> 	jnz	VIDEO_RETURN
  6599 00002595 668915[4E8A0100]    <1> 	mov 	[CURSOR_POSN], dx
  6600 0000259C E9BEF5FFFF          <1> 	JMP	VIDEO_RETURN
  6601                              <1> 
  6602                              <1> ; 07/07/2016
  6603                              <1> ; 27/06/2016 - TRDOS 386 (TRDOS v2.0)
  6604                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  6605                              <1> ;------------------------------------------------------
  6606                              <1> ;  SCROLL UP
  6607                              <1> ;   THIS ROUTINE SCROLLS UP THE INFORMATION ON THE CRT
  6608                              <1> ; ENTRY ---
  6609                              <1> ;  CH,CL = UPPER LEFT CORNER OF REGION TO SCROLL
  6610                              <1> ;  DH,DL = LOWER RIGHT CORNER OF REGION TO SCROLL
  6611                              <1> ;   BOTH OF THE ABOVE ARE IN CHARACTER POSITIONS
  6612                              <1> ;  BH = FILL VALUE FOR BLANKED LINES
  6613                              <1> ;  AL = # LINES TO SCROLL (AL=0 MEANS BLANK THE ENTIRE FIELD)
  6614                              <1> ;  DS = DATA SEGMENT
  6615                              <1> ;  ES = REGEN SEGMENT
  6616                              <1> ; EXIT --
  6617                              <1> ;  NOTHING, THE SCREEN IS SCROLLED
  6618                              <1> ;--------------------------------------------------------
  6619                              <1> 
  6620                              <1> 	; cl = upper left column
  6621                              <1> 	; ch = upper left row
  6622                              <1> 	; dl = lower rigth column
  6623                              <1> 	; dh = lower right row
  6624                              <1> 	;
  6625                              <1> 	; al = line count (AL=0 means blank entire fields)
  6626                              <1> 	; bl = fill value for blanked lines	
  6627                              <1> 	; bh = unused
  6628                              <1> 
  6629                              <1> GRAPHICS_UP:
  6630                              <1> 	; 07/07/2016
  6631                              <1> 	;AH = Current video mode, [CRT_MODE]
  6632 000025A1 80FC07              <1> 	cmp	ah, 7
  6633 000025A4 7766                <1> 	ja	short vga_graphics_up
  6634                              <1> 	;je	n0
  6635                              <1> 
  6636 000025A6 88C7                <1> 	MOV	bh, al			; save line count in BH
  6637 000025A8 6689C8              <1> 	MOV	AX, CX			; GET UPPER LEFT POSITION INTO AX REG
  6638                              <1> 
  6639                              <1> ;-----	USE CHARACTER SUBROUTINE FOR POSITIONING
  6640                              <1> ;-----	ADDRESS RETURNED IS MULTIPLIED BY 2 FROM CORRECT VALUE
  6641                              <1> 
  6642 000025AB E8DA050000          <1> 	CALL	GRAPH_POSN
  6643 000025B0 0FB7F8              <1> 	MOVzx	eDI, AX			; SAVE RESULT AS DESTINATION ADDRESS
  6644                              <1> 
  6645                              <1> ;-----	DETERMINE SIZE OF WINDOW
  6646                              <1> 
  6647 000025B3 6629CA              <1> 	SUB	DX, CX
  6648 000025B6 6681C20101          <1>         ADD     DX, 101h                ; ADJUST VALUES
  6649 000025BB C0E602              <1> 	SAL	DH, 2			; MULTIPLY ROWS BY 4 AT 8 VERT DOTS/CHAR
  6650                              <1> 					; AND EVEN/ODD ROWS
  6651                              <1> ;-----	DETERMINE CRT MODE
  6652                              <1> 
  6653 000025BE 803D[DA6F0000]06    <1> 	CMP	byte [CRT_MODE], 6	; TEST FOR MEDIUM RES
  6654 000025C5 7305                <1>         JNC     short _R7_              ; FIND_SOURCE
  6655                              <1> 
  6656                              <1> ;-----	MEDIUM RES UP
  6657 000025C7 D0E2                <1> 	SAL	DL, 1			; # COLUMNS * 2, SINCE 2 BYTES/CHAR
  6658 000025C9 66D1E7              <1> 	SAL	DI, 1			; OFFSET *2 SINCE 2 BYTES/CHAR
  6659                              <1> 
  6660                              <1> ;-----	DETERMINE THE SOURCE ADDRESS IN THE BUFFER
  6661                              <1> _R7_:                                   ; FIND_SOURCE
  6662 000025CC 81C700800B00        <1> 	add	edi, 0B8000h
  6663 000025D2 C0E702              <1> 	sal	bh, 2			; multiply number of lines by 4
  6664 000025D5 7431                <1>         JZ      short _R11              ; IF ZERO, THEN BLANK ENTIRE FIELD
  6665 000025D7 B050                <1> 	MOV	AL, 80			; 80 BYTES/ROW
  6666 000025D9 F6E7                <1> 	mul	bh			; determine offset to source
  6667 000025DB 0FB7F0              <1> 	movzx	esi, ax			; offset to source
  6668 000025DE 01FE                <1> 	add	eSI, eDI		; SET UP SOURCE
  6669 000025E0 88F4                <1> 	MOV	AH, DH			; NUMBER OF ROWS IN FIELD
  6670 000025E2 28FC                <1> 	sub	ah, bh			; determine number to move
  6671                              <1> 
  6672                              <1> ;-----	LOOP THROUGH, MOVING ONE ROW AT A TIME, BOTH EVEN AND ODD FIELDS
  6673                              <1> _R8:                                    ; ROW_LOOP
  6674 000025E4 E813040000          <1>         CALL    _R17                    ; MOVE ONE ROW
  6675 000025E9 6681EEB01F          <1> 	SUB	SI, 2000h-80		; MOVE TO NEXT ROW
  6676 000025EE 6681EFB01F          <1> 	SUB	DI, 2000h-80
  6677 000025F3 FECC                <1> 	DEC	AH			; NUMBER OF ROWS TO MOVE
  6678 000025F5 75ED                <1>         JNZ     short _R8               ; CONTINUE TILL ALL MOVED
  6679                              <1> 
  6680                              <1> ;-----	FILL IN THE VACATED LINE(S)
  6681                              <1> _R9:                                    ; CLEAR ENTRY
  6682 000025F7 88D8                <1> 	mov	al, bl			; attribute to fill with
  6683                              <1> _R10_:
  6684 000025F9 E81A040000          <1>         CALL    _R18                    ; CLEAR THAT ROW
  6685 000025FE 6681EFB01F          <1> 	SUB	DI, 2000h-80		; POINT TO NEXT LINE
  6686 00002603 FECF                <1> 	dec	bh			; number of lines to fill
  6687 00002605 75F2                <1>         JNZ     short _R10_             ; CLEAR LOOP
  6688 00002607 C3                  <1> 	retn				; EVERYYHING DONE
  6689                              <1> 
  6690                              <1> _R11:                                   ; BLANK_FIELD
  6691 00002608 88F7                <1> 	mov	bh, dh			; set blank count to everything in field
  6692 0000260A EBEB                <1>         JMP     short _R9               ; CLEAR THE FIELD
  6693                              <1> 
  6694                              <1> vga_graphics_up:
  6695                              <1> 	; 08/08/2016
  6696                              <1> 	; 07/08/2016
  6697                              <1> 	; 04/08/2016
  6698                              <1> 	; 01/08/2016
  6699                              <1> 	; 31/07/2016
  6700                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  6701                              <1> 	;
  6702                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  6703                              <1> 	; vgabios-0.7a (2011)
  6704                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  6705                              <1> 	; 'vgabios.c', 'biosfn_scroll'
  6706                              <1> 	;
  6707                              <1> 
  6708                              <1> 	; cl = upper left column
  6709                              <1> 	; ch = upper left row
  6710                              <1> 	; dl = lower rigth column
  6711                              <1> 	; dh = lower right row
  6712                              <1> 	;
  6713                              <1> 	; al = line count (AL=0 means blank entire fields)
  6714                              <1> 	; bl = fill value for blanked lines	
  6715                              <1> 	; bh = unused
  6716                              <1> 	;
  6717                              <1> 	; ah = [CRT_MODE], current video mode	
  6718                              <1> 
  6719 0000260C 88C7                <1> 	mov	bh, al ; 31/07/2016
  6720 0000260E BE[FE6F0000]        <1> 	mov	esi, vga_g_modes
  6721 00002613 89F7                <1> 	mov	edi, esi
  6722 00002615 83C708              <1> 	add	edi, vga_g_mode_count
  6723                              <1> vga_g_up_0:
  6724 00002618 AC                  <1> 	lodsb
  6725 00002619 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  6726 0000261B 7405                <1> 	je	short vga_g_up_1
  6727 0000261D 39FE                <1> 	cmp	esi, edi
  6728 0000261F 72F7                <1> 	jb	short vga_g_up_0
  6729                              <1> 	;xor	bh, bh ; 31/07/2016)
  6730 00002621 C3                  <1> 	retn	; nothing to do
  6731                              <1> vga_g_up_1:
  6732 00002622 88F8                <1> 	mov	al, bh ; 31/07/2016
  6733 00002624 83C64F              <1> 	add	esi, vga_g_memmodel - (vga_g_modes + 1)  
  6734                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  6735                              <1> 	
  6736                              <1> 	; if(rlr>=nbrows)rlr=nbrows-1;
  6737                              <1>  	; if(clr>=nbcols)clr=nbcols-1;
  6738                              <1>  	; if(nblines>nbrows)nblines=0;
  6739                              <1>  	; cols=clr-cul+1;
  6740                              <1> 
  6741 00002627 3A35[E26F0000]      <1> 	cmp	dh, [VGA_ROWS]
  6742 0000262D 7208                <1> 	jb	short vga_g_up_2
  6743 0000262F 8A35[E26F0000]      <1> 	mov	dh, [VGA_ROWS]
  6744 00002635 FECE                <1> 	dec	dh
  6745                              <1> vga_g_up_2:
  6746 00002637 3A15[DC6F0000]      <1> 	cmp	dl, [CRT_COLS]  ; = [VGA_COLS]
  6747 0000263D 7208                <1> 	jb	short vga_g_up_3
  6748 0000263F 8A15[DC6F0000]      <1> 	mov	dl, [CRT_COLS]
  6749 00002645 FECA                <1> 	dec	dl
  6750                              <1> vga_g_up_3:	
  6751 00002647 3A05[E26F0000]      <1> 	cmp	al, [VGA_ROWS]
  6752 0000264D 7602                <1> 	jna	short vga_g_up_4
  6753 0000264F 28C0                <1> 	sub	al, al ; 0
  6754                              <1> vga_g_up_4:
  6755 00002651 88D7                <1> 	mov	bh, dl ; clr
  6756 00002653 28CF                <1> 	sub	bh, cl ; cul
  6757 00002655 FEC7                <1> 	inc	bh ; cols = clr-cul+1
  6758                              <1> 
  6759 00002657 20C0                <1> 	and	al, al ; nblines = 0
  6760 00002659 755D                <1> 	jnz	short vga_g_up_6
  6761 0000265B 20ED                <1> 	and	ch, ch ; rul = 0
  6762 0000265D 7559                <1> 	jnz	short vga_g_up_6
  6763 0000265F 20C9                <1> 	and	cl, cl ; cul = 0
  6764 00002661 7555                <1> 	jnz	short vga_g_up_6
  6765                              <1> 
  6766 00002663 6650                <1> 	push	ax
  6767 00002665 A0[E26F0000]        <1> 	mov	al, [VGA_ROWS]
  6768 0000266A FEC8                <1> 	dec	al  
  6769 0000266C 38C6                <1> 	cmp	dh, al ; rlr = nbrows-1
  6770 0000266E 7546                <1> 	jne	short vga_g_up_5
  6771 00002670 A0[DC6F0000]        <1>         mov     al, [CRT_COLS]  ; = VGA_COLS
  6772 00002675 FEC8                <1> 	dec	al 
  6773 00002677 38C2                <1>  	cmp	dl, al ; clr = nbcols-1
  6774 00002679 753B                <1> 	jne	short vga_g_up_5
  6775 0000267B 6658                <1> 	pop	ax
  6776                              <1> 
  6777 0000267D 66B80502            <1> 	mov	ax, 0205h
  6778 00002681 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  6779 00002685 66EF                <1> 	out	dx, ax
  6780 00002687 A0[E26F0000]        <1> 	mov	al, [VGA_ROWS]
  6781 0000268C 8A25[DC6F0000]      <1> 	mov	ah, [CRT_COLS] ; = [VGA_COLS]
  6782 00002692 F6E4                <1> 	mul	ah
  6783 00002694 0FB7D0              <1> 	movzx	edx, ax
  6784                              <1> 	; 08/08/2016
  6785 00002697 0FB605[DE6F0000]    <1> 	movzx	eax, byte [CHAR_HEIGHT]
  6786 0000269E F7E2                <1> 	mul	edx
  6787                              <1> 	; eax = byte count	
  6788 000026A0 89C1                <1> 	mov	ecx, eax
  6789                              <1> 	;; 07/08/2016
  6790                              <1> 	;shl	dx, 3 ; * 8 ; * [CHAR_HEIGHT]
  6791                              <1> 	;mov	ecx, edx
  6792 000026A2 88D8                <1> 	mov	al, bl ; fill value for blanked lines
  6793 000026A4 BF00000A00          <1> 	mov	edi, 0A0000h
  6794 000026A9 F3AA                <1> 	rep	stosb		
  6795                              <1> 	
  6796 000026AB 66B80500            <1> 	mov	ax, 5
  6797 000026AF 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  6798 000026B3 66EF                <1> 	out	dx, ax ; 0005h	
  6799                              <1> 
  6800 000026B5 C3                  <1> 	retn
  6801                              <1> 
  6802                              <1> vga_g_up_5:
  6803 000026B6 6658                <1> 	pop	ax
  6804                              <1> 
  6805                              <1> vga_g_up_6:
  6806                              <1> 	; [ESI] = VGA memory model number for current video mode
  6807                              <1>         ;
  6808                              <1>         ; LINEAR8 equ 5
  6809                              <1>         ; PLANAR4 equ 4
  6810                              <1>         ; PLANAR1 equ 3
  6811                              <1> 
  6812 000026B8 803E04              <1> 	cmp	byte [esi], PLANAR4
  6813 000026BB 7424                <1> 	je	short vga_g_up_planar
  6814 000026BD 803E03              <1> 	cmp	byte [esi], PLANAR1
  6815 000026C0 741F                <1> 	je	short vga_g_up_planar
  6816                              <1> vga_g_up_linear8:
  6817                              <1> 	; 07/07/2016 (TEMPORARY)
  6818                              <1> 	;
  6819                              <1> 	; cl = upper left column ; cul
  6820                              <1> 	; ch = upper left row ; rul
  6821                              <1> 	; dl = lower rigth column ; clr
  6822                              <1> 	; dh = lower right row ; rlr
  6823                              <1> 
  6824                              <1> vga_g_up_l0:
  6825                              <1>  	;{for(i=rul;i<=rlr;i++)
  6826                              <1>   	; if((i+nblines>rlr)||(nblines==0))
  6827 000026C2 08C0                <1> 	or	al, al
  6828 000026C4 7414                <1> 	jz	short vga_g_up_l2
  6829 000026C6 88C4                <1> 	mov	ah, al
  6830 000026C8 00EC                <1> 	add	ah, ch ; i+nblines
  6831                              <1> 	;jc	short vga_g_up_l2	
  6832 000026CA 38F4                <1> 	cmp	ah, dh
  6833 000026CC 770C                <1> 	ja	short vga_g_up_l2
  6834                              <1> 	; else
  6835                              <1> 	;  vgamem_copy_pl4(cul,i+nblines,i,cols,nbcols,cheight);
  6836 000026CE E8F2000000          <1> 	call	vgamem_copy_l8
  6837                              <1> vga_g_up_l1:
  6838 000026D3 FEC5                <1> 	inc	ch
  6839 000026D5 38F5                <1> 	cmp	ch, dh
  6840 000026D7 76E9                <1> 	jna	short vga_g_up_l0
  6841 000026D9 C3                  <1> 	retn
  6842                              <1> vga_g_up_l2:
  6843                              <1> 	; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr);
  6844 000026DA E850010000          <1> 	call	vgamem_fill_l8
  6845 000026DF EBF2                <1> 	jmp	short vga_g_up_l1
  6846                              <1> 
  6847                              <1> vga_g_up_planar:
  6848                              <1> 	; cl = upper left column ; cul
  6849                              <1> 	; ch = upper left row ; rul
  6850                              <1> 	; dl = lower rigth column ; clr
  6851                              <1> 	; dh = lower right row ; rlr
  6852                              <1> vga_g_up_pl0:
  6853                              <1>  	;{for(i=rul;i<=rlr;i++)
  6854                              <1>   	; if((i+nblines>rlr)||(nblines==0))
  6855 000026E1 20C0                <1> 	and	al, al
  6856 000026E3 7414                <1> 	jz	short vga_g_up_pl2	
  6857 000026E5 88C4                <1> 	mov	ah, al
  6858 000026E7 00EC                <1> 	add	ah, ch ; i+nblines
  6859                              <1> 	;jc	short vga_g_up_pl2
  6860 000026E9 38F4                <1> 	cmp	ah, dh
  6861 000026EB 770C                <1> 	ja	short vga_g_up_pl2
  6862                              <1> 	; else
  6863                              <1> 	;  vgamem_copy_pl4(cul,i+nblines,i,cols,nbcols,cheight);
  6864 000026ED E80E000000          <1> 	call	vgamem_copy_pl4
  6865                              <1> vga_g_up_pl1:
  6866 000026F2 FEC5                <1> 	inc	ch 
  6867 000026F4 38F5                <1> 	cmp	ch, dh
  6868 000026F6 76E9                <1> 	jna	short vga_g_up_pl0
  6869 000026F8 C3                  <1> 	retn
  6870                              <1> vga_g_up_pl2:
  6871                              <1> 	; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr);
  6872 000026F9 E870000000          <1> 	call	vgamem_fill_pl4
  6873 000026FE EBF2                <1> 	jmp	short vga_g_up_pl1
  6874                              <1> 
  6875                              <1> vgamem_copy_pl4:
  6876                              <1> 	; 08/08/2016
  6877                              <1> 	; 07/08/2016
  6878                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  6879                              <1> 	;
  6880                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  6881                              <1> 	; vgabios-0.7a (2011)
  6882                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  6883                              <1> 	; 'vgabios.c', 'vgamem_copy_pl4'
  6884                              <1> 	;
  6885                              <1> 	; vgamem_copy_pl4(xstart,ysrc,ydest,cols,nbcols,cheight)
  6886                              <1> 	; cl = xstart, ah = ysrc (i+nblines), ch = ydest (i),
  6887                              <1> 	; bh = cols, [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight
  6888                              <1> 
  6889                              <1> 	; src=ysrc*cheight*nbcols+xstart;
  6890                              <1> 	; dest=ydest*cheight*nbcols+xstart;
  6891                              <1> 
  6892 00002700 52                  <1> 	push	edx
  6893 00002701 50                  <1> 	push	eax
  6894                              <1> 
  6895                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0105)
  6896 00002702 66B80501            <1> 	mov	ax, 0105h
  6897 00002706 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  6898 0000270A 66EF                <1> 	out	dx, ax
  6899                              <1> 
  6900                              <1> 	; 07/08/2016
  6901                              <1>  	;mov     ah, [esp+1]
  6902                              <1> 	;movzx	edx, ah ; ysrc
  6903 0000270C 0FB6542401          <1> 	movzx	edx, byte [esp+1]
  6904                              <1> 	; 08/08/2016
  6905 00002711 0FB605[DE6F0000]    <1> 	movzx	eax, byte [CHAR_HEIGHT]
  6906 00002718 8A25[DC6F0000]      <1> 	mov	ah, [CRT_COLS] ; nbcols
  6907 0000271E F6E4                <1> 	mul	ah 
  6908                              <1> 	;; 07/08/2016
  6909                              <1> 	;movzx	eax, byte [CRT_COLS]
  6910                              <1> 	;shl	ax, 3 ; * 8 ; * [CHAR_HEIGHT]
  6911 00002720 50                  <1> 	push	eax ; cheight * nbcols
  6912 00002721 F7E2                <1> 	mul	edx ; * ysrc
  6913                              <1> 	; eax = ysrc * cheight * nbcols
  6914                              <1> 	; edx = 0
  6915 00002723 88CA                <1> 	mov	dl, cl ; edx = xstart	
  6916 00002725 01D0                <1>  	add	eax, edx
  6917 00002727 89C6                <1> 	mov	esi, eax ; src
  6918 00002729 88EA                <1> 	mov	dl, ch ; ydest
  6919 0000272B 58                  <1> 	pop	eax ; cheight * nbcols
  6920 0000272C F7E2                <1> 	mul	edx
  6921                              <1> 	; eax = ydest * cheight * nbcols
  6922 0000272E 88CA                <1> 	mov	dl, cl ; edx = xstart	
  6923 00002730 01D0                <1>  	add	eax, edx
  6924 00002732 89C7                <1> 	mov	edi, eax ; dest
  6925                              <1> 	; esi = src
  6926                              <1> 	; edi = dest
  6927                              <1> 	; for(i=0;i<cheight;i++)
  6928                              <1>   	; {
  6929                              <1>    	;  memcpyb(0xa000,dest+i*nbcols,0xa000,src+i*nbcols,cols);
  6930                              <1>   	; }
  6931 00002734 51                  <1> 	push	ecx
  6932 00002735 B900000A00          <1> 	mov	ecx, 0A0000h
  6933 0000273A 01CE                <1> 	add	esi, ecx
  6934 0000273C 01CF                <1> 	add	edi, ecx
  6935                              <1> 	; 08/08/2016
  6936 0000273E 8A35[DE6F0000]      <1> 	mov	dh, [CHAR_HEIGHT]
  6937                              <1> 	;; 07/08/2016
  6938                              <1> 	;mov	dh, 8 ; 07/08/2016
  6939 00002744 28D2                <1> 	sub	dl, dl ; i
  6940                              <1> vgamem_copy_pl4_0:
  6941 00002746 56                  <1> 	push	esi
  6942 00002747 57                  <1> 	push	edi
  6943 00002748 0FB605[DC6F0000]    <1> 	movzx	eax, byte [CRT_COLS]
  6944 0000274F F6E2                <1> 	mul	dl
  6945                              <1> 	; eax = i * nbcols
  6946 00002751 01C7                <1> 	add	edi, eax ; dest+i*nbcols
  6947 00002753 01C6                <1> 	add	esi, eax
  6948 00002755 0FB6CF              <1> 	movzx	ecx, bh ; cols
  6949 00002758 F3A4                <1> 	rep	movsb
  6950 0000275A 5F                  <1> 	pop	edi
  6951 0000275B 5E                  <1> 	pop	esi
  6952 0000275C FECE                <1> 	dec	dh
  6953 0000275E 75E6                <1> 	jnz	short vgamem_copy_pl4_0
  6954                              <1> vgamem_copy_pl4_1:
  6955 00002760 59                  <1> 	pop	ecx
  6956                              <1> 
  6957                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0005);
  6958 00002761 66B80500            <1> 	mov	ax, 0005h
  6959 00002765 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  6960 00002769 66EF                <1> 	out	dx, ax
  6961                              <1> 
  6962 0000276B 58                  <1> 	pop	eax
  6963 0000276C 5A                  <1> 	pop	edx
  6964                              <1> 
  6965 0000276D C3                  <1> 	retn	
  6966                              <1> 
  6967                              <1> vgamem_fill_pl4:
  6968                              <1> 	; 08/08/2016
  6969                              <1> 	; 07/08/2016
  6970                              <1> 	; 04/08/2016
  6971                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  6972                              <1> 	;
  6973                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  6974                              <1> 	; vgabios-0.7a (2011)
  6975                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  6976                              <1> 	; 'vgabios.c', 'vgamem_fill_pl4'
  6977                              <1> 	;
  6978                              <1> 	; vgamem_fill_pl4(xstart,ystart,cols,nbcols,cheight,attr)
  6979                              <1> 	; cl = xstart, edi = ch = ystart, bh = cols,
  6980                              <1> 	; [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight, attr = 0
  6981                              <1> 
  6982                              <1> 	; dest=ystart*cheight*nbcols+xstart;
  6983 0000276E 52                  <1> 	push	edx
  6984 0000276F 50                  <1> 	push	eax
  6985                              <1> 
  6986                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0205)
  6987 00002770 66B80502            <1> 	mov	ax, 0205h
  6988 00002774 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  6989 00002778 66EF                <1> 	out	dx, ax
  6990                              <1> 
  6991                              <1>       	; 08/08/2016
  6992 0000277A 0FB605[DE6F0000]    <1> 	movzx   eax, byte [CHAR_HEIGHT]
  6993 00002781 F6E5                <1> 	mul	ch
  6994                              <1> 	;; 07/08/2016
  6995                              <1> 	;movzx	eax, ch
  6996                              <1> 	;shl	ax, 3 ; * 8 ; * [CHAR_HEIGHT]
  6997 00002783 0FB615[DC6F0000]    <1> 	movzx	edx, byte [CRT_COLS] ; = [VGA_COLS]
  6998 0000278A F7E2                <1> 	mul	edx
  6999                              <1> 	; edx  = 0
  7000 0000278C 88CA                <1> 	mov	dl, cl 
  7001 0000278E 01D0                <1> 	add	eax, edx
  7002 00002790 89C7                <1> 	mov	edi, eax
  7003                              <1> 	; edi = dest
  7004                              <1> 	; for(i=0;i<cheight;i++)
  7005                              <1>   	; {
  7006                              <1>    	;  memsetb(0xa000,dest+i*nbcols,attr,cols);
  7007                              <1>   	; }
  7008 00002792 81C700000A00        <1> 	add	edi, 0A0000h
  7009 00002798 51                  <1> 	push	ecx
  7010                              <1> 	; 08/08/2016
  7011 00002799 8A35[DE6F0000]      <1> 	mov	dh, [CHAR_HEIGHT]
  7012                              <1> 	;; 07/08/2016
  7013                              <1> 	;mov	dh, 8 ; 07/08/2016
  7014 0000279F 28D2                <1> 	sub	dl, dl ; i
  7015                              <1> vgamem_fill_pl4_0:
  7016 000027A1 57                  <1> 	push	edi
  7017 000027A2 0FB605[DC6F0000]    <1> 	movzx	eax, byte [CRT_COLS]
  7018 000027A9 F6E2                <1> 	mul	dl
  7019                              <1> 	; eax = i * nbcols
  7020 000027AB 01C7                <1> 	add	edi, eax ; dest+i*nbcols
  7021 000027AD 88D8                <1> 	mov	al, bl ; attr ; 04/08/2016
  7022 000027AF 0FB6CF              <1> 	movzx	ecx, bh ; cols
  7023 000027B2 F3AA                <1>  	rep	stosb
  7024 000027B4 5F                  <1> 	pop	edi
  7025 000027B5 75EA                <1> 	jnz	short vgamem_fill_pl4_0
  7026                              <1> vgamem_fill_pl4_1:
  7027 000027B7 59                  <1> 	pop	ecx
  7028                              <1> 
  7029                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0005);
  7030 000027B8 66B80500            <1> 	mov	ax, 0005h
  7031 000027BC 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  7032 000027C0 66EF                <1> 	out	dx, ax
  7033                              <1> 
  7034 000027C2 58                  <1> 	pop	eax
  7035 000027C3 5A                  <1> 	pop	edx 
  7036                              <1> 	
  7037 000027C4 C3                  <1> 	retn
  7038                              <1> 
  7039                              <1> vgamem_copy_l8:
  7040                              <1> 	; 08/08/2016
  7041                              <1> 	; 07/08/2016
  7042                              <1> 	; 06/08/2016
  7043                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  7044                              <1> 	;
  7045                              <1> 	; TEMPORARY
  7046                              <1> 	;
  7047                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  7048                              <1> 	; vgabios-0.7a (2011)
  7049                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  7050                              <1> 	; 'vgabios.c', 'vgamem_copy_pl4'
  7051                              <1> 	;
  7052                              <1> 	; vgamem_copy_pl4(xstart,ysrc,ydest,cols,nbcols,cheight)
  7053                              <1> 	; cl = xstart, ah = ysrc (i+nblines), ch = ydest (i),
  7054                              <1> 	; bh = cols, [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight
  7055                              <1> 
  7056                              <1> 	; src=ysrc*cheight*nbcols+xstart;
  7057                              <1> 	; dest=ydest*cheight*nbcols+xstart;
  7058                              <1> 
  7059 000027C5 52                  <1> 	push	edx
  7060 000027C6 50                  <1> 	push	eax
  7061                              <1> 
  7062                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0105)
  7063                              <1> 	;mov	ax, 0105h
  7064                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  7065                              <1> 	;out	dx, ax
  7066                              <1> 
  7067                              <1> 	;mov	ah, [esp+1]
  7068                              <1> 
  7069 000027C7 0FB6D4              <1> 	movzx	edx, ah ; ysrc
  7070                              <1> 	; 08/08/2016
  7071 000027CA 0FB605[DE6F0000]    <1> 	movzx	eax, byte [CHAR_HEIGHT]
  7072 000027D1 8A25[DC6F0000]      <1> 	mov	ah, [CRT_COLS] ; nbcols
  7073 000027D7 F6E4                <1> 	mul	ah 
  7074                              <1> 	;; 07/08/2016
  7075                              <1> 	;movzx	eax, byte [CRT_COLS]
  7076                              <1> 	;shl	ax, 3 ; * 8 ; * [CHAR_HEIGHT]
  7077 000027D9 50                  <1> 	push	eax ; cheight * nbcols
  7078 000027DA F7E2                <1> 	mul	edx ; * ysrc
  7079                              <1> 	; eax = ysrc * cheight * nbcols
  7080                              <1> 	; edx = 0
  7081 000027DC 88CA                <1> 	mov	dl, cl ; edx = xstart
  7082 000027DE 01D0                <1>  	add	eax, edx
  7083 000027E0 89C6                <1> 	mov	esi, eax ; src
  7084 000027E2 66C1E603            <1> 	shl	si, 3 ; * 8 ; 06/08/2016
  7085 000027E6 88EA                <1> 	mov	dl, ch ; ydest
  7086 000027E8 58                  <1> 	pop	eax ; cheight * nbcols
  7087 000027E9 F7E2                <1> 	mul	edx
  7088                              <1> 	; eax = ydest * cheight * nbcols
  7089 000027EB 88CA                <1> 	mov	dl, cl ; edx = xstart	
  7090 000027ED 01D0                <1>  	add	eax, edx
  7091 000027EF 89C7                <1> 	mov	edi, eax ; dest
  7092 000027F1 66C1E703            <1> 	shl	di, 3 ; * 8 ; 06/08/2016
  7093                              <1> 	; esi = src
  7094                              <1> 	; edi = dest
  7095                              <1> 	; for(i=0;i<cheight;i++)
  7096                              <1>   	; {
  7097                              <1>    	;  memcpyb(0xa000,dest+i*nbcols,0xa000,src+i*nbcols,cols);
  7098                              <1>   	; }
  7099 000027F5 51                  <1> 	push	ecx
  7100 000027F6 B900000A00          <1> 	mov	ecx, 0A0000h
  7101 000027FB 01CE                <1> 	add	esi, ecx
  7102 000027FD 01CF                <1> 	add	edi, ecx
  7103                              <1> 	; 08/08/2016
  7104 000027FF 8A35[DE6F0000]      <1> 	mov	dh, [CHAR_HEIGHT]
  7105                              <1> 	;; 07/08/2016
  7106                              <1> 	;mov	dh, 8 ; 07/08/2016
  7107 00002805 28D2                <1> 	sub	dl, dl ; i
  7108                              <1> vgamem_copy_l8_0:
  7109 00002807 56                  <1> 	push	esi
  7110 00002808 57                  <1> 	push	edi
  7111 00002809 0FB605[DC6F0000]    <1> 	movzx	eax, byte [CRT_COLS]
  7112 00002810 F6E2                <1> 	mul	dl
  7113                              <1> 	; eax = i * nbcols
  7114 00002812 66C1E003            <1> 	shl	ax, 3 ; * 8 ; 06/08/2016
  7115 00002816 01C7                <1> 	add	edi, eax ; dest+i*nbcols
  7116 00002818 01C6                <1> 	add	esi, eax
  7117 0000281A 0FB6CF              <1> 	movzx	ecx, bh ; cols
  7118 0000281D 66C1E103            <1> 	shl	cx, 3 ; * 8 ; 06/08/2016
  7119 00002821 F3A4                <1> 	rep	movsb
  7120 00002823 5F                  <1> 	pop	edi
  7121 00002824 5E                  <1> 	pop	esi
  7122 00002825 FEC2                <1> 	inc	dl ; 06/08/2016
  7123 00002827 FECE                <1> 	dec	dh
  7124 00002829 75DC                <1> 	jnz	short vgamem_copy_l8_0
  7125                              <1> vgamem_copy_l8_1:
  7126 0000282B 59                  <1> 	pop	ecx
  7127                              <1> 
  7128                              <1> 	;; outw(VGAREG_GRDC_ADDRESS, 0x0005);
  7129                              <1> 	;mov	ax, 0005h
  7130                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  7131                              <1> 	;out	dx, ax
  7132                              <1> 
  7133 0000282C 58                  <1> 	pop	eax
  7134 0000282D 5A                  <1> 	pop	edx
  7135                              <1> 
  7136 0000282E C3                  <1> 	retn
  7137                              <1> 
  7138                              <1> vgamem_fill_l8:
  7139                              <1> 	; 08/08/2016
  7140                              <1> 	; 07/08/2016
  7141                              <1> 	; 06/08/2016
  7142                              <1> 	; 04/08/2016
  7143                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  7144                              <1> 	;
  7145                              <1> 	; TEMPORARY
  7146                              <1> 	;
  7147                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  7148                              <1> 	; vgabios-0.7a (2011)
  7149                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  7150                              <1> 	; 'vgabios.c', 'vgamem_fill_pl4'
  7151                              <1> 	;
  7152                              <1> 	; vgamem_fill_pl4(xstart,ystart,cols,nbcols,cheight,attr)
  7153                              <1> 	; cl = xstart, edi = ch = ystart, bh = cols,
  7154                              <1> 	; [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight, attr = 0
  7155                              <1> 
  7156                              <1> 	; dest=ystart*cheight*nbcols+xstart;
  7157 0000282F 52                  <1> 	push	edx
  7158 00002830 50                  <1> 	push	eax
  7159                              <1> 
  7160                              <1> 	;; outw(VGAREG_GRDC_ADDRESS, 0x0205)
  7161                              <1> 	;mov	ax, 0205h
  7162                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  7163                              <1> 	;out	dx, ax
  7164                              <1> 
  7165                              <1>         ; 08/08/2016
  7166 00002831 0FB605[DE6F0000]    <1> 	movzx   eax, byte [CHAR_HEIGHT]
  7167 00002838 F6E5                <1> 	mul	ch
  7168                              <1> 	;; 07/08/2016
  7169                              <1> 	;movzx	eax, ch
  7170                              <1> 	;shl	ax, 3 ; * 8 ; * [CHAR_HEIGHT]
  7171 0000283A 0FB615[DC6F0000]    <1> 	movzx	edx, byte [CRT_COLS] ; = [VGA_COLS]
  7172 00002841 F7E2                <1> 	mul	edx
  7173                              <1> 	; edx  = 0
  7174 00002843 88CA                <1> 	mov	dl, cl 
  7175 00002845 01D0                <1> 	add	eax, edx
  7176 00002847 89C7                <1> 	mov	edi, eax
  7177 00002849 66C1E703            <1> 	shl	di, 3 ; * 8 ; 06/08/2016
  7178                              <1> 	; edi = dest
  7179                              <1> 	; for(i=0;i<cheight;i++)
  7180                              <1>   	; {
  7181                              <1>    	;  memsetb(0xa000,dest+i*nbcols,attr,cols);
  7182                              <1>   	; }
  7183 0000284D 81C700000A00        <1> 	add	edi, 0A0000h
  7184 00002853 51                  <1> 	push	ecx
  7185                              <1> 	; 08/08/2016
  7186 00002854 8A35[DE6F0000]      <1> 	mov	dh, [CHAR_HEIGHT]
  7187                              <1> 	;; 07/08/2016
  7188                              <1> 	;mov	dh, 8 ; 07/08/2016
  7189 0000285A 28D2                <1> 	sub	dl, dl ; i
  7190                              <1> vgamem_fill_l8_0:
  7191 0000285C 57                  <1> 	push	edi
  7192 0000285D 0FB605[DC6F0000]    <1> 	movzx	eax, byte [CRT_COLS]
  7193 00002864 F6E2                <1> 	mul	dl
  7194                              <1> 	; eax = i * nbcols
  7195 00002866 66C1E003            <1> 	shl	ax, 3 ; * 8 ; 06/08/2016
  7196 0000286A 01C7                <1> 	add	edi, eax ; dest+i*nbcols
  7197 0000286C 88D8                <1> 	mov	al, bl ; attr ; 04/08/2016
  7198 0000286E 0FB6CF              <1> 	movzx	ecx, bh ; cols
  7199 00002871 66C1E103            <1> 	shl	cx, 3 ; * 8 ; 06/08/2016
  7200 00002875 F3AA                <1>  	rep	stosb
  7201 00002877 5F                  <1> 	pop	edi
  7202 00002878 FEC2                <1> 	inc	dl ; 06/08/2016
  7203 0000287A FECE                <1> 	dec	dh
  7204 0000287C 75DE                <1> 	jnz	short vgamem_fill_l8_0
  7205                              <1> vgamem_fill_l8_1:
  7206 0000287E 59                  <1> 	pop	ecx
  7207                              <1> 
  7208                              <1> 	;; outw(VGAREG_GRDC_ADDRESS, 0x0005);
  7209                              <1> 	;mov	ax, 0005h
  7210                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  7211                              <1> 	;out	dx, ax
  7212                              <1> 
  7213 0000287F 58                  <1> 	pop	eax
  7214 00002880 5A                  <1> 	pop	edx 
  7215                              <1> 
  7216 00002881 C3                  <1> 	retn
  7217                              <1> 
  7218                              <1> vga_graphics_down:
  7219                              <1> 	; 08/08/2016
  7220                              <1> 	; 07/08/2016
  7221                              <1> 	; 31/07/2016
  7222                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  7223                              <1> 	;
  7224                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  7225                              <1> 	; vgabios-0.7a (2011)
  7226                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  7227                              <1> 	; 'vgabios.c', 'biosfn_scroll'
  7228                              <1> 	;
  7229                              <1> 
  7230                              <1> 	; cl = upper left column
  7231                              <1> 	; ch = upper left row
  7232                              <1> 	; dl = lower rigth column
  7233                              <1> 	; dh = lower right row
  7234                              <1> 	;
  7235                              <1> 	; al = line count (AL=0 means blank entire fields)
  7236                              <1> 	; bl = fill value for blanked lines	
  7237                              <1> 	; bh = unused
  7238                              <1> 	;
  7239                              <1> 	; ah = [CRT_MODE], current video mode	
  7240                              <1> 
  7241 00002882 FC                  <1>         cld     ; !!! Clear direction flag !!! 
  7242                              <1> 
  7243 00002883 88C7                <1> 	mov	bh, al ; 31/07/2016
  7244                              <1> 
  7245 00002885 BE[F66F0000]        <1> 	mov	esi, vga_modes
  7246 0000288A 89F7                <1> 	mov	edi, esi
  7247 0000288C 83C710              <1> 	add	edi, vga_mode_count
  7248                              <1> vga_g_down_0:
  7249 0000288F AC                  <1> 	lodsb
  7250 00002890 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  7251 00002892 7405                <1> 	je	short vga_g_down_1
  7252 00002894 39FE                <1> 	cmp	esi, edi
  7253 00002896 72F7                <1> 	jb	short vga_g_down_0
  7254                              <1> 	; xor 	bh, bh	; 31/07/2016
  7255 00002898 C3                  <1> 	retn	; nothing to do
  7256                              <1> vga_g_down_1:
  7257 00002899 88F8                <1> 	mov	al, bh ; 31/07/2016
  7258 0000289B 83C64F              <1> 	add	esi, vga_memmodel - (vga_modes + 1)  
  7259                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  7260                              <1> 	
  7261                              <1> 	; if(rlr>=nbrows)rlr=nbrows-1;
  7262                              <1>  	; if(clr>=nbcols)clr=nbcols-1;
  7263                              <1>  	; if(nblines>nbrows)nblines=0;
  7264                              <1>  	; cols=clr-cul+1;
  7265                              <1> 
  7266 0000289E 3A35[E26F0000]      <1> 	cmp	dh, [VGA_ROWS]
  7267 000028A4 7208                <1> 	jb	short vga_g_down_2
  7268 000028A6 8A35[E26F0000]      <1> 	mov	dh, [VGA_ROWS]
  7269 000028AC FECE                <1> 	dec	dh
  7270                              <1> vga_g_down_2:
  7271 000028AE 3A15[DC6F0000]      <1> 	cmp	dl, [CRT_COLS]  ; = [VGA_COLS]
  7272 000028B4 7208                <1> 	jb	short vga_g_down_3
  7273 000028B6 8A15[DC6F0000]      <1> 	mov	dl, [CRT_COLS]
  7274 000028BC FECA                <1> 	dec	dl
  7275                              <1> vga_g_down_3:	
  7276 000028BE 3A05[E26F0000]      <1> 	cmp	al, [VGA_ROWS]
  7277 000028C4 7602                <1> 	jna	short vga_g_down_4
  7278 000028C6 28C0                <1> 	sub	al, al ; 0
  7279                              <1> vga_g_down_4:
  7280 000028C8 88F7                <1> 	mov	bh, dh ; clr
  7281 000028CA 28CF                <1> 	sub	bh, cl ; cul
  7282 000028CC FEC7                <1> 	inc	bh ; cols = clr-cul+1
  7283                              <1> 
  7284 000028CE 20C0                <1> 	and	al, al ; nblines = 0
  7285 000028D0 755B                <1> 	jnz	short vga_g_down_6
  7286 000028D2 20ED                <1> 	and	ch, ch ; rul = 0
  7287 000028D4 7557                <1> 	jnz	short vga_g_down_6
  7288 000028D6 20C9                <1> 	and	cl, cl ; cul = 0
  7289 000028D8 7553                <1> 	jnz	short vga_g_down_6
  7290                              <1> 
  7291 000028DA 6650                <1> 	push	ax
  7292 000028DC A0[E26F0000]        <1> 	mov	al, [VGA_ROWS]
  7293 000028E1 FEC8                <1> 	dec	al  
  7294 000028E3 38C6                <1> 	cmp	dh, al ; rlr = nbrows-1
  7295 000028E5 7544                <1> 	jne	short vga_g_down_5
  7296 000028E7 A0[DC6F0000]        <1>         mov     al, [CRT_COLS]  ; = VGA_COLS
  7297 000028EC FEC8                <1> 	dec	al 
  7298 000028EE 38C2                <1>  	cmp	dl, al ; clr = nbcols-1
  7299 000028F0 7539                <1> 	jne	short vga_g_down_5
  7300 000028F2 6658                <1> 	pop	ax
  7301                              <1> 
  7302 000028F4 66B80502            <1> 	mov	ax, 0205h
  7303 000028F8 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  7304 000028FC 66EF                <1> 	out	dx, ax
  7305 000028FE A0[E26F0000]        <1> 	mov	al, [VGA_ROWS]
  7306 00002903 8A25[DC6F0000]      <1> 	mov	ah, [CRT_COLS] ; = [VGA_COLS]
  7307 00002909 F6E4                <1> 	mul	ah
  7308 0000290B 0FB7D0              <1> 	movzx	edx, ax
  7309                              <1> 	; 08/08/2016
  7310 0000290E 0FB605[DE6F0000]    <1> 	movzx	eax, byte [CHAR_HEIGHT]
  7311 00002915 F7E2                <1> 	mul	edx
  7312                              <1> 	; eax = byte count	
  7313 00002917 89C1                <1> 	mov	ecx, eax
  7314                              <1> 	;; 07/08/2016
  7315                              <1> 	;shl	dx, 3 ; * 8 ; * [CHAR_HEIGHT]
  7316                              <1> 	;mov	ecx, edx
  7317 00002919 88D8                <1> 	mov	al, bl ; fill value for blanked lines
  7318 0000291B BF00000A00          <1> 	mov	edi, 0A0000h
  7319 00002920 F3AA                <1> 	rep	stosb			
  7320                              <1> 	
  7321 00002922 B005                <1> 	mov	al, 5
  7322 00002924 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  7323 00002928 66EF                <1> 	out	dx, ax ; 0005h	
  7324                              <1> 
  7325 0000292A C3                  <1> 	retn
  7326                              <1> 
  7327                              <1> vga_g_down_5:
  7328 0000292B 6658                <1> 	pop	ax
  7329                              <1> 
  7330                              <1> vga_g_down_6:
  7331                              <1> 	; [ESI] = VGA memory model number for current video mode
  7332                              <1>         ;
  7333                              <1>         ; LINEAR8 equ 5
  7334                              <1>         ; PLANAR4 equ 4
  7335                              <1>         ; PLANAR1 equ 3
  7336                              <1> 
  7337 0000292D 803E04              <1> 	cmp	byte [esi], PLANAR4
  7338 00002930 742C                <1> 	je	short vga_g_down_planar
  7339 00002932 803E03              <1> 	cmp	byte [esi], PLANAR1
  7340 00002935 7427                <1> 	je	short vga_g_down_planar
  7341                              <1> vga_g_down_linear8:
  7342                              <1> 	; 07/07/2016 (TEMPORARY)
  7343                              <1> 	;
  7344                              <1> 	; cl = upper left column ; cul
  7345                              <1> 	; ch = upper left row ; rul
  7346                              <1> 	; dl = lower rigth column ; clr
  7347                              <1> 	; dh = lower right row ; rlr
  7348                              <1> 
  7349                              <1> vga_g_down_l0:
  7350                              <1> 	;{for(i=rlr;i>=rul;i--)
  7351                              <1>         ; if((i<rul+nblines)||(nblines==0))
  7352 00002937 08C0                <1> 	or	al, al
  7353 00002939 741C                <1> 	jz	short vga_g_down_l2
  7354 0000293B 88C4                <1> 	mov	ah, al
  7355 0000293D 00EC                <1> 	add	ah, ch
  7356                              <1> 	;jc	short vga_g_down_l2	
  7357 0000293F 86EE                <1> 	xchg	ch, dh
  7358 00002941 38E5                <1> 	cmp	ch, ah
  7359 00002943 7212                <1> 	jb	short vga_g_down_l2
  7360 00002945 88EC                <1> 	mov	ah, ch
  7361 00002947 28C4                <1> 	sub	ah, al ; ah = i - nblines
  7362                              <1> 	; else
  7363                              <1> 	; vgamem_copy_pl4(cul,i,i-nblines,cols,nbcols,cheight);
  7364 00002949 E877FEFFFF          <1> 	call	vgamem_copy_l8
  7365                              <1> vga_g_down_l1:
  7366 0000294E 86F5                <1> 	xchg	dh, ch
  7367 00002950 FECE                <1> 	dec	dh 
  7368 00002952 38EE                <1> 	cmp	dh, ch
  7369 00002954 73E1                <1> 	jnb	short vga_g_down_l0
  7370 00002956 C3                  <1> 	retn
  7371                              <1> 
  7372                              <1> vga_g_down_l2:
  7373                              <1> 	; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr);
  7374 00002957 E8D3FEFFFF          <1> 	call	vgamem_fill_l8
  7375 0000295C EBF0                <1> 	jmp	short vga_g_down_l1
  7376                              <1> 		 
  7377                              <1> vga_g_down_planar:
  7378                              <1> 	; cl = upper left column ; cul
  7379                              <1> 	; ch = upper left row ; rul
  7380                              <1> 	; dl = lower rigth column ; clr
  7381                              <1> 	; dh = lower right row ; rlr
  7382                              <1> vga_g_down_pl0:
  7383                              <1>  	;{for(i=rlr;i>=rul;i--)
  7384                              <1>         ; if((i<rul+nblines)||(nblines==0))
  7385 0000295E 08C0                <1> 	or	al, al
  7386 00002960 741C                <1> 	jz	short vga_g_down_pl2
  7387 00002962 88C4                <1> 	mov	ah, al
  7388 00002964 00EC                <1> 	add	ah, ch
  7389                              <1> 	;jc	short vga_g_down_pl2	
  7390 00002966 86EE                <1> 	xchg	ch, dh
  7391 00002968 38E5                <1> 	cmp	ch, ah
  7392 0000296A 7212                <1> 	jb	short vga_g_down_pl2
  7393 0000296C 88EC                <1> 	mov	ah, ch
  7394 0000296E 28C4                <1> 	sub	ah, al ; ah = i - nblines
  7395                              <1> 	; else
  7396                              <1> 	; vgamem_copy_pl4(cul,i,i-nblines,cols,nbcols,cheight);
  7397 00002970 E88BFDFFFF          <1> 	call	vgamem_copy_pl4
  7398                              <1> vga_g_down_pl1:
  7399 00002975 86F5                <1> 	xchg	dh, ch
  7400 00002977 FECE                <1> 	dec	dh 
  7401 00002979 38EE                <1> 	cmp	dh, ch
  7402 0000297B 73E1                <1> 	jnb	short vga_g_down_pl0
  7403 0000297D C3                  <1> 	retn
  7404                              <1> 
  7405                              <1> vga_g_down_pl2:
  7406                              <1> 	; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr);
  7407 0000297E E8EBFDFFFF          <1> 	call	vgamem_fill_pl4
  7408 00002983 EBF0                <1> 	jmp	short vga_g_down_pl1
  7409                              <1> 
  7410                              <1> ; 07/07/2016
  7411                              <1> ; 27/06/2016 - TRDOS 386 (TRDOS v2.0)
  7412                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  7413                              <1> ;------------------------------------------------------
  7414                              <1> ; SCROLL DOWN
  7415                              <1> ;  THIS ROUTINE SCROLLS DOWN THE INFORMATION ON THE CRT
  7416                              <1> ; ENTRY --
  7417                              <1> ;  CH,CL = UPPER LEFT CORNER OF REGION TO SCROLL
  7418                              <1> ;  DH,DL = LOWER RIGHT CORNER OF REGION TO SCROLL
  7419                              <1> ;   BOTH OF THE ABOVE ARE IN CHARACTER POSITIONS
  7420                              <1> ;  BH = FILL VALUE FOR BLANKED LINES
  7421                              <1> ;  AL = # LINES TO SCROLL (AL=0 MEANS BLANK THE ENTIRE FIELD)
  7422                              <1> ;  DS = DATA SEGMENT
  7423                              <1> ;  ES = REGEN SEGMENT
  7424                              <1> ; EXIT --
  7425                              <1> ;  NOTHING, THE SCREEN IS SCROLLED
  7426                              <1> ;--------------------------------------------------------
  7427                              <1> 
  7428                              <1> 	; cl = upper left column
  7429                              <1> 	; ch = upper left row
  7430                              <1> 	; dl = lower rigth column
  7431                              <1> 	; dh = lower right row
  7432                              <1> 	;
  7433                              <1> 	; al = line count (AL=0 means blank entire fields)
  7434                              <1> 	; bl = fill value for blanked lines	
  7435                              <1> 	; bh = unused
  7436                              <1> 
  7437                              <1> GRAPHICS_DOWN:
  7438                              <1> 	; 07/07/2016
  7439                              <1> 	;AH = Current video mode, [CRT_MODE]
  7440                              <1> 	;STD				; SET DIRECTION
  7441 00002985 80FC07              <1> 	cmp	ah, 7
  7442 00002988 0F87F4FEFFFF        <1>         ja      vga_graphics_down
  7443                              <1> 	;je	_n0
  7444                              <1> 
  7445 0000298E 88C7                <1> 	MOV	bh, al			; save line count in BH
  7446 00002990 6689D0              <1> 	MOV	AX, DX			; GET LOWER RIGHT POSITION INTO AX REG
  7447                              <1> 
  7448                              <1> ;-----	USE CHARACTER SUBROUTINE FOR POSITIONING
  7449                              <1> ;-----	ADDRESS RETURNED IS MULTIPLIED BY 2 FROM CORRECT VALUE
  7450                              <1> 
  7451 00002993 E8F2010000          <1> 	CALL	GRAPH_POSN
  7452 00002998 0FB7F8              <1> 	MOVzx	eDI, AX			; SAVE RESULT AS DESTINATION ADDRESS
  7453                              <1> 
  7454                              <1> ;-----	DETERMINE SIZE OF WINDOW
  7455                              <1> 
  7456 0000299B 6629CA              <1> 	SUB	DX, CX
  7457 0000299E 6681C20101          <1>         ADD     DX, 101h                ; ADJUST VALUES
  7458 000029A3 C0E602              <1> 	SAL	DH, 2			; MULTIPLY ROWS BY 4 AT 8 VERT DOTS/CHAR
  7459                              <1> 					; AND EVEN/ODD ROWS
  7460                              <1> 
  7461                              <1> ;-----	DETERMINE CRT MODE
  7462                              <1> 
  7463 000029A6 803D[DA6F0000]06    <1> 	CMP	byte [CRT_MODE], 6	; TEST FOR MEDIUM RES
  7464 000029AD 7307                <1>         JNC     short _R12              ; FIND_SOURCE_DOWN
  7465                              <1> 
  7466                              <1> ;-----	MEDIUM RES DOWN
  7467 000029AF D0E2                <1> 	SAL	DL, 1			; # COLUMNS * 2, SINCE 2 BYTES/CHAR
  7468 000029B1 66D1E7              <1> 	SAL	DI, 1			; OFFSET *2 SINCE 2 BYTES/CHAR
  7469 000029B4 6647                <1> 	INC	DI			; POINT TO LAST BYTE
  7470                              <1> 
  7471                              <1> ;-----	DETERMINE THE SOURCE ADDRESS IN THE BUFFER
  7472                              <1> 
  7473                              <1> _R12:                                   ; FIND_SOURCE_DOWN
  7474 000029B6 81C700800B00        <1> 	add	edi, 0B8000h		
  7475 000029BC 6681C7F000          <1> 	ADD	DI, 240			; POINT TO LAST ROW OF PIXELS
  7476 000029C1 C0E702              <1> 	sal	bh, 2			; multiply number of lines by 4
  7477 000029C4 74(06)              <1> 	JZ	short 6			; IF ZERO, THEN BLANK ENTIRE FIELD
  7478 000029C6 B050                <1> 	MOV	AL, 80			; 80 BYTES/ROW
  7479 000029C8 F6E7                <1> 	mul	bh			; determine offset to source
  7480 000029CA 89FE                <1> 	MOV	eSI, eDI		; SET UP SOURCE
  7481 000029CC 6629C6              <1> 	SUB	SI, AX			; SUBTRACT THE OFFSET
  7482 000029CF 88F4                <1> 	MOV	AH, DH			; NUMBER OF ROWS IN FIELD
  7483 000029D1 28FC                <1> 	sub	ah, bh			; determine number to move
  7484                              <1> 
  7485                              <1> ;-----	LOOP THROUGH, MOVING ONE ROW AT A TIME, BOTH EVEN AND ODD FIELDS
  7486                              <1> 
  7487                              <1> _R13:                                   ; ROW_LOOP_DOWN
  7488 000029D3 E824000000          <1>         CALL    _R17                    ; MOVE ONE ROW
  7489 000029D8 6681EE5020          <1> 	SUB	SI, 2000h+80		; MOVE TO NEXT ROW
  7490 000029DD 6681EF5020          <1> 	SUB	DI, 2000h+80
  7491 000029E2 FECC                <1> 	DEC	AH			; NUMBER OF ROWS TO MOVE
  7492 000029E4 75ED                <1>         JNZ     short _R13              ; CONTINUE TILL ALL MOVED
  7493                              <1> 
  7494                              <1> ;-----	FILL IN THE VACATED LINE(S)
  7495                              <1> _R14:                                   ; CLEAR_ENTRY_DOWN
  7496 000029E6 88D8                <1> 	mov	al, bl			; attribute to fill with
  7497                              <1> _R15_:                                  ; CLEAR_LOOP_DOWN
  7498 000029E8 E82B000000          <1> 	CALL	_R18			; CLEAR A ROW
  7499 000029ED 6681EF5020          <1> 	SUB	DI, 2000h+80		; POINT TO NEXT LINE
  7500 000029F2 FECF                <1> 	dec	bh			; number of lines to fill
  7501 000029F4 75F2                <1>         JNZ     short _R15_             ; CLEAR_LOOP_DOWN
  7502                              <1> 	; 18/11/2020
  7503 000029F6 FC                  <1> 	CLD				; RESET THE DIRECTION FLAG
  7504                              <1> 	
  7505 000029F7 C3                  <1> 	retn				; EVERYTHING DONE
  7506                              <1> 
  7507                              <1> _R16:                                   ; BLANK_FIELD_DOWN
  7508 000029F8 88F7                <1> 	mov	bh, dh			; set blank count to everything in field
  7509 000029FA EBEA                <1>         JMP     short _R14              ; CLEAR THE FIELD
  7510                              <1> 
  7511                              <1> ; 27/06/2016 - TRDOS 386 (TRDOS v2.0)
  7512                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  7513                              <1> 
  7514                              <1> ;-----	ROUTINE TO MOVE ONE ROW OF INFORMATION
  7515                              <1> 
  7516                              <1> _R17:
  7517 000029FC 0FB6CA              <1> 	MOVzx	ecx, DL			; NUMBER OF BYTES IN THE ROW
  7518 000029FF 56                  <1> 	PUSH	eSI
  7519 00002A00 57                  <1> 	PUSH	eDI			; SAVE POINTERS
  7520 00002A01 F3A4                <1> 	REP	MOVSB			; MOVE THE EVEN FIELD
  7521 00002A03 5F                  <1> 	POP	eDI
  7522 00002A04 5E                  <1> 	POP	eSI
  7523 00002A05 6681C60020          <1> 	ADD	SI, 2000h
  7524 00002A0A 6681C70020          <1> 	ADD	DI, 2000h		; POINT TO THE ODD FIELD
  7525 00002A0F 56                  <1> 	PUSH	eSI
  7526 00002A10 57                  <1> 	PUSH	eDI			; SAVE THE POINTERS
  7527 00002A11 88D1                <1> 	MOV	CL, DL			; COUNT BACK
  7528 00002A13 F3A4                <1> 	REP	MOVSB			; MOVE THE ODD FIELD
  7529 00002A15 5F                  <1> 	POP	eDI
  7530 00002A16 5E                  <1> 	POP	eSI			; POINTERS BACK
  7531 00002A17 C3                  <1> 	RETn				; RETURN TO CALLER
  7532                              <1> 
  7533                              <1> ;-----	CLEAR A SINGLE ROW
  7534                              <1> 
  7535                              <1> _R18:
  7536 00002A18 0FB6CA              <1> 	MOVzx	ecx, DL			; NUMBER OF BYTES IN FIELD
  7537 00002A1B 57                  <1> 	PUSH	eDI			; SAVE POINTER
  7538 00002A1C F3AA                <1> 	REP	STOSB			; STORE THE NEW VALUE
  7539 00002A1E 5F                  <1> 	POP	eDI			; POINTER BACK
  7540 00002A1F 6681C70020          <1> 	ADD	DI, 2000h		; POINT TO ODD FIELD
  7541 00002A24 57                  <1> 	PUSH	eDI
  7542 00002A25 88D1                <1> 	MOV	CL, DL
  7543 00002A27 F3AA                <1> 	REP	STOSB			; FILL THE ODD FIELD
  7544 00002A29 5F                  <1> 	POP	eDI
  7545 00002A2A C3                  <1> 	RETn				; RETURN TO CALLER
  7546                              <1> 
  7547                              <1> ; 04/07/2016
  7548                              <1> ; 01/07/2016
  7549                              <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0)
  7550                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  7551                              <1> ;--------------------------------------------------
  7552                              <1> ; GRAPHICS WRITE
  7553                              <1> ;  THIS ROUTINE WRITES THE ASCII CHARACTER TO THE CURRENT
  7554                              <1> ;  POSITION ON THE SCREEN.
  7555                              <1> ; ENTRY --
  7556                              <1> ;  AL = CHARACTER TO WRITE
  7557                              <1> ;  BL = COLOR ATTRIBUTE TO BE USED FOR FOREGROUND COLOR
  7558                              <1> ;	IF BIT 7 IS SET, THE CHAR IS XOR'D INTO THE REGEN BUFFER
  7559                              <1> ;	(0 IS USED FOR THE BACKGROUND COLOR)
  7560                              <1> ;  CX = NUMBER OF CHARS TO WRITE
  7561                              <1> ;  DS = DATA SEGMENT
  7562                              <1> ;  ES = REGEN SEGMENT
  7563                              <1> ; EXIT --
  7564                              <1> ;  NOTHING IS RETURNED
  7565                              <1> ;
  7566                              <1> ; GRAPHICS READ
  7567                              <1> ;  THIS ROUTINE READS THE ASCII CHARACTER AT THE CURRENT CURSOR
  7568                              <1> ;  POSITION ON THE SCREEN BY MATCHING THE DOTS ON THE SCREEN TO THE
  7569                              <1> ;  CHARACTER GENERATOR CODE POINTS
  7570                              <1> ; ENTRY --
  7571                              <1> ;  NONE (0 IS ASSUMED AS THE BACKGROUND COLOR)
  7572                              <1> ; EXIT --
  7573                              <1> ;  AL = CHARACTER READ AT THAT POSITION (0 RETURNED IF NONE FOUND)
  7574                              <1> ;
  7575                              <1> ; FOR BOTH ROUTINES, THE IMAGES USED TO FORM CHARS ARE CONTAINED IN ROM
  7576                              <1> ;  FOR THE 1ST 128 CHARS.  TO ACCESS CHARS IN THE SECOND HALF, THE USER
  7577                              <1> ;  MUST INITIALIZE THE VECTOR AT INTERRUPT 1FH (LOCATION 0007CH) TO
  7578                              <1> ;  POINT TO THE USER SUPPLIED TABLE OF GRAPHIC IMAGES (8X8 BOXES).
  7579                              <1> ;  FAILURE TO DO SO WILL CAUSE IN STRANGE RESULTS
  7580                              <1> ;-----------------------------------------------------
  7581                              <1> 
  7582                              <1> GRAPHICS_WRITE:
  7583 00002A2B 25FF000000          <1> 	and 	eax, 0FFh		; ZERO TO HIGH OF CODE POINT
  7584 00002A30 50                  <1> 	PUSH	eAX			; SAVE CODE POINT VALUE
  7585                              <1> 
  7586                              <1> ;-----	DETERMINE POSITION IN REGEN BUFFER TO PUT CODE POINTS
  7587                              <1> 
  7588 00002A31 E84D010000          <1> 	CALL	S26			; FIND LOCATION IN REGEN BUFFER
  7589 00002A36 89C7                <1> 	MOV	eDI, eAX		; REGEN POINTER IN DI
  7590                              <1> 
  7591                              <1> ;-----	DETERMINE REGION TO GET CODE POINTS FROM
  7592                              <1> 
  7593 00002A38 58                  <1> 	POP	eAX			; RECOVER CODE POINT
  7594                              <1> 
  7595 00002A39 BE[C4600100]        <1> 	MOV	eSI, CRT_CHAR_GEN	; OFFSET OF IMAGES
  7596                              <1> 
  7597                              <1> ;-----	DETERMINE GRAPHICS MODE IN OPERATION
  7598                              <1> 					; DETERMINE_MODE
  7599 00002A3E 66C1E003            <1> 	SAL	AX, 3			; MULTIPLY CODE POINT VALUE BY 8
  7600 00002A42 01C6                <1> 	ADD	eSI, eAX		; SI HAS OFFSET OF DESIRED CODES
  7601                              <1> 	
  7602 00002A44 803D[DA6F0000]06    <1> 	CMP	byte [CRT_MODE], 6
  7603 00002A4B 7231                <1> 	JC	short S6		; TEST FOR MEDIUM RESOLUTION MODE
  7604                              <1> 
  7605                              <1> ;-----	HIGH RESOLUTION MODE
  7606                              <1> 
  7607 00002A4D 81C700800B00        <1> 	add	edi, 0B8000h
  7608                              <1> S1:					; HIGH_CHAR
  7609 00002A53 57                  <1> 	PUSH	eDI			; SAVE REGEN POINTER
  7610 00002A54 56                  <1> 	PUSH	eSI			; SAVE CODE POINTER
  7611 00002A55 B604                <1> 	MOV	DH, 4			; NUMBER OF TIMES THROUGH LOOP
  7612                              <1> S2:
  7613 00002A57 AC                  <1> 	LODSB				; GET BYTE FROM CODE POINTS
  7614 00002A58 F6C380              <1> 	TEST	BL, 80H			; SHOULD WE USE THE FUNCTION
  7615 00002A5B 7515                <1> 	JNZ	short S5		; TO PUT CHAR IN
  7616 00002A5D AA                  <1> 	STOSB				; STORE IN REGEN BUFFER
  7617 00002A5E AC                  <1> 	LODSB
  7618                              <1> S4:
  7619 00002A5F 8887FF1F0000        <1> 	MOV	[eDI+2000H-1], AL ; STORE IN SECOND HALF
  7620 00002A65 83C74F              <1> 	ADD	eDI, 79			; MOVE TO NEXT ROW IN REGEN
  7621 00002A68 FECE                <1> 	DEC	DH			; DONE WITH LOOP
  7622 00002A6A 75EB                <1> 	JNZ	short S2
  7623 00002A6C 5E                  <1> 	POP	eSI
  7624 00002A6D 5F                  <1> 	POP	eDI			; RECOVER REGEN POINTER
  7625 00002A6E 47                  <1> 	INC	eDI			; POINT TO NEXT CHAR POSITION
  7626 00002A6F E2E2                <1> 	LOOP	S1			; MORE CHARS TO WRITE
  7627 00002A71 C3                  <1> 	retn
  7628                              <1> 
  7629                              <1> S5:
  7630 00002A72 3207                <1> 	XOR	AL, [eDI]		; EXCLUSIVE OR WITH CURRENT
  7631 00002A74 AA                  <1> 	STOSB				; STORE THE CODE POINT
  7632 00002A75 AC                  <1> 	LODSB				; AGAIN FOR ODD FIELD
  7633 00002A76 3287FF1F0000        <1> 	XOR	AL, [eDI+2000H-1]
  7634 00002A7C EBE1                <1> 	JMP	short S4		; BACK TO MAINSTREAM
  7635                              <1> 
  7636                              <1> ;-----	MEDIUM RESOLUTION WRITE
  7637                              <1> S6:					; MED_RES_WRITE
  7638 00002A7E 88DA                <1> 	MOV	DL, BL			; SAVE HIGH COLOR BIT
  7639 00002A80 66D1E7              <1> 	SAL	DI, 1			; OFFSET*2 SINCE 2 BYTES/CHAR
  7640                              <1> 					; EXPAND BL TO FULL WORD OF COLOR
  7641 00002A83 80E303              <1> 	AND	BL, 3			; ISOLATE THE COLOR BITS ( LOW 2 BITS )
  7642 00002A86 B055                <1> 	MOV	AL, 055H 		; GET BIT CONVERSION MULTIPLIER
  7643 00002A88 F6E3                <1> 	MUL	BL			; EXPAND 2 COLOR BITS TO 4 REPLICATIONS
  7644 00002A8A 88C3                <1> 	MOV	BL, AL			; PLACE BACK IN WORK REGISTER
  7645 00002A8C 88C7                <1> 	MOV	BH, AL			; EXPAND TO 8 REPLICATIONS OF COLOR BITS
  7646 00002A8E 81C700800B00        <1> 	add	edi, 0B8000h
  7647                              <1> S7:                                     ; MED_CHAR
  7648 00002A94 57                  <1> 	PUSH	eDI			; SAVE REGEN POINTER
  7649 00002A95 56                  <1> 	PUSH	eSI			; SAVE THE CODE POINTER
  7650 00002A96 B604                <1> 	MOV	DH, 4			; NUMBER OF LOOPS
  7651                              <1> S8:
  7652 00002A98 AC                  <1> 	LODSB				; GET CODE POINT
  7653 00002A99 E8B3000000          <1> 	CALL	S21			; DOUBLE UP ALL THE BITS
  7654 00002A9E 6621D8              <1> 	AND	AX, BX			; CONVERT TO FOREGROUND COLOR ( 0 BACK )
  7655 00002AA1 86E0                <1> 	XCHG	AH, AL			; SWAP HIGH/LOW BYTES FOR WORD MOVE
  7656 00002AA3 F6C280              <1> 	TEST	DL, 80H			; IS THIS XOR FUNCTION
  7657 00002AA6 7403                <1> 	JZ	short S9		; NO, STORE IT IN AS IS
  7658 00002AA8 663307              <1> 	XOR	AX, [eDI]		; DO FUNCTION WITH LOW/HIGH
  7659                              <1> S9:
  7660 00002AAB 668907              <1> 	MOV	[eDI], AX		; STORE FIRST BYTE HIGH, SECOND LOW
  7661 00002AAE AC                  <1> 	LODSB				; GET CODE POINT
  7662 00002AAF E89D000000          <1> 	CALL	S21
  7663 00002AB4 6621D8              <1> 	AND	AX, BX			; CONVERT TO COLOR
  7664 00002AB7 86E0                <1> 	XCHG	AH, AL			; SWAP HIGH/LOW BYTES FOR WORD MOVE
  7665 00002AB9 F6C280              <1> 	TEST	DL, 80H			; AGAIN, IS THIS XOR FUNCTION
  7666 00002ABC 7407                <1> 	JZ	short _S10		; NO, JUST STORE THE VALUES
  7667 00002ABE 66338700200000      <1> 	XOR	AX, [eDI+2000H]		; FUNCTION WITH FIRST HALF LOW
  7668                              <1> _S10:
  7669 00002AC5 66898700200000      <1> 	MOV	[eDI+2000H], AX		; STORE SECOND PORTION HIGH
  7670 00002ACC 6683C750            <1> 	ADD	DI, 80			; POINT TO NEXT LOCATION
  7671 00002AD0 FECE                <1> 	DEC	DH
  7672 00002AD2 75C4                <1> 	JNZ	short S8		; KEEP GOING
  7673 00002AD4 5E                  <1> 	POP	eSI			; RECOVER CODE POINTER
  7674 00002AD5 5F                  <1> 	POP	eDI			; RECOVER REGEN POINTER
  7675 00002AD6 47                  <1> 	INC	eDI			; POINT TO NEXT CHAR POSITION
  7676 00002AD7 47                  <1> 	INC	eDI
  7677 00002AD8 E2BA                <1> 	LOOP	S7			; MORE TO WRITE
  7678 00002ADA C3                  <1> 	retn
  7679                              <1> 
  7680                              <1> ; 04/07/2016
  7681                              <1> ; 01/07/2016
  7682                              <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0)
  7683                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  7684                              <1> ;----------------------------------------
  7685                              <1> ; GRAPHICS READ
  7686                              <1> ;----------------------------------------
  7687                              <1> GRAPHICS_READ:
  7688 00002ADB E8A3000000          <1> 	CALL	S26			; CONVERTED TO OFFSET IN REGEN
  7689 00002AE0 89C6                <1> 	MOV	eSI, eAX		; SAVE IN SI
  7690 00002AE2 81C600800B00        <1> 	add	esi, 0B8000h		; 01/07/2016
  7691 00002AE8 83EC08              <1> 	SUB	eSP, 8			; ALLOCATE SPACE FOR THE READ CODE POINT
  7692 00002AEB 89E5                <1> 	MOV	eBP, eSP		; POINTER TO SAVE AREA
  7693                              <1> 
  7694                              <1> ;-----	DETERMINE GRAPHICS MODES
  7695 00002AED B604                <1> 	mov	dh, 4			; number of passes ; 01/07/2016
  7696 00002AEF 803D[DA6F0000]06    <1> 	CMP	byte [CRT_MODE], 6
  7697 00002AF6 7219                <1> 	JC	short S12		; MEDIUM RESOLUTION
  7698                              <1> 
  7699                              <1> ;-----	HIGH RESOLUTION READ
  7700                              <1> ;-----	GET VALUES FROM REGEN BUFFER AND CONVERT TO CODE POINT
  7701                              <1> 	;MOV	DH,4			; NUMBER OF PASSES
  7702                              <1> S11:
  7703 00002AF8 8A06                <1> 	MOV	AL, [eSI] 		; GET FIRST BYTE
  7704 00002AFA 884500              <1> 	MOV	[eBP], AL 		; SAVE IN STORAGE AREA
  7705 00002AFD 45                  <1> 	INC	eBP			; NEXT LOCATION
  7706 00002AFE 8A8600200000        <1> 	MOV	AL, [eSI+2000H]		; GET LOWER REGION BYTE
  7707 00002B04 884500              <1> 	MOV	[eBP], AL 		; ADJUST AND STORE
  7708 00002B07 45                  <1> 	INC	eBP
  7709 00002B08 83C650              <1> 	ADD	eSI, 80			; POINTER INTO REGEN
  7710 00002B0B FECE                <1> 	DEC	DH			; LOOP CONTROL
  7711 00002B0D 75E9                <1> 	JNZ	short S11		; DO IT SOME MORE
  7712 00002B0F EB1D                <1> 	JMP	SHORT S14		; GO MATCH THE SAVED CODE POINTS
  7713                              <1> 
  7714                              <1> ;-----	MEDIUM RESOLUTION READ
  7715                              <1> S12:	
  7716 00002B11 66D1E6              <1> 	SAL	SI, 1			; OFFSET*2 SINCE 2 BYTES/CHAR
  7717                              <1> 	;MOV	DH, 4			; NUMBER OF PASSES
  7718                              <1> S13:
  7719 00002B14 E84D000000          <1> 	CALL	S23			; GET BYTES FROM REGEN INTO SINGLE SAVE
  7720 00002B19 81C6FE1F0000        <1> 	ADD	eSI, 2000H-2		; GO TO LOWER REGION
  7721 00002B1F E842000000          <1> 	CALL	S23			; GET THIS PAIR INTO SAVE
  7722 00002B24 81EEB21F0000        <1> 	SUB	eSI, 2000H-80+2		; ADJUST POINTER BACK INTO UPPER
  7723 00002B2A FECE                <1> 	DEC	DH
  7724 00002B2C 75E6                <1> 	JNZ	short S13		; KEEP GOING UNTIL ALL 8 DONE
  7725                              <1> 
  7726                              <1> ;-----	SAVE AREA HAS CHARACTER IN IT, MATCH IT
  7727                              <1> S14:					; FIND_CHAR
  7728 00002B2E BF[C4600100]        <1> 	MOV	eDI, CRT_CHAR_GEN	; ESTABLISH ADDRESSING
  7729 00002B33 83ED08              <1> 	SUB	eBP, 8			; ADJUST POINTER TO START OF SAVE AREA
  7730 00002B36 89EE                <1> 	MOV	eSI, eBP
  7731                              <1> S15:
  7732 00002B38 66B80001            <1> 	mov	ax, 256			; NUMBER TO TEST AGAINST
  7733                              <1> S16:
  7734 00002B3C 56                  <1> 	PUSH	eSI			; SAVE SAVE AREA POINTER
  7735 00002B3D 57                  <1> 	PUSH	eDI			; SAVE CODE POINTER
  7736                              <1> 	;MOV	eCX, 4			; NUMBER OF WORDS TO MATCH
  7737                              <1> 	;REPE	CMPSW			; COMPARE THE 8 BYTES AS WORDS
  7738 00002B3E A7                  <1> 	cmpsd				; compare first 4 bytes 
  7739 00002B3F 7501                <1> 	jne	short S17		; 
  7740 00002B41 A7                  <1> 	cmpsd				; compare last 4 bytes
  7741                              <1> S17:
  7742 00002B42 5F                  <1> 	POP	eDI			; RECOVER THE POINTERS
  7743 00002B43 5E                  <1> 	POP	eSI
  7744                              <1> 	;JZ	short S18		; IF ZERO FLAG SET, THEN MATCH OCCURRED
  7745 00002B44 7407                <1> 	je	short S18
  7746                              <1> 	;				; NO MATCH, MOVE ON TO NEXT
  7747 00002B46 83C708              <1> 	ADD	eDI, 8			; NEXT CODE POINT
  7748 00002B49 6648                <1> 	dec	ax			; LOOP CONTROL
  7749 00002B4B 75EF                <1> 	JNZ	short S16		; DO ALL OF THEM
  7750                              <1> 
  7751                              <1> ;-----	CHARACTER IS FOUND ( AL=0 IF NOT FOUND )
  7752                              <1> S18:	
  7753 00002B4D 83C408              <1> 	ADD	eSP, 8			; READJUST THE STACK, THROW AWAY SAVE
  7754 00002B50 C3                  <1> 	retn				; ALL DONE
  7755                              <1> 
  7756                              <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0)
  7757                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  7758                              <1> ;--------------------------------------------
  7759                              <1> ; EXPAND BYTE
  7760                              <1> ;  THIS ROUTINE TAKES THE BYTE IN AL AND DOUBLES ALL
  7761                              <1> ;  OF THE BITS, TURNING THE 8 BITS INTO 16 BITS.
  7762                              <1> ;  THE RESULT IS LEFT IN AX
  7763                              <1> ;--------------------------------------------
  7764                              <1> S21:
  7765 00002B51 6651                <1> 	PUSH	CX			; SAVE REGISTER
  7766                              <1> 	;MOV	CX, 8			; SHIFT COUNT REGISTER FOR ONE BYTE
  7767 00002B53 B108                <1> 	mov	cl, 8
  7768                              <1> S22:
  7769 00002B55 D0C8                <1> 	ROR	AL,1			; SHIFT BITS, LOW BIT INTO CARRY FLAG
  7770 00002B57 66D1DD              <1> 	RCR	BP,1			; MOVE CARRY FLAG (LOW BIT INTO RESULTS
  7771 00002B5A 66D1FD              <1> 	SAR	BP,1			; SIGN EXTEND HIGH BIT (DOUBLE IT)
  7772                              <1> 	;LOOP	S22			; REPEAT FOR ALL 8 BITS
  7773 00002B5D FEC9                <1> 	dec	cl
  7774 00002B5F 75F4                <1> 	jnz	short S22
  7775 00002B61 6695                <1> 	XCHG	AX, BP			; MOVE RESULTS TO PARAMETER REGISTER
  7776 00002B63 6659                <1> 	POP	CX			; RECOVER REGISTER
  7777 00002B65 C3                  <1> 	RETn				; ALL DONE
  7778                              <1> 
  7779                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
  7780                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  7781                              <1> ;--------------------------------------------------
  7782                              <1> ; MED_READ_BYTE
  7783                              <1> ; THIS ROUTINE WILL TAKE 2 BYTES FROM THE REGEN BUFFER,
  7784                              <1> ;  COMPARE AGAINST THE CURRENT FOREGROUND COLOR, AND PLACE
  7785                              <1> ;  THE CORRESPONDING ON/OFF BIT PATTERN INTO THE CURRENT
  7786                              <1> ;  POSITION IN THE SAVE AREA
  7787                              <1> ; ENTRY --
  7788                              <1> ;  SI,DS = POINTER TO REGEN AREA OF INTEREST
  7789                              <1> ;  BX = EXPANDED FOREGROUND COLOR
  7790                              <1> ;  BP = POINTER TO SAVE AREA
  7791                              <1> ; EXIT --
  7792                              <1> ;  SI AND BP ARE INCREMENTED
  7793                              <1> ;----------------------------------------------------
  7794                              <1> S23:
  7795 00002B66 66AD                <1> 	LODSW				; GET FIRST BYTE AND SECOND BYTES
  7796 00002B68 86C4                <1> 	XCHG	AL, AH			; SWAP FOR COMPARE
  7797 00002B6A 66B900C0            <1> 	MOV	CX, 0C000H		; 2 BIT MASK TO TEST THE ENTRIES
  7798 00002B6E B200                <1> 	MOV	DL, 0			; RESULT REGISTER
  7799                              <1> S24:
  7800 00002B70 6685C8              <1> 	TEST	AX, CX			; IS THIS SECTION BACKCROUND?
  7801 00002B73 7401                <1>         JZ      short S25               ; IF ZERO, IT IS BACKGROUND (CARRY=0)
  7802 00002B75 F9                  <1> 	STC				; WASN'T, SO SET CARRY
  7803                              <1> S25:
  7804 00002B76 D0D2                <1> 	RCL	DL, 1			; MOVE THAT BIT INTO THE RESULT
  7805 00002B78 66C1E902            <1> 	SHR	CX, 2			; MOVE THE MASK TO THE RIGHT BY 2 BITS
  7806 00002B7C 73F2                <1> 	JNC	short S24		; DO IT AGAIN IF MASK DIDN'T FALL OUT
  7807 00002B7E 885500              <1> 	MOV	[eBP], DL 		; STORE RESULT IN SAVE AREA
  7808 00002B81 45                  <1> 	INC	eBP			; ADJUST POINTER
  7809 00002B82 C3                  <1> 	RETn				; ALL DONE
  7810                              <1> 
  7811                              <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0)
  7812                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  7813                              <1> ;-----------------------------------------
  7814                              <1> ; V4_POSITION
  7815                              <1> ;  THIS ROUTINE TAKES THE CURSOR POSITION CONTAINED IN
  7816                              <1> ;  THE MEMORY LOCATION, AND CONVERTS IT INTO AN OFFSET
  7817                              <1> ;  INTO THE REGEN BUFFER, ASSUMING ONE BYTE/CHAR.
  7818                              <1> ;  FOR MEDIUM RESOLUTION GRAPHICS, THE NUMBER MUST
  7819                              <1> ;  BE DOUBLED.
  7820                              <1> ; ENTRY -- NO REGISTERS,MEMORY LOCATION @CURSOR_POSN IS USED
  7821                              <1> ; EXIT--
  7822                              <1> ;  AX CONTAINS OFFSET INTO REGEN BUFFER
  7823                              <1> ;-----------------------------------------
  7824                              <1> S26:
  7825 00002B83 0FB705[4E8A0100]    <1> 	movzx	eax, word [CURSOR_POSN]	; GET CURRENT CURSOR
  7826                              <1> GRAPH_POSN:
  7827 00002B8A 53                  <1> 	PUSH	eBX			; SAVE REGISTER
  7828 00002B8B 0FB6D8              <1> 	movzx	ebx, al			; SAVE A COPY OF CURRENT CURSOR
  7829 00002B8E A0[DC6F0000]        <1> 	MOV	AL, [CRT_COLS]		; GET BYTES PER COLUMN
  7830 00002B93 F6E4                <1> 	MUL	AH			; MULTIPLY BY ROWS
  7831 00002B95 66C1E002            <1> 	SHL	AX, 2			; MULTIPLY * 4 SINCE 4 ROWS/BYTE
  7832 00002B99 01D8                <1> 	ADD	eAX, eBX		; DETERMINE OFFSET
  7833 00002B9B 5B                  <1> 	POP	eBX			; RECOVER POINTER
  7834 00002B9C C3                  <1> 	RETn				; ALL DONE
  7835                              <1> 
  7836                              <1> ; 09/07/2016
  7837                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
  7838                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  7839                              <1> ;---------------------------------------------
  7840                              <1> ; SET_COLOR
  7841                              <1> ;	THIS ROUTINE WILL ESTABLISH THE BACKGROUND COLOR, THE OVERSCAN COLOR,
  7842                              <1> ;	AND THE FOREGROUND COLOR SET FOR MEDIUM RESOLUTION GRAPHICS
  7843                              <1> ; INPUT
  7844                              <1> ;	(BH) HAS COLOR ID
  7845                              <1> ;		IF BH=0, THE BACKGROUND COLOR VALUE IS SET
  7846                              <1> ;			FROM THE LOW BITS OF BL (0-31)
  7847                              <1> ;		IF BH=1, THE PALETTE SELECTION IS MADE
  7848                              <1> ;			BASED ON THE LOW BIT OF BL:
  7849                              <1> ;				0 = GREEN, RED, YELLOW FOR COLORS 1,2,3
  7850                              <1> ;				1 = BLUE, CYAN, MAGENTA FOR COLORS 1,2,3
  7851                              <1> ;	(BL) HAS THE COLOR VALUE TO BE USED
  7852                              <1> ; OUTPUT
  7853                              <1> ;	THE COLOR SELECTION IS UPDATED
  7854                              <1> ;----------------------------------------------
  7855                              <1> SET_COLOR:
  7856 00002B9D 803D[DA6F0000]07    <1>         cmp     byte [CRT_MODE], 7      ; 09/07/2016
  7857 00002BA4 0F87B5EFFFFF        <1> 	ja	VIDEO_RETURN		; nothing to do for VGA modes
  7858                              <1> 
  7859                              <1> 	;MOV	DX, [ADDR_6845]		; I/O PORT FOR PALETTE
  7860                              <1> 	;mov	dx, 3D4h
  7861                              <1> 	;ADD	DX,5			; OVERSCAN PORT
  7862 00002BAA 66BAD903            <1> 	mov	dx, 3D9h
  7863 00002BAE A0[DD6F0000]        <1> 	MOV	AL, [CRT_PALETTE] 	; GET THE CURRENT PALETTE VALUE
  7864 00002BB3 08FF                <1> 	OR	BH, BH			; IS THIS COLOR 0?
  7865 00002BB5 7512                <1> 	JNZ	short M20		; OUTPUT COLOR 1
  7866                              <1> 
  7867                              <1> ;-----	HANDLE COLOR 0 BY SETTING THE BACKGROUND COLOR
  7868                              <1> 
  7869 00002BB7 24E0                <1> 	AND	AL, 0E0H 		; TURN OFF LOW 5 BITS OF CURRENT
  7870 00002BB9 80E31F              <1> 	AND	BL, 01FH 		; TURN OFF HIGH 3 BITS OF INPUT VALUE
  7871 00002BBC 08D8                <1> 	OR	AL, BL			; PUT VALUE INTO REGISTER
  7872                              <1> M19:					; OUTPUT THE PALETTE
  7873 00002BBE EE                  <1> 	OUT	DX, AL			; OUTPUT COLOR SELECTION TO 3D9 PORT
  7874 00002BBF A2[DD6F0000]        <1> 	MOV	[CRT_PALETTE], AL 	; SAVE THE COLOR VALUE
  7875 00002BC4 E996EFFFFF          <1> 	JMP	VIDEO_RETURN
  7876                              <1> 
  7877                              <1> ;-----	HANDLE COLOR 1 BY SELECTING THE PALETTE TO BE USED
  7878                              <1> 
  7879                              <1> M20:
  7880 00002BC9 24DF                <1> 	AND	AL, 0DFH 		; TURN OFF PALETTE SELECT BIT
  7881 00002BCB D0EB                <1> 	SHR	BL, 1			; TEST THE LOW ORDER BIT OF BL
  7882 00002BCD 73EF                <1> 	JNC	short M19		; ALREADY DONE
  7883 00002BCF 0C20                <1> 	OR	AL, 20H			; TURN ON PALETTE SELECT BIT
  7884 00002BD1 EBEB                <1> 	JMP	short M19		; GO DO IT
  7885                              <1> 
  7886                              <1> ; 09/07/2016
  7887                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
  7888                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  7889                              <1> ;--------------------------------------------
  7890                              <1> ; READ DOT -- WRITE DOT
  7891                              <1> ; THESE ROUTINES WILL WRITE A DOT, OR READ THE
  7892                              <1> ;  DOT AT THE INDICATED LOCATION
  7893                              <1> ; ENTRY --
  7894                              <1> ;   DX = ROW (0-199)	(THE ACTUAL VALUE DEPENDS ON THE MODE)
  7895                              <1> ;   CX = COLUMN ( 0-639) ( THE VALUES ARE NOT RANGE CHECKED )
  7896                              <1> ;   AL = DOT VALUE TO WRITE (1,2 OR 4 BITS DEPENDING ON MODE,
  7897                              <1> ;	REQUIRED FOR WRITE DOT ONLY, RIGHT JUSTIFIED)
  7898                              <1> ;	BIT 7 OF AL = 1 INDICATES XOR THE VALUE INTO THE LOCATION
  7899                              <1> ;   DS = DATA SEGMENT
  7900                              <1> ;   ES = REGEN SEGMENT
  7901                              <1> ;
  7902                              <1> ; EXIT
  7903                              <1> ;	AL = DOT VALUE READ, RIGHT JUSTIFIED, READ ONLY
  7904                              <1> ;----------------------------------------------
  7905                              <1> 
  7906                              <1> READ_DOT:
  7907                              <1> 	; 09/07/2016
  7908 00002BD3 8A25[DA6F0000]      <1> 	mov	ah,  [CRT_MODE]
  7909 00002BD9 80FC07              <1> 	cmp	ah, 7 ; 6!?
  7910 00002BDC 760A                <1> 	jna	short read_dot_cga
  7911                              <1> 
  7912 00002BDE E8D7030000          <1> 	call	vga_read_pixel
  7913                              <1> 	; al = pixel value
  7914 00002BE3 E97CEFFFFF          <1> 	jmp	_video_return
  7915                              <1> 
  7916                              <1> read_dot_cga:
  7917                              <1> 	;je	VIDEO_RETURN ; 7	
  7918 00002BE8 80FC04              <1> 	cmp	ah, 4 ; graphics ? 
  7919 00002BEB 0F826EEFFFFF        <1> 	jb	VIDEO_RETURN ; no, text mode, nothing to do
  7920                              <1> 
  7921 00002BF1 E855000000          <1> 	CALL	R3			; DETERMINE BYTE POSITION OF DOT
  7922 00002BF6 8A06                <1> 	MOV	AL, [eSI]		; GET THE BYTE
  7923 00002BF8 20E0                <1> 	AND	AL, AH			; MASK OFF THE OTHER BITS IN THE BYTE
  7924 00002BFA D2E0                <1> 	SHL	AL, CL			; LEFT JUSTIFY THE VALUE
  7925 00002BFC 88F1                <1> 	MOV	CL, DH			; GET NUMBER OF BITS IN RESULT
  7926 00002BFE D2C0                <1> 	ROL	AL, CL			; RIGHT JUSTIFY THE RESULT
  7927                              <1> 	;JMP	VIDEO_RETURN		; RETURN FROM VIDEO I/O
  7928 00002C00 0FB6C0              <1> 	movzx	eax, al
  7929 00002C03 E95CEFFFFF          <1> 	jmp	_video_return
  7930                              <1> 
  7931                              <1> ; 09/07/2016
  7932                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
  7933                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  7934                              <1> 
  7935                              <1> WRITE_DOT:
  7936                              <1> 	; 09/07/2016
  7937 00002C08 8A25[DA6F0000]      <1> 	mov	ah, [CRT_MODE]
  7938 00002C0E 80FC07              <1> 	cmp	ah, 7 ; 6!?
  7939 00002C11 760A                <1> 	jna	short write_dot_cga
  7940                              <1> 	
  7941 00002C13 E811030000          <1> 	call	vga_write_pixel
  7942 00002C18 E942EFFFFF          <1> 	jmp	VIDEO_RETURN
  7943                              <1> 
  7944                              <1> write_dot_cga:
  7945                              <1> 	;je	VIDEO_RETURN ; 7	
  7946 00002C1D 80FC04              <1> 	cmp	ah, 4 ; graphics ? 
  7947 00002C20 0F8239EFFFFF        <1> 	jb	VIDEO_RETURN ; no, text mode, nothing to do
  7948                              <1> 
  7949                              <1> 	;PUSH	AX			; SAVE DOT VALUE
  7950 00002C26 6650                <1> 	PUSH	AX			; TWICE
  7951 00002C28 E81E000000          <1> 	CALL	R3			; DETERMINE BYTE POSITION OF THE DOT
  7952 00002C2D D2E8                <1> 	SHR	AL, CL			; SHIFT TO SET UP THE BITS FOR OUTPUT
  7953 00002C2F 20E0                <1> 	AND	AL, AH			; STRIP OFF THE OTHER BITS
  7954 00002C31 8A0E                <1> 	MOV	CL, [eSI]		; GET THE CURRENT BYTE
  7955 00002C33 665B                <1> 	POP	BX			; RECOVER XOR FLAG
  7956 00002C35 F6C380              <1> 	TEST	BL, 80H			; IS IT ON
  7957 00002C38 750D                <1> 	JNZ	short R2		; YES, XOR THE DOT
  7958 00002C3A F6D4                <1> 	NOT	AH			; SET MASK TO REMOVE THE INDICATED BITS
  7959 00002C3C 20E1                <1> 	AND	CL, AH
  7960 00002C3E 08C8                <1> 	OR	AL, CL			; OR IN THE NEW VALUE OF THOSE BITS
  7961                              <1> R1:					; FINISH_DOT
  7962 00002C40 8806                <1> 	MOV	[eSI], AL		; RESTORE THE BYTE IN MEMORY
  7963                              <1> 	;POP	AX
  7964 00002C42 E918EFFFFF          <1> 	JMP	VIDEO_RETURN		; RETURN FROM VIDEO I/O
  7965                              <1> R2:					; XOR_DOT
  7966 00002C47 30C8                <1> 	XOR	AL, CL			; EXCLUSIVE OR THE DOTS
  7967 00002C49 EBF5                <1> 	JMP	short R1		; FINISH UP THE WRITING
  7968                              <1> 
  7969                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
  7970                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  7971                              <1> 
  7972                              <1> ;----------------------------------------------
  7973                              <1> ; THIS SUBROUTINE DETERMINES THE REGEN BYTE LOCATION OF THE
  7974                              <1> ; INDICATED ROW COLUMN VALUE IN GRAPHICS MODE.
  7975                              <1> ; ENTRY --
  7976                              <1> ;  DX = ROW VALUE (0-199)
  7977                              <1> ;  CX = COLUMN VALUE (0-639)
  7978                              <1> ; EXIT --
  7979                              <1> ;  SI = OFFSET INTO REGEN BUFFER FOR BYTE OF INTEREST
  7980                              <1> ;  AH = MASK TO STRIP OFF THE BITS OF INTEREST
  7981                              <1> ;  CL = BITS TO SHIFT TO RIGHT JUSTIFY THE MASK IN AH
  7982                              <1> ;  DH = # BITS IN RESULT
  7983                              <1> ;  BX = MODIFIED
  7984                              <1> ;-----------------------------------------------
  7985                              <1> R3:
  7986                              <1> 
  7987                              <1> ;-----	DETERMINE 1ST BYTE IN INDICATED ROW BY MULTIPLYING ROW VALUE BY 40
  7988                              <1> ;-----	 ( LOW BIT OF ROW DETERMINES EVEN/ODD, 80 BYTES/ROW )
  7989                              <1> 
  7990 00002C4B 0FB7F0              <1> 	movzx	esi, ax			; WILL SAVE AL AND AH DURING OPERATION
  7991 00002C4E B028                <1> 	MOV	AL, 40
  7992 00002C50 F6E2                <1> 	MUL	DL			; AX= ADDRESS OF START OF INDICATED ROW
  7993 00002C52 A808                <1> 	TEST	AL, 08H 		; TEST FOR EVEN/ODD ROW CALCULATED
  7994 00002C54 7404                <1> 	JZ	short R4		; JUMP IF EVEN ROW
  7995 00002C56 6605D81F            <1> 	ADD	AX, 2000H-40		; OFFSET TO LOCATION OF ODD ROWS ADJUST
  7996                              <1> R4:					; EVEN_ROW
  7997 00002C5A 6696                <1> 	XCHG	SI, AX			; MOVE POINTER TO (SI) AND RECOVER (AX)
  7998 00002C5C 81C600800B00        <1> 	add	esi, 0B8000h
  7999 00002C62 6689CA              <1> 	MOV	DX, CX			; COLUMN VALUE TO DX
  8000                              <1> 
  8001                              <1> ;-----	DETERMINE GRAPHICS MODE CURRENTLY IN EFFECT
  8002                              <1> 
  8003                              <1> ; SET UP THE REGISTERS ACCORDING TO THE MODE
  8004                              <1> ; CH = MASK FOR LOW OF COLUMN ADDRESS ( 7/3 FOR HIGH/MED RES )
  8005                              <1> ; CL = # OF ADDRESS BITS IN COLUMN VALUE ( 3/2 FOR H/M )
  8006                              <1> ; BL = MASK TO SELECT BITS FROM POINTED BYTE ( 80H/C0H FOR H/M )
  8007                              <1> ; BH = NUMBER OF VALID BITS IN POINTED BYTE ( 1/2 FOR H/M )
  8008                              <1> 
  8009 00002C65 66BBC002            <1> 	MOV	BX, 2C0H
  8010 00002C69 66B90203            <1> 	MOV	CX, 302H 		; SET PARMS FOR MED RES
  8011 00002C6D 803D[DA6F0000]06    <1> 	CMP	byte [CRT_MODE], 6
  8012 00002C74 7208                <1> 	JC	short R5		; HANDLE IF MED RES
  8013 00002C76 66BB8001            <1> 	MOV	BX, 180H
  8014 00002C7A 66B90307            <1> 	MOV	CX, 703H 		; SET PARMS FOR HIGH RES
  8015                              <1> 
  8016                              <1> ;-----	DETERMINE BIT OFFSET IN BYTE FROM COLUMN MASK
  8017                              <1> R5:
  8018 00002C7E 20D5                <1> 	AND	CH, DL			; ADDRESS OF PEL WITHIN BYTE TO CH
  8019                              <1> 
  8020                              <1> ;-----	DETERMINE BYTE OFFSET FOR THIS LOCATION IN COLUMN
  8021                              <1> 
  8022 00002C80 66D3EA              <1> 	SHR	DX, CL			; SHIFT BY CORRECT AMOUNT
  8023 00002C83 6601D6              <1> 	ADD	SI, DX			; INCREMENT THE POINTER
  8024 00002C86 88FE                <1> 	MOV	DH, BH			; GET THE # OF BITS IN RESULT TO DH
  8025                              <1> 
  8026                              <1> ;-----	MULTIPLY BH (VALID BITS IN BYTE) BY CH (BIT OFFSET)
  8027                              <1> 
  8028 00002C88 28C9                <1> 	SUB	CL, CL			; ZERO INTO STORAGE LOCATION
  8029                              <1> R6:
  8030 00002C8A D0C8                <1> 	ROR	AL, 1			; LEFT JUSTIFY VALUE IN AL (FOR WRITE)
  8031 00002C8C 00E9                <1> 	ADD	CL, CH			; ADD IN THE BIT OFFSET VALUE
  8032 00002C8E FECF                <1> 	DEC	BH			; LOOP CONTROL
  8033 00002C90 75F8                <1> 	JNZ	short R6		; ON EXIT, CL HAS COUNT TO RESTORE BITS
  8034 00002C92 88DC                <1> 	MOV	AH, BL			;  GET MASK TO AH
  8035 00002C94 D2EC                <1> 	SHR	AH, CL			;  MOVE THE MASK TO CORRECT LOCATION
  8036 00002C96 C3                  <1> 	RETn				;  RETURN WITH EVERYTHING SET UP
  8037                              <1> 
  8038                              <1> load_dac_palette:
  8039                              <1> 	; 29/07/2016
  8040                              <1> 	; 23/07/2016
  8041                              <1> 	; 03/07/2016 (TRDOS 386 = TRDOS v2.0)
  8042                              <1> 	; (set_mode_vga)
  8043                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  8044                              <1> 	; vgabios-0.7a (2011)
  8045                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  8046                              <1> 	; 'vgabios.c', 'load_dac_palette'
  8047                              <1> 	;
  8048                              <1> 	; Oracle VirtualBox 5.0.24 VGABios Source Code
  8049                              <1> 	; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
  8050                              <1> 	;
  8051                              <1> 	; INPUT -> AH = DAC selection number (3, 2 or 1)
  8052                              <1> 	; OUTPUT -> ECX = 0, AX = 0
  8053                              <1> 	; (Modifed registers: EAX, ECX, EDX, ESI)
  8054                              <1> 	;
  8055 00002C97 66BAC803            <1> 	mov	dx, 3C8h  ; VGAREG_DAC_WRITE_ADDRESS
  8056 00002C9B 28C0                <1> 	sub	al, al ; 0
  8057 00002C9D EE                  <1> 	out	dx, al ; 0 ; color index, always 0 at the beginning
  8058 00002C9E 6642                <1> 	inc	dx   ; 3C9h ; VGAREG_DAC_DATA
  8059 00002CA0 B900010000          <1> 	mov	ecx, 256   ; always 256*3 values
  8060                              <1> 	;push	esi
  8061 00002CA5 88E0                <1> 	mov	al, ah
  8062 00002CA7 B43F                <1> 	mov	ah, 3Fh	; 3Fh except DAC selection number 3
  8063 00002CA9 3C02                <1> 	cmp 	al, 2
  8064 00002CAB 7414                <1> 	je	short l_dac_p_2
  8065 00002CAD 7719                <1> 	ja	short l_dac_p_3
  8066 00002CAF 20C0                <1> 	and	al, al
  8067 00002CB1 7507                <1> 	jnz	short l_dac_p_1
  8068                              <1> l_dac_p_0:
  8069 00002CB3 BE[845B0100]        <1> 	mov	esi, palette0
  8070 00002CB8 EB15                <1> 	jmp	short l_dac_p_4	
  8071                              <1> l_dac_p_1:
  8072 00002CBA BE[445C0100]        <1> 	mov	esi, palette1
  8073 00002CBF EB0E                <1> 	jmp	short l_dac_p_4
  8074                              <1> l_dac_p_2:
  8075 00002CC1 BE[045D0100]        <1> 	mov	esi, palette2
  8076 00002CC6 EB07                <1> 	jmp	short l_dac_p_4
  8077                              <1> l_dac_p_3:
  8078 00002CC8 B4FF                <1> 	mov	ah, 0FFh ; dac registers
  8079 00002CCA BE[C45D0100]        <1> 	mov	esi, palette3
  8080                              <1> l_dac_p_4:
  8081 00002CCF AC                  <1> 	lodsb
  8082 00002CD0 EE                  <1> 	out	dx, al  ; Red
  8083 00002CD1 AC                  <1> 	lodsb
  8084 00002CD2 EE                  <1> 	out	dx, al	; Green
  8085 00002CD3 AC                  <1> 	lodsb
  8086 00002CD4 EE                  <1> 	out	dx, al	; Blue
  8087 00002CD5 20E4                <1> 	and	ah, ah
  8088 00002CD7 7405                <1> 	jz	short l_dac_p_5	
  8089 00002CD9 FECC                <1> 	dec	ah
  8090 00002CDB E2F2                <1> 	loop	l_dac_p_4
  8091                              <1> 	;pop	esi
  8092 00002CDD C3                  <1> 	retn
  8093                              <1> l_dac_p_5:
  8094                              <1> 	; 29/07/2016
  8095 00002CDE FEC9                <1> 	dec	cl
  8096 00002CE0 7407                <1> 	jz	short l_dac_p_7
  8097                              <1> 	;
  8098 00002CE2 28C0                <1> 	sub	al, al ; 0
  8099                              <1> l_dac_p_6:
  8100 00002CE4 EE                  <1> 	out	dx, al ; outb(VGAREG_DAC_DATA,0);
  8101 00002CE5 EE                  <1> 	out	dx, al
  8102 00002CE6 EE                  <1> 	out	dx, al
  8103 00002CE7 E2FB                <1> 	loop	l_dac_p_6
  8104                              <1> l_dac_p_7:
  8105                              <1> 	;pop	esi
  8106 00002CE9 C3                  <1> 	retn
  8107                              <1> 
  8108                              <1> gray_scale_summing:
  8109                              <1> 	; 03/07/2016 (TRDOS 386 = TRDOS v2.0)
  8110                              <1> 	; (set_mode_vga)
  8111                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  8112                              <1> 	; vgabios-0.7a (2011)
  8113                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  8114                              <1> 	; 'vgabios.c', 'biosfn_perform_gray_scale_summing'
  8115                              <1> 	;
  8116                              <1> 	; Oracle VirtualBox 5.0.24 VGABios Source Code
  8117                              <1> 	; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
  8118                              <1> 	;
  8119                              <1> 
  8120                              <1> 	; INPUT -> EBX = Start address (color index <= 255)
  8121                              <1> 	;	   ECX = Count (<= 256)
  8122                              <1> 	; OUTPUT -> (E)CX = 0
  8123                              <1> 	; (Modifed registers: EAX, ECX, EDX, EBX)
  8124                              <1> 
  8125 00002CEA 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  8126 00002CEE EC                  <1> 	in	al, dx
  8127 00002CEF 30C0                <1> 	xor	al, al ; 0
  8128 00002CF1 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  8129 00002CF5 EE                  <1> 	out	dx, al	; clear bit 5
  8130                              <1> 			; (while loading palette registers)
  8131                              <1> 	; set read address and switch to read mode
  8132                              <1> g_s_s_1:
  8133 00002CF6 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
  8134 00002CFA 88D8                <1> 	mov	al, bl
  8135 00002CFC EE                  <1> 	out	dx, al
  8136                              <1> 	; get 6-bit wide RGB data values
  8137                              <1>  	; intensity = (0.3*Red)+(0.59*Green)+(0.11*Blue)
  8138                              <1> 	; i = ( ( 77*r + 151*g + 28*b ) + 0x80 ) >> 8;
  8139 00002CFD 66BAC903            <1> 	mov	dx, 3C9h ; VGAREG_DAC_DATA
  8140 00002D01 EC                  <1> 	in	al, dx ; red
  8141 00002D02 B44D                <1> 	mov	ah, 77 ; 0.3* Red
  8142 00002D04 F6E4                <1> 	mul	ah
  8143 00002D06 6650                <1> 	push	ax
  8144 00002D08 EC                  <1> 	in	al, dx ; green
  8145 00002D09 B497                <1> 	mov	ah, 151  ; 0.59 * Green
  8146 00002D0B F6E4                <1> 	mul	ah
  8147 00002D0D 6650                <1> 	push	ax
  8148 00002D0F EC                  <1> 	in	al, dx ; blue
  8149 00002D10 B41C                <1> 	mov	ah, 28 ; 0.11 * Blue
  8150 00002D12 F6E4                <1> 	mul	ah
  8151 00002D14 665A                <1> 	pop	dx
  8152 00002D16 6601D0              <1> 	add	ax, dx
  8153 00002D19 665A                <1> 	pop	dx
  8154 00002D1B 6601D0              <1> 	add	ax, dx
  8155 00002D1E 66058000            <1> 	add	ax, 80h  
  8156 00002D22 B03F                <1> 	mov	al, 3Fh
  8157 00002D24 38C4                <1> 	cmp	ah, al	; if(i>0x3f)i=0x3f
  8158 00002D26 7602                <1> 	jna	short g_s_s_2
  8159 00002D28 88C4                <1> 	mov	ah, al
  8160                              <1> g_s_s_2:
  8161 00002D2A 66BAC803            <1> 	mov	dx, 3C8h  ; VGAREG_DAC_WRITE_ADDRESS
  8162 00002D2E 88D8                <1> 	mov	al, bl ; color index
  8163 00002D30 EE                  <1> 	out	dx, al
  8164 00002D31 88E0                <1> 	mov	al, ah ; intensity
  8165 00002D33 6642                <1> 	inc	dx ; 3C9h ; VGAREG_DAC_DATA
  8166 00002D35 EE                  <1> 	out	dx, al ; R (R=G=B)
  8167 00002D36 88E0                <1> 	mov	al, ah ; intensity
  8168 00002D38 EE                  <1> 	out	dx, al ; G (R=G=B)
  8169 00002D39 88E0                <1>  	mov	al, ah ; intensity
  8170 00002D3B EE                  <1> 	out	dx, al ; B (R=G=B)
  8171 00002D3C 6649                <1> 	dec	cx
  8172 00002D3E 7404                <1> 	jz	short g_s_s_3
  8173 00002D40 FEC3                <1> 	inc	bl    ; next color index value
  8174 00002D42 EBB2                <1> 	jmp	short g_s_s_1
  8175                              <1> g_s_s_3:
  8176 00002D44 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  8177 00002D48 EC                  <1> 	in	al, dx
  8178 00002D49 B020                <1> 	mov	al, 20h
  8179 00002D4B 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  8180 00002D4F EE                  <1> 	out	dx, al ; 20h -> set bit 5
  8181                              <1> 		        ; (after loading palette regs)
  8182 00002D50 C3                  <1> 	retn
  8183                              <1> 
  8184                              <1> vga_write_char_attr:
  8185                              <1> vga_write_char_only: 
  8186                              <1> 	; 08/07/2016 (TRDOS 386 = TRDOS v2.0)
  8187                              <1> 	;
  8188                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  8189                              <1> 	; vgabios-0.7a (2011)
  8190                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  8191                              <1> 	; 'vgabios.c', 'biosfn_write_char_attr'
  8192                              <1> 	; 'biosfn_write_char_only'
  8193                              <1> 
  8194                              <1> 	; INPUT ->
  8195                              <1> 	; [CRT_MODE] = current video mode (>7)
  8196                              <1> 	; CX = Count of characters to write
  8197                              <1> 	; AL = Character to write
  8198                              <1> 	; BL = Color of character
  8199                              <1> 	; OUTPUT ->
  8200                              <1> 	; Regen buffer updated
  8201                              <1>  
  8202 00002D51 8A25[DA6F0000]      <1> 	mov 	ah, [CRT_MODE]
  8203 00002D57 668B15[4E8A0100]    <1> 	mov	dx, [CURSOR_POSN] ; cursor pos for page 0
  8204                              <1> 
  8205 00002D5E BE[F66F0000]        <1> 	mov	esi, vga_modes
  8206 00002D63 89F7                <1> 	mov	edi, esi
  8207 00002D65 83C710              <1> 	add	edi, vga_mode_count
  8208                              <1> vga_wca_0:
  8209 00002D68 AC                  <1> 	lodsb
  8210 00002D69 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  8211 00002D6B 7405                <1> 	je	short vga_wca_2
  8212 00002D6D 39FE                <1> 	cmp	esi, edi
  8213 00002D6F 72F7                <1> 	jb	short vga_wca_0
  8214                              <1> vga_wca_1:
  8215 00002D71 C3                  <1> 	retn	; nothing to do
  8216                              <1> vga_wca_2:
  8217 00002D72 83C64F              <1> 	add	esi, vga_memmodel - (vga_modes + 1)  
  8218                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  8219                              <1> 
  8220                              <1> 	; biosfn_write_char_attr (car,page,attr,count) 
  8221                              <1> 	; AL = car, page = 0, BL = attr, CX = count
  8222 00002D75 803E04              <1> 	cmp	byte [esi], PLANAR4
  8223 00002D78 741D                <1> 	je	short vga_wca_planar
  8224 00002D7A 803E03              <1> 	cmp	byte [esi], PLANAR1
  8225 00002D7D 7418                <1> 	je	short vga_wca_planar
  8226                              <1> vga_wca_linear8:
  8227                              <1> 	; while((count-->0) && (xcurs<nbcols))
  8228                              <1> 	; CX = count
  8229 00002D7F 6621C9              <1> 	and	cx, cx
  8230 00002D82 74ED                <1> 	jz	short vga_wca_1
  8231 00002D84 3A15[DC6F0000]      <1> 	cmp	dl, [CRT_COLS]
  8232 00002D8A 73E5                <1> 	jnb	short vga_wca_1
  8233                              <1> 	; write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols);
  8234                              <1> 	; AL = car, BL = attr, DL = xcurs, DH = ycurs, 
  8235                              <1> 	; [CRT_COLS] = nbcols
  8236 00002D8C E81E000000          <1> 	call	write_gfx_char_lin	 
  8237 00002D91 6649                <1> 	dec	cx ; count
  8238 00002D93 FEC2                <1> 	inc	dl ; xcurs
  8239 00002D95 EBE8                <1> 	jmp	short vga_wca_linear8
  8240                              <1> vga_wca_planar:
  8241                              <1> 	; while((count-->0) && (xcurs<nbcols))
  8242                              <1> 	; CX = count
  8243 00002D97 6621C9              <1> 	and	cx, cx
  8244 00002D9A 74D5                <1> 	jz	short vga_wca_1
  8245 00002D9C 3A15[DC6F0000]      <1> 	cmp	dl, [CRT_COLS]
  8246 00002DA2 73CD                <1> 	jnb	short vga_wca_1
  8247                              <1> 	; write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight);
  8248                              <1> 	; AL = car, BL = attr, DL = xcurs, DH = ycurs, 
  8249                              <1> 	; [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight
  8250 00002DA4 E8A9000000          <1> 	call	write_gfx_char_pl4
  8251 00002DA9 6649                <1> 	dec	cx ; count
  8252 00002DAB FEC2                <1> 	inc	dl ; xcurs
  8253 00002DAD EBE8                <1> 	jmp	short vga_wca_planar
  8254                              <1> 
  8255                              <1> write_gfx_char_lin:
  8256                              <1> 	; 08/01/2021
  8257                              <1> 	; 05/01/2021 (TRDOS 386 v2.0.3)
  8258                              <1> 	; 08/08/2016
  8259                              <1> 	; 31/07/2016
  8260                              <1> 	; 08/07/2016 (TRDOS 386 = TRDOS v2.0)
  8261                              <1> 	;
  8262                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  8263                              <1> 	; vgabios-0.7a (2011)
  8264                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  8265                              <1> 	; 'vgabios.c', 'write_gfx_char_lin'
  8266                              <1> 
  8267                              <1> 	; write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols)
  8268                              <1> 	; INPUT ->
  8269                              <1> 	; AL = car, BL = attr, DL = xcurs, DH = ycurs, 
  8270                              <1> 	; [CRT_COLS] = nbcols
  8271                              <1> 	; OUTPUT ->
  8272                              <1> 	; Regen buffer updated
  8273                              <1> 
  8274 00002DAF 51                  <1> 	push	ecx
  8275 00002DB0 53                  <1> 	push	ebx
  8276 00002DB1 52                  <1> 	push	edx
  8277 00002DB2 50                  <1> 	push	eax
  8278                              <1> 	; addr=xcurs*8+ycurs*nbcols*64;
  8279                              <1> 	; 08/08/2016
  8280 00002DB3 0FB6F0              <1> 	movzx	esi, al ; car
  8281                              <1> 	; 08/01/2021
  8282                              <1> 	;movzx	eax, dh ; ycurs
  8283                              <1> 	;mov	ah, [CRT_COLS] ; nbcols
  8284                              <1> 	;mul	ah
  8285 00002DB6 A0[DC6F0000]        <1> 	mov	al, [CRT_COLS]
  8286 00002DBB F6E6                <1> 	mul	dh
  8287                              <1> 	;shl	ax, 6 ; * 64
  8288 00002DBD 66C1E003            <1>  	shl	ax, 3 ; 8 * ycurs * [CRT_COLS]
  8289                              <1> 	;sub	dh, dh
  8290                              <1> 	;shl	dx, 3 ; xcurs * 8
  8291                              <1> 	;movzx	edi, dx
  8292 00002DC1 BF00000A00          <1> 	mov	edi, 0A0000h
  8293 00002DC6 30F6                <1> 	xor	dh, dh
  8294 00002DC8 6689D7              <1> 	mov	di, dx
  8295                              <1> 	;movzx	edi, dl
  8296 00002DCB 66C1E703            <1> 	shl	di, 3 ; xcurs * 8
  8297                              <1> 	;xor	dh, dh
  8298 00002DCF 8A15[DE6F0000]      <1> 	mov	dl, [CHAR_HEIGHT]
  8299 00002DD5 66F7E2              <1> 	mul	dx
  8300                              <1> 	; eax = ycurs*nbcols*8*[CHAR_HEIGHT]
  8301                              <1> 	;add	edi, eax ; addr
  8302                              <1> 	;add	edi, 0A0000h
  8303 00002DD8 6601C7              <1> 	add	di, ax
  8304                              <1> 	;shl	si, 3 ; car * 8
  8305 00002DDB 30E4                <1> 	xor	ah, ah
  8306 00002DDD A0[DE6F0000]        <1> 	mov	al, [CHAR_HEIGHT]
  8307 00002DE2 66F7E6              <1> 	mul	si
  8308 00002DE5 6689C6              <1> 	mov	si, ax
  8309                              <1> 	;; esi = src = car * 8
  8310                              <1> 	; esi = src = car * [CHAR_HEIGHT]
  8311                              <1> 	; i = 0
  8312                              <1> 	;add	esi, vgafont8 ; fdata [src+i]
  8313                              <1> 	; 08/08/2016
  8314 00002DE8 A1[DA960100]        <1> 	mov	eax, [VGA_INT43H]
  8315 00002DED 09C0                <1> 	or	eax, eax ; 0 ?
  8316 00002DEF 743F                <1> 	jz	short wfxl_7 ; yes, default font
  8317                              <1> 	;cmp	eax, vgafont16
  8318                              <1>         ;je	short wgfxl_0
  8319                              <1> 	;cmp	eax, vgafont14
  8320                              <1> 	;je	short wgfxl_0
  8321                              <1> 	;cmp	eax, vgafont8
  8322                              <1> 	;je	short wgfxl_0
  8323                              <1> 	;; 05/01/2021 (TRDOS 386 v2.0.3)
  8324                              <1> 	;; user font  
  8325                              <1> 	;mov	eax, VGAFONTUSR ; 8x16 or 8x8 or 8x14 font
  8326                              <1> 	;			; (256 characters)
  8327                              <1> wgfxl_0:
  8328 00002DF1 01C6                <1> 	add	esi, eax
  8329                              <1> wgfxl_1:
  8330 00002DF3 28FF                <1> 	sub	bh, bh ; i = 0
  8331                              <1> wgfxl_2:
  8332                              <1> 	; for(i=0;i<8;i++)
  8333 00002DF5 57                  <1> 	push	edi ; addr
  8334 00002DF6 0FB605[DC6F0000]    <1> 	movzx	eax, byte [CRT_COLS] ; nbcols
  8335 00002DFD F6E7                <1> 	mul	bh ; nbcols*i
  8336 00002DFF 66C1E003            <1> 	shl	ax, 3 ; i*nbcols*8
  8337                              <1>  	; dest=addr+i*nbcols*8;
  8338 00002E03 01C7                <1> 	add	edi, eax ; dest + j ; j = 0
  8339 00002E05 B180                <1> 	mov	cl, 80h ; mask = 0x80;
  8340                              <1> 	; esi = fdata + src + i
  8341                              <1> 	; for(j=0;j<8;j++)
  8342 00002E07 29D2                <1> 	sub	edx, edx ; j = 0
  8343                              <1> wgfxl_3:
  8344 00002E09 8A06                <1> 	mov	al, [esi] ; al = fdata[src+i]
  8345 00002E0B 20C8                <1> 	and	al, cl ; if (fdata[src+i] & mask)
  8346 00002E0D 7402                <1> 	jz	short wgfxl_4  ; data = 0, zf = 1
  8347 00002E0F 88D8                <1> 	mov	al, bl ; data = attr;
  8348                              <1> wgfxl_4:
  8349                              <1> 	; write_byte(0xa000,dest+j,data);		
  8350 00002E11 AA                  <1> 	stosb  ; dest + j (+ 0A0000h)
  8351                              <1> 	;inc	dl ; j++
  8352                              <1> 	;cmp	dl, 8
  8353 00002E12 80FA07              <1> 	cmp	dl, 7
  8354 00002E15 720E                <1> 	jb	short wgfxl_5
  8355 00002E17 5F                  <1> 	pop	edi
  8356                              <1> 	; 08/08/2016
  8357                              <1> 	;cmp	bh, 7
  8358                              <1> 	;jnb	short wgfxl_6
  8359 00002E18 FEC7                <1> 	inc	bh ; i++
  8360 00002E1A 3A3D[DE6F0000]      <1> 	cmp	bh, [CHAR_HEIGHT]
  8361 00002E20 7309                <1> 	jnb	short wgfxl_6
  8362 00002E22 46                  <1> 	inc	esi
  8363 00002E23 EBD0                <1> 	jmp	short wgfxl_2
  8364                              <1> wgfxl_5:
  8365 00002E25 D0E9                <1> 	shr	cl, 1 ; mask >>= 1;
  8366 00002E27 FEC2                <1> 	inc	dl ; j++
  8367 00002E29 EBDE                <1>         jmp     short wgfxl_3
  8368                              <1> wgfxl_6:
  8369 00002E2B 58                  <1> 	pop	eax
  8370 00002E2C 5A                  <1> 	pop	edx
  8371 00002E2D 5B                  <1> 	pop	ebx
  8372 00002E2E 59                  <1> 	pop	ecx
  8373 00002E2F C3                  <1> 	retn
  8374                              <1> wfxl_7:
  8375                              <1> 	; 08/01/2021
  8376                              <1> 	; 05/01/2021
  8377                              <1> 	; Default font (8x8 or 8x14 or 8x16)
  8378 00002E30 A0[DE6F0000]        <1> 	mov	al, [CHAR_HEIGHT]
  8379 00002E35 3C08                <1> 	cmp	al, 8
  8380 00002E37 7507                <1> 	jne	short wfxl_8
  8381 00002E39 B8[C4600100]        <1> 	mov	eax, vgafont8
  8382 00002E3E EBB1                <1> 	jmp	short wgfxl_0
  8383                              <1> wfxl_8:
  8384 00002E40 3C0E                <1> 	cmp	al, 14
  8385 00002E42 7507                <1> 	jne	short wfxl_9
  8386 00002E44 B8[C4680100]        <1> 	mov	eax, vgafont14
  8387 00002E49 EBA6                <1> 	jmp	short wgfxl_0
  8388                              <1> wfxl_9:
  8389 00002E4B B8[C4760100]        <1> 	mov	eax, vgafont16
  8390 00002E50 EB9F                <1> 	jmp	short wgfxl_0
  8391                              <1> 
  8392                              <1> write_gfx_char_pl4:
  8393                              <1> 	; 08/08/2016
  8394                              <1> 	; 08/07/2016 (TRDOS 386 = TRDOS v2.0)
  8395                              <1> 	;
  8396                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  8397                              <1> 	; vgabios-0.7a (2011)
  8398                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  8399                              <1> 	; 'vgabios.c', 'write_gfx_char_pl4'
  8400                              <1> 
  8401                              <1> 	; write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight)
  8402                              <1> 	; INPUT ->
  8403                              <1> 	; AL = car, BL = attr, DL = xcurs, DH = ycurs, 
  8404                              <1> 	; [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight
  8405                              <1> 	; OUTPUT ->
  8406                              <1> 	; Regen buffer updated
  8407                              <1> 
  8408 00002E52 51                  <1> 	push	ecx
  8409 00002E53 53                  <1> 	push	ebx
  8410 00002E54 52                  <1> 	push	edx
  8411 00002E55 50                  <1> 	push	eax
  8412                              <1> wgfxpl_f0:
  8413                              <1> 	; switch(cheight)
  8414 00002E56 8A25[DE6F0000]      <1> 	mov	ah, [CHAR_HEIGHT]
  8415 00002E5C 80FC10              <1> 	cmp	ah, 16 ; case 16:
  8416 00002E5F 7507                <1> 	jne	short wgfxpl_f1
  8417                              <1> 	; fdata = &vgafont16;
  8418 00002E61 BE[C4760100]        <1> 	mov	esi, vgafont16
  8419 00002E66 EB13                <1> 	jmp	short wgfxpl_f3
  8420                              <1> wgfxpl_f1:
  8421 00002E68 80FC0E              <1> 	cmp	ah, 14 ; case 14:
  8422 00002E6B 7507                <1> 	jne	short wgfxpl_f2
  8423 00002E6D BE[C4680100]        <1> 	mov	esi, vgafont14
  8424 00002E72 EB07                <1> 	jmp	short wgfxpl_f3
  8425                              <1> wgfxpl_f2:
  8426                              <1> 	; default:
  8427                              <1> 	;  fdata = &vgafont8;
  8428 00002E74 BE[C4600100]        <1> 	mov	esi, vgafont8
  8429 00002E79 B408                <1> 	mov	ah, 8	
  8430                              <1> wgfxpl_f3:
  8431                              <1> 	; al = car
  8432 00002E7B F6E4                <1> 	mul	ah ; ah = cheight
  8433 00002E7D 25FFFF0000          <1> 	and	eax, 0FFFFh ; car * cheight
  8434                              <1> 	; src = car * cheight;
  8435 00002E82 01C6                <1> 	add	esi, eax ; esi = fdata[src+i]
  8436                              <1> 	; addr=xcurs*8+ycurs*nbcols*64;
  8437 00002E84 88F0                <1> 	mov	al, dh ; ycurs
  8438 00002E86 8A25[DC6F0000]      <1> 	mov	ah, [CRT_COLS] ; nbcols
  8439 00002E8C F6E4                <1> 	mul	ah
  8440                              <1> 	; 08/08/2016
  8441                              <1> 	;shl	ax, 6 ; * 64
  8442 00002E8E 66C1E003            <1> 	shl	ax, 3 ; * 8
  8443                              <1> 	;sub	dh, dh ; 0
  8444                              <1> 	;shl	dx, 3 ; xcurs * 8
  8445                              <1> 	;movzx	edi, dx
  8446 00002E92 0FB6FA              <1> 	movzx	edi, dl
  8447 00002E95 66C1E703            <1> 	shl	di, 3 ; xcurs * 8
  8448 00002E99 30F6                <1> 	xor	dh, dh
  8449 00002E9B 8A15[DE6F0000]      <1> 	mov	dl, [CHAR_HEIGHT]
  8450 00002EA1 66F7E2              <1> 	mul	dx
  8451                              <1> 	; eax = ycurs*nbcols*8*[CHAR_HEIGHT]
  8452 00002EA4 01C7                <1> 	add	edi, eax ; addr
  8453 00002EA6 81C700000A00        <1> 	add	edi, 0A0000h
  8454                              <1> 	;
  8455                              <1> 	; outw(VGAREG_SEQU_ADDRESS, 0x0f02);
  8456                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0205);
  8457 00002EAC 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  8458 00002EB0 66B8020F            <1> 	mov	ax, 0F02h
  8459 00002EB4 66EF                <1> 	out	dx, ax
  8460 00002EB6 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  8461 00002EBA 66B80502            <1> 	mov	ax, 0205h
  8462 00002EBE 66EF                <1> 	out	dx, ax
  8463                              <1> 	;
  8464 00002EC0 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  8465 00002EC4 F6C380              <1> 	test	bl, 80h ; if(attr&0x80)
  8466 00002EC7 7406                <1> 	jz	short wgfxpl_f4 ; else
  8467                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x1803);
  8468 00002EC9 66B80318            <1> 	mov	ax, 1803h
  8469 00002ECD EB04                <1> 	jmp	short wgfxpl_f5
  8470                              <1> wgfxpl_f4:
  8471                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0003);
  8472 00002ECF 66B80300            <1> 	mov	ax, 0003h	
  8473                              <1> wgfxpl_f5:
  8474 00002ED3 66EF                <1> 	out	dx, ax
  8475                              <1> 	;	
  8476 00002ED5 28FF                <1> 	sub	bh, bh ; i = 0
  8477                              <1> wgfxpl_0:
  8478                              <1> 	; for(i=0;i<cheight;i++)
  8479 00002ED7 57                  <1> 	push	edi ; addr
  8480 00002ED8 0FB605[DC6F0000]    <1> 	movzx	eax, byte [CRT_COLS] ; nbcols
  8481 00002EDF F6E7                <1> 	mul	bh ; nbcols*i
  8482                              <1> 	; dest=addr+i*nbcols
  8483 00002EE1 01C7                <1> 	add	edi, eax ; dest
  8484 00002EE3 B580                <1> 	mov	ch, 80h ; mask = 0x80;
  8485                              <1> 	; for(j=0;j<8;j++)
  8486 00002EE5 28C9                <1> 	sub	cl, cl ; j = 0
  8487                              <1> wgfxpl_1:
  8488 00002EE7 D2ED                <1> 	shr	ch, cl ; mask=0x80>>j;
  8489                              <1> 	;
  8490                              <1> 	; outw(VGAREG_GRDC_ADDRESS, (mask << 8) | 0x08);
  8491                              <1>      	; read_byte(0xa000,dest);
  8492                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  8493 00002EE9 88EC                <1> 	mov	ah, ch
  8494 00002EEB B008                <1> 	mov	al, 8
  8495 00002EED 66EF                <1> 	out	dx, ax
  8496 00002EEF 8A07                <1> 	mov	al, [edi] ; ? (io delay?)
  8497                              <1> 	;
  8498 00002EF1 28C0                <1> 	sub	al, al ; attr = 0
  8499                              <1> 	; if (fdata[src+i] & mask)
  8500 00002EF3 842E                <1> 	test	byte [esi], ch
  8501 00002EF5 7404                <1> 	jz	short wgfxpl_2  ; zf = 1
  8502                              <1> 	; write_byte(0xa000,dest,attr&0x0f);
  8503 00002EF7 88D8                <1> 	mov	al, bl ; attr;
  8504 00002EF9 240F                <1> 	and	al, 0Fh	; attr&0x0f
  8505                              <1> wgfxpl_2:
  8506                              <1> 	; write_byte(0xa000,dest,0x00);		
  8507 00002EFB 8807                <1> 	mov	[edi], al ; dest (+ 0A0000h)
  8508 00002EFD FEC1                <1> 	inc	cl ; j++
  8509 00002EFF 80F908              <1> 	cmp	cl, 8
  8510 00002F02 72E3                <1> 	jb	short wgfxpl_1
  8511 00002F04 5F                  <1> 	pop	edi
  8512                              <1> 	; 08/08/2016
  8513                              <1> 	;cmp	bh, 7
  8514                              <1> 	;jnb	short wgfxpl_3
  8515 00002F05 FEC7                <1> 	inc	bh ; i++
  8516 00002F07 3A3D[DE6F0000]      <1> 	cmp	bh, [CHAR_HEIGHT]
  8517 00002F0D 7303                <1> 	jnb	short wgfxpl_3
  8518 00002F0F 46                  <1> 	inc	esi
  8519 00002F10 EBC5                <1> 	jmp	short wgfxpl_0
  8520                              <1> wgfxpl_3:
  8521                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  8522 00002F12 66B808FF            <1>   	mov	ax, 0FF08h
  8523 00002F16 66EF                <1> 	out	dx, ax
  8524 00002F18 66B80500            <1> 	mov	ax, 0005h
  8525 00002F1C 66EF                <1> 	out	dx, ax
  8526 00002F1E 66B80300            <1> 	mov	ax, 0003h
  8527 00002F22 66EF                <1> 	out	dx, ax
  8528                              <1> 	;
  8529 00002F24 58                  <1> 	pop	eax
  8530 00002F25 5A                  <1> 	pop	edx
  8531 00002F26 5B                  <1> 	pop	ebx
  8532 00002F27 59                  <1> 	pop	ecx
  8533 00002F28 C3                  <1> 	retn
  8534                              <1> 
  8535                              <1> vga_write_pixel: 
  8536                              <1> 	; 09/07/2016 (TRDOS 386 = TRDOS v2.0)
  8537                              <1> 	;
  8538                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  8539                              <1> 	; vgabios-0.7a (2011)
  8540                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  8541                              <1> 	; 'vgabios.c', 'biosfn_write_pixel'
  8542                              <1> 
  8543                              <1> 	; INPUT ->
  8544                              <1> 	; 	DX = row (0-239)
  8545                              <1> 	; 	CX = column (0-799)
  8546                              <1> 	; 	AL = pixel value
  8547                              <1> 	;	(AH = [CRT_MODE])
  8548                              <1> 	; OUTPUT ->
  8549                              <1> 	; 	none
  8550                              <1>  
  8551 00002F29 88C3                <1> 	mov	bl, al ; pixel value
  8552                              <1> 	;mov 	ah, [CRT_MODE]
  8553 00002F2B BE[F66F0000]        <1> 	mov	esi, vga_modes
  8554 00002F30 89F7                <1> 	mov	edi, esi
  8555 00002F32 83C710              <1> 	add	edi, vga_mode_count
  8556                              <1> vga_wp_0:
  8557 00002F35 AC                  <1> 	lodsb
  8558 00002F36 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  8559 00002F38 7405                <1> 	je	short vga_wp_1
  8560 00002F3A 39FE                <1> 	cmp	esi, edi
  8561 00002F3C 72F7                <1> 	jb	short vga_wp_0
  8562 00002F3E C3                  <1> 	retn	; nothing to do
  8563                              <1> vga_wp_1:
  8564 00002F3F 83C64F              <1> 	add	esi, vga_memmodel - (vga_modes + 1)  
  8565                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  8566 00002F42 BF00000A00          <1> 	mov	edi, 0A0000h
  8567                              <1> 	;
  8568 00002F47 803E04              <1> 	cmp	byte [esi], PLANAR4
  8569 00002F4A 741D                <1> 	je	short vga_wp_planar
  8570 00002F4C 803E03              <1> 	cmp	byte [esi], PLANAR1
  8571 00002F4F 7418                <1> 	je	short vga_wp_planar
  8572                              <1> vga_wp_linear8:
  8573                              <1> 	; addr=CX+DX*(read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS)*8);
  8574 00002F51 0FB605[DC6F0000]    <1> 	movzx	eax, byte [CRT_COLS] ; = [VGA_COLS] ; nbcols
  8575 00002F58 66C1E003            <1>      	shl	ax, 3 ; * 8
  8576 00002F5C 66F7E2              <1> 	mul	dx
  8577 00002F5F 50                  <1> 	push	eax
  8578                              <1> 	;mov	edi, 0A0000h
  8579 00002F60 6601CF              <1> 	add	di, cx
  8580 00002F63 58                  <1> 	pop	eax
  8581 00002F64 01C7                <1> 	add	edi, eax ; addr
  8582                              <1> 	; write_byte(0xa000,addr,AL);
  8583 00002F66 881F                <1> 	mov	[edi], bl
  8584 00002F68 C3                  <1> 	retn    
  8585                              <1> vga_wp_planar:
  8586                              <1> 	; addr = CX/8+DX*read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS);
  8587 00002F69 0FB7C1              <1> 	movzx	eax, cx
  8588 00002F6C 66C1E803            <1> 	shr	ax, 3 ; CX/8
  8589 00002F70 50                  <1> 	push	eax
  8590 00002F71 28E4                <1> 	sub	ah, ah ; 0
  8591 00002F73 A0[DC6F0000]        <1> 	mov	al, [CRT_COLS] ; = [VGA_COLS] ; nbcols
  8592 00002F78 66F7E2              <1> 	mul	dx
  8593                              <1> 	;mov	edi, 0A0000h
  8594 00002F7B 6601C7              <1>         add     di, ax
  8595 00002F7E 58                  <1> 	pop	eax
  8596 00002F7F 01C7                <1> 	add	edi, eax ; addr
  8597 00002F81 80E107              <1> 	and	cl, 7
  8598 00002F84 B580                <1> 	mov	ch, 80h ; mask
  8599 00002F86 D2ED                <1> 	shr	ch, cl 	; mask = 0x80 >> (CX & 0x07);
  8600                              <1> 	
  8601                              <1> 	; outw(VGAREG_GRDC_ADDRESS, (mask << 8) | 0x08);
  8602 00002F88 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  8603 00002F8C 88EC                <1> 	mov	ah, ch
  8604 00002F8E B008                <1> 	mov	al, 8
  8605 00002F90 66EF                <1> 	out	dx, ax
  8606                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0205);
  8607 00002F92 66B80502            <1> 	mov	ax, 0205h
  8608 00002F96 66EF                <1> 	out	dx, ax
  8609                              <1> 	; data = read_byte(0xa000,addr);
  8610 00002F98 8A07                <1> 	mov	al, [edi] ; (delay?)	
  8611                              <1> 	; if (AL & 0x80)
  8612                              <1> 	; {
  8613                              <1> 	;  outw(VGAREG_GRDC_ADDRESS, 0x1803);
  8614                              <1> 	; }
  8615 00002F9A F6C380              <1> 	test	bl, 80h
  8616 00002F9D 7406                <1> 	jz	short vga_wp_2
  8617 00002F9F 66B80318            <1> 	mov	ax, 1803h
  8618 00002FA3 66EF                <1> 	out	dx, ax
  8619                              <1> vga_wp_2:	
  8620                              <1> 	; write_byte(0xa000,addr,AL);
  8621 00002FA5 881F                <1> 	mov	[edi], bl
  8622                              <1> 	;
  8623                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  8624 00002FA7 66B808FF            <1>   	mov	ax, 0FF08h
  8625 00002FAB 66EF                <1> 	out	dx, ax
  8626 00002FAD 66B80500            <1> 	mov	ax, 0005h
  8627 00002FB1 66EF                <1> 	out	dx, ax
  8628 00002FB3 66B80300            <1> 	mov	ax, 0003h
  8629 00002FB7 66EF                <1> 	out	dx, ax
  8630                              <1> 	;
  8631 00002FB9 C3                  <1> 	retn
  8632                              <1> 
  8633                              <1> vga_read_pixel: 
  8634                              <1> 	; 09/07/2016 (TRDOS 386 = TRDOS v2.0)
  8635                              <1> 	;
  8636                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  8637                              <1> 	; vgabios-0.7a (2011)
  8638                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  8639                              <1> 	; 'vgabios.c', 'biosfn_read_pixel'
  8640                              <1> 
  8641                              <1> 	; INPUT ->
  8642                              <1> 	; 	DX = row (0-239)
  8643                              <1> 	; 	CX = column (0-799)
  8644                              <1> 	;	(AH = [CRT_MODE])
  8645                              <1> 	; OUTPUT ->
  8646                              <1> 	; 	AL = pixel value
  8647                              <1> 	 
  8648                              <1> 	;mov 	ah, [CRT_MODE]
  8649 00002FBA BE[F66F0000]        <1> 	mov	esi, vga_modes
  8650 00002FBF 89F7                <1> 	mov	edi, esi
  8651 00002FC1 83C710              <1> 	add	edi, vga_mode_count
  8652                              <1> vga_rp_0:
  8653 00002FC4 AC                  <1> 	lodsb
  8654 00002FC5 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  8655 00002FC7 7405                <1> 	je	short vga_rp_1
  8656 00002FC9 39FE                <1> 	cmp	esi, edi
  8657 00002FCB 72F7                <1> 	jb	short vga_rp_0
  8658 00002FCD C3                  <1> 	retn	; nothing to do
  8659                              <1> vga_rp_1:
  8660 00002FCE 83C64F              <1> 	add	esi, vga_memmodel - (vga_modes + 1)  
  8661                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  8662 00002FD1 BF00000A00          <1> 	mov	edi, 0A0000h
  8663                              <1> 	;
  8664 00002FD6 803E04              <1> 	cmp	byte [esi], PLANAR4
  8665 00002FD9 741D                <1> 	je	short vga_rp_planar
  8666 00002FDB 803E03              <1> 	cmp	byte [esi], PLANAR1
  8667 00002FDE 7418                <1> 	je	short vga_rp_planar
  8668                              <1> vga_rp_linear8:
  8669                              <1> 	; addr=CX+DX*(read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS)*8);
  8670 00002FE0 0FB605[DC6F0000]    <1> 	movzx	eax, byte [CRT_COLS] ; = [VGA_COLS] ; nbcols
  8671 00002FE7 66C1E003            <1>      	shl	ax, 3 ; * 8
  8672 00002FEB 66F7E2              <1> 	mul	dx
  8673 00002FEE 50                  <1> 	push	eax
  8674                              <1> 	;mov	edi, 0A0000h
  8675 00002FEF 6601CF              <1> 	add	di, cx
  8676 00002FF2 58                  <1> 	pop	eax
  8677 00002FF3 01C7                <1> 	add	edi, eax ; addr
  8678                              <1> 	; attr=read_byte(0xa000,addr);
  8679 00002FF5 8A07                <1> 	mov	al, [edi] ; pixel value
  8680 00002FF7 C3                  <1> 	retn    
  8681                              <1> vga_rp_planar:
  8682                              <1> 	; addr = CX/8+DX*read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS);
  8683 00002FF8 0FB7C1              <1> 	movzx	eax, cx
  8684 00002FFB 66C1E803            <1> 	shr	ax, 3 ; CX/8
  8685 00002FFF 50                  <1> 	push	eax
  8686 00003000 28E4                <1> 	sub	ah, ah ; 0
  8687 00003002 A0[DC6F0000]        <1> 	mov	al, [CRT_COLS] ; = [VGA_COLS] ; nbcols
  8688 00003007 66F7E2              <1> 	mul	dx
  8689                              <1> 	;mov	edi, 0A0000h
  8690 0000300A 6601C7              <1>         add     di, ax
  8691 0000300D 58                  <1> 	pop	eax
  8692 0000300E 01C7                <1> 	add	edi, eax ; addr
  8693 00003010 80E107              <1> 	and	cl, 7
  8694 00003013 B580                <1> 	mov	ch, 80h ; mask
  8695 00003015 D2ED                <1> 	shr	ch, cl 	; mask = 0x80 >> (CX & 0x07);
  8696                              <1> 	; attr = 0x00;
  8697 00003017 30DB                <1> 	xor	bl, bl ; attr = bl = 0, 
  8698 00003019 30C9                <1> 	xor	cl, cl ; i = cl = 0
  8699                              <1> 	; for(i=0;i<4;i++)
  8700                              <1>       	; {
  8701                              <1>        	;  outw(VGAREG_GRDC_ADDRESS, (i << 8) | 0x04);
  8702                              <1>        	;  data = read_byte(0xa000,addr) & mask;
  8703                              <1>        	;  if (data > 0) attr |= (0x01 << i);
  8704                              <1>       	; }
  8705                              <1> vga_rp_2:
  8706 0000301B 88CC                <1> 	mov	ah, cl ; i << 8
  8707 0000301D B004                <1> 	mov	al, 4  ; | 0x04
  8708 0000301F 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  8709 00003023 66EF                <1> 	out	dx, ax
  8710                              <1> 	; data = read_byte(0xa000,addr) & mask;
  8711 00003025 8A07                <1> 	mov	al, [edi]
  8712 00003027 20E8                <1> 	and	al, ch ; & mask
  8713                              <1> 	; if (data > 0) attr |= (0x01 << i);
  8714 00003029 08C0                <1> 	or	al, al
  8715 0000302B 7408                <1> 	jz	short vga_rp_3 ; al = 0 
  8716 0000302D B701                <1> 	mov	bh, 1
  8717 0000302F D2E7                <1> 	shl	bh, cl ; (0x01 << i)
  8718 00003031 08FB                <1> 	or	bl, bh ; attr |= (0x01 << i)
  8719 00003033 88D8                <1> 	mov	al, bl ; pixel value	
  8720                              <1> vga_rp_3:	
  8721 00003035 C3                  <1> 	retn
  8722                              <1> 
  8723                              <1> vga_beeper:
  8724                              <1> 	; 04/08/2016  (TRDOS 386 = TRDOS v2.0)
  8725 00003036 FB                  <1> 	sti
  8726                              <1> 	;mov	bh, [ACTIVE_PAGE]
  8727 00003037 E9BEF3FFFF          <1>         jmp     beeper_gfx
  8728                              <1> 
  8729                              <1> vga_write_teletype:
  8730                              <1> 	; 09/12/2017
  8731                              <1> 	; 06/08/2016
  8732                              <1> 	; 04/08/2016
  8733                              <1> 	; 01/08/2016
  8734                              <1> 	; 31/07/2016
  8735                              <1> 	; 09/07/2016 (TRDOS 386 = TRDOS v2.0)
  8736                              <1> 	;
  8737                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  8738                              <1> 	; vgabios-0.7a (2011)
  8739                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  8740                              <1> 	; 'vgabios.c', 'biosfn_write_teletype'
  8741                              <1> 	; 'biosfn_write_char_only'
  8742                              <1> 
  8743                              <1> 	; INPUT ->
  8744                              <1> 	; [CRT_MODE] = current video mode (>7)
  8745                              <1> 	; AL = Character to write
  8746                              <1> 	; BL = Color of character
  8747                              <1> 	; OUTPUT ->
  8748                              <1> 	; Regen buffer updated
  8749                              <1> 
  8750                              <1> 	; biosfn_write_teletype (car, page, attr, flag) 
  8751                              <1> 	; car = character (AL)
  8752                              <1> 	; page = 0
  8753                              <1> 	; attr = color (BL)
  8754                              <1> 	; 'flag' not used
  8755                              <1> 
  8756 0000303C 8A25[DA6F0000]      <1> 	mov 	ah, [CRT_MODE]
  8757 00003042 88C7                <1> 	mov	bh, al ; character
  8758 00003044 668B15[4E8A0100]    <1> 	mov	dx, [CURSOR_POSN] ; cursor pos for page 0
  8759                              <1> 
  8760 0000304B BE[FE6F0000]        <1> 	mov	esi, vga_g_modes
  8761 00003050 89F7                <1> 	mov	edi, esi
  8762 00003052 83C708              <1> 	add	edi, vga_g_mode_count
  8763                              <1> vga_wtty_0:
  8764 00003055 AC                  <1> 	lodsb
  8765 00003056 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  8766 00003058 7405                <1> 	je	short vga_wtty_2
  8767 0000305A 39FE                <1> 	cmp	esi, edi
  8768 0000305C 72F7                <1> 	jb	short vga_wtty_0
  8769                              <1> vga_wtty_1:
  8770 0000305E C3                  <1> 	retn	; nothing to do
  8771                              <1> vga_wtty_2:
  8772 0000305F 80FF07              <1> 	cmp	bh, 07h ; bell (beep)
  8773 00003062 74D2                <1> 	je	short vga_beeper  ; u11
  8774 00003064 80FF08              <1> 	cmp	bh, 08h ; backspace
  8775 00003067 7508                <1> 	jne	short vga_wtty_3
  8776                              <1> 	; if(xcurs>0)xcurs--;
  8777 00003069 08D2                <1> 	or	dl, dl ; xcurs (column)
  8778 0000306B 74F1                <1> 	jz	short vga_wtty_1
  8779 0000306D FECA                <1> 	dec	dl ; xcurs--;
  8780 0000306F EB59                <1>         jmp     short vga_wtty_12 
  8781                              <1> vga_wtty_3:			
  8782 00003071 80FF0D              <1> 	cmp	bh, 0Dh ; carriage return (\r)
  8783 00003074 7504                <1> 	jne	short vga_wtty_4
  8784                              <1> 	; xcurs=0;
  8785 00003076 28D2                <1> 	sub	dl, dl ; 0
  8786 00003078 EB50                <1>         jmp     short vga_wtty_12 
  8787                              <1> vga_wtty_4:	
  8788 0000307A 80FF0A              <1> 	cmp	bh, 0Ah ; new line (\n)
  8789 0000307D 7504                <1> 	jne	short vga_wtty_5
  8790                              <1> 	; ycurs++;
  8791 0000307F FEC6                <1> 	inc	dh ; next row
  8792 00003081 EB62                <1>         jmp     short vga_wtty_11
  8793                              <1> vga_wtty_5:
  8794 00003083 80FF09              <1> 	cmp 	bh, 09h ; tab stop
  8795 00003086 7527                <1> 	jne	short vga_wtty_8
  8796 00003088 88D0                <1> 	mov	al, dl
  8797                              <1> 	;cbw
  8798 0000308A 30E4                <1> 	xor	ah, ah ; 09/12/2017
  8799 0000308C B108                <1> 	mov	cl, 8
  8800 0000308E F6F1                <1> 	div	cl
  8801 00003090 28E1                <1> 	sub	cl, ah
  8802                              <1> 	;
  8803 00003092 B720                <1> 	mov	bh, 20h ; space
  8804                              <1> vga_wtty_6: ; tab stop loop
  8805 00003094 6651                <1> 	push	cx
  8806 00003096 6653                <1> 	push	bx
  8807 00003098 E812000000          <1> 	call	vga_wtty_8
  8808 0000309D 665B                <1> 	pop	bx  ; bh = character, bl = color
  8809 0000309F 6659                <1> 	pop	cx
  8810 000030A1 FEC9                <1> 	dec	cl
  8811 000030A3 7409                <1> 	jz	short vga_wtty_7
  8812 000030A5 668B15[4E8A0100]    <1> 	mov	dx, [CURSOR_POSN] ; new cursor position (pg 0)
  8813 000030AC EBE6                <1> 	jmp	short vga_wtty_6
  8814                              <1> vga_wtty_7:
  8815 000030AE C3                  <1> 	retn
  8816                              <1> 	;
  8817                              <1> vga_wtty_8:
  8818 000030AF 83C64F              <1> 	add	esi, vga_g_memmodel - (vga_g_modes + 1)  
  8819                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  8820 000030B2 BF00000A00          <1> 	mov	edi, 0A0000h
  8821                              <1> 	;
  8822 000030B7 88F8                <1> 	mov	al, bh ; character
  8823                              <1> 	;
  8824 000030B9 803E04              <1> 	cmp	byte [esi], PLANAR4
  8825 000030BC 7414                <1> 	je	short vga_wtty_planar
  8826 000030BE 803E03              <1> 	cmp	byte [esi], PLANAR1
  8827 000030C1 740F                <1> 	je	short vga_wtty_planar
  8828                              <1> vga_wtty_linear8:
  8829                              <1> 	; write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols);
  8830                              <1> 	; AL = car, BL = attr (color), DL = xcurs, DH = ycurs, 
  8831                              <1> 	; [CRT_COLS] = nbcols
  8832 000030C3 E8E7FCFFFF          <1> 	call	write_gfx_char_lin
  8833 000030C8 EB0D                <1> 	jmp	short vga_wtty_9
  8834                              <1> 
  8835                              <1> vga_wtty_12:
  8836                              <1> 	; 09/07/2016
  8837                              <1> 	; set cursor position
  8838                              <1> 	; NOTE: Hardware cursor position will not be set
  8839                              <1> 	;   in any VGA modes (>7)
  8840                              <1> 	;   But, cursor position will be saved into
  8841                              <1> 	;   [CURSOR_POSN].
  8842                              <1> 	;   TRDOS 386 (TRDOS v2.0) uses only one page
  8843                              <1> 	;   (page 0) for all graphics modes.
  8844                              <1> 
  8845 000030CA 668915[4E8A0100]    <1> 	mov	[CURSOR_POSN], dx ; save cursor pos for pg 0
  8846                              <1> 	; 04/08/2016
  8847                              <1> 	;mov	bh, [ACTIVE_PAGE] ; = 0
  8848                              <1> 	;call	_set_cpos
  8849 000030D1 C3                  <1> 	retn
  8850                              <1> 
  8851                              <1> vga_wtty_planar:
  8852                              <1> 	; write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight);
  8853                              <1> 	; AL = car, BL = attr (color), DL = xcurs, DH = ycurs, 
  8854                              <1> 	; [CRT_COLS]= nbcols, [CHAR_HEIGHT] = cheight
  8855 000030D2 E87BFDFFFF          <1> 	call	write_gfx_char_pl4
  8856                              <1> vga_wtty_9:
  8857 000030D7 FEC2                <1> 	inc	dl ; xcurs++;
  8858                              <1> vga_wtty_10:
  8859                              <1> 	; Do we need to wrap ?
  8860                              <1> 	; if(xcurs==nbcols)
  8861 000030D9 3A15[DC6F0000]      <1> 	cmp	dl, [CRT_COLS] ; [VGA_COLS]
  8862 000030DF 7204                <1> 	jb	short vga_wtty_11 ; no
  8863 000030E1 28D2                <1> 	sub	dl, dl ; xcurs=0;
  8864 000030E3 FEC6                <1> 	inc	dh ;  ycurs++;
  8865                              <1> vga_wtty_11:
  8866                              <1> 	; Do we need to scroll ?
  8867                              <1> 	; if(ycurs==nbrows)
  8868 000030E5 3A35[E26F0000]      <1> 	cmp	dh, [VGA_ROWS]
  8869 000030EB 72DD                <1> 	jb	short vga_wtty_12 ; no
  8870                              <1> 	;
  8871                              <1> 	; biosfn_scroll (nblines,attr,rul,cul,rlr,clr,page,dir)
  8872                              <1> 	; al = nblines = 1, bl = attr (color) = 0
  8873                              <1> 	; ch = rul, cl = cul, dh = rlr, dl = clr, page = 0
  8874                              <1> 	; dir = SCROLL_UP
  8875                              <1> 	
  8876 000030ED B001                <1> 	mov	al, 1
  8877 000030EF 28DB                <1> 	sub	bl, bl ; 0 ; blank/black line (attr=0) will be used
  8878 000030F1 6629C9              <1> 	sub	cx, cx ; 0,0
  8879                              <1> 
  8880                              <1> 	; 06/08/2016
  8881 000030F4 8A35[E26F0000]      <1> 	mov	dh, [VGA_ROWS]
  8882 000030FA FECE                <1> 	dec	dh ; nbrows -1
  8883                              <1> 
  8884 000030FC 6652                <1> 	push	dx 	; 04/08/2016
  8885 000030FE 8A15[DC6F0000]      <1> 	mov	dl, [CRT_COLS]
  8886 00003104 FECA                <1> 	dec	dl ; nbcols -1
  8887                              <1> 	
  8888 00003106 8A25[DA6F0000]      <1> 	mov	ah, [CRT_MODE]
  8889                              <1> 	
  8890                              <1> 	; biosfn_scroll(0x01,0x00,0,0,nbrows-1,nbcols-1,page,SCROLL_UP);
  8891 0000310C E8FBF4FFFF          <1> 	call	vga_graphics_up
  8892                              <1> 	; 04/08/2016
  8893 00003111 665A                <1> 	pop	dx
  8894                              <1> 	;dec	dh ; ycurs-=1
  8895 00003113 EBB5                <1> 	jmp	short vga_wtty_12 
  8896                              <1> 
  8897                              <1> font_setup:
  8898                              <1> 	; 09/01/2021 (TRDOS 386 v2.0.3)
  8899                              <1> 	; 09/07/2016
  8900                              <1> 	; character generator (font loading) functions
  8901                              <1> 	;
  8902                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  8903                              <1> 	; vgabios-0.7a (2011)
  8904                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  8905                              <1> 	; 'vgabios.c', 'int10_func'
  8906                              <1> 
  8907                              <1> 	; AX = 1100H ; Load User-Defined Font (EGA/VGA)
  8908                              <1> 	;
  8909                              <1>         ; BH    height of each character (bytes per character definition)
  8910                              <1>         ; (BL   font block to load (EGA: 0-3; VGA: 0-7))
  8911                              <1> 	; CX    number of characters to redefine (<=256)
  8912                              <1>         ; DX    ASCII code of the first character defined at ES:BP
  8913                              <1>         ; EBP	address of font-definition information
  8914                              <1> 	;	(in user's memory space)
  8915                              <1> 
  8916                              <1> 	; case 0x11:
  8917                              <1>      	; switch(GET_AL())
  8918                              <1>       	; {
  8919                              <1> 	; case 0x00:
  8920                              <1>         ; case 0x10:
  8921                              <1>         ; biosfn_load_text_user_pat(GET_AL(),ES,BP,CX,DX,GET_BL(),GET_BH());
  8922                              <1>         ; break;
  8923                              <1> 
  8924                              <1> 	; AX = 1110H ; Load and Activate User-Defined Font (EGA/VGA)
  8925 00003115 08C0                <1> 	or	al, al ; 0
  8926 00003117 7404                <1> 	jz	short font_setup_0
  8927 00003119 3C10                <1> 	cmp	al, 10h
  8928 0000311B 7511                <1> 	jne	short font_setup_1	
  8929                              <1> font_setup_0:
  8930 0000311D E8CE000000          <1> 	call	transfer_user_fonts
  8931 00003122 721C                <1> 	jc	short font_setup_error
  8932 00003124 E8B2010000          <1> 	call	load_text_user_pat
  8933 00003129 E931EAFFFF          <1>         jmp     VIDEO_RETURN 
  8934                              <1> font_setup_1:
  8935                              <1> 	; AX = 1101H ; Load ROM 8x14 Character Set (EGA/VGA)
  8936                              <1> 	; case 0x01:
  8937                              <1>         ; case 0x11:
  8938                              <1>         ; biosfn_load_text_8_14_pat(GET_AL(),GET_BL());
  8939                              <1>         ; break;
  8940 0000312E 3C01                <1> 	cmp	al, 1
  8941 00003130 7404                <1> 	je	short font_setup_2
  8942 00003132 3C11                <1> 	cmp	al, 11h
  8943 00003134 7511                <1> 	jne	short font_setup_3	
  8944                              <1> font_setup_2:
  8945                              <1> 	; AX = 1111H ; Load and Activate ROM 8x14 Character Set (EGA/VGA)
  8946                              <1> 	; (BL = font block to load (EGA: 0-3; VGA: 0-7))
  8947 00003136 E8DC020000          <1> 	call	load_text_8_14_pat
  8948 0000313B E91FEAFFFF          <1>         jmp     VIDEO_RETURN
  8949                              <1> font_setup_error:
  8950 00003140 29C0                <1> 	sub	eax, eax ; 0 -> fonts could not be loaded
  8951 00003142 E91DEAFFFF          <1> 	jmp	_video_return
  8952                              <1> font_setup_3:
  8953                              <1> 	; AX = 1102H ; Load ROM 8x8 Character Set (EGA/VGA)
  8954                              <1> 	; case 0x02:
  8955                              <1>         ; case 0x12:
  8956                              <1>         ; biosfn_load_text_8_8_pat(GET_AL(),GET_BL());
  8957                              <1>         ; break;
  8958 00003147 3C02                <1> 	cmp	al, 2
  8959 00003149 7404                <1> 	je	short font_setup_4
  8960 0000314B 3C12                <1> 	cmp	al, 12h
  8961 0000314D 750A                <1> 	jne	short font_setup_5	
  8962                              <1> font_setup_4:
  8963                              <1> 	; AX = 1112H ; Load and Activate ROM 8x8 Character Set (EGA/VGA)
  8964                              <1> 	; (BL = font block to load (EGA: 0-3; VGA: 0-7))
  8965 0000314F E8F3020000          <1> 	call	load_text_8_8_pat
  8966 00003154 E906EAFFFF          <1>         jmp     VIDEO_RETURN
  8967                              <1> font_setup_5:
  8968                              <1> 	; AX = 1104H ; Load ROM 8x16 Character Set (EGA/VGA)
  8969                              <1> 	; case 0x04:
  8970                              <1>         ; case 0x14:
  8971                              <1>         ; biosfn_load_text_8_16_pat(GET_AL(),GET_BL());
  8972                              <1>         ; break;
  8973 00003159 3C04                <1> 	cmp	al, 4
  8974 0000315B 7404                <1> 	je	short font_setup_6
  8975 0000315D 3C14                <1> 	cmp	al, 14h
  8976 0000315F 750A                <1> 	jne	short font_setup_7	
  8977                              <1> font_setup_6:
  8978                              <1> 	; AX = 1114H ; Load and Activate ROM 8x16 Character Set (EGA/VGA)
  8979                              <1> 	; (BL = font block to load (EGA: 0-3; VGA: 0-7))
  8980 00003161 E82A030000          <1> 	call	load_text_8_16_pat
  8981 00003166 E9F4E9FFFF          <1>         jmp     VIDEO_RETURN
  8982                              <1> font_setup_7:
  8983                              <1> 	; Note: AX=1120h (Setup INT 1Fh, EXT_PTR) is not needed
  8984                              <1> 	; for TRDOS 386 (TRDOS v2.0) video functionality;
  8985                              <1> 	; because, originally EXT_PTR (font address) was used for
  8986                              <1> 	; chars 80h to 0FFh (after the first 128 ASCII char fonts), for
  8987                              <1> 	; CGA graphics mode; currenty, 'vgafont8' address has 256 chars!
  8988                              <1> 	; 
  8989                              <1> 	; case 0x20:
  8990                              <1>         ; biosfn_load_gfx_8_8_chars(ES,BP);
  8991                              <1>         ; break; 
  8992                              <1> 	; case 0x21:
  8993                              <1>         ; biosfn_load_gfx_user_chars(ES,BP,CX,GET_BL(),GET_DL());
  8994                              <1>         ; break;
  8995                              <1> 	; AX = 1121H ; Setup User-Defined Font for Graphics Mode (VGA)
  8996                              <1> 	; BL   screen rows code: 00H = user-specified (in DL)
  8997                              <1>         ;                        01H = 14 rows
  8998                              <1>         ;                        02H = 25 rows
  8999                              <1>         ;                        03H = 43 rows
  9000                              <1>         ; CX   bytes per character definition
  9001                              <1>         ; DL   (when BL=0) custom number of character rows on screen
  9002                              <1>         ; EBP  address of font-definition information (user's mem space)
  9003                              <1> 
  9004 0000316B 3C21                <1> 	cmp	al, 21h
  9005 0000316D 7531                <1> 	jne	short font_setup_9
  9006                              <1> 
  9007                              <1> 	; TRDOS 386 modification !
  9008                              <1> 	; dh = 0 -> 256 characters
  9009                              <1> 	; dh = 80h -> second 128 characters
  9010                              <1> 	; dh = 0FFh -> first 128 characters
  9011                              <1> 
  9012                              <1> 	; 09/01/2021 (TRDOS 386 v2.0.3)
  9013                              <1> 	;push	ebx
  9014 0000316F 51                  <1> 	push	ecx
  9015 00003170 52                  <1> 	push	edx
  9016 00003171 30D2                <1> 	xor	dl, dl
  9017 00003173 88CF                <1> 	mov	bh, cl ; character height
  9018 00003175 66B90001            <1> 	mov	cx, 100h ; 256
  9019 00003179 08F6                <1> 	or	dh, dh ; 0
  9020 0000317B 7410                <1> 	jz	short  font_setup_8
  9021 0000317D FECD                <1> 	dec	ch ; cx = 0
  9022 0000317F 80FEFF              <1> 	cmp	dh, 0FFh
  9023 00003182 7409                <1> 	je	short font_setup_8 ; 1st 128 chars
  9024                              <1> 	; 2nd 128 chars
  9025 00003184 80FE80              <1> 	cmp	dh, 80h
  9026 00003187 75B7                <1> 	jne	short font_setup_error ; invalid !
  9027 00003189 88F1                <1> 	mov	cl, dh
  9028 0000318B 86D6                <1> 	xchg	dl, dh
  9029                              <1> 	; number of chars, cx = 80h 
  9030                              <1> 	; start char, dl = 80h
  9031                              <1> font_setup_8:	
  9032 0000318D E85E000000          <1> 	call	transfer_user_fonts
  9033 00003192 5A                  <1> 	pop	edx
  9034 00003193 59                  <1> 	pop	ecx
  9035                              <1> 	;pop	ebx
  9036 00003194 72AA                <1> 	jc	short font_setup_error
  9037                              <1> 	; ebp = user's font data address in system's memory space
  9038 00003196 E83F030000          <1> 	call	load_gfx_user_chars
  9039 0000319B E9BFE9FFFF          <1>         jmp     VIDEO_RETURN 
  9040                              <1> font_setup_9:
  9041                              <1> 	; case 0x22:
  9042                              <1>         ; biosfn_load_gfx_8_14_chars(GET_BL());
  9043                              <1>         ; break;
  9044 000031A0 3C22                <1> 	cmp	al, 22h
  9045 000031A2 750A                <1> 	jne	short font_setup_10
  9046 000031A4 E86D030000          <1> 	call	load_gfx_8_14_chars	
  9047 000031A9 E9B1E9FFFF          <1>         jmp     VIDEO_RETURN 
  9048                              <1> font_setup_10:	
  9049                              <1> 	; case 0x23:
  9050                              <1>         ; biosfn_load_gfx_8_8_dd_chars(GET_BL());
  9051                              <1>         ; break;
  9052 000031AE 3C23                <1> 	cmp	al, 23h
  9053 000031B0 750A                <1> 	jne	short font_setup_11
  9054 000031B2 E8A0030000          <1> 	call	load_gfx_8_8_chars	
  9055 000031B7 E9A3E9FFFF          <1>         jmp     VIDEO_RETURN 
  9056                              <1> font_setup_11:	
  9057                              <1> 	; case 0x24:
  9058                              <1>         ; biosfn_load_gfx_8_16_chars(GET_BL());
  9059                              <1>         ; break;
  9060 000031BC 3C24                <1> 	cmp	al, 24h
  9061 000031BE 750A                <1> 	jne	short font_setup_12
  9062 000031C0 E8D3030000          <1> 	call	load_gfx_8_16_chars	
  9063 000031C5 E995E9FFFF          <1>         jmp     VIDEO_RETURN 
  9064                              <1> font_setup_12:
  9065                              <1>  	; case 0x30:
  9066                              <1>         ; biosfn_get_font_info(GET_BH(),&ES,&BP,&CX,&DX);
  9067                              <1>         ; break;
  9068 000031CA 3C30                <1> 	cmp	al, 30h
  9069 000031CC 750A                <1> 	jne	short font_setup_13			
  9070 000031CE E806040000          <1> 	call	get_font_info
  9071                              <1> 	; eax = return value (info: 4 bytes for 4 parms)
  9072                              <1> 	; eax = 0 -> invalid function (input)
  9073 000031D3 E98CE9FFFF          <1>         jmp     _video_return
  9074                              <1> font_setup_13:
  9075 000031D8 3C03                <1> 	cmp	al, 03h ; AX = 1103h	
  9076 000031DA 750D                <1> 	jne	short font_setup_14
  9077                              <1> 	; biosfn_set_text_block_specifier:
  9078                              <1> 	; BL = font block selector code	
  9079                              <1> 	; NOTE: TRDOS 386 only uses and sets font block 0
  9080                              <1> 	; (It is as BL = 0 for TRDOS 386)
  9081 000031DC 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  9082                              <1> 	;mov	ah, bl
  9083 000031E0 28E4                <1> 	sub	ah, ah ; 0
  9084                              <1> 	;mov	al, 03h
  9085 000031E2 66EF                <1> 	out	dx, ax
  9086 000031E4 E976E9FFFF          <1> 	jmp     VIDEO_RETURN 
  9087                              <1> 	
  9088                              <1> font_setup_14:
  9089 000031E9 29C0                <1> 	sub	eax, eax ; 0 = invalid function
  9090 000031EB E974E9FFFF          <1>         jmp     _video_return
  9091                              <1> 
  9092                              <1> transfer_user_fonts:
  9093                              <1> 	; 19/01/2021
  9094                              <1> 	; 09/01/2021
  9095                              <1> 	; 05/01/2021 (TRDOS 386 v2.0.3)
  9096                              <1> 
  9097                              <1> 	; BH    height of each character (bytes per character)
  9098                              <1> 	; CX    number of characters to redefine (<=256)
  9099                              <1>         ; DX    ASCII code of the first character defined at EBP
  9100                              <1>         ; EBP	address of font-definition information
  9101                              <1> 	;	(in user's memory space)
  9102                              <1> 
  9103                              <1> 	; Modified registers: eax, edx, ecx, esi, edi, ebp
  9104                              <1> 	;
  9105                              <1> 	; output:
  9106                              <1> 	;	ebp = user font data address in system memory
  9107                              <1> 
  9108 000031F0 81E2FFFF0000        <1> 	and	edx, 0FFFFh
  9109 000031F6 81E1FFFF0000        <1> 	and	ecx, 0FFFFh
  9110 000031FC 7537                <1> 	jnz	short transfer_user_fonts_5
  9111                              <1> 
  9112 000031FE 09D2                <1> 	or	edx, edx
  9113 00003200 7531                <1> 	jnz	short transfer_user_fonts_4
  9114 00003202 09ED                <1> 	or	ebp, ebp
  9115 00003204 752D                <1> 	jnz	short transfer_user_fonts_4
  9116                              <1> 
  9117                              <1> 	; cx = 0, dx = 0, ebp = 0
  9118                              <1> 	; copy system font to user font
  9119                              <1> 
  9120 00003206 B140                <1> 	mov	cl, 64 ; 64 dwords
  9121                              <1> 	
  9122 00003208 80FF10              <1> 	cmp	bh, 16
  9123 0000320B 7417                <1> 	je	short transfer_user_fonts_2
  9124 0000320D 80FF08              <1> 	cmp	bh, 8
  9125 00003210 7406                <1> 	je	short transfer_user_fonts_1
  9126                              <1> 
  9127 00003212 BD[C4680100]        <1> 	mov	ebp, vgafont14
  9128 00003217 C3                  <1> 	retn 
  9129                              <1> 
  9130                              <1> transfer_user_fonts_1:
  9131 00003218 BF00500900          <1> 	mov	edi, VGAFONT8USER
  9132 0000321D BE[C4600100]        <1> 	mov	esi, vgafont8
  9133 00003222 EB0A                <1> 	jmp	short transfer_user_fonts_3
  9134                              <1> 
  9135                              <1> transfer_user_fonts_2:
  9136 00003224 BF00400900          <1> 	mov	edi, VGAFONT16USER
  9137 00003229 BE[C4760100]        <1> 	mov	esi, vgafont16
  9138                              <1> transfer_user_fonts_3:
  9139 0000322E 89FD                <1> 	mov	ebp, edi
  9140 00003230 F3A5                <1> 	rep	movsd
  9141 00003232 C3                  <1> 	retn
  9142                              <1> 
  9143                              <1> transfer_user_fonts_4:
  9144 00003233 F9                  <1> 	stc	
  9145 00003234 C3                  <1> 	retn
  9146                              <1> 	
  9147                              <1> transfer_user_fonts_5:
  9148 00003235 09ED                <1> 	or	ebp, ebp
  9149 00003237 74FA                <1> 	jz	short transfer_user_fonts_4 ; invalid address !
  9150                              <1> 
  9151 00003239 6681F90001          <1> 	cmp	cx, 256
  9152 0000323E 77F3                <1> 	ja	short transfer_user_fonts_4
  9153 00003240 29D1                <1> 	sub	ecx, edx
  9154 00003242 76EF                <1> 	jna	short transfer_user_fonts_4
  9155                              <1> 
  9156 00003244 80FF0E              <1> 	cmp	bh, 14 ; 8x14 font
  9157                              <1> 		       ; (there is not an alternative buffer)
  9158 00003247 7525                <1> 	jne	short transfer_user_fonts_6
  9159                              <1> 	
  9160                              <1> 	; use system's 8x14 font space if permission flag is 1
  9161 00003249 F605[7E120300]80    <1> 	test	byte [ufont], 80h
  9162 00003250 74E1                <1> 	jz	short transfer_user_fonts_4 ; not allowed
  9163                              <1> 
  9164                              <1> 	; permission is given (for vgafont14 location etc.)
  9165                              <1> 	; (for permanent font modification)
  9166                              <1> 	;
  9167                              <1> 	; 19/01/2021
  9168                              <1> 	; Note: Permission flag can be set by 'root' while
  9169                              <1> 	;	system is not in multi tasking/user mode
  9170                              <1> 	;	while [multi_tasking] = 0 and [u.uid] = 0
  9171                              <1> 
  9172 00003252 52                  <1> 	push	edx	
  9173 00003253 30E4                <1> 	xor	ah, ah
  9174 00003255 88F8                <1> 	mov	al, bh ; mov al, 14 
  9175 00003257 66F7E1              <1> 	mul	cx 
  9176                              <1> 		; ecx = byte count 
  9177 0000325A 89C1                <1> 	mov	ecx, eax
  9178 0000325C 5A                  <1> 	pop	edx	
  9179 0000325D 30E4                <1> 	xor	ah, ah
  9180 0000325F 88F8                <1> 	mov	al, bh ; mov ax, 14 ; bytes per character
  9181 00003261 66F7E2              <1> 	mul	dx
  9182 00003264 6689C2              <1> 	mov	dx, ax ; char offset
  9183 00003267 BF[C4680100]        <1> 	mov	edi, vgafont14
  9184 0000326C EB4C                <1> 	jmp	short transfer_user_fonts_8			
  9185                              <1> transfer_user_fonts_6:
  9186 0000326E 80FF08              <1> 	cmp	bh, 8 ; 8x8 font
  9187 00003271 7522                <1> 	jne	short transfer_user_fonts_7 ; 8x16 font
  9188 00003273 66C1E203            <1> 	shl	dx, 3 ; * 8
  9189 00003277 66C1E103            <1> 	shl	cx, 3 ; * 8
  9190                              <1> 	; 09/01/2021
  9191 0000327B BF00500900          <1> 	mov	edi, VGAFONT8USER
  9192 00003280 F605[7E120300]08    <1> 	test	byte [ufont], 8  ; already loaded ?	
  9193 00003287 7531                <1> 	jnz	short transfer_user_fonts_8 ; yes
  9194 00003289 BE[C4600100]        <1> 	mov	esi, vgafont8
  9195 0000328E E83B000000          <1> 	call	transfer_user_fonts_10
  9196 00003293 EB25                <1> 	jmp	short transfer_user_fonts_8
  9197                              <1> transfer_user_fonts_7:
  9198 00003295 80FF10              <1> 	cmp	bh, 16 ; 8x16 font
  9199 00003298 7599                <1> 	jne	short transfer_user_fonts_4  ; invalid !
  9200 0000329A 66C1E204            <1> 	shl	dx, 4 ; * 16
  9201 0000329E 66C1E104            <1> 	shl	cx, 4 ; * 16 
  9202 000032A2 BF00400900          <1> 	mov	edi, VGAFONT16USER
  9203 000032A7 F605[7E120300]10    <1> 	test	byte [ufont], 16  ; already loaded ?	
  9204 000032AE 750A                <1> 	jnz	short transfer_user_fonts_8 ; yes
  9205 000032B0 BE[C4760100]        <1> 	mov	esi, vgafont16
  9206 000032B5 E814000000          <1> 	call	transfer_user_fonts_10
  9207                              <1> transfer_user_fonts_8:
  9208 000032BA 01D7                <1> 	add	edi, edx ; char offset
  9209                              <1> 	; 09/07/2016
  9210                              <1> 	;and	ecx, 0FFFFh
  9211                              <1> 	; ECX = byte count
  9212                              <1> 	;push	ecx
  9213 000032BC 89EE                <1> 	mov	esi, ebp ; user's font buffer
  9214                              <1> 	; 09/01/2021
  9215 000032BE 89FD                <1> 	mov	ebp, edi ; system addr for user's font
  9216                              <1> 	; 05/01/2021
  9217                              <1> 	;mov	edi, Cluster_Buffer  ; system buffer
  9218 000032C0 E8E9E80000          <1> 	call	transfer_from_user_buffer
  9219                              <1> 	;pop	ecx
  9220                              <1> 	; ecx = transfer (byte) count = character count
  9221 000032C5 7206                <1> 	jc	short transfer_user_fonts_9
  9222                              <1> 	; 05/01/2021
  9223                              <1> 	;mov	ebp, Cluster_Buffer
  9224                              <1> 	
  9225 000032C7 083D[7E120300]      <1> 	or	byte [ufont], bh 
  9226                              <1> 			; 8x8 or 8x16 user font ready 
  9227                              <1> transfer_user_fonts_9:
  9228 000032CD C3                  <1> 	retn
  9229                              <1> 
  9230                              <1> transfer_user_fonts_10:
  9231                              <1> 	; 09/01/2021
  9232 000032CE 56                  <1> 	push	esi
  9233 000032CF 57                  <1> 	push	edi
  9234 000032D0 51                  <1> 	push	ecx
  9235 000032D1 66B94000            <1> 	mov	cx, 64
  9236 000032D5 F3A5                <1> 	rep	movsd
  9237 000032D7 59                  <1> 	pop	ecx
  9238 000032D8 5F                  <1> 	pop	edi
  9239 000032D9 5E                  <1> 	pop	esi
  9240 000032DA C3                  <1> 	retn
  9241                              <1> 
  9242                              <1> load_text_user_pat:
  9243                              <1> 	; 26/07/2016
  9244                              <1> 	; 09/07/2016
  9245                              <1> 	; load user defined (EGA/VGA) text fonts
  9246                              <1> 	;
  9247                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  9248                              <1> 	; vgabios-0.7a (2011)
  9249                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  9250                              <1> 	; 'vgabios.c', 'biosfn_load_text_user_pat'
  9251                              <1> 
  9252                              <1> 	; biosfn_load_text_user_pat (AL,ES,BP,CX,DX,BL,BH)
  9253                              <1> 
  9254                              <1> 	; get_font_access();
  9255                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  9256                              <1> 	; for(i=0;i<CX;i++)
  9257                              <1> 	; {
  9258                              <1> 	;  src = BP + i * BH;
  9259                              <1> 	;  dest = blockaddr + (DX + i) * 32;
  9260                              <1> 	;  memcpyb(0xA000, dest, ES, src, BH);
  9261                              <1> 	; }
  9262                              <1> 	; release_font_access();
  9263                              <1> 	; if(AL>=0x10)
  9264                              <1> 	; {
  9265                              <1> 	; set_scan_lines(BH);
  9266                              <1> 	; }
  9267                              <1> 
  9268 000032DB 50                  <1> 	push	eax
  9269 000032DC E83C000000          <1> 	call	get_font_access
  9270 000032E1 28DB                <1> 	sub	bl, bl ; i = 0
  9271                              <1> ltup_1:
  9272 000032E3 88D8                <1> 	mov	al, bl
  9273 000032E5 F6E7                <1> 	mul	bh
  9274 000032E7 0FB7F0              <1> 	movzx	esi, ax
  9275 000032EA 01EE                <1> 	add	esi, ebp
  9276 000032EC 88D8                <1> 	mov	al, bl
  9277 000032EE 28E4                <1> 	sub	ah, ah
  9278 000032F0 6601D0              <1> 	add	ax, dx ; (DX + i)
  9279 000032F3 66C1E005            <1> 	shl	ax, 5  ; * 32
  9280 000032F7 0FB7F8              <1> 	movzx	edi, ax
  9281 000032FA 81C700000A00        <1> 	add	edi, 0A0000h
  9282 00003300 51                  <1> 	push	ecx
  9283 00003301 0FB6CF              <1> 	movzx	ecx, bh
  9284 00003304 F3A4                <1> 	rep	movsb
  9285 00003306 59                  <1> 	pop	ecx
  9286 00003307 FEC3                <1> 	inc	bl
  9287 00003309 38CB                <1> 	cmp	bl, cl
  9288 0000330B 75D6                <1> 	jne	short ltup_1
  9289                              <1> 	;
  9290 0000330D E840000000          <1> 	call	release_font_access
  9291                              <1> 	;
  9292 00003312 58                  <1> 	pop	eax
  9293                              <1> 	; if(AL>=0x10)
  9294 00003313 3C10                <1> 	cmp	al, 10h
  9295 00003315 7205                <1> 	jb	short ltup_2
  9296                              <1>    	; set_scan_lines(BH);
  9297 00003317 E875000000          <1> 	call	set_scan_lines
  9298                              <1> ltup_2:
  9299 0000331C C3                  <1> 	retn
  9300                              <1> 
  9301                              <1> get_font_access:
  9302                              <1> 	; 09/07/2016
  9303                              <1> 	;
  9304                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  9305                              <1> 	; vgabios-0.7a (2011)
  9306                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  9307                              <1> 	; 'vgabios.c', 'get_font_access'
  9308                              <1> 
  9309                              <1> 	; get_font_access()
  9310 0000331D 52                  <1> 	push	edx
  9311 0000331E 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  9312 00003322 66B80001            <1> 	mov	ax, 0100h
  9313 00003326 66EF                <1> 	out	dx, ax
  9314 00003328 66B80204            <1> 	mov	ax, 0402h
  9315 0000332C 66EF                <1> 	out	dx, ax
  9316 0000332E 66B80407            <1> 	mov	ax, 0704h
  9317 00003332 66EF                <1> 	out	dx, ax
  9318 00003334 66B80003            <1> 	mov	ax, 0300h
  9319 00003338 66EF                <1> 	out	dx, ax
  9320 0000333A 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  9321 0000333E 66B80402            <1> 	mov	ax, 0204h
  9322 00003342 66EF                <1> 	out	dx, ax
  9323 00003344 66B80500            <1> 	mov	ax, 0005h
  9324 00003348 66EF                <1> 	out	dx, ax
  9325 0000334A 66B80604            <1> 	mov	ax, 0406h
  9326 0000334E 66EF                <1> 	out	dx, ax
  9327 00003350 5A                  <1> 	pop	edx
  9328 00003351 C3                  <1> 	retn
  9329                              <1> 
  9330                              <1> release_font_access:
  9331                              <1> 	; 29/07/2016
  9332                              <1> 	; 09/07/2016
  9333                              <1> 	;
  9334                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  9335                              <1> 	; vgabios-0.7a (2011)
  9336                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  9337                              <1> 	; 'vgabios.c', 'release_font_access'
  9338                              <1> 
  9339 00003352 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  9340 00003356 66B80001            <1> 	mov	ax, 0100h
  9341 0000335A 66EF                <1> 	out	dx, ax
  9342 0000335C 66B80203            <1> 	mov	ax, 0302h
  9343 00003360 66EF                <1> 	out	dx, ax
  9344 00003362 66B80403            <1> 	mov	ax, 0304h
  9345 00003366 66EF                <1> 	out	dx, ax
  9346 00003368 66B80003            <1> 	mov	ax, 0300h
  9347 0000336C 66EF                <1> 	out	dx, ax
  9348 0000336E 66BACC03            <1> 	mov	dx, 3CCh ; VGAREG_READ_MISC_OUTPUT
  9349 00003372 EC                  <1>  	in	al, dx
  9350 00003373 2401                <1> 	and	al, 01h
  9351 00003375 C0E002              <1> 	shl	al, 2
  9352 00003378 0C0A                <1> 	or	al, 0Ah
  9353 0000337A 88C4                <1> 	mov	ah, al
  9354 0000337C B006                <1> 	mov	al, 06h
  9355 0000337E 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  9356 00003382 66EF                <1> 	out	dx, ax
  9357 00003384 66B80400            <1> 	mov	ax, 0004h
  9358 00003388 66EF                <1> 	out	dx, ax
  9359 0000338A 66B80510            <1> 	mov	ax, 1005h
  9360 0000338E 66EF                <1> 	out	dx, ax
  9361 00003390 C3                  <1> 	retn
  9362                              <1> 
  9363                              <1> set_scan_lines:
  9364                              <1> 	; 09/07/2016
  9365                              <1> 	;
  9366                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  9367                              <1> 	; vgabios-0.7a (2011)
  9368                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  9369                              <1> 	; 'vgabios.c', 'set_scan_lines'
  9370                              <1> 
  9371                              <1> 	; set_scan_lines(lines)
  9372                              <1> 	; BH = lines
  9373                              <1> 
  9374                              <1> 	; outb(crtc_addr, 0x09);
  9375 00003391 66BAD403            <1> 	mov	dx, 3D4h ; CRTC_ADDRESS = 3D4h (always)
  9376 00003395 B009                <1> 	mov	al, 09h
  9377 00003397 EE                  <1> 	out	dx, al
  9378                              <1> 	; crtc_r9 = inb(crtc_addr+1);
  9379 00003398 6642                <1> 	inc	dx ; 3D5h
  9380 0000339A EC                  <1> 	in	al, dx
  9381                              <1> 	; crtc_r9 = (crtc_r9 & 0xe0) | (lines - 1);
  9382 0000339B 24E0                <1> 	and	al, 0E0h
  9383 0000339D FECF                <1> 	dec	bh ; lines - 1
  9384 0000339F 08F8                <1> 	or	al, bh
  9385                              <1> 	; outb(crtc_addr+1, crtc_r9);
  9386 000033A1 EE                  <1> 	out	dx, al
  9387                              <1> 	;inc	bh 
  9388                              <1> 	; if(lines==8)
  9389                              <1> 	;cmp	bh, 8
  9390 000033A2 80FF07              <1> 	cmp	bh, 7
  9391 000033A5 7506                <1> 	jne	short ssl_1
  9392                              <1> 	; biosfn_set_cursor_shape(0x06,0x07);
  9393 000033A7 66B90706            <1> 	mov	cx, 0607h
  9394 000033AB EB06                <1> 	jmp	short ssl_2
  9395                              <1> ssl_1:
  9396                              <1> 	; biosfn_set_cursor_shape(lines-4,lines-3);
  9397 000033AD 88F9                <1> 	mov	cl, bh ; lines - 1
  9398 000033AF 88CD                <1> 	mov	ch, cl ; lines - 1 (16 -> 15)
  9399 000033B1 FECD                <1> 	dec	ch  ; lines - 2 (16 -> 14)
  9400                              <1> ssl_2:
  9401                              <1> 	; CH = start line, CL = stop line
  9402 000033B3 B40A                <1> 	mov	ah, 10	; 6845 register for cursor set
  9403 000033B5 66890D[F36F0000]    <1> 	mov	[CURSOR_MODE], cx ; save in data area
  9404 000033BC E809F0FFFF          <1> 	call	m16	; output cx register
  9405                              <1> 	; write_word(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT, lines);
  9406 000033C1 FEC7                <1> 	inc	bh ; lines
  9407 000033C3 883D[DE6F0000]      <1> 	mov	[CHAR_HEIGHT], bh
  9408                              <1> 	;  outb(crtc_addr, 0x12);
  9409 000033C9 66BAD403            <1> 	mov	dx, 3D4h ; CRTC_ADDRESS
  9410 000033CD B012                <1> 	mov	al, 12h
  9411 000033CF EE                  <1> 	out	dx, al
  9412                              <1> 	; vde = inb(crtc_addr+1);
  9413 000033D0 6642                <1> 	inc	dx
  9414 000033D2 EC                  <1> 	in	al, dx
  9415 000033D3 88C4                <1> 	mov	ah, al
  9416                              <1> 	; outb(crtc_addr, 0x07);
  9417 000033D5 664A                <1> 	dec	dx
  9418 000033D7 B007                <1> 	mov	al, 07h
  9419 000033D9 EE                  <1> 	out	dx, al
  9420                              <1> 	; ovl = inb(crtc_addr+1);
  9421 000033DA 6642                <1> 	inc	dx
  9422 000033DC EC                  <1> 	in	al, dx
  9423                              <1> 	; vde += (((ovl & 0x02) << 7) + ((ovl & 0x40) << 3) + 1);
  9424 000033DD 88E2                <1> 	mov	dl, ah ; vde
  9425 000033DF 88C6                <1> 	mov	dh, al ; ovl
  9426 000033E1 6683E002            <1> 	and	ax, 02h
  9427 000033E5 66C1E007            <1> 	shl	ax, 7
  9428 000033E9 6689C1              <1> 	mov	cx, ax ; (ovl & 0x02) << 7)	
  9429 000033EC 88F0                <1> 	mov	al, dh ; ovl
  9430 000033EE 6683E040            <1> 	and	ax, 40h			
  9431 000033F2 66C1E003            <1> 	shl	ax, 3  ; (ovl & 0x40) << 3)
  9432 000033F6 6640                <1> 	inc	ax ; + 1 
  9433 000033F8 6601C8              <1> 	add	ax, cx
  9434 000033FB 30F6                <1> 	xor	dh, dh
  9435 000033FD 6601D0              <1> 	add	ax, dx ; + vde
  9436                              <1> 	; rows = vde / lines;
  9437 00003400 F6F7                <1> 	div	bh
  9438                              <1> 	;dec	al ; rows -1
  9439                              <1> 	; write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, rows-1);
  9440 00003402 A2[E26F0000]        <1> 	mov	[VGA_ROWS], al ; rows (not 'rows-1' !)
  9441                              <1> 	; write_word(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE, rows * cols * 2);
  9442                              <1> 	;mov	ah, [CRT_COLS]
  9443                              <1> 	;mul	ah
  9444                              <1> 	; 17/11/2020
  9445 00003407 F625[DC6F0000]      <1> 	mul	byte [CRT_COLS]
  9446 0000340D 66D1E0              <1> 	shl	ax, 1
  9447 00003410 66A3[C8960100]      <1> 	mov 	[CRT_LEN], ax	
  9448 00003416 C3                  <1> 	retn
  9449                              <1> 
  9450                              <1> load_text_8_14_pat:
  9451                              <1> 	; 26/07/2016
  9452                              <1> 	; 25/07/2016
  9453                              <1> 	; 23/07/2016
  9454                              <1> 	; 09/07/2016
  9455                              <1> 	; load user defined (EGA/VGA) text fonts
  9456                              <1> 	;
  9457                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  9458                              <1> 	; vgabios-0.7a (2011)
  9459                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  9460                              <1> 	; 'vgabios.c', 'biosfn_load_text_8_14_pat'
  9461                              <1> 
  9462                              <1> 	; biosfn_load_text_8_14_pat (AL,BL)
  9463                              <1> 
  9464                              <1> 	; get_font_access();
  9465                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  9466                              <1> 	; for(i=0;i<0x100;i++)
  9467                              <1> 	; {
  9468                              <1> 	;  src = i * 14;
  9469                              <1> 	;  dest = blockaddr + i * 32;
  9470                              <1> 	;  memcpyb(0xA000, dest, 0xC000, vgafont14+src, 14);
  9471                              <1> 	; }
  9472                              <1> 	; release_font_access();
  9473                              <1> 	; if(AL>=0x10)
  9474                              <1> 	; {
  9475                              <1> 	; set_scan_lines(14);
  9476                              <1> 	; }
  9477                              <1> 
  9478 00003417 50                  <1> 	push	eax
  9479 00003418 E800FFFFFF          <1> 	call	get_font_access
  9480                              <1> 
  9481                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  9482                              <1> 	;mov	dl, bl
  9483                              <1> 	;and	dl, 3
  9484                              <1> 	;shl	dx, 14
  9485                              <1> 	;xchg	dx, bx
  9486                              <1> 	;and	dl, 4
  9487                              <1> 	;shl	dx, 11
  9488                              <1> 	;add	dx, bx 	
  9489                              <1>  
  9490                              <1> 	;xor	dx, dx  ; blockaddr = 0
  9491                              <1> 	; Always block 0 for TRDOS 386 ! (blockaddr=0)
  9492                              <1> 
  9493 0000341D 28DB                <1> 	sub	bl, bl ; i = 0
  9494 0000341F B70E                <1> 	mov	bh, 14
  9495 00003421 BE[C4680100]        <1> 	mov	esi, vgafont14
  9496 00003426 BF00000A00          <1> 	mov	edi, 0A0000h		
  9497                              <1> lt8_14_1:
  9498                              <1> 	;mov	al, bl
  9499                              <1> 	;mul	bh
  9500                              <1> 	;movzx	esi, ax
  9501                              <1> 	;add	esi, vgafont14
  9502                              <1> 	;mov	al, bl
  9503                              <1> 	;sub	ah, ah
  9504                              <1> 	;shl	ax, 5 ; * 32
  9505                              <1> 	;;add	ax, dx ; blockaddr + i * 32;
  9506                              <1> 	;movzx	edi, ax ; dest
  9507                              <1> 	;add	edi, 0A0000h
  9508 0000342B 0FB6CF              <1> 	movzx	ecx, bh
  9509 0000342E F3A4                <1> 	rep	movsb
  9510 00003430 83C712              <1> 	add	edi, 18 ; 32 - 14
  9511 00003433 FEC3                <1> 	inc	bl
  9512 00003435 75F4                <1> 	jnz	short lt8_14_1	
  9513                              <1> 	;
  9514 00003437 E816FFFFFF          <1> 	call	release_font_access
  9515                              <1> 	;
  9516 0000343C 58                  <1> 	pop	eax
  9517                              <1> 	; if(AL>=0x10)
  9518 0000343D 3C10                <1> 	cmp	al, 10h
  9519 0000343F 7205                <1> 	jb	short lt8_14_4
  9520                              <1> 	; BH = 14
  9521                              <1>    	; set_scan_lines(14);
  9522 00003441 E84BFFFFFF          <1> 	call	set_scan_lines
  9523                              <1> lt8_14_4:
  9524 00003446 C3                  <1> 	retn
  9525                              <1> 
  9526                              <1> load_text_8_8_pat:
  9527                              <1> 	; 05/01/2021 (TRDOS 386 v2.0.3)
  9528                              <1> 	; 26/07/2016
  9529                              <1> 	; 25/07/2016
  9530                              <1> 	; 23/07/2016
  9531                              <1> 	; 09/07/2016
  9532                              <1> 	; load user defined (EGA/VGA) text fonts
  9533                              <1> 	;
  9534                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  9535                              <1> 	; vgabios-0.7a (2011)
  9536                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  9537                              <1> 	; 'vgabios.c', 'biosfn_load_text_8_8_pat'
  9538                              <1> 
  9539                              <1> 	; biosfn_load_text_8_8_pat (AL,BL)
  9540                              <1> 
  9541                              <1> 	; get_font_access();
  9542                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  9543                              <1> 	; for(i=0;i<0x100;i++)
  9544                              <1> 	; {
  9545                              <1> 	;  src = i * 8;
  9546                              <1> 	;  dest = blockaddr + i * 32;
  9547                              <1> 	;  memcpyb(0xA000, dest, 0xC000, vgafont8+src, 8);
  9548                              <1> 	; }
  9549                              <1> 	; release_font_access();
  9550                              <1> 	; if(AL>=0x10)
  9551                              <1> 	; {
  9552                              <1> 	; set_scan_lines(8);
  9553                              <1> 	; }
  9554                              <1> 
  9555 00003447 50                  <1> 	push	eax
  9556 00003448 E8D0FEFFFF          <1> 	call	get_font_access
  9557                              <1> 
  9558                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  9559                              <1> 	;mov	dl, bl
  9560                              <1> 	;and	dl, 3
  9561                              <1> 	;shl	dx, 14
  9562                              <1> 	;xchg	dx, bx
  9563                              <1> 	;and	dl, 4
  9564                              <1> 	;shl	dx, 11
  9565                              <1> 	;add	dx, bx 	
  9566                              <1>  
  9567                              <1> 	;xor	dx, dx  ; blockaddr = 0
  9568                              <1> 	; Always block 0 for TRDOS 386 ! (blockaddr=0)
  9569                              <1> 
  9570 0000344D 28DB                <1> 	sub	bl, bl ; i = 0
  9571 0000344F B708                <1> 	mov	bh, 8
  9572                              <1> 	;mov	esi, vgafont8
  9573 00003451 BF00000A00          <1> 	mov	edi, 0A0000h
  9574                              <1> 
  9575                              <1> 	; 05/01/2021
  9576 00003456 F605[7E120300]80    <1> 	test	byte [ufont], 80h
  9577 0000345D 7410                <1> 	jz	short lt8_8_0
  9578                              <1> 		; user font permission (after set mode)
  9579 0000345F F605[7E120300]08    <1>  	test	byte [ufont], 8
  9580 00003466 7407                <1> 	jz	short lt8_8_0
  9581 00003468 BE00500900          <1> 	mov	esi, VGAFONT8USER
  9582 0000346D EB05                <1> 	jmp	short lt8_8_1
  9583                              <1> lt8_8_0:
  9584 0000346F BE[C4600100]        <1> 	mov	esi, vgafont8	
  9585                              <1> lt8_8_1:
  9586                              <1> 	;mov	al, bl
  9587                              <1> 	;mul	bh
  9588                              <1> 	;movzx	esi, ax
  9589                              <1> 	;add	esi, vgafont8
  9590                              <1> 	;mov	al, bl
  9591                              <1> 	;sub	ah, ah
  9592                              <1> 	;shl	ax, 5 ; * 32
  9593                              <1> 	;;add	ax, dx ; blockaddr + i * 32;
  9594                              <1> 	;movzx	edi, ax ; dest
  9595                              <1> 	;add	edi, 0A0000h
  9596 00003474 0FB6CF              <1> 	movzx	ecx, bh 		
  9597 00003477 F3A4                <1> 	rep	movsb
  9598 00003479 83C718              <1> 	add	edi, 24 ; 32 - 8
  9599 0000347C FEC3                <1> 	inc	bl
  9600 0000347E 75F4                <1> 	jnz	short lt8_8_1
  9601                              <1> 	;
  9602 00003480 E8CDFEFFFF          <1> 	call	release_font_access
  9603                              <1> 	;
  9604 00003485 58                  <1> 	pop	eax
  9605                              <1> 	; if(AL>=0x10)
  9606 00003486 3C10                <1> 	cmp	al, 10h
  9607 00003488 7205                <1> 	jb	short lt8_8_2
  9608                              <1> 	; BH = 8
  9609                              <1>    	; set_scan_lines(8);
  9610 0000348A E802FFFFFF          <1> 	call	set_scan_lines
  9611                              <1> lt8_8_2:
  9612 0000348F C3                  <1> 	retn
  9613                              <1> 
  9614                              <1> load_text_8_16_pat:
  9615                              <1> 	; 05/01/2021 (TRDOS 386 v2.0.3)
  9616                              <1> 	; 26/07/2016
  9617                              <1> 	; 25/07/2016
  9618                              <1> 	; 23/07/2016
  9619                              <1> 	; 09/07/2016
  9620                              <1> 	; load user defined (EGA/VGA) text fonts
  9621                              <1> 	;
  9622                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  9623                              <1> 	; vgabios-0.7a (2011)
  9624                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  9625                              <1> 	; 'vgabios.c', 'biosfn_load_text_8_16_pat'
  9626                              <1> 
  9627                              <1> 	; biosfn_load_text_8_16_pat (AL,BL)
  9628                              <1> 
  9629                              <1> 	; get_font_access();
  9630                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  9631                              <1> 	; for(i=0;i<0x100;i++)
  9632                              <1> 	; {
  9633                              <1> 	;  src = i * 16;
  9634                              <1> 	;  dest = blockaddr + i * 32;
  9635                              <1> 	;  memcpyb(0xA000, dest, 0xC000, vgafont16+src, 16);
  9636                              <1> 	; }
  9637                              <1> 	; release_font_access();
  9638                              <1> 	; if(AL>=0x10)
  9639                              <1> 	; {
  9640                              <1> 	; set_scan_lines(16);
  9641                              <1> 	; }
  9642                              <1> 
  9643 00003490 50                  <1> 	push	eax
  9644 00003491 E887FEFFFF          <1> 	call	get_font_access
  9645                              <1> 
  9646                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  9647                              <1> 	;mov	dl, bl
  9648                              <1> 	;and	dl, 3
  9649                              <1> 	;shl	dx, 14
  9650                              <1> 	;xchg	dx, bx
  9651                              <1> 	;and	dl, 4
  9652                              <1> 	;shl	dx, 11
  9653                              <1> 	;add	dx, bx 	
  9654                              <1>  
  9655                              <1> 	;xor	dx, dx  ; blockaddr = 0
  9656                              <1> 	; Always block 0 for TRDOS 386 ! (blockaddr=0)
  9657                              <1> 
  9658 00003496 28DB                <1> 	sub	bl, bl ; i = 0
  9659 00003498 B710                <1> 	mov	bh, 16
  9660                              <1> 	;mov	esi, vgafont16
  9661 0000349A BF00000A00          <1> 	mov	edi, 0A0000h
  9662 0000349F 0FB6C7              <1> 	movzx	eax, bh
  9663                              <1> 
  9664                              <1> 	; 05/01/2021
  9665 000034A2 F605[7E120300]80    <1> 	test	byte [ufont], 80h
  9666 000034A9 7410                <1> 	jz	short lt8_16_0
  9667                              <1> 		; user font permission (after set mode)
  9668 000034AB F605[7E120300]10    <1>  	test	byte [ufont], 16
  9669 000034B2 7407                <1> 	jz	short lt8_16_0
  9670 000034B4 BE00400900          <1> 	mov	esi, VGAFONT16USER
  9671 000034B9 EB05                <1> 	jmp	short lt8_16_1
  9672                              <1> lt8_16_0:
  9673 000034BB BE[C4760100]        <1> 	mov	esi, vgafont16
  9674                              <1> lt8_16_1:
  9675                              <1> 	;mov	al, bl
  9676                              <1> 	;mul	bh
  9677                              <1> 	;movzx	esi, ax
  9678                              <1> 	;add	esi, vgafont16
  9679                              <1> 	;mov	al, bl ; i
  9680                              <1> 	;sub	ah, ah
  9681                              <1> 	;shl	ax, 5 ; * 32
  9682                              <1> 	;;add	ax, dx ; blockaddr + i * 32;
  9683                              <1> 	;movzx	edi, ax ; dest
  9684                              <1> 	;add	edi, 0A0000h
  9685                              <1> 	;movzx	ecx, bh
  9686 000034C0 89C1                <1> 	mov	ecx, eax ; 16	
  9687 000034C2 F3A4                <1> 	rep	movsb
  9688 000034C4 01C7                <1> 	add	edi, eax ; add edi, 16
  9689 000034C6 FEC3                <1> 	inc	bl
  9690 000034C8 75F6                <1> 	jnz	short lt8_16_1
  9691                              <1> 	;
  9692 000034CA E883FEFFFF          <1> 	call	release_font_access
  9693                              <1> 	;
  9694 000034CF 58                  <1> 	pop	eax
  9695                              <1> 	; if(AL>=0x10)
  9696 000034D0 3C10                <1> 	cmp	al, 10h
  9697 000034D2 7205                <1> 	jb	short lt8_16_2
  9698                              <1> 	; BH = 16
  9699                              <1>    	; set_scan_lines(16);
  9700 000034D4 E8B8FEFFFF          <1> 	call	set_scan_lines
  9701                              <1> lt8_16_2:
  9702 000034D9 C3                  <1> 	retn
  9703                              <1> 
  9704                              <1> load_gfx_user_chars:
  9705                              <1> 	; 08/01/2021
  9706                              <1> 	; 05/01/2021 (TRDOS 386 v2.0.3)
  9707                              <1> 	; 08/08/2016
  9708                              <1> 	; 10/07/2016
  9709                              <1> 	; Setup User-Defined Font for Graphics Mode (VGA)
  9710                              <1> 	;
  9711                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  9712                              <1> 	; vgabios-0.7a (2011)
  9713                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  9714                              <1> 	; 'vgabios.c', 'biosfn_load_gfx_user_chars'
  9715                              <1> 
  9716                              <1> 	; biosfn_load_gfx_user_chars (ES,BP,CX,BL,DL)
  9717                              <1> 	; /* set 0x43 INT pointer */
  9718                              <1>     	; write_word(0x0, 0x43*4, BP);
  9719                              <1>     	; write_word(0x0, 0x43*4+2, ES);
  9720                              <1> 	
  9721                              <1> 	; 08/01/2021
  9722                              <1> 		
  9723                              <1> 	; BL   screen rows code: 00H = user-specified (in DL)
  9724                              <1>         ;                        01H = 14 rows
  9725                              <1>         ;                        02H = 25 rows
  9726                              <1>         ;                        03H = 43 rows
  9727                              <1>         ; CX   bytes per character definition
  9728                              <1>         ; DL   (when BL=0) custom number of character rows on screen
  9729                              <1>         ; EBP  address of font-definition information (user's mem space)
  9730                              <1> 
  9731                              <1> 	; 05/01/2021
  9732                              <1> 	;xor	eax, eax
  9733                              <1> 	;dec	eax ; 0FFFFFFFFh (user defined fonts)
  9734                              <1> 	;mov	[VGA_INT43H], eax
  9735                              <1> 
  9736                              <1> 	; 08/01/2021
  9737                              <1> 	; ebp = video font data (buffer) address
  9738 000034DA 892D[DA960100]      <1> 	mov	[VGA_INT43H], ebp
  9739                              <1> 
  9740                              <1> 	; switch (BL) {
  9741                              <1> 	; case 0:
  9742                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1);
  9743                              <1> 	;    break;
  9744 000034E0 20DB                <1> 	and	bl, bl
  9745 000034E2 7508                <1> 	jnz	short l_gfx_uc_1
  9746 000034E4 8815[E26F0000]      <1> 	mov	[VGA_ROWS], dl  ; not DL-1 !
  9747 000034EA EB23                <1> 	jmp	short l_gfx_uc_4
  9748                              <1> l_gfx_uc_1:
  9749                              <1> 	; case 1:
  9750                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13);
  9751                              <1> 	;    break;
  9752 000034EC FECB                <1> 	dec	bl
  9753 000034EE 7509                <1> 	jnz	short l_gfx_uc_2
  9754                              <1> 	; bl = 1
  9755 000034F0 C605[E26F0000]0E    <1> 	mov	byte [VGA_ROWS], 14  ; not 13 !
  9756 000034F7 EB16                <1> 	jmp	short l_gfx_uc_4
  9757                              <1> l_gfx_uc_2:
  9758 000034F9 FECB                <1> 	dec	bl
  9759 000034FB 740B                <1> 	jz	short l_gfx_uc_3 ; bl = 2
  9760 000034FD FECB                <1> 	dec	bl
  9761 000034FF 750E                <1> 	jnz	short l_gfx_uc_4 ; bl > 3
  9762                              <1> 	; bl = 3
  9763                              <1> 	; case 3:
  9764                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42);
  9765                              <1> 	;    break;
  9766 00003501 C605[E26F0000]2B    <1> 	mov	byte [VGA_ROWS], 43  ; not 42 !
  9767                              <1> l_gfx_uc_3:
  9768                              <1>     	; case 2:
  9769                              <1>     	; default:
  9770                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24);
  9771                              <1> 	;    break;
  9772                              <1> 	; bl = 2 or bl > 3
  9773 00003508 C605[E26F0000]19    <1> 	mov	byte [VGA_ROWS], 25  ; not 24 !	
  9774                              <1>     	; }
  9775                              <1> l_gfx_uc_4:
  9776                              <1>     	; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, CX);
  9777 0000350F 880D[DE6F0000]      <1> 	mov	[CHAR_HEIGHT], cl
  9778                              <1> 	; }
  9779 00003515 C3                  <1> 	retn
  9780                              <1> 
  9781                              <1> load_gfx_8_14_chars:
  9782                              <1> 	; 08/08/2016
  9783                              <1> 	; 10/07/2016
  9784                              <1> 	; Setup ROM 8x14 Font for Graphics Mode (VGA)
  9785                              <1> 	;
  9786                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  9787                              <1> 	; vgabios-0.7a (2011)
  9788                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  9789                              <1> 	; 'vgabios.c', 'biosfn_load_gfx_8_14_chars'
  9790                              <1> 
  9791                              <1> 	; biosfn_load_gfx_8_14_chars (BL)
  9792                              <1> 	; /* set 0x43 INT pointer */
  9793                              <1>     	; write_word(0x0, 0x43*4, &vgafont14);
  9794                              <1>     	; write_word(0x0, 0x43*4+2, 0xC000);
  9795 00003516 C705[DA960100]-     <1> 	mov	dword [VGA_INT43H], vgafont14
  9795 0000351C [C4680100]          <1>
  9796                              <1> 		
  9797                              <1> 	; BL    screen rows code: 00H = user-specified (in DL)
  9798                              <1>         ;                         01H = 14 rows
  9799                              <1>         ;                         02H = 25 rows
  9800                              <1>         ;                         03H = 43 rows
  9801                              <1>         ; DL    (when BL=0) custom number of char rows on screen
  9802                              <1> 
  9803                              <1> 	; switch (BL) {
  9804                              <1> 	; case 0:
  9805                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1);
  9806                              <1> 	;    break;
  9807 00003520 20DB                <1> 	and	bl, bl
  9808 00003522 7508                <1> 	jnz	short l_gfx_8_14c_1
  9809 00003524 8815[E26F0000]      <1> 	mov	[VGA_ROWS], dl  ; not DL-1 !
  9810 0000352A EB23                <1> 	jmp	short l_gfx_8_14c_4
  9811                              <1> l_gfx_8_14c_1:
  9812                              <1> 	; case 1:
  9813                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13);
  9814                              <1> 	;    break;
  9815 0000352C FECB                <1> 	dec	bl
  9816 0000352E 7509                <1> 	jnz	short l_gfx_8_14c_2
  9817                              <1> 	; bl = 1
  9818 00003530 C605[E26F0000]0E    <1> 	mov	byte [VGA_ROWS], 14  ; not 13 !
  9819 00003537 EB16                <1> 	jmp	short l_gfx_8_14c_4
  9820                              <1> l_gfx_8_14c_2:
  9821 00003539 FECB                <1> 	dec	bl
  9822 0000353B 740B                <1> 	jz	short l_gfx_8_14c_3 ; bl = 2
  9823 0000353D FECB                <1> 	dec	bl
  9824 0000353F 750E                <1> 	jnz	short l_gfx_8_14c_4 ; bl > 3
  9825                              <1> 	; bl = 3
  9826                              <1> 	; case 3:
  9827                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42);
  9828                              <1> 	;    break;
  9829 00003541 C605[E26F0000]2B    <1> 	mov	byte [VGA_ROWS], 43  ; not 42 !
  9830                              <1> l_gfx_8_14c_3:
  9831                              <1>     	; case 2:
  9832                              <1>     	; default:
  9833                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24);
  9834                              <1> 	;    break;
  9835                              <1> 	; bl = 2 or bl > 3
  9836 00003548 C605[E26F0000]19    <1> 	mov	byte [VGA_ROWS], 25  ; not 24 !
  9837                              <1>     	; }
  9838                              <1> l_gfx_8_14c_4:
  9839                              <1>     	; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, 14);
  9840 0000354F C605[DE6F0000]0E    <1>         mov     byte [CHAR_HEIGHT], 14
  9841                              <1> 	; }
  9842 00003556 C3                  <1> 	retn	
  9843                              <1> 
  9844                              <1> load_gfx_8_8_chars:
  9845                              <1> 	; 08/08/2016
  9846                              <1> 	; 10/07/2016
  9847                              <1> 	; Setup ROM 8x14 Font for Graphics Mode (VGA)
  9848                              <1> 	;
  9849                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  9850                              <1> 	; vgabios-0.7a (2011)
  9851                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  9852                              <1> 	; 'vgabios.c', 'biosfn_load_gfx_8_8_dd_chars'
  9853                              <1> 
  9854                              <1> 	; biosfn_load_gfx_8_8_dd_chars (BL)
  9855                              <1> 	; /* set 0x43 INT pointer */
  9856                              <1>     	; write_word(0x0, 0x43*4, &vgafont8);
  9857                              <1>     	; write_word(0x0, 0x43*4+2, 0xC000);
  9858 00003557 C705[DA960100]-     <1> 	mov	dword [VGA_INT43H], vgafont8
  9858 0000355D [C4600100]          <1>
  9859                              <1> 		
  9860                              <1> 	; BL    screen rows code: 00H = user-specified (in DL)
  9861                              <1>         ;                         01H = 14 rows
  9862                              <1>         ;                         02H = 25 rows
  9863                              <1>         ;                         03H = 43 rows
  9864                              <1>         ; DL    (when BL=0) custom number of char rows on screen
  9865                              <1> 
  9866                              <1> 	; switch (BL) {
  9867                              <1> 	; case 0:
  9868                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1);
  9869                              <1> 	;    break;
  9870 00003561 20DB                <1> 	and	bl, bl
  9871 00003563 7508                <1> 	jnz	short l_gfx_8_8c_1
  9872 00003565 8815[E26F0000]      <1> 	mov	[VGA_ROWS], dl  ; not DL-1 !
  9873 0000356B EB23                <1> 	jmp	short l_gfx_8_8c_4 	
  9874                              <1> l_gfx_8_8c_1:
  9875                              <1> 	; case 1:
  9876                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13);
  9877                              <1> 	;    break;
  9878 0000356D FECB                <1> 	dec	bl
  9879 0000356F 7509                <1> 	jnz	short l_gfx_8_8c_2
  9880                              <1> 	; bl = 1
  9881 00003571 C605[E26F0000]0E    <1> 	mov	byte [VGA_ROWS], 14  ; not 13 !
  9882 00003578 EB16                <1> 	jmp	short l_gfx_8_8c_4 	
  9883                              <1> l_gfx_8_8c_2:
  9884 0000357A FECB                <1> 	dec	bl
  9885 0000357C 740B                <1> 	jz	short l_gfx_8_8c_3 ; bl = 2
  9886 0000357E FECB                <1> 	dec	bl
  9887 00003580 750E                <1> 	jnz	short l_gfx_8_8c_4 ; bl > 3
  9888                              <1> 	; bl = 3
  9889                              <1> 	; case 3:
  9890                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42);
  9891                              <1> 	;    break;
  9892 00003582 C605[E26F0000]2B    <1> 	mov	byte [VGA_ROWS], 43  ; not 42 !
  9893                              <1> l_gfx_8_8c_3:
  9894                              <1>     	; case 2:
  9895                              <1>     	; default:
  9896                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24);
  9897                              <1> 	;    break;
  9898                              <1> 	; bl = 2 or bl > 3
  9899 00003589 C605[E26F0000]19    <1> 	mov	byte [VGA_ROWS], 25  ; not 24 !	
  9900                              <1>     	; }
  9901                              <1> l_gfx_8_8c_4:
  9902                              <1>     	; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, 8);
  9903 00003590 C605[DE6F0000]08    <1>         mov     byte [CHAR_HEIGHT], 8
  9904                              <1> 	; }
  9905 00003597 C3                  <1> 	retn
  9906                              <1> 
  9907                              <1> load_gfx_8_16_chars:
  9908                              <1> 	; 08/08/2016
  9909                              <1> 	; 10/07/2016
  9910                              <1> 	; Setup ROM 8x14 Font for Graphics Mode (VGA)
  9911                              <1> 	;
  9912                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  9913                              <1> 	; vgabios-0.7a (2011)
  9914                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  9915                              <1> 	; 'vgabios.c', 'biosfn_load_gfx_8_16_chars'
  9916                              <1> 
  9917                              <1> 	; biosfn_load_gfx_8_16_chars (BL)
  9918                              <1> 	; /* set 0x43 INT pointer */
  9919                              <1>     	; write_word(0x0, 0x43*4, &vgafont16);
  9920                              <1>     	; write_word(0x0, 0x43*4+2, 0xC000);
  9921 00003598 C705[DA960100]-     <1> 	mov	dword [VGA_INT43H], vgafont16
  9921 0000359E [C4760100]          <1>
  9922                              <1> 		
  9923                              <1> 	; BL    screen rows code: 00H = user-specified (in DL)
  9924                              <1>         ;                         01H = 14 rows
  9925                              <1>         ;                         02H = 25 rows
  9926                              <1>         ;                         03H = 43 rows
  9927                              <1>         ; DL    (when BL=0) custom number of char rows on screen
  9928                              <1> 
  9929                              <1> 	; switch (BL) {
  9930                              <1> 	; case 0:
  9931                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1);
  9932                              <1> 	;    break;
  9933 000035A2 20DB                <1> 	and	bl, bl
  9934 000035A4 7508                <1> 	jnz	short l_gfx_8_16c_1
  9935 000035A6 8815[E26F0000]      <1> 	mov	[VGA_ROWS], dl  ; not DL-1 !
  9936 000035AC EB23                <1> 	jmp	short l_gfx_8_16c_4 	
  9937                              <1> l_gfx_8_16c_1:
  9938                              <1> 	; case 1:
  9939                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13);
  9940                              <1> 	;    break;
  9941 000035AE FECB                <1> 	dec	bl
  9942 000035B0 7509                <1> 	jnz	short l_gfx_8_16c_2
  9943                              <1> 	; bl = 1
  9944 000035B2 C605[E26F0000]0E    <1> 	mov	byte [VGA_ROWS], 14  ; not 13 !
  9945 000035B9 EB16                <1> 	jmp	short l_gfx_8_16c_4
  9946                              <1> l_gfx_8_16c_2:
  9947 000035BB FECB                <1> 	dec	bl
  9948 000035BD 740B                <1> 	jz	short l_gfx_8_16c_3 ; bl = 2
  9949 000035BF FECB                <1> 	dec	bl
  9950 000035C1 750E                <1> 	jnz	short l_gfx_8_16c_4 ; bl > 3
  9951                              <1> 	; bl = 3
  9952                              <1> 	; case 3:
  9953                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42);
  9954                              <1> 	;    break;
  9955 000035C3 C605[E26F0000]2B    <1> 	mov	byte [VGA_ROWS], 43  ; not 42 !
  9956                              <1> l_gfx_8_16c_3:
  9957                              <1>     	; case 2:
  9958                              <1>     	; default:
  9959                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24);
  9960                              <1> 	;    break;
  9961                              <1> 	; bl = 2 or bl > 3
  9962 000035CA C605[E26F0000]19    <1> 	mov	byte [VGA_ROWS], 25  ; not 24 !	
  9963                              <1>     	; }
  9964                              <1> l_gfx_8_16c_4:
  9965                              <1>     	; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, 16);
  9966 000035D1 C605[DE6F0000]10    <1>         mov     byte [CHAR_HEIGHT], 16
  9967                              <1> 	; }
  9968 000035D8 C3                  <1> 	retn
  9969                              <1> 			
  9970                              <1> get_font_info:
  9971                              <1> 	; 08/01/2021 (TRDOS 386 v2.0.3)
  9972                              <1> 	; 19/09/2016
  9973                              <1> 	; 08/08/2016
  9974                              <1> 	; 10/07/2016
  9975                              <1> 	; Get Current Character Generator Info (VGA)
  9976                              <1> 	;
  9977                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  9978                              <1> 	; vgabios-0.7a (2011)
  9979                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  9980                              <1> 	; 'vgabios.c', 'biosfn_get_font_info'
  9981                              <1> 
  9982                              <1> 	; Modified for TRDOS 386 !
  9983                              <1> 	;
  9984                              <1> 	; INPUT ->
  9985                              <1> 	;    AX = 1130h
  9986                              <1> 	;    BL = 0 -> Get info for current VGA font
  9987                              <1> 	;	       (BH = unused)
  9988                              <1> 	;    19/09/2016
  9989                              <1> 	;    BL > 0 -> Get requested character font data
  9990                              <1> 	;	 BL = 1 -> vgafont8
  9991                              <1> 	;        BL = 2 -> vgafont14
  9992                              <1> 	;	 BL = 3 -> vgafont16   
  9993                              <1> 	;	;08/01/2021
  9994                              <1> 	;	 BL = 4 -> user defined 8x8 font
  9995                              <1> 	;	 BL = 5 -> user defined 8x14 font
  9996                              <1> 	;	 BL = 6 -> user defined 8x16 font
  9997                              <1> 	;	 BL > 6 -> Invalid function (for now!)
  9998                              <1> 	;	 BH = ASCII code of the first character
  9999                              <1> 	;	 ECX = Number of characters from the 1st char
 10000                              <1> 	;	 ECX >= 256 -> All (256-BH) characters
 10001                              <1> 	;	 ECX = 0 -> All characters (BH = unused)
 10002                              <1> 	;        EDX = User's Buffer Address	
 10003                              <1> 	; OUTPUT ->
 10004                              <1> 	;    AL = height (scanlines), bytes per character
 10005                              <1> 	;    AH = screen rows
 10006                              <1> 	;    Byte 16-23 of EAX = number of columns
 10007                              <1> 	;    Byte 24-31 of EAX = 
 10008                              <1> 	;	  0 -> default font (not configured yet)
 10009                              <1> 	;	  0FFh -> user defined font
 10010                              <1> 	;	  14 = vgafont14
 10011                              <1> 	;	   8 = vgafont8
 10012                              <1> 	;	  16 = vgafont16
 10013                              <1> 	;   If BL input > 0 -> 
 10014                              <1> 	;       EAX = Actual transfer count
 10015                              <1> 	;
 10016 000035D9 20DB                <1> 	and	bl, bl
 10017 000035DB 740F                <1> 	jz	short gfi_1
 10018                              <1> 	; invalid function (input)
 10019                              <1> 	; 08/01/2021
 10020 000035DD 80FB04              <1> 	cmp	bl, 4
 10021 000035E0 7263                <1> 	jb	short gfi_5
 10022 000035E2 7441                <1> 	je	short gfi_3	
 10023 000035E4 80FB06              <1> 	cmp	bl, 6
 10024 000035E7 744C                <1> 	je	short gfi_4
 10025                              <1> 	; bh = 5 or bh > 6
 10026                              <1> gfi_0:
 10027 000035E9 31C0                <1> 	xor	eax, eax ; 0
 10028 000035EB C3                  <1> 	retn
 10029                              <1> gfi_1:
 10030 000035EC A0[DE6F0000]        <1> 	mov	al, [CHAR_HEIGHT]
 10031 000035F1 8A25[E26F0000]      <1> 	mov	ah, [VGA_ROWS]
 10032 000035F7 C1E010              <1> 	shl	eax, 16
 10033 000035FA A0[DC6F0000]        <1> 	mov	al, [CRT_COLS]
 10034 000035FF 8B0D[DA960100]      <1> 	mov	ecx, [VGA_INT43H]
 10035 00003605 21C9                <1> 	and	ecx, ecx
 10036 00003607 7418                <1> 	jz	short gfi_2 ; 0 = default font
 10037                              <1> 	; 08/01/2021
 10038 00003609 FECC                <1> 	dec	ah ; 0FFh
 10039 0000360B 81F900400900        <1> 	cmp	ecx, VGAFONT16USER
 10040 00003611 740E                <1> 	je	short gfi_2
 10041 00003613 81F900500900        <1> 	cmp	ecx, VGAFONT8USER
 10042 00003619 7406                <1> 	je	short gfi_2	
 10043 0000361B 8A25[DE6F0000]      <1> 	mov	ah, [CHAR_HEIGHT] ; font size = height
 10044                              <1> gfi_2:
 10045 00003621 C1C010              <1> 	rol	eax, 16
 10046 00003624 C3                  <1> 	retn
 10047                              <1> gfi_3:
 10048                              <1> 	; 08/01/2021
 10049 00003625 F605[7E120300]08    <1> 	test	byte [ufont], 08h ; 8x8 user font
 10050 0000362C 74BB                <1> 	jz	short gfi_0 ; not loaded !
 10051 0000362E BE00500900          <1> 	mov	esi, VGAFONT8USER ; *
 10052                              <1> 	;mov	bl, 8
 10053                              <1> 	;jmp	short gfi_8
 10054 00003633 EB4D                <1> 	jmp	short gfi_10
 10055                              <1> gfi_4:
 10056                              <1> 	; 08/01/2021
 10057 00003635 F605[7E120300]10    <1> 	test	byte [ufont], 10h ; 8x16 user font
 10058 0000363C 74AB                <1> 	jz	short gfi_0 ; not loaded !
 10059 0000363E BE00400900          <1> 	mov	esi, VGAFONT16USER ; *
 10060 00003643 EB15                <1> 	jmp	short gfi_7
 10061                              <1> gfi_5:
 10062 00003645 80FB02              <1> 	cmp	bl, 2
 10063 00003648 7233                <1> 	jb	short gfi_9
 10064 0000364A 7709                <1> 	ja	short gfi_6
 10065                              <1> 	;BL = 2 -> vgafont14
 10066 0000364C BE[C4680100]        <1> 	mov	esi, vgafont14 ; *
 10067 00003651 B30E                <1> 	mov	bl, 14
 10068 00003653 EB07                <1> 	jmp	short gfi_8 
 10069                              <1> gfi_6:
 10070                              <1> 	;BL = 3 -> vgafont16
 10071 00003655 BE[C4760100]        <1> 	mov	esi, vgafont16 ; *
 10072                              <1> gfi_7:
 10073 0000365A B310                <1> 	mov	bl, 16
 10074                              <1> gfi_8:
 10075 0000365C 89D7                <1> 	mov	edi, edx ; **
 10076 0000365E 09C9                <1> 	or	ecx, ecx
 10077 00003660 7424                <1> 	jz	short gfi_11 ; all chars from the 00h
 10078 00003662 88F8                <1> 	mov	al, bh ; character index
 10079 00003664 F6E3                <1> 	mul	bl ; char index * char height/size
 10080 00003666 0FB7D0              <1> 	movzx	edx, ax
 10081 00003669 01D6                <1> 	add	esi, edx ; *
 10082 0000366B 66BAFF00            <1> 	mov	dx, 255
 10083 0000366F 28FA                <1> 	sub	dl, bh
 10084 00003671 6642                <1> 	inc	dx	
 10085 00003673 39D1                <1> 	cmp	ecx, edx
 10086 00003675 770F                <1> 	ja	short gfi_11
 10087 00003677 7412                <1> 	je	short gfi_12
 10088 00003679 89D1                <1> 	mov	ecx, edx
 10089 0000367B EB0E                <1> 	jmp	short gfi_12
 10090                              <1> gfi_9:
 10091                              <1> 	;BL = 1 -> vgafont8
 10092 0000367D BE[C4600100]        <1> 	mov	esi, vgafont8 ; *
 10093                              <1> gfi_10:
 10094 00003682 B308                <1> 	mov	bl, 8
 10095 00003684 EBD6                <1> 	jmp	short gfi_8
 10096                              <1> gfi_11:
 10097 00003686 B900010000          <1> 	mov	ecx, 256
 10098                              <1> gfi_12:
 10099                              <1> 	; 08/01/2021
 10100 0000368B 89C8                <1> 	mov	eax, ecx ; character count
 10101 0000368D 30FF                <1> 	xor	bh, bh
 10102 0000368F 66F7E3              <1> 	mul	bx ; char count * char height/size
 10103 00003692 89C1                <1>  	mov	ecx, eax
 10104                              <1> 
 10105                              <1> 	; ESI = source address in system space
 10106                              <1> 	; EDI = user's buffer address
 10107                              <1> 	; ECX = transfer (byte) count
 10108 00003694 E8CBE40000          <1> 	call	transfer_to_user_buffer
 10109 00003699 89C8                <1> 	mov	eax, ecx ; actual transfer count
 10110 0000369B C3                  <1> 	retn
 10111                              <1> 	
 10112                              <1> vga_pal_funcs:
 10113                              <1> 	; 10/08/2016
 10114                              <1> 	; VGA Palette functions
 10115                              <1> 	;
 10116                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 10117                              <1> 	; vgabios-0.7a (2011)
 10118                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 10119                              <1> 	; 'vgabios.c', 'vgarom.asm'
 10120                              <1> 
 10121 0000369C 3C00                <1> 	cmp	al, 0
 10122 0000369E 0F848F000000        <1>         je      set_single_palette_reg
 10123                              <1> vga_palf_1001:
 10124 000036A4 3C01                <1> 	cmp	al, 1
 10125 000036A6 0F84B4000000        <1>         je      set_overscan_border_color
 10126                              <1> vga_palf_1002:
 10127 000036AC 3C02                <1> 	cmp	al, 2
 10128 000036AE 0F84B0000000        <1>         je      set_all_palette_reg
 10129                              <1> vga_palf_1003:
 10130 000036B4 3C03                <1> 	cmp	al, 3
 10131 000036B6 0F84E8000000        <1>         je      toggle_intensity
 10132                              <1> vga_palf_1007:
 10133 000036BC 3C07                <1> 	cmp	al, 7
 10134 000036BE 0F840D010000        <1>         je      get_single_palette_reg
 10135 000036C4 7266                <1> 	jb	short vga_palf_unknown
 10136                              <1> vga_palf_1008:
 10137 000036C6 3C08                <1> 	cmp	al, 8
 10138 000036C8 0F8437010000        <1>         je      read_overscan_border_color
 10139                              <1> vga_palf_1009:
 10140 000036CE 3C09                <1> 	cmp	al, 9
 10141 000036D0 0F8433010000        <1> 	je	get_all_palette_reg
 10142                              <1> vga_palf_1010:
 10143 000036D6 3C10                <1> 	cmp	al, 10h
 10144 000036D8 0F8487010000        <1> 	je 	set_single_dac_reg
 10145 000036DE 724C                <1> 	jb	short vga_palf_unknown
 10146                              <1> vga_palf_1012:
 10147 000036E0 3C12                <1> 	cmp	al, 12h
 10148 000036E2 0F8498010000        <1>         je      set_all_dac_reg
 10149 000036E8 7242                <1> 	jb	short vga_palf_unknown
 10150                              <1> vga_palf_1013:
 10151 000036EA 3C13                <1> 	cmp	al, 13h
 10152 000036EC 0F84CC010000        <1>         je      select_video_dac_color_page
 10153                              <1> vga_palf_1015:
 10154 000036F2 3C15                <1> 	cmp	al, 15h
 10155 000036F4 0F8412020000        <1> 	je	read_single_dac_reg
 10156 000036FA 7230                <1> 	jb	short vga_palf_unknown
 10157                              <1> vga_palf_1017:
 10158 000036FC 3C17                <1> 	cmp	al, 17h
 10159 000036FE 0F8428020000        <1>         je      read_all_dac_reg
 10160 00003704 7226                <1> 	jb	short vga_palf_unknown
 10161                              <1> vga_palf_1018:
 10162 00003706 3C18                <1> 	cmp	al, 18h
 10163 00003708 0F845E020000        <1>         je      set_pel_mask
 10164                              <1> vga_palf_1019:
 10165 0000370E 3C19                <1> 	cmp	al, 19h
 10166 00003710 0F8462020000        <1>         je      read_pel_mask
 10167                              <1> vga_palf_101A:
 10168 00003716 3C1A                <1> 	cmp	al, 1Ah
 10169 00003718 0F8468020000        <1>         je      read_video_dac_state
 10170                              <1> vga_palf_101B:
 10171 0000371E 3C1B                <1> 	cmp	al, 1Bh
 10172                              <1> 	;jne	short vga_palf_unknown
 10173 00003720 770A                <1> 	ja	short vga_palf_unknown
 10174                              <1>  
 10175 00003722 E8C3F5FFFF          <1> 	call	gray_scale_summing
 10176 00003727 E933E4FFFF          <1>         jmp     VIDEO_RETURN 	
 10177                              <1> 
 10178                              <1> vga_palf_unknown:
 10179 0000372C 29C0                <1> 	sub	eax, eax ; 0 = invalid function
 10180 0000372E E931E4FFFF          <1>         jmp     _video_return
 10181                              <1> 
 10182                              <1> set_single_palette_reg:
 10183                              <1> 	; 10/08/2016
 10184                              <1> 	; Set One Palette Register
 10185                              <1> 	; BL = register number to set
 10186                              <1> 	;     (a 4-bit attribute nibble: 00h-0Fh)
 10187                              <1> 	; BH = 6-bit RGB color to display 
 10188                              <1> 	;      for that attribute
 10189                              <1> 
 10190 00003733 80FB14              <1> 	cmp	bl, 14h
 10191                              <1> 	;ja	short no_actl_reg1
 10192 00003736 0F8723E4FFFF        <1> 	ja	VIDEO_RETURN
 10193 0000373C 6650                <1> 	push	ax
 10194 0000373E 6652                <1> 	push	dx
 10195 00003740 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10196 00003744 EC                  <1> 	in	al, dx
 10197 00003745 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10198 00003749 88D8                <1> 	mov	al, bl
 10199 0000374B EE                  <1> 	out	dx, al
 10200 0000374C 88F8                <1> 	mov	al, bh
 10201 0000374E EE                  <1> 	out	dx, al
 10202 0000374F B020                <1> 	mov	al, 20h
 10203 00003751 EE                  <1> 	out	dx, al
 10204                              <1> 	; ifdef VBOX
 10205 00003752 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10206 00003756 EC                  <1> 	in	al, dx
 10207                              <1> 	; endif ; VBOX
 10208 00003757 665A                <1> 	pop	dx
 10209 00003759 6658                <1> 	pop	ax
 10210                              <1> ;no_actl_reg1:
 10211 0000375B E9FFE3FFFF          <1> 	jmp	VIDEO_RETURN
 10212                              <1> 
 10213                              <1> set_overscan_border_color:
 10214                              <1> 	; 10/08/2016
 10215                              <1> 	; Set Overscan/Border Color Register
 10216                              <1> 	; BH = 6-bit RGB color to display 
 10217                              <1> 	;      for that attribute
 10218                              <1> 	
 10219 00003760 B311                <1> 	mov	bl, 11h
 10220 00003762 EBCF                <1>   	jmp	short set_single_palette_reg
 10221                              <1> 
 10222                              <1> set_all_palette_reg:
 10223                              <1> 	; 10/08/2016
 10224                              <1> 	; Set All Palette Registers and Overscan
 10225                              <1> 	; EDX = Address of 17 bytes; 
 10226                              <1> 	; an rgbRGB value for each of 16 palette
 10227                              <1> 	; registers plus one for the border.
 10228                              <1> 
 10229 00003764 89D6                <1> 	mov	esi, edx ; user buffer
 10230 00003766 B911000000          <1> 	mov	ecx, 17
 10231 0000376B 89E7                <1> 	mov	edi, esp
 10232 0000376D 83EC14              <1> 	sub	esp, 20	 	 
 10233 00003770 E839E40000          <1> 	call	transfer_from_user_buffer
 10234                              <1> 	;jc	VIDEO_RETURN
 10235                              <1> 
 10236 00003775 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10237 00003779 EC                  <1> 	in	al, dx
 10238 0000377A B100                <1> 	mov	cl, 0
 10239 0000377C 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10240                              <1> set_palette_loop:
 10241 00003780 88C8                <1> 	mov	al, cl
 10242 00003782 EE                  <1> 	out	dx, al
 10243 00003783 8A07                <1> 	mov	al, [edi]
 10244 00003785 EE                  <1> 	out	dx, al
 10245 00003786 47                  <1> 	inc	edi
 10246 00003787 FEC1                <1> 	inc	cl
 10247 00003789 80F910              <1> 	cmp	cl, 10h
 10248 0000378C 75F2                <1> 	jne	short set_palette_loop
 10249 0000378E B011                <1> 	mov	al, 11h
 10250 00003790 EE                  <1> 	out	dx, al
 10251 00003791 8A07                <1> 	mov	al, [edi]
 10252 00003793 EE                  <1> 	out	dx, al
 10253 00003794 B020                <1> 	mov	al, 20h
 10254 00003796 EE                  <1> 	out	dx, al
 10255                              <1> 	; ifdef VBOX
 10256 00003797 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10257 0000379B EC                  <1> 	in	al, dx
 10258                              <1> 	; endif ; VBOX
 10259 0000379C 83C414              <1> 	add	esp, 20
 10260 0000379F E9BBE3FFFF          <1> 	jmp	VIDEO_RETURN
 10261                              <1> 
 10262                              <1> toggle_intensity:
 10263                              <1> 	; 10/08/2016
 10264                              <1> 	; Select Foreground Blink or Bold Background
 10265                              <1> 	; BL = 00h = enable bold backgrounds
 10266                              <1> 	;	    (16 background colors)
 10267                              <1>         ;      01h = enable blinking foreground
 10268                              <1> 	;	    (8 background colors)
 10269                              <1> 
 10270 000037A4 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10271 000037A8 EC                  <1> 	in	al, dx
 10272 000037A9 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10273 000037AD B010                <1> 	mov	al, 10h
 10274 000037AF EE                  <1> 	out	dx, al
 10275 000037B0 66BAC103            <1> 	mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
 10276 000037B4 EC                  <1> 	in	al, dx
 10277 000037B5 24F7                <1> 	and	al, 0F7h
 10278 000037B7 80E301              <1> 	and	bl, 01h
 10279 000037BA C0E303              <1> 	shl	bl, 3
 10280 000037BD 08D8                <1> 	or	al, bl
 10281 000037BF 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10282 000037C3 EE                  <1> 	out	dx, al
 10283 000037C4 B020                <1> 	mov	al, 20h
 10284 000037C6 EE                  <1> 	out	dx, al
 10285                              <1> 	; ifdef VBOX
 10286 000037C7 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10287 000037CB EC                  <1> 	in	al, dx
 10288                              <1> 	; endif ; VBOX
 10289 000037CC E98EE3FFFF          <1> 	jmp	VIDEO_RETURN
 10290                              <1> 
 10291                              <1> get_single_palette_reg:
 10292                              <1> 	; 10/08/2016
 10293                              <1> 	; Read One Palette Register
 10294                              <1>         ; INPUT:
 10295                              <1> 	; BL = Palette register to read (00h-0Fh)
 10296                              <1> 	; OUTPUT:
 10297                              <1> 	; BH = Current rgbRGB value of specified register
 10298                              <1> 	;      for that attribute
 10299                              <1> 
 10300 000037D1 80FB14              <1> 	cmp	bl, 14h
 10301                              <1> 	;ja	short no_actl_reg2
 10302 000037D4 0F8785E3FFFF        <1> 	ja	VIDEO_RETURN
 10303                              <1> 
 10304 000037DA 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10305 000037DE EC                  <1> 	in	al, dx
 10306 000037DF 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10307 000037E3 88D8                <1> 	mov	al, bl
 10308 000037E5 EE                  <1> 	out	dx, al
 10309 000037E6 66BAC103            <1> 	mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
 10310 000037EA EC                  <1> 	in	al, dx
 10311 000037EB 8844240D            <1> 	mov	[esp+13], al ; bh
 10312 000037EF 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10313 000037F3 EC                  <1> 	in	al, dx
 10314 000037F4 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10315 000037F8 B020                <1> 	mov	al, 20h
 10316 000037FA EE                  <1> 	out	dx, al
 10317                              <1> 	; ifdef VBOX
 10318 000037FB 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10319 000037FF EC                  <1> 	in	al, dx
 10320                              <1> 	; endif ; VBOX
 10321 00003800 E95AE3FFFF          <1> 	jmp	VIDEO_RETURN
 10322                              <1> 
 10323                              <1> read_overscan_border_color:
 10324                              <1> 	; 10/08/2016
 10325                              <1> 	; Read Overscan Register
 10326                              <1> 	; OUTPUT:
 10327                              <1> 	; BH = current rgbRGB value 
 10328                              <1> 	;      of the overscan/border register
 10329                              <1> 
 10330 00003805 B311                <1> 	mov	bl, 11h
 10331 00003807 EBC8                <1> 	jmp	short get_single_palette_reg
 10332                              <1> 
 10333                              <1> get_all_palette_reg:
 10334                              <1> 	; 10/08/2016
 10335                              <1> 	; Read All Palette Registers
 10336                              <1> 	; EDX = Address of 17-byte buffer 
 10337                              <1> 	;	to receive data
 10338                              <1> 	
 10339 00003809 89D7                <1> 	mov	edi, edx
 10340 0000380B 89E3                <1> 	mov	ebx, esp
 10341 0000380D 89DE                <1> 	mov	esi, ebx
 10342 0000380F 83EC14              <1> 	sub	esp, 20	 
 10343                              <1> 
 10344 00003812 B100                <1> 	mov	cl, 0
 10345                              <1> get_palette_loop:
 10346 00003814 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10347 00003818 EC                  <1> 	in	al, dx
 10348 00003819 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10349 0000381D 88C8                <1> 	mov	al, cl
 10350 0000381F EE                  <1> 	out	dx, al
 10351 00003820 66BAC103            <1> 	mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
 10352 00003824 EC                  <1> 	in	al, dx
 10353 00003825 8803                <1> 	mov	[ebx], al
 10354 00003827 43                  <1> 	inc	ebx
 10355 00003828 FEC1                <1> 	inc	cl
 10356 0000382A 80F910              <1> 	cmp	cl, 10h
 10357 0000382D 75E5                <1> 	jne	short get_palette_loop
 10358 0000382F 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10359 00003833 EC                  <1> 	in	al, dx
 10360 00003834 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10361 00003838 B011                <1> 	mov	al, 11h
 10362 0000383A EE                  <1> 	out	dx, al
 10363 0000383B 66BAC103            <1> 	mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
 10364 0000383F EC                  <1> 	in	al, dx
 10365 00003840 8803                <1> 	mov	[ebx], al
 10366 00003842 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10367 00003846 EC                  <1> 	in	al, dx
 10368 00003847 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10369 0000384B B020                <1> 	mov	al, 20h
 10370 0000384D EE                  <1> 	out	dx, al
 10371                              <1> 	; ifdef VBOX
 10372 0000384E 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10373 00003852 EC                  <1> 	in	al, dx
 10374                              <1> 	; endif ; VBOX
 10375                              <1> 
 10376 00003853 B911000000          <1> 	mov	ecx, 17 ; transfer (byte) count
 10377                              <1> 	; ESI = source address in system space
 10378                              <1> 	; EDI = user's buffer address
 10379 00003858 E807E30000          <1> 	call	transfer_to_user_buffer
 10380                              <1> 
 10381 0000385D 83C414              <1> 	add	esp, 20
 10382 00003860 E9FAE2FFFF          <1> 	jmp	VIDEO_RETURN
 10383                              <1> 
 10384                              <1> set_single_dac_reg:
 10385                              <1> 	; 10/08/2016
 10386                              <1> 	; Set One DAC Color Register
 10387                              <1> 	; BX = color register to set (0-255)
 10388                              <1>         ; CH = green value (00h-3Fh)
 10389                              <1>         ; CL = blue value  (00h-3Fh)
 10390                              <1>         ; DH = red value   (00h-3Fh)
 10391                              <1> 
 10392 00003865 6652                <1> 	push	dx
 10393 00003867 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
 10394 0000386B 88D8                <1> 	mov	al, bl
 10395 0000386D EE                  <1> 	out	dx, al
 10396                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 10397 0000386E 6642                <1> 	inc	dx
 10398 00003870 6658                <1> 	pop	ax
 10399 00003872 88E0                <1> 	mov	al, ah
 10400 00003874 EE                  <1> 	out	dx, al
 10401 00003875 88E8                <1> 	mov	al, ch
 10402 00003877 EE                  <1> 	out	dx, al
 10403 00003878 88C8                <1> 	mov	al, cl
 10404 0000387A EE                  <1> 	out	dx, al
 10405 0000387B E9DFE2FFFF          <1> 	jmp	VIDEO_RETURN
 10406                              <1> 
 10407                              <1> set_all_dac_reg:
 10408                              <1> 	; 12/08/2016
 10409                              <1> 	; 11/08/2016
 10410                              <1> 	; 10/08/2016
 10411                              <1> 	; Set a Block of DAC Color Register
 10412                              <1> 	; BX = first DAC register to set (0-00FFh)
 10413                              <1> 	; ECX = number of registers to set (0-00FFh)
 10414                              <1> 	; EDX = addr of a table of R,G,B values 
 10415                              <1> 	;	(it will be CX*3 bytes long)
 10416                              <1> 
 10417 00003880 89D6                <1> 	mov	esi, edx ; user buffer
 10418 00003882 89CA                <1> 	mov	edx, ecx
 10419 00003884 66D1E1              <1> 	shl	cx, 1 ; *2
 10420 00003887 01D1                <1> 	add	ecx, edx ; ecx = 3*ecx
 10421 00003889 89E5                <1> 	mov	ebp, esp
 10422 0000388B 89EF                <1> 	mov	edi, ebp
 10423 0000388D 29CF                <1> 	sub	edi, ecx
 10424 0000388F 6683E7FC            <1> 	and	di, 0FFFCh ; (dword alignment)
 10425 00003893 89FC                <1> 	mov	esp, edi
 10426 00003895 E814E30000          <1> 	call	transfer_from_user_buffer
 10427                              <1> 	;jc	VIDEO_RETURN
 10428                              <1> 
 10429 0000389A 89D1                <1> 	mov	ecx, edx
 10430 0000389C 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
 10431 000038A0 88D8                <1> 	mov	al, bl
 10432 000038A2 EE                  <1> 	out	dx, al
 10433 000038A3 66BAC903            <1> 	mov	dx, 3C9h ; VGAREG_DAC_DATA
 10434                              <1> set_dac_loop:
 10435 000038A7 8A07                <1> 	mov	al, [edi]
 10436 000038A9 EE                  <1> 	out	dx, al
 10437 000038AA 47                  <1> 	inc	edi
 10438 000038AB 8A07                <1> 	mov	al, [edi]
 10439 000038AD EE                  <1> 	out	dx, al
 10440 000038AE 47                  <1> 	inc	edi
 10441 000038AF 8A07                <1> 	mov	al, [edi]
 10442 000038B1 EE                  <1> 	out	dx, al
 10443 000038B2 47                  <1> 	inc	edi
 10444 000038B3 6649                <1> 	dec	cx
 10445 000038B5 75F0                <1> 	jnz	short set_dac_loop
 10446 000038B7 89EC                <1> 	mov	esp, ebp
 10447 000038B9 E9A1E2FFFF          <1> 	jmp	VIDEO_RETURN
 10448                              <1> 
 10449                              <1> select_video_dac_color_page:
 10450                              <1> 	; 10/08/2016
 10451                              <1> 	; DAC Color Paging Functions
 10452                              <1> 	; BL = 00H = select color paging mode
 10453                              <1>         ;       BH = paging mode
 10454                              <1>         ;            00h = 4 blocks of 64 registers
 10455                              <1>         ;            01h = 16 blocks of 16 registers
 10456                              <1> 	; BL = 01H = activate color page
 10457                              <1>         ;       BH = DAC color page number
 10458                              <1>         ;            00h-03h (4-page/64-reg mode)
 10459                              <1>         ;            00h-0Fh (16-page/16-reg mode)
 10460                              <1> 
 10461 000038BE 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10462 000038C2 EC                  <1> 	in	al, dx
 10463 000038C3 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10464 000038C7 B010                <1> 	mov	al, 10h
 10465 000038C9 EE                  <1> 	out	dx, al
 10466 000038CA 66BAC103            <1> 	mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
 10467 000038CE EC                  <1> 	in	al, dx
 10468 000038CF 80E301              <1> 	and	bl, 01h
 10469 000038D2 750E                <1> 	jnz	short set_dac_page
 10470 000038D4 247F                <1> 	and	al, 07Fh
 10471 000038D6 C0E707              <1> 	shl	bh, 7
 10472 000038D9 08F8                <1> 	or	al, bh
 10473 000038DB 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10474 000038DF EE                  <1> 	out	dx, al
 10475 000038E0 EB1D                <1> 	jmp	short set_actl_normal
 10476                              <1> set_dac_page:
 10477 000038E2 6650                <1> 	push	ax
 10478 000038E4 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10479 000038E8 EC                  <1> 	in	al, dx
 10480 000038E9 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10481 000038ED B014                <1> 	mov	al, 14h
 10482 000038EF EE                  <1> 	out	dx, al
 10483 000038F0 6658                <1> 	pop	ax
 10484 000038F2 2480                <1> 	and	al, 80h
 10485 000038F4 7503                <1> 	jnz	short set_dac_16_page
 10486 000038F6 C0E702              <1> 	shl	bh, 2
 10487                              <1> set_dac_16_page:
 10488 000038F9 80E70F              <1> 	and	bh, 0Fh
 10489 000038FC 88F8                <1> 	mov	al, bh
 10490 000038FE EE                  <1> 	out	dx, al
 10491                              <1> set_actl_normal:
 10492 000038FF B020                <1> 	mov	al, 20h
 10493 00003901 EE                  <1> 	out	dx, al
 10494                              <1> 	; ifdef VBOX
 10495 00003902 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10496 00003906 EC                  <1> 	in	al, dx
 10497                              <1> 	; endif ; VBOX
 10498 00003907 E953E2FFFF          <1> 	jmp	VIDEO_RETURN	
 10499                              <1> 
 10500                              <1> read_single_dac_reg:
 10501                              <1> 	; 10/08/2016
 10502                              <1> 	; Read One DAC Color Register
 10503                              <1> 	; INPUT:
 10504                              <1> 	; BX = color register to read (0-255)
 10505                              <1> 	; OUTPUT:
 10506                              <1> 	; CH = green value (00h-3Fh)
 10507                              <1>         ; CL = blue value  (00h-3Fh)
 10508                              <1>         ; DH = red value   (00h-3Fh)
 10509                              <1> 
 10510 0000390C 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
 10511 00003910 88D8                <1> 	mov	al, bl
 10512 00003912 EE                  <1> 	out	dx, al
 10513 00003913 66BAC903            <1> 	mov	dx, 3C9h ; VGAREG_DAC_DATA
 10514 00003917 EC                  <1> 	in	al, dx
 10515 00003918 88442415            <1> 	mov	[esp+21], al ; dh
 10516 0000391C EC                  <1> 	in	al, dx
 10517 0000391D 88C5                <1> 	mov	ch, al
 10518 0000391F EC                  <1> 	in	al, dx
 10519 00003920 88C1                <1> 	mov	cl, al
 10520 00003922 66894C2410          <1> 	mov	[esp+16], cx ; cx
 10521 00003927 E933E2FFFF          <1> 	jmp	VIDEO_RETURN	
 10522                              <1> 
 10523                              <1> read_all_dac_reg:
 10524                              <1> 	; 12/08/2016
 10525                              <1> 	; 11/08/2016
 10526                              <1> 	; 10/08/2016
 10527                              <1> 	; Read a Block of DAC Color Registers
 10528                              <1>         ; BX = first DAC register to read (0-00FFh)
 10529                              <1>         ; ECX = number of registers to read (0-00FFh)
 10530                              <1>         ; EDX = addr of a buffer to hold R,G,B values
 10531                              <1> 	;	(CX*3 bytes long)
 10532                              <1> 
 10533 0000392C 89D7                <1> 	mov	edi, edx ; user buffer
 10534 0000392E 89CA                <1> 	mov	edx, ecx
 10535 00003930 66D1E2              <1> 	shl	dx, 1 ; *2
 10536 00003933 01CA                <1> 	add	edx, ecx ; edx = 3*ecx
 10537 00003935 89E5                <1> 	mov	ebp, esp
 10538 00003937 89EE                <1> 	mov	esi, ebp
 10539 00003939 29D6                <1> 	sub	esi, edx
 10540 0000393B 6683E6FC            <1> 	and	si, 0FFFCh ; (dword alignment)
 10541 0000393F 89F4                <1> 	mov	esp, esi
 10542 00003941 52                  <1> 	push	edx ; 3*ecx
 10543 00003942 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
 10544 00003946 88D8                <1> 	mov	al, bl
 10545 00003948 EE                  <1> 	out	dx, al
 10546 00003949 66BAC903            <1> 	mov	dx, 3C9h ; VGAREG_DAC_DATA
 10547 0000394D 89F3                <1> 	mov	ebx, esi
 10548                              <1> read_dac_loop:
 10549 0000394F EC                  <1> 	in	al, dx
 10550 00003950 8803                <1> 	mov	[ebx], al
 10551 00003952 43                  <1> 	inc	ebx
 10552 00003953 EC                  <1> 	in	al, dx
 10553 00003954 8803                <1> 	mov	[ebx], al
 10554 00003956 43                  <1> 	inc	ebx
 10555 00003957 EC                  <1> 	in	al, dx
 10556 00003958 8803                <1> 	mov	[ebx], al
 10557 0000395A 43                  <1> 	inc	ebx
 10558 0000395B 6649                <1> 	dec	cx
 10559 0000395D 75F0                <1> 	jnz	short read_dac_loop
 10560 0000395F 59                  <1> 	pop	ecx ; 3*ecx
 10561                              <1> 	; ECX = transfer (byte) count
 10562                              <1> 	; ESI = source address in system space
 10563                              <1> 	; EDI = user's buffer address
 10564 00003960 E8FFE10000          <1> 	call	transfer_to_user_buffer
 10565 00003965 89EC                <1> 	mov	esp, ebp
 10566 00003967 E9F3E1FFFF          <1> 	jmp	VIDEO_RETURN
 10567                              <1> 
 10568                              <1> set_pel_mask:
 10569                              <1> 	; 10/08/2016
 10570                              <1> 	; BL = mask value
 10571 0000396C 66BAC603            <1> 	mov	dx, 3C6h ; VGAREG_PEL_MASK
 10572 00003970 88D8                <1> 	mov	al, bl
 10573 00003972 EE                  <1> 	out	dx, al
 10574 00003973 E9E7E1FFFF          <1> 	jmp	VIDEO_RETURN
 10575                              <1> 
 10576                              <1> read_pel_mask:
 10577                              <1> 	; 10/08/2016
 10578                              <1> 	; Output: BL = mask value 
 10579 00003978 66BAC603            <1> 	mov	dx, 3C6h ; VGAREG_PEL_MASK
 10580 0000397C EC                  <1> 	in	al, dx
 10581 0000397D 8844240C            <1> 	mov	[esp+12], al ; bl
 10582 00003981 E9D9E1FFFF          <1> 	jmp	VIDEO_RETURN
 10583                              <1> 
 10584                              <1> read_video_dac_state:
 10585                              <1> 	; 10/08/2016
 10586                              <1> 	; Query DAC Color Paging State
 10587                              <1> 	; Output:
 10588                              <1> 	; BH = current active DAC color page
 10589                              <1>         ; BL = current active DAC paging mode
 10590                              <1> 
 10591 00003986 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10592 0000398A EC                  <1> 	in	al, dx
 10593 0000398B 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10594 0000398F B010                <1> 	mov	al, 10h
 10595 00003991 EE                  <1> 	out	dx, al
 10596 00003992 66BAC103            <1> 	mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
 10597 00003996 EC                  <1> 	in	al, dx
 10598 00003997 88C3                <1> 	mov	bl, al
 10599 00003999 C0EB07              <1> 	shr	bl, 7
 10600 0000399C 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10601 000039A0 EC                  <1> 	in	al, dx
 10602 000039A1 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10603 000039A5 B014                <1> 	mov	al, 14h
 10604 000039A7 EE                  <1> 	out	dx, al
 10605 000039A8 66BAC103            <1> 	mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
 10606 000039AC EC                  <1> 	in	al, dx
 10607 000039AD 88C7                <1> 	mov	bh, al
 10608 000039AF 80E70F              <1> 	and	bh, 0Fh
 10609 000039B2 F6C301              <1> 	test	bl, 01
 10610 000039B5 7503                <1> 	jnz	short get_dac_16_page
 10611 000039B7 C0EF02              <1> 	shr	bh, 2
 10612                              <1> get_dac_16_page:
 10613 000039BA 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10614 000039BE EC                  <1> 	in	al, dx
 10615 000039BF 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10616 000039C3 B020                <1> 	mov	al, 20h
 10617 000039C5 EE                  <1> 	out	dx, al
 10618                              <1> 	; ifdef VBOX
 10619 000039C6 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10620 000039CA EC                  <1> 	in	al, dx
 10621                              <1> 	; endif ; VBOX 
 10622 000039CB 66895C240C          <1> 	mov	[esp+12], bx ; bx
 10623 000039D0 E98AE1FFFF          <1> 	jmp	VIDEO_RETURN
 10624                              <1> 
 10625                              <1> ; 23/11/2020 - TRDOS 386 v2.0.3
 10626                              <1> ; VBE 2 BOCHS/QEMU emulator extensions 
 10627                              <1> ;	for TRDOS 386 v2 kernel (video bios)
 10628                              <1> 
 10629                              <1> ; BOCH/QEMU VBE2 VGA BIOS code 
 10630                              <1> ;	by Jeroen Janssen (2002)
 10631                              <1> ;	by Volker Rupper (2003-2020)
 10632                              <1> ; vbe.c (02/01/2020) 
 10633                              <1> 
 10634                              <1> ; vbe.h (02/01/2020)
 10635                              <1> 
 10636                              <1> VBE_DISPI_BANK_ADDRESS	equ	0A0000h
 10637                              <1> VBE_DISPI_BANK_SIZE_KB	equ	64
 10638                              <1> 
 10639                              <1> VBE_DISPI_MAX_XRES	equ	2560
 10640                              <1> VBE_DISPI_MAX_YRES	equ	1600
 10641                              <1> 
 10642                              <1> VBE_DISPI_IOPORT_INDEX	equ	01CEh
 10643                              <1> VBE_DISPI_IOPORT_DATA	equ	01CFh
 10644                              <1> 
 10645                              <1> VBE_DISPI_INDEX_ID	equ	00h
 10646                              <1> VBE_DISPI_INDEX_XRES	equ	01h
 10647                              <1> VBE_DISPI_INDEX_YRES	equ	02h
 10648                              <1> VBE_DISPI_INDEX_BPP	equ	03h
 10649                              <1> VBE_DISPI_INDEX_ENABLE	equ	04h
 10650                              <1> VBE_DISPI_INDEX_BANK	equ	05h
 10651                              <1> VBE_DISPI_INDEX_VIRT_WIDTH equ	06h
 10652                              <1> VBE_DISPI_INDEX_VIRT_HEIGHT equ	07h
 10653                              <1> VBE_DISPI_INDEX_X_OFFSET equ	08h
 10654                              <1> VBE_DISPI_INDEX_Y_OFFSET equ	09h
 10655                              <1> VBE_DISPI_INDEX_VIDEO_MEMORY_64K equ 0Ah
 10656                              <1> VBE_DISPI_INDEX_DDC	equ	0Bh
 10657                              <1> 
 10658                              <1> VBE_DISPI_ID0		equ	0B0C0h
 10659                              <1> VBE_DISPI_ID1		equ	0B0C1h
 10660                              <1> VBE_DISPI_ID2		equ	0B0C2h
 10661                              <1> VBE_DISPI_ID3		equ	0B0C3h
 10662                              <1> VBE_DISPI_ID4		equ	0B0C4h
 10663                              <1> VBE_DISPI_ID5		equ	0B0C5h
 10664                              <1> 
 10665                              <1> VBE_DISPI_DISABLED	equ	00h
 10666                              <1> VBE_DISPI_ENABLED	equ	01h
 10667                              <1> VBE_DISPI_GETCAPS	equ	02h
 10668                              <1> VBE_DISPI_8BIT_DAC	equ	20h
 10669                              <1> VBE_DISPI_LFB_ENABLED	equ	40h
 10670                              <1> VBE_DISPI_NOCLEARMEM	equ	80h
 10671                              <1> 
 10672                              <1> VBE_DISPI_LFB_PHYSICAL_ADDRESS equ 0E0000000h
 10673                              <1> 
 10674                              <1> ; ***
 10675                              <1> 
 10676                              <1> ;// VBE Return Status Info
 10677                              <1> ;// AL
 10678                              <1> VBE_RETURN_STATUS_SUPPORTED	equ	4Fh
 10679                              <1> VBE_RETURN_STATUS_UNSUPPORTED	equ	00h
 10680                              <1> ;// AH
 10681                              <1> VBE_RETURN_STATUS_SUCCESSFULL	equ	00h
 10682                              <1> VBE_RETURN_STATUS_FAILED	equ	01h
 10683                              <1> VBE_RETURN_STATUS_NOT_SUPPORTED	equ	02h
 10684                              <1> VBE_RETURN_STATUS_INVALID	equ	03h
 10685                              <1> 
 10686                              <1> ;// VBE Mode Numbers
 10687                              <1> 
 10688                              <1> VBE_MODE_VESA_DEFINED		equ	0100h
 10689                              <1> VBE_MODE_REFRESH_RATE_USE_CRTC	equ	0800h
 10690                              <1> VBE_MODE_LINEAR_FRAME_BUFFER	equ	4000h
 10691                              <1> VBE_MODE_PRESERVE_DISPLAY_MEMORY equ	8000h
 10692                              <1> 
 10693                              <1> ;// Mode Attributes
 10694                              <1> 
 10695                              <1> VBE_MODE_ATTRIBUTE_SUPPORTED		   equ	0001h
 10696                              <1> VBE_MODE_ATTRIBUTE_EXTENDED_INFO_AVAILABLE equ	0002h
 10697                              <1> VBE_MODE_ATTRIBUTE_COLOR_MODE		   equ	0008h
 10698                              <1> VBE_MODE_ATTRIBUTE_GRAPHICS_MODE	   equ	0010h
 10699                              <1> VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE equ	0080h
 10700                              <1> VBE_MODE_ATTRIBUTE_DOUBLE_SCAN_MODE	   equ	0100h
 10701                              <1> VBE_MODE_ATTRIBUTE_INTERLACE_MODE	   equ	0200h
 10702                              <1> 
 10703                              <1> ;// Window attributes
 10704                              <1> 
 10705                              <1> VBE_WINDOW_ATTRIBUTE_RELOCATABLE equ	01h
 10706                              <1> VBE_WINDOW_ATTRIBUTE_READABLE	 equ	02h
 10707                              <1> VBE_WINDOW_ATTRIBUTE_WRITEABLE	 equ	04h
 10708                              <1> 
 10709                              <1> ;/* Video memory */
 10710                              <1> VGAMEM_GRAPH equ 0A000h
 10711                              <1> VGAMEM_CTEXT equ 0B800h
 10712                              <1> ;VGAMEM_MTEXT equ 0B000h
 10713                              <1> 
 10714                              <1> ;// Memory model
 10715                              <1> 
 10716                              <1> ;VBE_MEMORYMODEL_TEXT_MODE	equ	00h
 10717                              <1> ;VBE_MEMORYMODEL_CGA_GRAPHICS	equ	01h
 10718                              <1> ;VBE_MEMORYMODEL_PLANAR		equ	03h
 10719                              <1> VBE_MEMORYMODEL_PACKED_PIXEL	equ	04h
 10720                              <1> ;VBE_MEMORYMODEL_NON_CHAIN_4_256 equ	05h
 10721                              <1> VBE_MEMORYMODEL_DIRECT_COLOR	equ	06h
 10722                              <1> ;VBE_MEMORYMODEL_YUV		equ	07h
 10723                              <1> 
 10724                              <1> ;// DirectColorModeInfo
 10725                              <1> 
 10726                              <1> ;VBE_DIRECTCOLOR_COLOR_RAMP_PROGRAMMABLE equ 01h
 10727                              <1> VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE equ 02h
 10728                              <1> 
 10729                              <1> VBE_DISPI_TOTAL_VIDEO_MEMORY_MB	equ 16
 10730                              <1> 
 10731                              <1> ; 24/11/2020
 10732                              <1> ; vbe.c
 10733                              <1> 
 10734                              <1> %if 1
 10735                              <1> 
 10736                              <1> _vbe_biosfn_return_mode_info:
 10737                              <1> 	; 15/12/2020
 10738                              <1> 	; 12/12/2020
 10739                              <1> 	; Return VBE Mode Information	
 10740                              <1> 	; (call from 'sysvideo')
 10741                              <1> 	;
 10742                              <1> 	; Input:
 10743                              <1> 	;	cx = video (bios) mode
 10744                              <1> 	; Output:
 10745                              <1> 	;	cf = 0 -> (successful)
 10746                              <1> 	;	   MODE_INFO_LIST addr contains MODEINFO
 10747                              <1> 	;	cf = 1 -> error
 10748                              <1> 	;
 10749                              <1> 	; Modified registers: eax, edx, edi
 10750                              <1> 	;
 10751                              <1> 
 10752                              <1> 	; pushes for subroutine stack pops compatibility
 10753                              <1> 	
 10754                              <1> 	;push	ds  ; *
 10755                              <1> 	;push	es  ; **
 10756                              <1> 
 10757 000039D5 55                  <1> 	push	ebp ; ***
 10758 000039D6 56                  <1> 	push	esi ; **** 
 10759                              <1> 	
 10760 000039D7 31FF                <1> 	xor	edi, edi  ; mov edi, 0
 10761                              <1> 
 10762 000039D9 803D[5C090000]03    <1> 	cmp	byte [vbe3], 3
 10763 000039E0 7221                <1> 	jb	short _vbe_rmi_1
 10764                              <1> 
 10765                              <1> 	;sub	edi, edi  ; 0 = kernel call (sign)
 10766                              <1> 	;	; no transfer to user's buffer
 10767                              <1> 	
 10768                              <1> 	; cx = Video mode (for 4F01h, with LFB flag)
 10769                              <1> 
 10770 000039E2 66B8014F            <1> 	mov	ax, 4F01h
 10771                              <1> 
 10772 000039E6 E820DFFFFF          <1> 	call	_vbe3_pmfn_return_mode_info
 10773                              <1> 
 10774 000039EB 6683F84F            <1> 	cmp	ax, 004Fh
 10775 000039EF 7533                <1> 	jne	short _vbe_rmi_2 ; fail
 10776                              <1> 
 10777                              <1> 	; 15/12/2020
 10778                              <1> 	; cx = vbe video mode
 10779 000039F1 80E501              <1> 	and	ch, 01h ; clear LFB flag
 10780 000039F4 BEFE7B0900          <1> 	mov	esi, VBE3MODEINFOBLOCK - 2
 10781 000039F9 66890E              <1> 	mov	[esi], cx ; MODEINFO.mode
 10782 000039FC E8A6000000          <1> 	call	set_lfbinfo_table
 10783 00003A01 EB22                <1> 	jmp	short _vbe_rmi_3  ; cf = 0 
 10784                              <1> _vbe_rmi_1:
 10785 00003A03 803D[5C090000]02    <1> 	cmp	byte [vbe3], 2
 10786 00003A0A 7219                <1> 	jb	short _vbe_rmi_3 ; cf = 1
 10787 00003A0C A0[5D090000]        <1> 	mov	al, [vbe2bios] ; 0C0h-0C5h for emu (*)
 10788 00003A11 3CC0                <1> 	cmp	al, 0C0h ; BOCHS/QEMU/VIRTUALBOX (*) ? 
 10789 00003A13 7210                <1> 	jb	short _vbe_rmi_3  ; cf = 1
 10790 00003A15 3CC5                <1> 	cmp	al, 0C5h ; (*)
 10791 00003A17 770B                <1> 	ja	short _vbe_rmi_2 ; unknown vbios !? 
 10792                              <1> 	
 10793                              <1> 	;xor	edi, edi  ; 0 = kernel call (sign)
 10794                              <1> 	;	; no transfer to user's buffer
 10795                              <1> 
 10796                              <1> 	;mov	ax, 4F01h
 10797                              <1> 
 10798                              <1> 	; cx = Video mode (for 4F01h, with LFB flag)
 10799                              <1> 
 10800 00003A19 E80A000000          <1> 	call	vbe_biosfn_return_mode_info
 10801 00003A1E 6683F84F            <1> 	cmp	ax, 004Fh ; successful ?
 10802 00003A22 7401                <1> 	je	short _vbe_rmi_3  ; cf = 0
 10803                              <1> _vbe_rmi_2:
 10804 00003A24 F9                  <1> 	stc
 10805                              <1> 	; cf = 1	
 10806                              <1> _vbe_rmi_3:
 10807 00003A25 5E                  <1> 	pop	esi ; ****
 10808 00003A26 5D                  <1> 	pop	ebp ; ***
 10809                              <1> 	
 10810                              <1> 	;pop	es  ; **
 10811                              <1> 	;pop	ss  ; *
 10812                              <1> 	
 10813 00003A27 C3                  <1> 	retn
 10814                              <1> 
 10815                              <1> 
 10816                              <1> ; * (TRDOS 386, INT 31h, VESA Video Bios functions) 
 10817                              <1> ; * ---------------------------------------------------------
 10818                              <1> ; * Function 01h - Return VBE Mode Information
 10819                              <1> ; * ---------------------------------------------------------
 10820                              <1> ; * Input:
 10821                              <1> ; *		AX = 4F01h
 10822                              <1> ; *		CX = Mode number
 10823                              <1> ; *    (ES:DI) EDI = Pointer to ModeInfoBlock structure	
 10824                              <1> ; * Output:
 10825                              <1> ; *		AX = VBE Return Status
 10826                              <1> ; * 
 10827                              <1> ; *----------------------------------------------------------
 10828                              <1> ; *
 10829                              <1> 
 10830                              <1> vbe_biosfn_return_mode_info:
 10831                              <1> 	; 15/12/2020 
 10832                              <1> 	; 14/12/2020
 10833                              <1> 	; 12/12/2020
 10834                              <1> 	; 11/12/2020 (TRDOS 386 v2.0.3)
 10835                              <1> 	;
 10836                              <1> 	; Input:
 10837                              <1> 	;	cx = video (bios) mode
 10838                              <1> 	;      edi = ModeInfoBlock buffer address
 10839                              <1> 	;	     (in user's memory space)
 10840                              <1> 	;      (ax = 4F01h)
 10841                              <1> 	; Output:
 10842                              <1> 	;	ax = 004Fh (successful)
 10843                              <1> 	;	ah > 0 -> error
 10844                              <1> 	;
 10845                              <1> 	; Modified registers: esi
 10846                              <1> 
 10847                              <1> 	;;push	ds  ; *
 10848                              <1> 	;;push	es  ; **
 10849                              <1> 	;;push	ebp ; ***
 10850                              <1> 	;;push	esi ; **** 
 10851                              <1> 
 10852 00003A28 F6C501              <1> 	test	ch, 1
 10853 00003A2B 7505                <1> 	jnz	short vbe_rmi_1
 10854                              <1> 
 10855                              <1> 	; mode number < 100h
 10856                              <1> 	; CGA/VGA mode is not proper this VBE function 
 10857                              <1> 
 10858 00003A2D 29C0                <1> 	sub	eax, eax
 10859                              <1> vbe_rmi_0:	
 10860                              <1> 	;mov	ax, 0100h  ; Function is not supported
 10861 00003A2F B401                <1> 	mov	ah, 1
 10862 00003A31 C3                  <1> 	retn
 10863                              <1> vbe_rmi_1:
 10864 00003A32 52                  <1> 	push	edx ; *****
 10865 00003A33 51                  <1> 	push	ecx ; ******
 10866 00003A34 53                  <1> 	push	ebx ; *******	
 10867 00003A35 57                  <1> 	push	edi ; ********
 10868                              <1> 	
 10869                              <1> 	; 14/12/2020
 10870 00003A36 89CB                <1> 	mov	ebx, ecx
 10871                              <1>  			
 10872                              <1> 	;xor	eax, eax
 10873 00003A38 80E7C1              <1> 	and	bh, 0C1h ; use bit 15, 14, 8 only (for bh)
 10874 00003A3B 883D[1D120300]      <1> 	mov	[vbe_mode_x], bh
 10875                              <1> 	;and	bx, 1FFh
 10876 00003A41 80E701              <1> 	and	bh, 1
 10877                              <1> 	;mov	bh, 1
 10878                              <1> 
 10879                              <1> 	; Alternative 2 (instead of 'Mode_info_find_mode')
 10880 00003A44 E88A060000          <1> 	call	set_mode_info_list ; (alternative 2)
 10881                              <1> 
 10882                              <1> 	; eax = 0	
 10883                              <1> 
 10884                              <1> 	;mov	bx, [esi] ; mode
 10885                              <1> 
 10886                              <1> 	; Alternative 1 (instead of 'set_mode_info_list')
 10887                              <1> 	;call	mode_info_find_mode ; (alternative 1)
 10888                              <1> 
 10889 00003A49 09F6                <1> 	or	esi, esi
 10890                              <1> 	; 14/12/2020
 10891 00003A4B 744D                <1> 	jz	short vbe_rmi_4	; VBE mode number is wrong
 10892                              <1> 				; or it is not supported
 10893                              <1> 
 10894                              <1> 	; 15/12/2020
 10895                              <1> 	;mov	bx, [esi] ; mode
 10896                              <1> 
 10897                              <1> 	; 12/12/2020
 10898                              <1> 	;call	set_lfbinfo_table
 10899                              <1> 
 10900 00003A4D F605[1D120300]40    <1> 	test	byte [vbe_mode_x], 40h ; LFB model ?
 10901 00003A54 7404                <1> 	jz	short vbe_rmi_2
 10902                              <1> 	
 10903 00003A56 C6461C01            <1> 	mov	byte [esi+MODEINFO.NumberOfBanks], 1
 10904                              <1> vbe_rmi_2:
 10905                              <1> 	; (vbe.c, 02/01/2020, vruppert)
 10906                              <1> 	; 11/12/2020 (Erdogan Tan, video.s) 
 10907                              <1> 	; Bochs Graphics Adapter
 10908                              <1> 	; vendor_id: 1111h, device id: 1234h
 10909                              <1> 
 10910 00003A5A E855070000          <1> 	call	pci_get_lfb_addr
 10911                              <1> 	;or	eax, eax
 10912 00003A5F 7404                <1> 	jz	short vbe_rmi_3
 10913                              <1> 	; zf = 0, ax > 0 (high word of LFB address)
 10914                              <1> 	; set/change LFB address in MODEINFO structure
 10915 00003A61 6689462C            <1> 	mov	[esi+MODEINFO.PhysBasePtr+2], ax
 10916                              <1> 	; 12/12/2020
 10917                              <1> 	;mov	[edi+LFBINFO.LFB_addr+2], ax
 10918                              <1> vbe_rmi_3:
 10919                              <1> 	;test	byte [esi+MODEINFO.WinAAttributes], 1 
 10920                              <1> 	;		; VBE_WINDOW_ATTRIBUTE_RELOCATABLE = 1
 10921                              <1>         ;jz	short vbe_rmi_4
 10922                              <1> 	;; 11/12/2020
 10923                              <1> 	;; In fact, this is far call address in (Bochs/BGA) Video Bios
 10924                              <1> 	;; Direct user access to kernel subroutines is not possible 
 10925                              <1> 	;; in TRDOS 386. Also, TRDOS 386 kernel will support only LFB.
 10926                              <1> 	;; Bank select may be a seperate sysvideo function in future
 10927                              <1> 	;; (if it will be required).
 10928                              <1> 	;mov	dword [esi+MODEINFO.WinFuncPtr], dispi_set_bank_farcall
 10929                              <1> ;vbe_rmi_4:
 10930                              <1> 	; 12/12/2020
 10931 00003A65 E83D000000          <1> 	call	set_lfbinfo_table
 10932                              <1> 
 10933                              <1> 	; 11/12/2020
 10934                              <1> 	; copy 68 bytes of MODE_INFO_LIST to user
 10935                              <1> 
 10936 00003A6A 8B3C24              <1> 	mov	edi, [esp]  ; user's buffer address
 10937                              <1> 	; 12/12/2020
 10938 00003A6D 09FF                <1> 	or	edi, edi ; 0 = kernel call 
 10939                              <1> 			 ; (call from '_vbe_biosfn_return_mode_info')
 10940 00003A6F 7432                <1> 	jz	short vbe_rmi_6
 10941                              <1> 
 10942                              <1> 	; 15/12/2020
 10943                              <1> 	; prepare 256 bytes MODEINFO buffer at VBE3MODEINFOBLOCK
 10944                              <1> 	; and then, copy buffer conttent to user's buffer
 10945 00003A71 57                  <1> 	push	edi
 10946 00003A72 BE[3C120300]        <1> 	mov	esi, MODE_INFO_LIST + 2	; MODEINFO.ModeAttributes
 10947 00003A77 BF007C0900          <1> 	mov	edi, VBE3MODEINFOBLOCK
 10948 00003A7C B910000000          <1> 	mov	ecx, 66/4  ; 66 bytes
 10949 00003A81 F3A5                <1> 	rep	movsd
 10950 00003A83 31C0                <1> 	xor	eax, eax
 10951 00003A85 B12F                <1> 	mov	cl, (256-68)/4 ; 188 bytes
 10952 00003A87 F3AB                <1> 	rep	stosd
 10953 00003A89 66AB                <1> 	stosw	; 2 bytes
 10954 00003A8B 5F                  <1> 	pop	edi
 10955 00003A8C BE007C0900          <1> 	mov	esi, VBE3MODEINFOBLOCK
 10956                              <1> 	;mov	cx, 256 
 10957 00003A91 FEC5                <1> 	inc	ch ; cx = 256
 10958 00003A93 E8CCE00000          <1> 	call	transfer_to_user_buffer
 10959 00003A98 7309                <1> 	jnc	short vbe_rmi_5
 10960                              <1> vbe_rmi_4:
 10961                              <1> 	;mov	eax, 014Fh ; fail/error
 10962 00003A9A 31C0                <1> 	xor	eax, eax
 10963 00003A9C B401                <1> 	mov	ah, 01h
 10964                              <1> 	;jmp	short vbe_rmi_6
 10965 00003A9E E981000000          <1> 	jmp	vbe_sm_ret1 ; 11/12/2020
 10966                              <1> vbe_rmi_5:
 10967                              <1> 	; 256 bytes of MODEINFO have been transferred to user
 10968                              <1> 	;mov	eax, 4Fh ; succesfull
 10969                              <1> vbe_rmi_6: ; 12/12/2020
 10970 00003AA3 31C0                <1> 	xor	eax, eax
 10971                              <1> ;vbe_rmi_6:
 10972 00003AA5 EB7D                <1> 	jmp	vbe_sm_ret1 ; 11/12/2020
 10973                              <1> 
 10974                              <1> 	;pop	edi ; ********
 10975                              <1> 	;pop	ebx ; *******
 10976                              <1> 	;pop	ecx ; ******
 10977                              <1> 	;pop	edx ; *****	
 10978                              <1> 	
 10979                              <1> 	;;pop	esi ; ****
 10980                              <1> 	;;pop	ebp ; ***
 10981                              <1> 	;;pop	es  ; **
 10982                              <1> 	;;pop	ds  ; * 
 10983                              <1> 
 10984                              <1> 	;retn
 10985                              <1> 
 10986                              <1> set_lfbinfo_table:
 10987                              <1> 	; 19/12/2020
 10988                              <1> 	; 11/12/2020
 10989                              <1> 	; Set/Fill LFBINFO structure/table
 10990                              <1> 	;
 10991                              <1> 	; Input:
 10992                              <1> 	;	esi = Mode info list address 
 10993                              <1> 	; Output:
 10994                              <1> 	;	LFB_Info address is filled with LFBINFO
 10995                              <1> 	;	edi = LFB_Info address
 10996                              <1> 	;
 10997                              <1> 	; Modified registers: eax, edx (=0), edi
 10998                              <1> 
 10999 00003AA7 BF[2A120300]        <1> 	mov	edi, LFB_Info
 11000 00003AAC 8B462A              <1> 	mov	eax, [esi+MODEINFO.PhysBasePtr]
 11001 00003AAF 894702              <1> 	mov	[edi+LFBINFO.LFB_addr], eax ; LFB address
 11002                              <1> 	;mov	ax, [esi+MODEINFO.mode]
 11003 00003AB2 668B06              <1> 	mov	ax, [esi]
 11004 00003AB5 668907              <1> 	mov	[edi+LFBINFO.mode],ax
 11005 00003AB8 8A461B              <1> 	mov	al, [esi+MODEINFO.BitsPerPixel]
 11006 00003ABB 88470E              <1> 	mov	[edi+LFBINFO.bpp], al
 11007 00003ABE 29C0                <1> 	sub	eax, eax
 11008 00003AC0 668B4614            <1> 	mov	ax, [esi+MODEINFO.XResolution]
 11009 00003AC4 6689470A            <1> 	mov	[edi+LFBINFO.X_res], ax
 11010 00003AC8 89C2                <1> 	mov	edx, eax ; 19/12/2020
 11011 00003ACA 668B4616            <1> 	mov	ax, [esi+MODEINFO.YResolution]
 11012 00003ACE 6689470C            <1> 	mov	[edi+LFBINFO.Y_res], ax
 11013                              <1> 	; eax = Y_res ; screen height
 11014                              <1> 	; 19/12/2020	
 11015 00003AD2 F7E2                <1> 	mul	edx ; X_res*Y_res
 11016                              <1> 	; edx = 0
 11017 00003AD4 8A570E              <1> 	mov	dl, [edi+LFBINFO.bpp]
 11018                              <1> 	; Note:
 11019                              <1> 	; Bits per pixel may be 8,16,24,32 for TRDOS 386 v2.
 11020                              <1> 	; (4 bits for pixel is not used for VESA modes here)
 11021 00003AD7 C0EA03              <1> 	shr	dl, 3 ; convert bits to byte
 11022 00003ADA F7E2                <1> 	mul	edx
 11023                              <1> 	; eax = screen/page/buffer size in bytes
 11024 00003ADC 894706              <1> 	mov	[edi+LFBINFO.LFB_size], eax
 11025                              <1> 	; edx = 0
 11026                              <1> 	; clear reserved byte in LFBINFO structure/table
 11027 00003ADF 88570F              <1> 	mov	[edi+LFBINFO.reserved], dl ; not necessary
 11028 00003AE2 C3                  <1> 	retn
 11029                              <1> 
 11030                              <1> ; * (TRDOS 386, INT 31h, VESA Video Bios functions) 
 11031                              <1> ; * ---------------------------------------------------------
 11032                              <1> ; * Function 02h - Set VBE Mode
 11033                              <1> ; * ---------------------------------------------------------
 11034                              <1> ; * Input:
 11035                              <1> ; *		AX = 4F02h
 11036                              <1> ; *		BX = Desired Mode to set
 11037                              <1> ; * Output:
 11038                              <1> ; *		AX = VBE Return Status
 11039                              <1> ; * 
 11040                              <1> ; *----------------------------------------------------------
 11041                              <1> ; *
 11042                              <1> 
 11043                              <1> vbe_biosfn_set_mode:
 11044                              <1> 	; 07/03/2021
 11045                              <1> 	; 12/12/2020
 11046                              <1> 	; 11/12/2020 (LFBINFO table for VESA VBE modes)
 11047                              <1> 	; 27/11/2020
 11048                              <1> 	; 25/11/2020
 11049                              <1> 	; 23/11/2020 (TRDOS 386 v2.0.3)
 11050                              <1> 	; (ref: vbe.c, 02/01/2020, vruppert)
 11051                              <1> 	;
 11052                              <1> 	; Input:
 11053                              <1> 	;	bx = video (bios) mode
 11054                              <1> 	;	ax = 4F02h
 11055                              <1> 	; Output:
 11056                              <1> 	;	ax = 004Fh (successful)
 11057                              <1> 	;	ah > 0 -> error
 11058                              <1> 	;
 11059                              <1> 	; Modified registers: esi
 11060                              <1> 
 11061                              <1> 	; 27/11/2020
 11062                              <1> 
 11063                              <1> 	;;push	ds  ; *
 11064                              <1> 	;;push	es  ; **
 11065                              <1> 	;;push	ebp ; ***
 11066                              <1> 	;;push	esi ; **** 
 11067                              <1> 	
 11068                              <1> 	; 11/12/2020 			
 11069 00003AE3 52                  <1> 	push	edx ; *****
 11070 00003AE4 51                  <1> 	push	ecx ; ******
 11071 00003AE5 53                  <1> 	push	ebx ; *******	
 11072 00003AE6 57                  <1> 	push	edi ; ********
 11073                              <1> 
 11074                              <1> 	;xor	eax, eax
 11075 00003AE7 80E7C1              <1> 	and	bh, 0C1h ; use bit 15, 14, 8 only (for bh)
 11076 00003AEA 883D[1D120300]      <1> 	mov	[vbe_mode_x], bh
 11077 00003AF0 80E701              <1> 	and	bh, 1
 11078 00003AF3 753C                <1> 	jnz	short vbe_sm_3  ; VESA VBE mode
 11079                              <1> 
 11080                              <1>  	;;test	bx, 4000h ; VBE_MODE_LINEAR_FRAME_BUFFER
 11081                              <1> 	;test	bh, 40h
 11082                              <1> 	;jz	short vbe_sm_0
 11083                              <1> 	;; lfb_flag
 11084                              <1> 	;mov	al, 40h	; VBE_DISPI_LFB_ENABLED
 11085                              <1> vbe_sm_0:
 11086                              <1> 	; 27/11/2020
 11087 00003AF5 B080                <1> 	mov	al, 80h
 11088                              <1> 	;test	bh, 80h ; VBE_MODE_PRESERVE_DISPLAY_MEMORY 	
 11089                              <1> 	;jnz	short vbe_sm_1 ; no_clear
 11090                              <1> 	;; clear
 11091                              <1> 	;sub	al, al ; 0
 11092 00003AF7 8405[1D120300]      <1> 	test	[vbe_mode_x], al ; 80h
 11093 00003AFD 7402                <1> 	jz	short vbe_sm_1 ; clear display memory
 11094                              <1> 	; no_clear
 11095 00003AFF 08C3                <1> 	or	bl, al ; VBE_MODE_PRESERVE_DISPLAY_MEMORY
 11096                              <1> vbe_sm_1:
 11097                              <1> 	; check non vesa mode
 11098                              <1> 	;;cmp	bx, 100h ; VBE_MODE_VESA_DEFINED
 11099                              <1> 	;;jna	short vbe_sm_2
 11100                              <1> 	;and	bh, 1
 11101                              <1> 	;jnz	short vbe_sm_3 
 11102                              <1> 
 11103                              <1> 	; BX <= 1FFh
 11104                              <1> 
 11105                              <1> 	; 27/11/2020
 11106                              <1> 	;or	bl, al	; al = 80h if no_clear option is set 
 11107                              <1> 	;		; al = 0 if no_clear option is not set 
 11108                              <1> 
 11109                              <1> 	; 25/11/2020
 11110                              <1> 	; VBE DISPI will be disabled in 'biosfn_set_video_mode'
 11111                              <1>  
 11112                              <1> 	;xor	al, al ; 0 ; VBE_DISPI_DISABLED
 11113                              <1> 	;call	dispi_set_enable
 11114                              <1> 
 11115                              <1> 	; call the vgabios in order to set the video mode
 11116                              <1> 	; this allows for going back to textmode with a VBE call
 11117                              <1> 	; (some applications expect that to work)
 11118                              <1> 
 11119                              <1> 	;and	bx, 0FFh
 11120                              <1> 	
 11121                              <1> 	; 27/11/2020
 11122                              <1> biosfn_set_video_mode:
 11123                              <1> 	; _call: call subroutine
 11124                              <1> 	; 26/11/2020 (TRDOS 386 v2.0.3)
 11125                              <1> 	; (ref: vgabios.c, 02/01/2020, vruppert)
 11126                              <1> 	; Input:
 11127                              <1> 	;	bl = VGA video (bios) mode
 11128                              <1> 	; Output:
 11129                              <1> 	;	cf = 1 -> error
 11130                              <1> 	;	cf = 0 -> ok
 11131                              <1> 	;
 11132                              <1> 	; Modified registers: esi
 11133                              <1> 
 11134                              <1> 	; 'dispi_set_enable(VBE_DISPI_DISABLED);'
 11135                              <1> 	
 11136                              <1> 	;mov	ax, 0 ; VBE_DISPI_DISABLED 
 11137 00003B01 31C0                <1> 	xor	eax, eax ; 0 
 11138 00003B03 E8A3040000          <1> 	call	dispi_set_enable
 11139                              <1> 	
 11140 00003B08 88D8                <1> 	mov	al, bl
 11141                              <1> 	;jmp	_set_mode ; (in 'biosfn_set_video_mode' sub)
 11142 00003B0A E861E0FFFF          <1> 	call	_set_mode ; will return with cf=1 only if
 11143                              <1> 			; desired mode is not implemented
 11144                              <1> 	; _retn: return from subroutine
 11145 00003B0F 721A                <1> 	jc	short vbe_sm_2 ; 25/11/2020
 11146                              <1> 
 11147                              <1> 	; 26/11/2020
 11148 00003B11 31C0                <1> 	xor	eax, eax 
 11149 00003B13 A0[DA6F0000]        <1> 	mov	al, [CRT_MODE]
 11150                              <1> 	; 27/11/2020
 11151 00003B18 8A25[C7960100]      <1> 	mov	ah, [noclearmem] ; 80h or 0
 11152                              <1> 	;and	ah 80h
 11153 00003B1E 66A3[1E120300]      <1> 	mov	[video_mode], ax ; bit 15 = no_clear flag
 11154                              <1> 				 ; bit 14 = 0 (not LFB model)
 11155                              <1> vbe_sm_ret1:
 11156                              <1> 	; 11/12/2020
 11157                              <1> 	; (vbe_rmi_4 and vbe_rmi_6 jump here)
 11158                              <1> 	; 27/11/2020
 11159 00003B24 B04F                <1> 	mov	al, 4Fh ; Function call successful
 11160                              <1> 	; eax = 004Fh
 11161                              <1> vbe_sm_ret2:
 11162                              <1> 	; 11/12/2020
 11163 00003B26 5F                  <1> 	pop	edi ; ********
 11164 00003B27 5B                  <1> 	pop	ebx ; *******
 11165 00003B28 59                  <1> 	pop	ecx ; ******
 11166 00003B29 5A                  <1> 	pop	edx ; *****
 11167                              <1> 
 11168                              <1> 	;;pop	esi ; ****
 11169                              <1> 	;;pop	ebp ; ***
 11170                              <1> 	;;pop	es  ; **
 11171                              <1> 	;;pop	ds  ; * 
 11172                              <1> 
 11173 00003B2A C3                  <1> 	retn
 11174                              <1> 
 11175                              <1> vbe_sm_2:
 11176                              <1> 	;mov	ax, 0100h ; Function is not supported
 11177                              <1> 	; 27/11/2020
 11178 00003B2B 31C0                <1> 	xor	eax, eax
 11179 00003B2D B401                <1> 	mov	ah, 01h
 11180                              <1> 	; eax = 0100h
 11181                              <1> 	;retn
 11182 00003B2F EBF5                <1> 	jmp	short vbe_sm_ret2
 11183                              <1> 
 11184                              <1> vbe_sm_3:
 11185                              <1> 	; 12/12/2020
 11186                              <1> 	; check current mode, if it is 03h
 11187                              <1> 	; save page contents and cursor positions
 11188 00003B31 803D[DA6F0000]03    <1> 	cmp	byte [CRT_MODE], 03h
 11189                              <1> 	;jne	short vbe_sm_0
 11190 00003B38 7505                <1> 	jne	short vbe_sm_4 ; 07/03/2021
 11191 00003B3A E8E6E2FFFF          <1> 	call	save_mode3_multiscreen
 11192                              <1> 	; set current mode to extended (SVGA) mode
 11193                              <1> 	;mov	byte [CRT_MODE], 0FFh ; VESA VBE mode
 11194                              <1> vbe_sm_4:
 11195                              <1> 	; 27/11/2020
 11196                              <1> 	; bx = mode (bit 0 to 8)
 11197                              <1> 
 11198                              <1> 	; 25/11/2020
 11199                              <1> 
 11200                              <1> 	; Alternative 2 (instead of 'Mode_info_find_mode')
 11201                              <1> 	;push	edi
 11202 00003B3F E88F050000          <1> 	call	set_mode_info_list ; (alternative 2)
 11203                              <1> 	;pop	edi
 11204                              <1> 
 11205                              <1> 	;mov	bx, [esi] ; mode
 11206                              <1> 
 11207                              <1> 	; Alternative 1 (instead of 'set_mode_info_list')
 11208                              <1> 	;call	mode_info_find_mode ; (alternative 1)
 11209                              <1> 
 11210 00003B44 09F6                <1> 	or	esi, esi
 11211 00003B46 74E3                <1> 	jz	short vbe_sm_2 ; VBE mode number is wrong
 11212                              <1> 			       ; or it is not supported
 11213                              <1> 
 11214                              <1> 	; 11/12/2020
 11215 00003B48 668B1E              <1> 	mov	bx, [esi] ; mode
 11216                              <1> 
 11217                              <1> 	; 27/11/2020
 11218 00003B4B 0A3D[1D120300]      <1> 	or	bh, [vbe_mode_x]
 11219                              <1> 
 11220                              <1> 	; save VESA VBE mode
 11221 00003B51 66891D[1E120300]    <1> 	mov	[video_mode], bx
 11222                              <1> 		; 27/11/2020
 11223                              <1> 		; bit 0 to 8 = VESA VBE mode
 11224                              <1> 		; bit 9 to 13 = 0 (bit 0 to 13 = mode)
 11225                              <1> 		; bit 14 = Linear/Flat Frame Buffer flag
 11226                              <1> 		; bit 15 = 'memory not cleared
 11227                              <1> 		;	   at last mode set' flag
 11228                              <1> 
 11229                              <1> 	; first disable current mode
 11230                              <1> 	; (when switching between vesa modes)
 11231                              <1> 	; 'dispi_set_enable(VBE_DISPI_DISABLED);'
 11232                              <1> 
 11233                              <1> 	;mov	ax, VBE_DISPI_DISABLED ; 0
 11234 00003B58 29C0                <1> 	sub	eax, eax ; 0
 11235                              <1> 
 11236 00003B5A E84C040000          <1> 	call	dispi_set_enable
 11237                              <1> 
 11238                              <1> 	; 11/12/2020
 11239 00003B5F 8A461B              <1> 	mov	al, [esi+MODEINFO.BitsPerPixel]
 11240                              <1> 	; ah = 0
 11241                              <1> 
 11242                              <1> 	;cmp	byte [esi+MODEINFO.BitsPerPixel], 8
 11243 00003B62 3C08                <1> 	cmp	al, 8
 11244 00003B64 750B                <1> 	jne	short vbe_sm_5
 11245                              <1> 
 11246                              <1> 	; 11/12/2020
 11247                              <1> 	;push	edi
 11248 00003B66 50                  <1> 	push	eax
 11249                              <1> 	; 'load_dac_palette(3);'
 11250 00003B67 56                  <1> 	push	esi
 11251 00003B68 B403                <1> 	mov	ah, 3  ; palette3, 256 colors
 11252 00003B6A E828F1FFFF          <1> 	call	load_dac_palette
 11253 00003B6F 5E                  <1> 	pop	esi
 11254                              <1> 	; 11/12/2020
 11255 00003B70 58                  <1> 	pop	eax
 11256                              <1> 	;pop	edi
 11257                              <1> vbe_sm_5:	
 11258                              <1>   	;'dispi_set_bpp(cur_info->info.BitsPerPixel);'
 11259                              <1> 	; 11/12/2020 (al = bits per pixel, ah = 0)
 11260                              <1> 	;xor	ah, ah
 11261                              <1> 	;mov	al, [esi+MODEINFO.BitsPerPixel]
 11262 00003B71 E849040000          <1> 	call	dispi_set_bpp
 11263                              <1>         ;'dispi_set_xres(cur_info->info.XResolution);'
 11264 00003B76 668B4614            <1> 	mov	ax, [esi+MODEINFO.XResolution]
 11265 00003B7A E846040000          <1> 	call	dispi_set_xres
 11266                              <1>         ;'dispi_set_yres(cur_info->info.YResolution);'
 11267 00003B7F 668B4616            <1> 	mov	ax, [esi+MODEINFO.YResolution]
 11268 00003B83 E843040000          <1> 	call	dispi_set_yres
 11269                              <1> 
 11270                              <1> 	;'dispi_set_bank(0);'
 11271                              <1> 	;xor	ax, ax
 11272 00003B88 31C0                <1> 	xor	eax, eax ; 0
 11273 00003B8A E842040000          <1> 	call	dispi_set_bank
 11274                              <1>         ;'dispi_set_enable(VBE_DISPI_ENABLED|no_clear|lfb_flag);'
 11275                              <1> 	;mov	ax, di
 11276                              <1> 	; ah = 0 ; 27/11/2020
 11277 00003B8F A0[1D120300]        <1> 	mov	al, [vbe_mode_x] ; restore VBE mode bit 14 & 15
 11278 00003B94 0C01                <1> 	or	al, 1 ; VBE_DISPI_ENABLED
 11279 00003B96 E810040000          <1> 	call	dispi_set_enable
 11280                              <1> 
 11281                              <1>         ; 'vga_compat_setup();'
 11282 00003B9B E846040000          <1> 	call	vga_compat_setup
 11283                              <1> 
 11284                              <1> 	; 11/12/2020
 11285 00003BA0 E802FFFFFF          <1> 	call	set_lfbinfo_table
 11286                              <1> 
 11287                              <1> 	; 26/11/2020
 11288 00003BA5 31C0                <1> 	xor	eax, eax
 11289 00003BA7 FEC8                <1> 	dec	al 
 11290 00003BA9 A2[DA6F0000]        <1> 	mov	[CRT_MODE], al ; 0FFh = VESA VBE mode sign
 11291                              <1> 
 11292                              <1> 	; 27/11/2020
 11293 00003BAE E971FFFFFF          <1> 	jmp	vbe_sm_ret1 ; Function call successful
 11294                              <1> 	
 11295                              <1> 	; 27/11/2020
 11296                              <1> 	;mov	al, 4Fh
 11297                              <1> 	;	; eax = 004Fh = Function call successful
 11298                              <1> 	;jmp	short vbe_sm_ret2
 11299                              <1> 
 11300                              <1> ; * (TRDOS 386, INT 31h, VESA Video Bios functions)
 11301                              <1> ; * ---------------------------------------------------------
 11302                              <1> ; * Function 03h - Return Current VBE Mode
 11303                              <1> ; * ---------------------------------------------------------
 11304                              <1> ; * Input:
 11305                              <1> ; *		AX = 4F03h
 11306                              <1> ; * Output:
 11307                              <1> ; *		AX = VBE Return Status
 11308                              <1> ; *		BX = Current VBE Mode
 11309                              <1> ; * 
 11310                              <1> ; *----------------------------------------------------------
 11311                              <1> ; *
 11312                              <1> 
 11313                              <1> vbe_biosfn_return_current_mode:
 11314                              <1> 	; 11/12/2020
 11315                              <1> 	; 27/11/2020 (TRDOS 386 v2.0.3)
 11316                              <1> 	; (ref: vbe.c, 02/01/2020, vruppert)
 11317                              <1> 	;
 11318                              <1> 	; Input:
 11319                              <1> 	;	none
 11320                              <1> 	; Output:
 11321                              <1> 	;	ax = 004Fh (successful)
 11322                              <1> 	;	ah > 0 -> error
 11323                              <1> 	;	bx = current video (bios) mode (if ah = 0)
 11324                              <1> 	;
 11325                              <1> 	; Modified registers: eax, ebx
 11326                              <1> 
 11327                              <1> 	; 27/11/2020
 11328                              <1> 
 11329                              <1> 	;;push	ds  ; *
 11330                              <1> 	;;push	es  ; **
 11331                              <1> 	;;push	ebp ; ***
 11332                              <1> 	;;push	esi ; **** 
 11333                              <1> 	 			
 11334                              <1> 	;push	edx ; *****
 11335                              <1> 
 11336                              <1> 	; (vbe.c)
 11337                              <1> 	;call	dispi_get_enable
 11338                              <1> 	;	; ax = vbe display interface status
 11339                              <1> 	;and	al, 1 ; VBE_DISPI_ENABLED
 11340                              <1> 	;jnz	short vbe_gm_1  ; VBE graphics mode
 11341                              <1> 
 11342 00003BB3 A0[DA6F0000]        <1> 	mov	al, [CRT_MODE] ; current cga/vga mode
 11343 00003BB8 3CFF                <1> 	cmp	al, 0FFh ; VBE extension signature
 11344 00003BBA 720E                <1> 	jb	short vbe_gm_1 ; get CGA/VGA mode
 11345                              <1> 
 11346                              <1> 	; get VBE mode
 11347                              <1> vbe_gm_0:
 11348 00003BBC 66A1[1E120300]      <1> 	mov	ax, [video_mode]
 11349                              <1> 		; BX bits:
 11350                              <1> 		; bit 0 to 8 = VESA VBE video mode
 11351                              <1> 		; bit 9 to 13 = 0 
 11352                              <1> 		; bit 14 = last mode set LFB option
 11353                              <1> 		;	   1 - linear/flat frame buffer
 11354                              <1> 		;	   0 - windowed frame buffer
 11355                              <1> 		; bit 15 = last mode set no_clear option
 11356                              <1> 		;	   0 - video memory cleared
 11357                              <1> 		;	   1 - video memory not cleared
 11358                              <1> 	
 11359                              <1> vbe_gm_return:
 11360                              <1> 	;pop	edx ; ******
 11361 00003BC2 0FB7D8              <1> 	movzx	ebx, ax
 11362                              <1> ;vbe_srs_retn:
 11363 00003BC5 31C0                <1> 	xor	eax, eax ; 0
 11364 00003BC7 B04F                <1> 	mov	al, 4Fh ; ax = 004Fh (successful)
 11365 00003BC9 C3                  <1> 	retn	
 11366                              <1> 
 11367                              <1> vbe_gm_1:
 11368                              <1> 	; legacy (old, standard) CGA/VGA bios video mode
 11369 00003BCA 8A25[C7960100]      <1> 	mov	ah, [noclearmem] ; 80h or 0
 11370                              <1> 		; BX bits: 
 11371                              <1> 		; bit 0 to 7 = video mode
 11372                              <1> 		; bit 8 to 13 = 0 
 11373                              <1> 		; bit 14 = 0 (not LFB mode) CGA/VGA
 11374                              <1> 		; bit 15 = 1 if [noclearmem] = 80h
 11375                              <1> 		;	   0 if [noclearmem] = 0
 11376 00003BD0 EBF0                <1> 	jmp	short vbe_gm_return
 11377                              <1> 
 11378                              <1> ; * (TRDOS 386, INT 31h, VESA Video Bios functions) 
 11379                              <1> ; * ---------------------------------------------------------
 11380                              <1> ; * Function 04h - Save/Restore State
 11381                              <1> ; * ---------------------------------------------------------
 11382                              <1> ; * Input:
 11383                              <1> ; *		AX = 4F04h
 11384                              <1> ; *             DL = 00h Return Save/Restore State buff size
 11385                              <1> ; *                  01h Save State
 11386                              <1> ; *                  02h Restore State
 11387                              <1> ; *             CX = Requested states
 11388                              <1> ; *		     bit 0 - controller hardware state
 11389                              <1> ; *		     bit 1 - BIOS data state
 11390                              <1> ; *		     bit 2 - DAC state
 11391                              <1> ; *		     bit 3 - register state
 11392                              <1> ; *    (ES:BX) EBX = Pointer to buffer (if DL <> 00h)
 11393                              <1> ; * Output:
 11394                              <1> ; *		AX = VBE Return Status
 11395                              <1> ; *		BX = Number of 64-byte blocks 
 11396                              <1> ; *		     to hold the state buffer (if DL=00h)
 11397                              <1> ; * 
 11398                              <1> ; *----------------------------------------------------------
 11399                              <1> ; *
 11400                              <1> 
 11401                              <1> vbe_biosfn_save_restore_state:
 11402                              <1> 	; 23/01/2021
 11403                              <1> 	; 16/01/2021
 11404                              <1> 	; 14/01/2021
 11405                              <1> 	; 13/01/2021
 11406                              <1> 	; 12/01/2021
 11407                              <1> 	; 11/01/2021 (TRDOS 386 v2.0.3)
 11408                              <1> 	; (ref: vbe.c, 02/01/2020, vruppert)
 11409                              <1> 	;
 11410                              <1> 	; Input:
 11411                              <1> 	;	dl = sub function
 11412                              <1> 	;	cl = requested state
 11413                              <1> 	;      ebx = pointer to buffer (if dl<>00h) 
 11414                              <1> 	; Output:
 11415                              <1> 	;	ax = 004Fh (successful)
 11416                              <1> 	;	ah > 0 -> error
 11417                              <1> 	;	bx = Number of 64-byte blocks 
 11418                              <1> 	;	     to hold the state buffer (if DL=00h)
 11419                              <1> 
 11420                              <1> 	; Modified registers: eax, ebx, edi
 11421                              <1> 	
 11422                              <1> 	; 14/01/2021
 11423 00003BD2 09DB                <1> 	or	ebx, ebx ; user's buffer address
 11424 00003BD4 750A                <1> 	jnz	short _vbe_biosfn_save_restore_state
 11425                              <1> 
 11426 00003BD6 20D2                <1> 	and	dl, dl
 11427 00003BD8 7406                <1> 	jz	short _vbe_biosfn_save_restore_state
 11428                              <1> 
 11429                              <1> 	; function failed
 11430                              <1> 	;mov	eax, 0100h
 11431                              <1> 	;xor	eax, eax
 11432                              <1> 	;inc	ah  ; eax = 0100h
 11433                              <1> 	; 16/01/2021
 11434 00003BDA B84F010000          <1> 	mov	eax, 014Fh
 11435 00003BDF C3                  <1> 	retn
 11436                              <1> 
 11437                              <1> _vbe_biosfn_save_restore_state:
 11438                              <1> 	; 23/01/2021
 11439                              <1> 	; 14/01/2021
 11440                              <1> 	; ebx = 0 if the caller is kernel ('sysvideo')
 11441                              <1> 
 11442                              <1> 	; 13/01/2021
 11443 00003BE0 57                  <1> 	push	edi
 11444 00003BE1 52                  <1> 	push	edx
 11445 00003BE2 51                  <1> 	push	ecx
 11446                              <1> 
 11447                              <1> 	; 23/01/2021
 11448                              <1> 	; 12/01/2021
 11449 00003BE3 80FA02              <1> 	cmp	dl, 2
 11450 00003BE6 7757                <1> 	ja	short vbe_srs_7 ; 23/01/2021
 11451                              <1> 			; invalid sub function
 11452 00003BE8 83F90F              <1> 	cmp	ecx, 0Fh
 11453 00003BEB 7752                <1> 	ja	short vbe_srs_7 ; invalid !
 11454                              <1> 	
 11455 00003BED 20D2                <1> 	and	dl, dl
 11456 00003BEF 7515                <1> 	jnz	short vbe_srs_4
 11457                              <1> 
 11458                              <1> 	; DL = 0
 11459                              <1> 	; Return Save/Restore State buffer size
 11460                              <1> 
 11461                              <1> 	;mov	ebx, ecx
 11462                              <1> 	;shl	bl, 1
 11463                              <1> 	;mov	bx, [ebx+vbestatebufsize]
 11464 00003BF1 E881000000          <1> 	call	vbe_srs_gbs
 11465                              <1> 
 11466                              <1> ;	; 11/01/2021
 11467                              <1> ;	test	cl, 8
 11468                              <1> ;	jz	short vbe_srs_3
 11469                              <1> ;	; vbe_biosfn_read_video_state_size();
 11470                              <1> ;	; return 9 * 2;
 11471                              <1> ;	mov	bl, 18 ; register state size
 11472                              <1> ;vbe_srs_0:
 11473                              <1> ;	test	cl, 1
 11474                              <1> ;	jz	short vbe_srs_1
 11475                              <1> ;	; size += 0x46;
 11476                              <1> ;	add	bl, 70	; controller state size
 11477                              <1> ;vbe_srs_1:
 11478                              <1> ;	test	cl, 2
 11479                              <1> ;	jz	short vbe_srs_2
 11480                              <1> ;	; size += (5 + 8 + 5) * 2 + 6;
 11481                              <1> ;	;add	bl, 42 ; BIOS data state size ; Bochs/Plex86
 11482                              <1> ;	; 12/01/2021
 11483                              <1> ;	add	bl, 40 ; TRDOS 386 v2 VBIOS data state size
 11484                              <1> ;vbe_srs_2:
 11485                              <1> ;	test	cl, 4
 11486                              <1> ;	jz	short vbe_srs_3
 11487                              <1> ;	; size += 3 + 256 * 3 + 1;
 11488                              <1> ;	add	bx, 772 ; DAC state size
 11489                              <1> 
 11490                              <1> vbe_srs_3:
 11491 00003BF6 6683C33F            <1> 	add	bx, 63
 11492 00003BFA 66C1EB06            <1> 	shr	bx, 6 ; / 64
 11493                              <1> 
 11494                              <1> vbe_srs_retn:
 11495 00003BFE 31C0                <1> 	xor	eax, eax ; 0
 11496                              <1> vbe_srs_0:  ; 16/01/2021
 11497 00003C00 B04F                <1> 	mov	al, 4Fh ; ax = 004Fh (successful)
 11498                              <1> ;vbe_srs_0:
 11499                              <1> 	; 13/01/2021
 11500 00003C02 59                  <1> 	pop	ecx
 11501 00003C03 5A                  <1> 	pop	edx
 11502 00003C04 5F                  <1> 	pop	edi	
 11503                              <1> 
 11504 00003C05 C3                  <1> 	retn
 11505                              <1> 
 11506                              <1> 	; 23/01/2021
 11507                              <1> ;vbe_srs_10:
 11508                              <1> 	;; 14/01/2021
 11509                              <1> 	; return to 'sysvideo'
 11510                              <1> 	;mov	ebx, ecx ; transfer count
 11511                              <1> 	;	; (byte count for saving current video state)
 11512                              <1> 	;jmp	short vbe_srs_retn 
 11513                              <1> 
 11514                              <1> vbe_srs_4:
 11515                              <1> 	; 23/01/2021
 11516 00003C06 80E10F              <1> 	and	cl, 0Fh ; 8, 4, 2, 1
 11517 00003C09 7434                <1> 	jz	short vbe_srs_7 ; cx = 0 -> invalid !
 11518                              <1> 
 11519 00003C0B BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
 11520                              <1> 
 11521 00003C10 80FA01              <1> 	cmp	dl, 1
 11522 00003C13 7730                <1> 	ja	short vbe_srs_8
 11523                              <1> 
 11524                              <1> 	; save video state
 11525                              <1> 
 11526 00003C15 F6C107              <1> 	test	cl, 07h ; 4, 2, 1
 11527 00003C18 740A                <1> 	jz	short vbe_srs_5  ; vbe dispi regs state
 11528                              <1> 
 11529 00003C1A E884000000          <1> 	call	biosfn_save_video_state
 11530                              <1> 	; edi = current position
 11531                              <1> 	;	in VBE3SAVERESTOREBLOCK
 11532                              <1> 	; 	(VGA save_state offset)
 11533                              <1> 	; modified regs: edi, eax, edx, ch
 11534 00003C1F F6C108              <1> 	test	cl, 8
 11535 00003C22 7405                <1> 	jz	short vbe_srs_6
 11536                              <1> vbe_srs_5:
 11537 00003C24 E8AC010000          <1> 	call	vbe_biosfn_save_video_state
 11538                              <1> 	; edi = end position
 11539                              <1> 	;	in VBE3SAVERESTOREBLOCK
 11540                              <1> 	; 	(VGA save_state offset)
 11541                              <1> 	; modified regs: edi, eax, edx, ch
 11542                              <1> vbe_srs_6:
 11543                              <1> 	; 23/01/2021
 11544 00003C29 21DB                <1> 	and	ebx, ebx 
 11545 00003C2B 74D1                <1> 	jz	short vbe_srs_retn ; the caller is kernel
 11546                              <1> 	
 11547 00003C2D BE00760900          <1> 	mov	esi, VBE3SAVERESTOREBLOCK
 11548 00003C32 29F7                <1> 	sub	edi, esi
 11549 00003C34 89F9                <1> 	mov	ecx, edi ; transfer count in bytes
 11550                              <1> 
 11551                              <1> 	;; 14/01/2021
 11552                              <1> 	;and	ebx, ebx 
 11553                              <1> 	;jz	short vbe_srs_10 ; the caller is kernel
 11554                              <1> 
 11555 00003C36 89DF                <1> 	mov	edi, ebx ; user's buffer address
 11556 00003C38 E827DF0000          <1> 	call	transfer_to_user_buffer
 11557 00003C3D 73BF                <1> 	jnc	short vbe_srs_retn
 11558                              <1> vbe_srs_7:
 11559                              <1> 	; // function failed
 11560                              <1> 	;mov	eax, 0100h
 11561 00003C3F 31C0                <1> 	xor	eax, eax
 11562 00003C41 FEC4                <1> 	inc	ah  ; eax = 0100h
 11563                              <1> 	; 16/01/2021
 11564                              <1> 	; ax = 0014Fh
 11565                              <1> 	;retn
 11566                              <1> 	; 13/01/2021
 11567 00003C43 EBBB                <1> 	jmp	short vbe_srs_0
 11568                              <1> vbe_srs_8:
 11569                              <1> 	;cmp	dl, 2
 11570                              <1> 	;jne	short vbe_srs_7
 11571                              <1> 	;		; invalid sub function
 11572                              <1> 
 11573                              <1> 	; 14/01/2021
 11574 00003C45 09DB                <1> 	or	ebx, ebx ; user's buffer address
 11575                              <1> 	;jnz	short vbe_srs_11
 11576                              <1> 
 11577                              <1> 	; the caller is kernel ('sysvideo')
 11578                              <1> 	;jmp	short vbe_srs_12
 11579                              <1> 	; 23/01/2021
 11580 00003C47 7414                <1> 	jz	short vbe_srs_12 ; 'sysvideo' call
 11581                              <1> vbe_srs_11:
 11582 00003C49 89DE                <1> 	mov	esi, ebx ; user's buffer address
 11583                              <1> 	; 23/01/2021
 11584                              <1> 	;push	ebx
 11585                              <1> 	
 11586 00003C4B E827000000          <1> 	call	vbe_srs_gbs
 11587                              <1> 	
 11588                              <1> 	; restore video state
 11589                              <1> 
 11590                              <1> 	;mov	edi, VBE3SAVERESTOREBLOCK
 11591 00003C50 51                  <1> 	push	ecx
 11592 00003C51 89D9                <1> 	mov	ecx, ebx ; transfer count in bytes
 11593 00003C53 E856DF0000          <1> 	call	transfer_from_user_buffer
 11594 00003C58 59                  <1> 	pop	ecx
 11595                              <1> 	; 23/01/2021
 11596                              <1> 	;pop	ebx
 11597 00003C59 89F3                <1> 	mov	ebx, esi
 11598 00003C5B 72E2                <1> 	jc	short vbe_srs_7
 11599                              <1> 
 11600                              <1> vbe_srs_12:
 11601                              <1> 	;mov	esi, VBE3SAVERESTOREBLOCK
 11602 00003C5D 89FE                <1> 	mov	esi, edi
 11603                              <1> 
 11604 00003C5F F6C107              <1> 	test	cl, 07h ; 4, 2, 1
 11605 00003C62 740C                <1> 	jz	short vbe_srs_9	; vbe dispi regs state
 11606                              <1> 
 11607 00003C64 E8A8010000          <1> 	call	biosfn_restore_video_state
 11608 00003C69 72D4                <1> 	jc	short vbe_srs_7 ; invalid buffer content !
 11609                              <1> 	; esi = current position
 11610                              <1> 	;	in VBE3SAVERESTOREBLOCK
 11611                              <1> 	; 	(VGA save_state offset)
 11612                              <1> 	; modified regs: esi, eax, edx, ch
 11613 00003C6B F6C108              <1> 	test	cl, 8
 11614                              <1> 	;jz	short vbe_srs_10
 11615                              <1> 	; 23/01/2020
 11616 00003C6E EB8E                <1> 	jmp	short vbe_srs_retn
 11617                              <1> vbe_srs_9:
 11618 00003C70 E8F8020000          <1> 	call	vbe_biosfn_restore_video_state
 11619                              <1> 
 11620                              <1> 	; modified regs: esi, eax, edx, ch
 11621                              <1> 
 11622 00003C75 EB87                <1> 	jmp	short vbe_srs_retn
 11623                              <1> 
 11624                              <1> ;vbe_srs_10:
 11625                              <1> ;	; successful
 11626                              <1> ;	xor	eax, eax ; 0
 11627                              <1> ;	mov	al, 4Fh ; ax = 004Fh (successful)
 11628                              <1> ;	retn
 11629                              <1> 
 11630                              <1> vbe_srs_gbs:
 11631                              <1> 	; return buffer size according to flags
 11632 00003C77 89CB                <1> 	mov	ebx, ecx ; options/flags
 11633 00003C79 D0E3                <1> 	shl	bl, 1
 11634 00003C7B 668B9B[833C0000]    <1> 	mov	bx, [ebx+vbestatebufsize]
 11635 00003C82 C3                  <1> 	retn
 11636                              <1> 
 11637                              <1> vbestatebufsize:
 11638                              <1> 	; ----------------------------------------
 11639                              <1> 	; CL =	0  1   2    3    4    5    6    7
 11640                              <1> 	; ----------------------------------------
 11641 00003C83 0000460028006E0004- <1> 	dw	0, 70, 40, 110, 772, 842, 812, 882
 11641 00003C8C 034A032C037203      <1>
 11642                              <1> 	; ----------------------------------------
 11643                              <1> 	; CL =	8   9   10  11   12   13   14   15
 11644                              <1> 	; ----------------------------------------
 11645 00003C93 120058003A00800016- <1> 	dw	18, 88, 58, 128, 790, 860, 830, 900
 11645 00003C9C 035C033E038403      <1>
 11646                              <1> 
 11647                              <1> ; 11/01/2021
 11648                              <1> VGAREG_ACTL_ADDRESS	equ 3C0h
 11649                              <1> VGAREG_ACTL_WRITE_DATA	equ 3C0h
 11650                              <1> VGAREG_ACTL_READ_DATA	equ 3C1h
 11651                              <1> 
 11652                              <1> VGAREG_INPUT_STATUS	equ 3C2h
 11653                              <1> VGAREG_WRITE_MISC_OUTPUT equ 3C2h
 11654                              <1> VGAREG_VIDEO_ENABLE	equ 3C3h
 11655                              <1> VGAREG_SEQU_ADDRESS	equ 3C4h
 11656                              <1> VGAREG_SEQU_DATA	equ 3C5h
 11657                              <1> 
 11658                              <1> VGAREG_PEL_MASK		equ 3C6h
 11659                              <1> VGAREG_DAC_STATE	equ 3C7h
 11660                              <1> VGAREG_DAC_READ_ADDRESS	equ 3C7h
 11661                              <1> VGAREG_DAC_WRITE_ADDRESS equ 3C8h
 11662                              <1> VGAREG_DAC_DATA		equ 3C9h
 11663                              <1> 
 11664                              <1> VGAREG_READ_FEATURE_CTL	equ 3CAh
 11665                              <1> VGAREG_READ_MISC_OUTPUT	equ 3CCh
 11666                              <1> 
 11667                              <1> VGAREG_GRDC_ADDRESS	equ 3CEh
 11668                              <1> VGAREG_GRDC_DATA	equ 3CFh
 11669                              <1> 
 11670                              <1> ;VGAREG_MDA_CRTC_ADDRESS equ 3B4h
 11671                              <1> ;VGAREG_MDA_CRTC_DATA	equ 3B5h
 11672                              <1> VGAREG_VGA_CRTC_ADDRESS	equ 3D4h
 11673                              <1> VGAREG_VGA_CRTC_DATA	equ 3D5h
 11674                              <1> 
 11675                              <1> ;VGAREG_MDA_WRITE_FEATURE_CTL equ 3BAh
 11676                              <1> VGAREG_VGA_WRITE_FEATURE_CTL equ 3DAh
 11677                              <1> VGAREG_ACTL_RESET	equ 3DAh
 11678                              <1> 
 11679                              <1> ;VGAREG_MDA_MODECTL	equ 3B8h
 11680                              <1> VGAREG_CGA_MODECTL	equ 3D8h
 11681                              <1> VGAREG_CGA_PALETTE	equ 3D9h
 11682                              <1> 
 11683                              <1> biosfn_save_video_state:
 11684                              <1> 	; 22/01/2021
 11685                              <1> 	; 12/01/2021
 11686                              <1> 	; 11/01/2021 (TRDOS 386 v2.0.3)
 11687                              <1> 	; (vgabios.c)
 11688                              <1> 
 11689                              <1> 	; modified registers: eax, edx, edi, ch
 11690                              <1> 
 11691                              <1> 	;mov	edi, VBE3SAVERESTOREBLOCK
 11692                              <1> 
 11693                              <1> 	; input: edi = state buffer address
 11694                              <1> 
 11695 00003CA3 F6C101              <1> 	test	cl, 1
 11696 00003CA6 0F8485000000        <1> 	jz	bfn_svs_4
 11697                              <1> 
 11698 00003CAC 66BAC403            <1> 	mov	dx, VGAREG_SEQU_ADDRESS ; 3C7h
 11699 00003CB0 EC                  <1> 	in	al, dx
 11700 00003CB1 AA                  <1> 	stosb
 11701                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 11702 00003CB2 B2D4                <1> 	mov	dl, 0D4h
 11703 00003CB4 EC                  <1> 	in	al, dx
 11704 00003CB5 AA                  <1> 	stosb
 11705                              <1>   	;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh 
 11706 00003CB6 B2CE                <1>         mov	dl, 0CEh
 11707 00003CB8 EC                  <1> 	in	al, dx
 11708 00003CB9 AA                  <1> 	stosb
 11709                              <1> 	;mov	dx, VGAREG_ACTL_RESET ; 3DAh
 11710 00003CBA B2DA                <1> 	mov	dl, 0DAh
 11711 00003CBC EC                  <1> 	in	al, dx
 11712                              <1> 	;mov	dx, VGAREG_ACTL_ADDRESS ; 3C0h
 11713 00003CBD B2C0                <1> 	mov	dl, 0C0h
 11714 00003CBF EC                  <1> 	in	al, dx
 11715 00003CC0 AA                  <1> 	stosb
 11716 00003CC1 88C4                <1> 	mov	ah, al ; ar_index
 11717                              <1> 	;mov	dx, VGAREG_READ_FEATURE_CTL ; 3CAh
 11718 00003CC3 B2CA                <1> 	mov	dl, 0CAh
 11719 00003CC5 EC                  <1> 	in	al, dx
 11720 00003CC6 AA                  <1> 	stosb
 11721                              <1> 	; (5 bytes are writen above)
 11722                              <1> 
 11723                              <1> 	; for(i=1;i<=4;i++){
 11724 00003CC7 B001                <1> 	mov	al, 1
 11725                              <1> 	;;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
 11726                              <1> 	;mov	dl, 0C4h
 11727 00003CC9 B504                <1> 	mov	ch, 4
 11728                              <1> bfn_svs_0:
 11729                              <1> 	; outb(VGAREG_SEQU_ADDRESS, i);
 11730                              <1> 	;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
 11731 00003CCB B2C4                <1> 	mov	dl, 0C4h
 11732 00003CCD EE                  <1> 	out	dx, al
 11733                              <1> 	;mov	dx, VGAREG_SEQU_DATA  ; 3C5h
 11734 00003CCE FEC2                <1> 	inc	dl  ; dx = 3C5h
 11735                              <1> 	; inb(VGAREG_SEQU_DATA)
 11736 00003CD0 50                  <1> 	push	eax
 11737 00003CD1 EC                  <1> 	in	al, dx
 11738 00003CD2 AA                  <1> 	stosb	; (4 bytes in loop)
 11739 00003CD3 58                  <1> 	pop	eax
 11740                              <1> 	;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
 11741                              <1> 	;dec	dl	
 11742 00003CD4 FEC0                <1> 	inc	al  ; i++
 11743 00003CD6 FECD                <1> 	dec	ch
 11744 00003CD8 75F1                <1> 	jnz	short bfn_svs_0
 11745                              <1> 
 11746                              <1> 	; outb(VGAREG_SEQU_ADDRESS, 0);
 11747 00003CDA 28C0                <1> 	sub	al, al ; 0
 11748 00003CDC EE                  <1> 	out	dx, al
 11749                              <1> 	; inb(VGAREG_SEQU_DATA)
 11750                              <1> 	;mov	dx, VGAREG_SEQU_DATA ; 3C5h
 11751 00003CDD FEC2                <1> 	inc	dl  ; dx = 3C5h
 11752 00003CDF EC                  <1> 	in	al, dx
 11753 00003CE0 AA                  <1> 	stosb	; (+1 byte)
 11754                              <1> 
 11755                              <1>         ; for(i=0;i<=0x18;i++) {
 11756 00003CE1 28C0                <1> 	sub	al, al ; 0
 11757                              <1> 	;;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 11758                              <1> 	;mov	dl, 0D4h
 11759 00003CE3 B519                <1> 	mov	ch, 25
 11760                              <1> bfn_svs_1:
 11761                              <1>         ; outb(crtc_addr,i);
 11762                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 11763 00003CE5 B2D4                <1> 	mov	dl, 0D4h
 11764 00003CE7 EE                  <1> 	out	dx, al
 11765                              <1> 	;mov	dx, VGAREG_VGA_CRTC_DATA ; 3D5h
 11766 00003CE8 FEC2                <1> 	inc	dl  ; dx = 3D5h
 11767                              <1> 	; inb(crtc_addr+1)
 11768 00003CEA 50                  <1> 	push	eax
 11769 00003CEB EC                  <1> 	in	al, dx
 11770 00003CEC AA                  <1> 	stosb	; (25 bytes in loop)
 11771 00003CED 58                  <1> 	pop	eax
 11772                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 11773                              <1> 	;dec	dl	
 11774 00003CEE FEC0                <1> 	inc	al  ; i++
 11775 00003CF0 FECD                <1> 	dec	ch
 11776 00003CF2 75F1                <1> 	jnz	short bfn_svs_1
 11777                              <1> 
 11778 00003CF4 80E420              <1> 	and	ah, 20h  ; (ar_index & 0x20)
 11779                              <1>         ; for(i=0;i<=0x13;i++) {
 11780 00003CF7 28C0                <1> 	sub	al, al ; 0
 11781 00003CF9 B514                <1> 	mov	ch, 20
 11782                              <1> bfn_svs_2:
 11783                              <1> 	; inb(VGAREG_ACTL_RESET);
 11784                              <1> 	;mov	dx, VGAREG_ACTL_RESET ; 3DAh
 11785 00003CFB B2DA                <1> 	mov	dl, 0DAh
 11786 00003CFD 50                  <1> 	push	eax
 11787 00003CFE EC                  <1> 	in	al, dx
 11788 00003CFF 8A0424              <1> 	mov	al, [esp]
 11789                              <1>  	; outb(VGAREG_ACTL_ADDRESS, i | (ar_index & 0x20));
 11790 00003D02 08E0                <1> 	or	al, ah
 11791                              <1> 	;mov	dx, VGAREG_ACTL_ADDRESS ; 3C0h
 11792 00003D04 B2C0                <1> 	mov	dl, 0C0h
 11793 00003D06 EE                  <1> 	out	dx, al
 11794                              <1> 	;mov	dx, VGAREG_ACTL_READ_DATA ; 3C1h
 11795                              <1> 	;mov	dl, 0C1h
 11796 00003D07 FEC2                <1> 	inc	dl
 11797 00003D09 EC                  <1> 	in	al, dx
 11798 00003D0A AA                  <1> 	stosb	; (20 bytes in loop)
 11799 00003D0B 58                  <1> 	pop	eax
 11800 00003D0C FEC0                <1> 	inc	al  ; i++
 11801 00003D0E FECD                <1> 	dec	ch
 11802 00003D10 75E9                <1> 	jnz	short bfn_svs_2
 11803                              <1> 
 11804                              <1> 	; inb(VGAREG_ACTL_RESET);
 11805                              <1> 	;mov	dx, VGAREG_ACTL_RESET ; 3DAh
 11806 00003D12 B2DA                <1> 	mov	dl, 0DAh
 11807 00003D14 EC                  <1> 	in	al, dx
 11808                              <1> 
 11809                              <1>         ; for(i=0;i<=8;i++) {
 11810 00003D15 28C0                <1> 	sub	al, al ; 0
 11811                              <1> 	;;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh
 11812                              <1> 	;mov	dl, 0CEh
 11813 00003D17 B509                <1> 	mov	ch, 9
 11814                              <1> bfn_svs_3:
 11815                              <1> 	; outb(VGAREG_GRDC_ADDRESS,i)
 11816                              <1> 	;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh
 11817 00003D19 B2CE                <1> 	mov	dl, 0CEh
 11818 00003D1B EE                  <1> 	out	dx, al
 11819                              <1> 	; inb(VGAREG_ACTL_READ_DATA)
 11820 00003D1C 50                  <1> 	push	eax
 11821                              <1> 	;mov	dx, VGAREG_GRDC_DATA ; 3CFh
 11822                              <1> 	;mov	dl, 0CFh
 11823 00003D1D FEC2                <1> 	inc	dl
 11824 00003D1F EC                  <1> 	in	al, dx
 11825 00003D20 AA                  <1> 	stosb	; (9 bytes in loop)
 11826 00003D21 58                  <1> 	pop	eax
 11827                              <1> 	;dec	dl
 11828 00003D22 FEC0                <1> 	inc	al  ; i++
 11829 00003D24 FECD                <1> 	dec	ch
 11830 00003D26 75F1                <1> 	jnz	short bfn_svs_3
 11831                              <1> 
 11832                              <1> 	; write_word(ES, BX, crtc_addr); BX+= 2;
 11833                              <1> 	; (offset 64)
 11834 00003D28 66B8D403            <1> 	mov	ax, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
 11835 00003D2C 66AB                <1> 	stosw	; (2 bytes (1 word))
 11836                              <1> 
 11837                              <1>         ; /* XXX: read plane latches */
 11838 00003D2E 31C0                <1> 	xor	eax, eax  ; 0
 11839 00003D30 AB                  <1>        	stosd	; (4 bytes)
 11840                              <1> 
 11841                              <1> 	; (total 70 bytes are written above as controller hardware state)
 11842                              <1> 
 11843                              <1> bfn_svs_4:		
 11844                              <1> 	; 12/01/2021 (TRDOS 386 v2.0.3)
 11845 00003D31 F6C102              <1> 	test	cl, 2
 11846 00003D34 7476                <1> 	jz	short bfn_svs_6
 11847                              <1> 
 11848                              <1> 	; VIDEO BIOS DATA
 11849                              <1> 	; !!! this data is valid for TRDOS 386 v2 kernel only !!!
 11850                              <1> 	; (this is not same with BOCHS/PLEX86 video bios, BIOS data)  
 11851                              <1>   
 11852                              <1>     	; if (CX & 2) {
 11853                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE)); BX++;
 11854                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS)); BX += 2;
 11855                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE)); BX += 2;
 11856                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CRTC_ADDRESS)); BX += 2;
 11857                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS)); BX++;
 11858                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT)); BX += 2;
 11859                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL)); BX++;
 11860                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_SWITCHES)); BX++;
 11861                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_MODESET_CTL)); BX++;
 11862                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CURSOR_TYPE)); BX += 2;
 11863                              <1>         ;for(i=0;i<8;i++) {
 11864                              <1>         ;   write_word(ES, BX, read_word(BIOSMEM_SEG, BIOSMEM_CURSOR_POS+2*i));
 11865                              <1>         ;   BX += 2;
 11866                              <1>         ;}
 11867                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CURRENT_START)); BX += 2;
 11868                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE)); BX++;
 11869                              <1>         ;/* current font */
 11870                              <1>         ;write_word(ES, BX, read_word(0, 0x1f * 4)); BX += 2;
 11871                              <1>         ;write_word(ES, BX, read_word(0, 0x1f * 4 + 2)); BX += 2;
 11872                              <1>         ;write_word(ES, BX, read_word(0, 0x43 * 4)); BX += 2;
 11873                              <1>         ;write_word(ES, BX, read_word(0, 0x43 * 4 + 2)); BX += 2;
 11874                              <1> 
 11875                              <1> 	; !!! save TRDOS 386 v2 kernel spesific video bios data !!!
 11876                              <1> 	; (which is/are used by 'SET_MODE' function and/or it's sub functions)
 11877                              <1> 
 11878 00003D36 66B8D403            <1> 	mov	ax, 3D4h ; CRTC_ADDR, always 3D4h (color VGA) for TRDOS 386 v2
 11879 00003D3A 66AB                <1> 	stosw
 11880 00003D3C A0[DA6F0000]        <1> 	mov	al, [CRT_MODE] ; Current video mode (0FFh for VESA VBE modes) 
 11881 00003D41 AA                  <1> 	stosb
 11882 00003D42 A0[DB6F0000]        <1> 	mov	al, [CRT_MODE_SET] ; 29h for mode 03h ; TRDOS 386 feature only !
 11883 00003D47 AA                  <1> 	stosb	
 11884 00003D48 66A1[1E120300]      <1>  	mov	ax, [video_mode] ; Current VESA VBE (SVGA, extended VGA) mode 
 11885 00003D4E 66AB                <1> 	stosw			 ; (valid if [CRT_MODE] = 0FFh)	
 11886 00003D50 66A1[C8960100]      <1> 	mov	ax, [CRT_LEN] ; page size (in bytes)
 11887 00003D56 66AB                <1> 	stosw
 11888 00003D58 66A1[4C8A0100]      <1> 	mov	ax, [CRT_START] ; video page start offset
 11889 00003D5E 66AB                <1>  	stosw
 11890 00003D60 A0[DC6F0000]        <1> 	mov	al, [CRT_COLS] ; nbcols, characters per row	
 11891 00003D65 AA                  <1> 	stosb
 11892 00003D66 A0[E26F0000]        <1> 	mov	al, [VGA_ROWS] ; nbrows, (character) rows per page (not rows-1)
 11893 00003D6B AA                  <1> 	stosb
 11894 00003D6C A0[DE6F0000]        <1> 	mov	al, [CHAR_HEIGHT] ; character font height (8 or 16 or 14)
 11895 00003D71 AA                  <1> 	stosb
 11896 00003D72 A0[DF6F0000]        <1> 	mov	al, [VGA_VIDEO_CTL] ; ROM BIOS DATA AREA Offset 87h
 11897 00003D77 AA                  <1> 	stosb
 11898 00003D78 A0[E06F0000]        <1> 	mov	al, [VGA_SWITCHES] ; feature bit switches
 11899 00003D7D AA                  <1> 	stosb
 11900 00003D7E A0[E16F0000]        <1> 	mov	al, [VGA_MODESET_CTL] ; basic mode set options
 11901 00003D83 AA                  <1> 	stosb
 11902                              <1> 	; followings are only used by TRDOS 386 v2 (IBM PC/AT ROMBIOS) code 
 11903                              <1> 	; (bochs/plex86 does not use and return those)
 11904 00003D84 A0[DD6F0000]        <1> 	mov	al, [CRT_PALETTE] ; current color palette ; TRDOS 386 feature only !
 11905 00003D89 AA                  <1> 	stosb
 11906 00003D8A A0[5E8A0100]        <1> 	mov	al, [ACTIVE_PAGE] ; current video page 
 11907 00003D8F AA                  <1> 	stosb
 11908 00003D90 66A1[F36F0000]      <1> 	mov	ax, [CURSOR_MODE] ; cursor type
 11909 00003D96 66AB                <1> 	stosw
 11910                              <1> 	;mov	eax, [CURSOR_POSN] ; cursor position for video page 0 and 1 
 11911                              <1> 	;stosd
 11912                              <1> 	;mov	eax, [CURSOR_POSN+4] ; cursor position for video page 2 and 3 
 11913                              <1> 	;stosd
 11914                              <1> 	;mov	eax, [CURSOR_POSN+8] ; cursor position for video page 4 and 5 
 11915                              <1> 	;stosd
 11916                              <1> 	;mov	eax, [CURSOR_POSN+12] ; cursor position for video page 6 and 7 
 11917                              <1> 	;stosd
 11918 00003D98 56                  <1> 	push	esi
 11919 00003D99 B504                <1> 	mov	ch, 4
 11920 00003D9B BE[4E8A0100]        <1> 	mov	esi, CURSOR_POSN
 11921                              <1> bfn_svs_5:
 11922 00003DA0 A5                  <1> 	movsd
 11923 00003DA1 FECD                <1> 	dec	ch
 11924 00003DA3 75FB                <1> 	jnz	short bfn_svs_5
 11925 00003DA5 5E                  <1> 	pop	esi
 11926                              <1> 	; (font addr) protected mode address in kernel's/system memory space 
 11927                              <1> 	; (not accessable/meaningful address value by user)
 11928 00003DA6 A1[DA960100]        <1> 	mov	eax, [VGA_INT43H] ; VGA current (default) font address
 11929 00003DAB AB                  <1> 	stosd
 11930                              <1> 	
 11931                              <1> 	; (total 40 bytes are written above as BIOS data state)
 11932                              <1> 
 11933                              <1> bfn_svs_6:
 11934                              <1> 	; 12/01/2021
 11935 00003DAC F6C104              <1> 	test	cl, 4
 11936 00003DAF 7423                <1> 	jz	short bfn_svs_8
 11937                              <1> 
 11938                              <1>   	;/* XXX: check this */
 11939                              <1> 		; /* read/write mode dac */
 11940                              <1>         ;write_byte(ES, BX, inb(VGAREG_DAC_STATE)); BX++;
 11941                              <1> 	;	; /* pix address */
 11942                              <1>         ;write_byte(ES, BX, inb(VGAREG_DAC_WRITE_ADDRESS)); BX++;
 11943                              <1>         ;write_byte(ES, BX, inb(VGAREG_PEL_MASK)); BX++;
 11944                              <1>         ;// Set the whole dac always, from 0
 11945                              <1>         ;outb(VGAREG_DAC_WRITE_ADDRESS,0x00);
 11946                              <1>         ;for(i=0;i<256*3;i++) {
 11947                              <1>         ;   write_byte(ES, BX, inb(VGAREG_DAC_DATA)); BX++;
 11948                              <1>         ;}
 11949                              <1>         ;write_byte(ES, BX, 0); BX++; /* color select register */
 11950                              <1> 
 11951                              <1> 	; /* read/write mode dac */
 11952 00003DB1 66BAC703            <1>     	mov	dx, 3C7h ; VGAREG_DAC_STATE
 11953 00003DB5 EC                  <1> 	in	al, dx
 11954 00003DB6 AA                  <1> 	stosb
 11955                              <1> 	; /* pix address */
 11956                              <1>     	;mov	dx, VGAREG_DAC_WRITE_ADDRESS ; 3C8h
 11957                              <1> 	;mov	dl, 0C8h
 11958 00003DB7 FEC2                <1> 	inc	dl
 11959 00003DB9 EC                  <1> 	in	al, dx
 11960 00003DBA AA                  <1> 	stosb
 11961                              <1>     	;mov	dx, VGAREG_PEL_MASK  ; 3C6h
 11962 00003DBB B2C6                <1> 	mov	dl, 0C6h
 11963 00003DBD EC                  <1> 	in	al, dx
 11964 00003DBE AA                  <1> 	stosb
 11965                              <1> 	;// Set the whole dac always, from 0
 11966 00003DBF 30C0                <1> 	xor	al, al ; 0
 11967                              <1> 	;mov	dx, VGAREG_DAC_WRITE_ADDRESS ; 3C8h
 11968 00003DC1 B2C8                <1> 	mov	dl, 0C8h
 11969 00003DC3 EE                  <1> 	out	dx, al
 11970                              <1> 
 11971 00003DC4 51                  <1> 	push	ecx ; 22/01/2021
 11972                              <1> 	;for(i=0;i<256*3;i++) {
 11973 00003DC5 B900030000          <1> 	mov	ecx, 256*3 ; 768 bytes
 11974                              <1> 	;mov	dx, VGAREG_DAC_DATA ; 3C9h
 11975                              <1> 	;mov	dl, 0C9h
 11976 00003DCA FEC2                <1> 	inc	dl ; dx = 3C9h
 11977                              <1> bfn_svs_7:
 11978 00003DCC EC                  <1> 	in	al, dx
 11979 00003DCD AA                  <1> 	stosb
 11980 00003DCE E2FC                <1> 	loop	bfn_svs_7
 11981 00003DD0 59                  <1> 	pop	ecx ; 22/01/2021
 11982                              <1> 
 11983                              <1> 	; /* color select register */
 11984 00003DD1 28C0                <1> 	sub	al, al ; 0
 11985 00003DD3 AA                  <1> 	stosb
 11986                              <1> 
 11987                              <1> 	; (total 772 bytes are written above as DAC state)
 11988                              <1> bfn_svs_8:
 11989 00003DD4 C3                  <1> 	retn
 11990                              <1> 
 11991                              <1> vbe_biosfn_save_video_state:
 11992                              <1> 	; 23/01/2021
 11993                              <1> 	; 13/01/2021
 11994                              <1> 	; 12/01/2021 (TRDOS 386 v2.0.3)
 11995                              <1> 	; (vbe.c)
 11996                              <1> 
 11997                              <1> 	; modified registers: eax, edx, edi, ch
 11998                              <1> 	
 11999                              <1> 	; input: edi = state buffer address
 12000                              <1> 	; output: 
 12001                              <1> 	;	 VBE DISPI register contents will be saved
 12002                              <1> 	;	 (18 bytes, 9 words)
 12003                              <1> 
 12004                              <1> 	; outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
 12005                              <1> 	; enable = inw(VBE_DISPI_IOPORT_DATA);
 12006                              <1>   	; write_word(ES, BX, enable);
 12007                              <1>  	; BX += 2;
 12008                              <1> 	; if (!(enable & VBE_DISPI_ENABLED)) 
 12009                              <1> 	;	return;
 12010                              <1> 	; for(i = VBE_DISPI_INDEX_XRES;
 12011                              <1> 	;		 i <= VBE_DISPI_INDEX_Y_OFFSET; i++) {
 12012                              <1> 	;    if (i != VBE_DISPI_INDEX_ENABLE) {
 12013                              <1> 	;        outw(VBE_DISPI_IOPORT_INDEX, i);
 12014                              <1> 	;        write_word(ES, BX, inw(VBE_DISPI_IOPORT_DATA));
 12015                              <1>         ;    BX += 2;
 12016                              <1> 	;        }
 12017                              <1> 	; }
 12018                              <1> 
 12019 00003DD5 66BACE01            <1> 	mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 12020 00003DD9 B804000000          <1> 	mov	eax, 04h  ; VBE_DISPI_INDEX_ENABLE
 12021 00003DDE 66EF                <1> 	out	dx, ax
 12022                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA	
 12023 00003DE0 FEC2                <1> 	inc	dl
 12024 00003DE2 66ED                <1> 	in	ax, dx ; enable (status)
 12025 00003DE4 66AB                <1> 	stosw 
 12026 00003DE6 6683E001            <1> 	and	ax, 1 ; VBE_DISPI_ENABLED
 12027 00003DEA 7505                <1> 	jnz	short vbe_bfn_svs_0
 12028                              <1> 	; 23/01/2021
 12029                              <1> 	; ax = 0
 12030                              <1> 	; VBE_DISPI_DISABLED
 12031                              <1> 	; 13/01/2021
 12032                              <1> 	; clear remain 8 bytes 
 12033                              <1> 	;xor	eax, eax
 12034 00003DEC AB                  <1> 	stosd	; 2
 12035 00003DED AB                  <1> 	stosd	; 2
 12036 00003DEE AB                  <1> 	stosd	; 2
 12037 00003DEF AB                  <1> 	stosd	; 2
 12038 00003DF0 C3                  <1> 	retn
 12039                              <1> vbe_bfn_svs_0:
 12040                              <1> 	; VBE_DISPI_ENABLED
 12041                              <1> 
 12042                              <1> 	;sub	eax, eax
 12043 00003DF1 28C0                <1> 	sub	al, al ; eax = 0
 12044                              <1> 	
 12045                              <1> 	; from VBE_DISPI_INDEX_XRES
 12046                              <1> 	;   to VBE_DISPI_INDEX_BPP	
 12047                              <1> 
 12048 00003DF3 B503                <1>  	mov	ch, 3
 12049                              <1> 	; al = 0 ; VBE_DISPI_INDEX_XRES - 1
 12050                              <1> 
 12051 00003DF5 E804000000          <1> 	call	vbe_bfn_svs_1
 12052                              <1> 
 12053                              <1> 	; from VBE_DISPI_INDEX_BANK
 12054                              <1> 	;   to VBE_DISPI_INDEX_Y_OFFSET
 12055                              <1> 
 12056 00003DFA FEC0                <1> 	inc	al 
 12057                              <1> 	; al = 4 ; VBE_DISPI_INDEX_BANK - 1
 12058                              <1> 
 12059 00003DFC B505                <1> 	mov	ch, 5
 12060                              <1> vbe_bfn_svs_1:
 12061 00003DFE FEC0                <1> 	inc	al ; from VBE_DISPI_INDEX_XRES
 12062                              <1> 		   ;   to VBE_DISPI_INDEX_BPP	
 12063                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 12064 00003E00 FECA                <1> 	dec	dl ; 1CEh
 12065 00003E02 66EF                <1> 	out	dx, ax
 12066 00003E04 50                  <1> 	push	eax
 12067                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 12068 00003E05 FEC2                <1> 	inc	dl ; 1CFh
 12069 00003E07 66ED                <1> 	in	ax, dx
 12070 00003E09 66AB                <1> 	stosw
 12071 00003E0B 58                  <1> 	pop	eax
 12072 00003E0C FECD                <1> 	dec	ch
 12073 00003E0E 75EE                <1> 	jnz	short vbe_bfn_svs_1		
 12074 00003E10 C3                  <1> 	retn
 12075                              <1> 
 12076                              <1> ; 11/01/2021
 12077                              <1> VGAREG_ACTL_ADDRESS	equ 3C0h
 12078                              <1> VGAREG_ACTL_WRITE_DATA	equ 3C0h
 12079                              <1> VGAREG_ACTL_READ_DATA	equ 3C1h
 12080                              <1> 
 12081                              <1> VGAREG_INPUT_STATUS	equ 3C2h
 12082                              <1> VGAREG_WRITE_MISC_OUTPUT equ 3C2h
 12083                              <1> VGAREG_VIDEO_ENABLE	equ 3C3h
 12084                              <1> VGAREG_SEQU_ADDRESS	equ 3C4h
 12085                              <1> VGAREG_SEQU_DATA	equ 3C5h
 12086                              <1> 
 12087                              <1> VGAREG_PEL_MASK		equ 3C6h
 12088                              <1> VGAREG_DAC_STATE	equ 3C7h
 12089                              <1> VGAREG_DAC_READ_ADDRESS	equ 3C7h
 12090                              <1> VGAREG_DAC_WRITE_ADDRESS equ 3C8h
 12091                              <1> VGAREG_DAC_DATA		equ 3C9h
 12092                              <1> 
 12093                              <1> VGAREG_READ_FEATURE_CTL	equ 3CAh
 12094                              <1> VGAREG_READ_MISC_OUTPUT	equ 3CCh
 12095                              <1> 
 12096                              <1> VGAREG_GRDC_ADDRESS	equ 3CEh
 12097                              <1> VGAREG_GRDC_DATA	equ 3CFh
 12098                              <1> 
 12099                              <1> ;VGAREG_MDA_CRTC_ADDRESS equ 3B4h
 12100                              <1> ;VGAREG_MDA_CRTC_DATA	equ 3B5h
 12101                              <1> VGAREG_VGA_CRTC_ADDRESS	equ 3D4h
 12102                              <1> VGAREG_VGA_CRTC_DATA	equ 3D5h
 12103                              <1> 
 12104                              <1> ;VGAREG_MDA_WRITE_FEATURE_CTL equ 3BAh
 12105                              <1> VGAREG_VGA_WRITE_FEATURE_CTL equ 3DAh
 12106                              <1> VGAREG_ACTL_RESET	equ 3DAh
 12107                              <1> 
 12108                              <1> ;VGAREG_MDA_MODECTL	equ 3B8h
 12109                              <1> VGAREG_CGA_MODECTL	equ 3D8h
 12110                              <1> VGAREG_CGA_PALETTE	equ 3D9h
 12111                              <1> 
 12112                              <1> biosfn_restore_video_state:
 12113                              <1> 	; 22/01/2021
 12114                              <1> 	; 13/01/2021
 12115                              <1> 	; 12/01/2021 (TRDOS 386 v2.0.3)
 12116                              <1> 	; (vgabios.c)
 12117                              <1> 
 12118                              <1> 	; modified registers: eax, edx, esi, edi, ch
 12119                              <1> 
 12120                              <1> 	;mov	esi, VBE3SAVERESTOREBLOCK
 12121                              <1> 
 12122                              <1> 	; input: esi = state buffer address
 12123                              <1> 
 12124 00003E11 F6C101              <1> 	test	cl, 1
 12125 00003E14 0F84A9000000        <1> 	jz	bfn_rvs_6
 12126                              <1> 
 12127 00003E1A 66817E40D403        <1> 	cmp	word [esi+64], 3D4h ; must be 3D4h
 12128 00003E20 7402                <1> 	je	short bfn_rvs_0  
 12129                              <1> 			; it is seen as valid buffer
 12130 00003E22 F9                  <1> 	stc
 12131 00003E23 C3                  <1> 	retn
 12132                              <1> 
 12133                              <1> bfn_rvs_0:
 12134 00003E24 89F7                <1> 	mov	edi, esi ; addr1
 12135 00003E26 83C605              <1> 	add	esi, 5 ; skip 1st 5 bytes for now
 12136                              <1> 
 12137                              <1> 	; // Reset Attribute Ctl flip-flop
 12138                              <1>         ; inb(VGAREG_ACTL_RESET);
 12139 00003E29 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 12140 00003E2D EC                  <1> 	in	al, dx
 12141                              <1> 
 12142                              <1> 	; for(i=1;i<=4;i++){
 12143 00003E2E B001                <1> 	mov	al, 1
 12144                              <1> 	;;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
 12145                              <1> 	;mov	dl, 0C4h
 12146 00003E30 B504                <1> 	mov	ch, 4
 12147                              <1> bfn_rvs_1:
 12148                              <1> 	; outb(VGAREG_SEQU_ADDRESS, i);
 12149                              <1> 	;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
 12150 00003E32 B2C4                <1> 	mov	dl, 0C4h
 12151 00003E34 EE                  <1> 	out	dx, al
 12152                              <1> 	;mov	dx, VGAREG_SEQU_DATA  ; 3C5h
 12153 00003E35 FEC2                <1> 	inc	dl  ; dx = 3C5h
 12154                              <1> 	; outb(VGAREG_SEQU_DATA)
 12155 00003E37 50                  <1> 	push	eax
 12156 00003E38 AC                  <1> 	lodsb	; (4 bytes in loop)
 12157 00003E39 EE                  <1> 	out	dx, al
 12158 00003E3A 58                  <1> 	pop	eax
 12159                              <1> 	;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
 12160                              <1> 	;dec	dl	
 12161 00003E3B FEC0                <1> 	inc	al  ; i++
 12162 00003E3D FECD                <1> 	dec	ch
 12163 00003E3F 75F1                <1> 	jnz	short bfn_rvs_1
 12164                              <1> 
 12165                              <1> 	; outb(VGAREG_SEQU_ADDRESS, 0);
 12166 00003E41 28C0                <1> 	sub	al, al ; 0
 12167 00003E43 EE                  <1> 	out	dx, al
 12168                              <1> 	; outb(VGAREG_SEQU_DATA)
 12169                              <1> 	;mov	dx, VGAREG_SEQU_DATA ; 3C5h
 12170 00003E44 FEC2                <1> 	inc	dl  ; dx = 3C5h
 12171 00003E46 AC                  <1> 	lodsb	; (+1 byte)
 12172 00003E47 EE                  <1> 	out	dx, al
 12173                              <1> 
 12174                              <1> 	; // Disable CRTC write protection
 12175                              <1> 	; outw(crtc_addr,0x0011);
 12176                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 12177 00003E48 B2D4                <1> 	mov	dl, 0D4h
 12178 00003E4A 66B81100            <1> 	mov	ax, 11h
 12179 00003E4E 66EF                <1> 	out	dx, ax
 12180                              <1> 
 12181                              <1> 	; // Set CRTC regs
 12182                              <1>        
 12183                              <1> 	; for(i=0;i<=0x18;i++) {
 12184                              <1>         ;   if (i != 0x11) {
 12185 00003E50 28C0                <1> 	sub	al, al ; 0
 12186                              <1> 	;;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 12187                              <1> 	;mov	dl, 0D4h
 12188 00003E52 B519                <1> 	mov	ch, 25
 12189                              <1> bfn_rvs_2:
 12190                              <1>         ; outb(crtc_addr,i);
 12191                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 12192 00003E54 B2D4                <1> 	mov	dl, 0D4h
 12193 00003E56 EE                  <1> 	out	dx, al
 12194                              <1> 	;mov	dx, VGAREG_VGA_CRTC_DATA ; 3D5h
 12195 00003E57 FEC2                <1> 	inc	dl  ; dx = 3D5h
 12196                              <1> 	; inb(crtc_addr+1)
 12197 00003E59 50                  <1> 	push	eax
 12198 00003E5A AC                  <1> 	lodsb	; (25 bytes in loop)
 12199 00003E5B EE                  <1> 	out	dx, al
 12200 00003E5C 58                  <1> 	pop	eax
 12201                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 12202                              <1> 	;dec	dl
 12203 00003E5D FEC0                <1> 	inc	al  ; i++
 12204 00003E5F 3C11                <1> 	cmp	al, 17 ; 11h
 12205 00003E61 7505                <1> 	jne	short bfn_rvs_3
 12206 00003E63 AC                  <1> 	lodsb
 12207 00003E64 88C4                <1> 	mov	ah, al ; *
 12208 00003E66 B012                <1> 	mov	al, 18 
 12209                              <1> bfn_rvs_3:
 12210 00003E68 FECD                <1> 	dec	ch
 12211 00003E6A 75E8                <1> 	jnz	short bfn_rvs_2
 12212                              <1> 
 12213                              <1> 	; // select crtc base address
 12214                              <1>         ; v = inb(VGAREG_READ_MISC_OUTPUT) & ~0x01;
 12215                              <1> 	;if (crtc_addr = 0x3d4)
 12216                              <1> 	;   v |= 0x01;
 12217                              <1> 	; outb(VGAREG_WRITE_MISC_OUTPUT, v);
 12218                              <1> 
 12219                              <1> 	;;mov	dx, VGAREG_READ_MISC_OUTPUT ; 3CCh
 12220                              <1> 	;mov	dl, 0CCh
 12221                              <1> 	;in	al, dl
 12222                              <1> 	;and	al, 1
 12223                              <1> 	;;mov	dx, VGAREG_WRITE_MISC_OUTPUT ; 3C2h
 12224                              <1> 	;mov	dl, 0C2h
 12225                              <1> 	;or	al, 1
 12226                              <1> 	;out	dx, al
 12227                              <1> 
 12228                              <1> 	; // enable write protection if needed
 12229                              <1> 	;outb(crtc_addr, 0x11);
 12230                              <1>         ;outb(crtc_addr+1, read_byte(ES, BX - 0x18 + 0x11));
 12231                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 12232 00003E6C B2D4                <1> 	mov	dl, 0D4h
 12233 00003E6E B011                <1> 	mov	al, 11h
 12234 00003E70 EE                  <1> 	out	dx, al
 12235 00003E71 88E0                <1> 	mov	al, ah ; *
 12236 00003E73 FEC2                <1> 	inc	dl ; dx = 3D5h
 12237 00003E75 EE                  <1> 	out	dx, al
 12238                              <1> 
 12239                              <1> 	; // Set Attribute Ctl
 12240 00003E76 8A6703              <1> 	mov	ah, [edi+3] ; addr1+3, ah = ar_index
 12241 00003E79 80E420              <1> 	and	ah, 20h  ; (ar_index & 0x20)
 12242                              <1> 
 12243                              <1>         ; inb(VGAREG_ACTL_RESET);
 12244                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
 12245 00003E7C B2DA                <1> 	mov	dl, 0DAh
 12246 00003E7E EC                  <1> 	in	al, dx
 12247                              <1> 
 12248                              <1>         ; for(i=0;i<=0x13;i++) {
 12249 00003E7F 28C0                <1> 	sub	al, al ; 0
 12250 00003E81 B514                <1> 	mov	ch, 20
 12251                              <1> bfn_rvs_4:
 12252                              <1>  	; outb(VGAREG_ACTL_ADDRESS, i | (ar_index & 0x20));
 12253 00003E83 50                  <1> 	push	eax
 12254 00003E84 08E0                <1> 	or	al, ah
 12255                              <1> 	;mov	dx, VGAREG_ACTL_ADDRESS ; 3C0h
 12256 00003E86 B2C0                <1> 	mov	dl, 0C0h
 12257 00003E88 EE                  <1> 	out	dx, al
 12258                              <1> 	;mov	dx, VGAREG_ACTL_WRITE_DATA ; 3C0h
 12259                              <1> 	;mov	dl, 0C0h
 12260 00003E89 AC                  <1> 	lodsb	; (20 bytes in loop)
 12261 00003E8A EE                  <1> 	out	dx, al
 12262 00003E8B 58                  <1> 	pop	eax
 12263 00003E8C FEC0                <1> 	inc	al  ; i++
 12264 00003E8E FECD                <1> 	dec	ch
 12265 00003E90 75F1                <1> 	jnz	short bfn_rvs_4
 12266                              <1> 
 12267                              <1> 	; outb(VGAREG_ACTL_ADDRESS, ar_index);
 12268                              <1> 	;mov	dx, VGAREG_ACTL_ADDRESS ; 3C0h
 12269                              <1> 	;mov	dl, 0C0h
 12270 00003E92 88E0                <1> 	mov	al, ah ; ar_index
 12271 00003E94 EE                  <1> 	out	dx, al
 12272                              <1> 
 12273                              <1> 	; inb(VGAREG_ACTL_RESET);
 12274                              <1> 	;mov	dx, VGAREG_ACTL_RESET ; 3DAh
 12275 00003E95 B2DA                <1> 	mov	dl, 0DAh
 12276 00003E97 EC                  <1> 	in	al, dx
 12277                              <1> 
 12278                              <1>         ; for(i=0;i<=8;i++) {
 12279 00003E98 28C0                <1> 	sub	al, al ; 0
 12280                              <1> 	;;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh
 12281                              <1> 	;mov	dl, 0CEh
 12282 00003E9A B509                <1> 	mov	ch, 9
 12283                              <1> bfn_rvs_5:
 12284                              <1> 	; outb(VGAREG_GRDC_ADDRESS,i)
 12285                              <1> 	;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh
 12286 00003E9C B2CE                <1> 	mov	dl, 0CEh
 12287 00003E9E EE                  <1> 	out	dx, al
 12288                              <1> 	; outb(VGAREG_ACTL_READ_DATA)
 12289 00003E9F 50                  <1> 	push	eax
 12290                              <1> 	;mov	dx, VGAREG_GRDC_DATA ; 3CFh
 12291                              <1> 	;mov	dl, 0CFh
 12292 00003EA0 FEC2                <1> 	inc	dl
 12293 00003EA2 AC                  <1> 	lodsb	; (9 bytes in loop)
 12294 00003EA3 EE                  <1> 	out	dx, al
 12295 00003EA4 58                  <1> 	pop	eax
 12296                              <1> 	;dec	dl
 12297 00003EA5 FEC0                <1> 	inc	al  ; i++
 12298 00003EA7 FECD                <1> 	dec	ch
 12299 00003EA9 75F1                <1> 	jnz	short bfn_rvs_5
 12300                              <1> 
 12301                              <1> 	; BX += 2; /* crtc_addr */     ; 3D4h
 12302                              <1>         ; BX += 4; /* plane latches */ ; 0
 12303 00003EAB 83C606              <1> 	add	esi, 6	      
 12304 00003EAE 56                  <1> 	push	esi ; *	
 12305                              <1> 
 12306                              <1> 	;outb(VGAREG_SEQU_ADDRESS, read_byte(ES, addr1)); addr1++;
 12307                              <1>         ;outb(crtc_addr, read_byte(ES, addr1)); addr1++;
 12308                              <1>         ;outb(VGAREG_GRDC_ADDRESS, read_byte(ES, addr1)); addr1++;
 12309                              <1>         ;addr1++;
 12310                              <1>         ;outb(crtc_addr - 0x4 + 0xa, read_byte(ES, addr1)); addr1++;
 12311                              <1> 
 12312 00003EAF 89FE                <1> 	mov	esi, edi ; start of state buffer
 12313                              <1> 
 12314                              <1> 	;mov	dx, VGAREG_SEQU_ADDRESS ; 3C7h
 12315 00003EB1 B2C7                <1> 	mov	dl, 0C7h 
 12316 00003EB3 AC                  <1> 	lodsb
 12317 00003EB4 EE                  <1> 	out	dx, al
 12318                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 12319 00003EB5 B2D4                <1> 	mov	dl, 0D4h
 12320 00003EB7 AC                  <1> 	lodsb
 12321 00003EB8 EE                  <1> 	out	dx, al
 12322                              <1> 	;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh 
 12323 00003EB9 B2CE                <1>         mov	dl, 0CEh
 12324 00003EBB AC                  <1> 	lodsb
 12325 00003EBC EE                  <1> 	out	dx, al
 12326 00003EBD AC                  <1> 	lodsb	; addr1++
 12327                              <1> 	;mov	dx, VGAREG_VGA_WRITE_FEATURE_CTL ; 3DAh
 12328 00003EBE B2DA                <1> 	mov	dl, 0DAh
 12329 00003EC0 AC                  <1> 	lodsb
 12330 00003EC1 EE                  <1> 	out	dx, al
 12331                              <1> 
 12332 00003EC2 5E                  <1> 	pop	esi ; *
 12333                              <1> 
 12334                              <1> 	; (total 70 bytes are read above as controller hardware state)
 12335                              <1> 
 12336                              <1> bfn_rvs_6:		
 12337                              <1> 	; 13/01/2021
 12338 00003EC3 F6C102              <1> 	test	cl, 2
 12339 00003EC6 747D                <1> 	jz	short bfn_rvs_9
 12340                              <1> 
 12341                              <1> 	; VIDEO BIOS DATA
 12342                              <1> 	; !!! this data is valid for TRDOS 386 v2 kernel only !!!
 12343                              <1> 	; (this is not same with BOCHS/PLEX86 video bios, BIOS data)  
 12344                              <1>   
 12345                              <1>     	; if (CX & 2) {
 12346                              <1> 	;write_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE, read_byte(ES, BX)); BX++;
 12347                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_NB_COLS, read_word(ES, BX)); BX += 2;
 12348                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE, read_word(ES, BX)); BX += 2;
 12349                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_CRTC_ADDRESS, read_word(ES, BX)); BX += 2;
 12350                              <1>         ;write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, read_byte(ES, BX)); BX++;
 12351                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT, read_word(ES, BX)); BX += 2;
 12352                              <1>         ;write_byte(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL, read_byte(ES, BX)); BX++;
 12353                              <1>         ;write_byte(BIOSMEM_SEG,BIOSMEM_SWITCHES, read_byte(ES, BX)); BX++;
 12354                              <1>         ;write_byte(BIOSMEM_SEG,BIOSMEM_MODESET_CTL, read_byte(ES, BX)); BX++;
 12355                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_CURSOR_TYPE, read_word(ES, BX)); BX += 2;
 12356                              <1>         ;for(i=0;i<8;i++) {
 12357                              <1>         ;   write_word(BIOSMEM_SEG, BIOSMEM_CURSOR_POS+2*i, read_word(ES, BX));
 12358                              <1>         ;   BX += 2;
 12359                              <1>         ;}
 12360                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_CURRENT_START, read_word(ES, BX)); BX += 2;
 12361                              <1>         ;write_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE, read_byte(ES, BX)); BX++;
 12362                              <1>         ;/* current font */
 12363                              <1>         ;write_word(0, 0x1f * 4, read_word(ES, BX)); BX += 2;
 12364                              <1>         ;write_word(0, 0x1f * 4 + 2, read_word(ES, BX)); BX += 2;
 12365                              <1>         ;write_word(0, 0x43 * 4, read_word(ES, BX)); BX += 2;
 12366                              <1>         ;write_word(0, 0x43 * 4 + 2, read_word(ES, BX)); BX += 2;
 12367                              <1> 
 12368                              <1> 	; !!! save TRDOS 386 v2 kernel spesific video bios data !!!
 12369                              <1> 	; (which is/are used by 'SET_MODE' function and/or it's sub functions)
 12370                              <1> 
 12371 00003EC8 66AD                <1> 	lodsw	 ; CRTC_ADDR, always 3D4h (color VGA) for TRDOS 386 v2
 12372                              <1> 	; skip 3D4h check if it is already checked
 12373 00003ECA F6C101              <1> 	test	cl, 1
 12374 00003ECD 7508                <1> 	jnz	short bfn_rvs_7
 12375 00003ECF 663DD403            <1> 	cmp	ax, 3D4h
 12376 00003ED3 7402                <1> 	je	short bfn_rvs_7
 12377 00003ED5 F9                  <1> 	stc
 12378 00003ED6 C3                  <1> 	retn
 12379                              <1> bfn_rvs_7:
 12380 00003ED7 AC                  <1> 	lodsb
 12381 00003ED8 A2[DA6F0000]        <1> 	mov	[CRT_MODE], al ; Current video mode (0FFh for VESA VBE modes) 
 12382 00003EDD AC                  <1> 	lodsb
 12383 00003EDE A2[DB6F0000]        <1> 	mov	[CRT_MODE_SET], al ; 29h for mode 03h ; TRDOS 386 feature only !
 12384 00003EE3 66AD                <1> 	lodsw	
 12385 00003EE5 66A3[1E120300]      <1>  	mov	[video_mode], ax ; Current VESA VBE (SVGA, extended VGA) mode 
 12386 00003EEB 66AD                <1> 	lodsw		 ; (valid if [CRT_MODE] = 0FFh)	
 12387 00003EED 66A3[C8960100]      <1> 	mov	[CRT_LEN], ax ; page size (in bytes)
 12388 00003EF3 66AD                <1> 	lodsw
 12389 00003EF5 66A3[4C8A0100]      <1> 	mov	[CRT_START], ax ; video page start offset
 12390 00003EFB AC                  <1>  	lodsb
 12391 00003EFC A2[DC6F0000]        <1> 	mov	[CRT_COLS], al ; nbcols, characters per row
 12392 00003F01 AC                  <1> 	lodsb
 12393 00003F02 A2[E26F0000]        <1> 	mov	[VGA_ROWS], al ; nbrows, (character) rows per page (not rows-1)
 12394 00003F07 AC                  <1> 	lodsb
 12395 00003F08 A2[DE6F0000]        <1> 	mov	[CHAR_HEIGHT], al ; character font height (8 or 16 or 14)
 12396 00003F0D AC                  <1> 	lodsb
 12397 00003F0E A2[DF6F0000]        <1> 	mov	[VGA_VIDEO_CTL], al ; ROM BIOS DATA AREA Offset 87h
 12398 00003F13 AC                  <1> 	lodsb
 12399 00003F14 A2[E06F0000]        <1> 	mov	[VGA_SWITCHES], al ; feature bit switches
 12400 00003F19 AC                  <1> 	lodsb
 12401 00003F1A A2[E16F0000]        <1> 	mov	[VGA_MODESET_CTL], al ; basic mode set options
 12402                              <1> 	; followings are only used by TRDOS 386 v2 (IBM PC/AT ROMBIOS) code 
 12403                              <1> 	; (bochs/plex86 does not use and return those)
 12404 00003F1F AC                  <1> 	lodsb
 12405 00003F20 A2[DD6F0000]        <1> 	mov	[CRT_PALETTE], al ; current color palette ; TRDOS 386 feature only !
 12406 00003F25 AC                  <1> 	lodsb
 12407 00003F26 A2[5E8A0100]        <1> 	mov	[ACTIVE_PAGE], al ; current video page 
 12408 00003F2B 66AD                <1> 	lodsw
 12409 00003F2D 66A3[F36F0000]      <1> 	mov	[CURSOR_MODE], ax ; cursor type
 12410                              <1> 	;lodsd
 12411                              <1> 	;mov	[CURSOR_POSN], eax ; cursor position for video page 0 and 1 
 12412                              <1> 	;lodsd
 12413                              <1> 	;mov	[CURSOR_POSN+4], eax ; cursor position for video page 2 and 3 
 12414                              <1> 	;lodsd
 12415                              <1> 	;mov	[CURSOR_POSN+8], eax ; cursor position for video page 4 and 5 
 12416                              <1> 	;lodsd
 12417                              <1> 	;mov	[CURSOR_POSN+12], eax ; cursor position for video page 6 and 7 
 12418 00003F33 B504                <1> 	mov	ch, 4
 12419 00003F35 BF[4E8A0100]        <1> 	mov	edi, CURSOR_POSN
 12420                              <1> bfn_rvs_8:
 12421 00003F3A A5                  <1> 	movsd
 12422 00003F3B FECD                <1> 	dec	ch
 12423 00003F3D 75FB                <1> 	jnz	short bfn_rvs_8
 12424                              <1> 	; (font addr) protected mode address in kernel's/system memory space 
 12425                              <1> 	; (not accessable/meaningful address value by user)
 12426 00003F3F AD                  <1> 	lodsd
 12427 00003F40 A3[DA960100]        <1> 	mov	[VGA_INT43H], eax ; VGA current (default) font address
 12428                              <1> 
 12429                              <1> 	; (total 40 bytes are read&written above as BIOS data state)
 12430                              <1> bfn_rvs_9:
 12431                              <1> 	; 13/01/2021
 12432 00003F45 F6C104              <1> 	test	cl, 4
 12433 00003F48 7422                <1> 	jz	short bfn_rvs_11
 12434                              <1> 
 12435                              <1> 	;BX++;
 12436                              <1>         ;v = read_byte(ES, BX); BX++;
 12437                              <1>         ;outb(VGAREG_PEL_MASK, read_byte(ES, BX)); BX++;
 12438                              <1>         ;// Set the whole dac always, from 0
 12439                              <1>         ;outb(VGAREG_DAC_WRITE_ADDRESS,0x00);
 12440                              <1>         ;for(i=0;i<256*3;i++) {
 12441                              <1>         ;   outb(VGAREG_DAC_DATA, read_byte(ES, BX)); BX++;
 12442                              <1>         ;}
 12443                              <1>         ;BX++;
 12444                              <1>         ;outb(VGAREG_DAC_WRITE_ADDRESS, v);
 12445                              <1> 
 12446                              <1> 	; /* read/write mode dac */
 12447 00003F4A AC                  <1> 	lodsb	; skip ; VGAREG_DAC_STATE
 12448 00003F4B AC                  <1> 	lodsb
 12449 00003F4C 88C4                <1> 	mov	ah, al ; * ; v
 12450 00003F4E AC                  <1> 	lodsb
 12451 00003F4F 66BAC603            <1> 	mov	dx, VGAREG_PEL_MASK  ; 3C6h
 12452 00003F53 EE                  <1> 	out	dx, al
 12453                              <1> 	;// Set the whole dac always, from 0
 12454 00003F54 30C0                <1> 	xor	al, al ; 0
 12455                              <1> 	;mov	dx, VGAREG_DAC_WRITE_ADDRESS ; 3C8h
 12456 00003F56 B2C8                <1> 	mov	dl, 0C8h
 12457 00003F58 EE                  <1> 	out	dx, al
 12458                              <1> 
 12459 00003F59 51                  <1> 	push	ecx ; 22/01/2021
 12460                              <1> 	;for(i=0;i<256*3;i++) {
 12461 00003F5A B900030000          <1> 	mov	ecx, 256*3 ; 768 bytes
 12462                              <1> 	;mov	dx, VGAREG_DAC_DATA ; 3C9h
 12463                              <1> 	;mov	dl, 0C9h
 12464 00003F5F FEC2                <1> 	inc	dl ; dx = 3C9h
 12465                              <1> bfn_rvs_10:
 12466 00003F61 AC                  <1> 	lodsb
 12467 00003F62 EE                  <1> 	out	dx, al
 12468 00003F63 E2FC                <1> 	loop	bfn_rvs_10
 12469 00003F65 59                  <1> 	pop	ecx ; 22/01/2021
 12470                              <1> 
 12471                              <1> 	; /* color select register */
 12472 00003F66 AC                  <1> 	lodsb	 ; skip 
 12473                              <1> 	
 12474 00003F67 88E0                <1> 	mov	al, ah ; * ; v
 12475                              <1> 
 12476                              <1> 	;mov	dx, VGAREG_DAC_WRITE_ADDRESS ; 3C8h
 12477                              <1> 	;mov	dl, 0C8h
 12478 00003F69 FECA                <1> 	dec	dl ; dx  = 3C8h
 12479 00003F6B EE                  <1> 	out	dx, al ; * ; v
 12480                              <1> 	
 12481                              <1> 	; (total 772 bytes are read above as DAC state)
 12482                              <1> bfn_rvs_11:
 12483 00003F6C C3                  <1> 	retn
 12484                              <1> 
 12485                              <1> vbe_biosfn_restore_video_state:
 12486                              <1> 	; 23/01/2021
 12487                              <1> 	; 13/01/2021 (TRDOS 386 v2.0.3)
 12488                              <1> 	; (vbe.c)
 12489                              <1> 
 12490                              <1> 	; modified registers: eax, edx, esi, ch
 12491                              <1> 	
 12492                              <1> 	; input: esi = state buffer address
 12493                              <1> 	; output: 
 12494                              <1> 	;	 VBE DISPI register contents will be restored
 12495                              <1> 	;	 (18 bytes, 9 words)
 12496                              <1> 
 12497                              <1>  	; enable = read_word(ES, BX);
 12498                              <1> 	; BX += 2;
 12499                              <1> 	;
 12500                              <1> 	; if (!(enable & VBE_DISPI_ENABLED)) {
 12501                              <1>         ;   outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
 12502                              <1>         ;   outw(VBE_DISPI_IOPORT_DATA, enable);
 12503                              <1> 	; } else {
 12504                              <1>         ;   outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_XRES);
 12505                              <1>         ;   outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
 12506                              <1>         ;   BX += 2;
 12507                              <1>         ;   outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_YRES);
 12508                              <1>         ;   outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
 12509                              <1>         ;   BX += 2;
 12510                              <1>         ;   outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_BPP);
 12511                              <1>         ;   outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
 12512                              <1>         ;   BX += 2;
 12513                              <1>         ;   outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
 12514                              <1>         ;   outw(VBE_DISPI_IOPORT_DATA, enable);
 12515                              <1> 	;
 12516                              <1>         ;  for(i = VBE_DISPI_INDEX_BANK; i <= VBE_DISPI_INDEX_Y_OFFSET; i++)
 12517                              <1> 	;    {
 12518                              <1>         ;     outw(VBE_DISPI_IOPORT_INDEX, i);
 12519                              <1>         ;     outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
 12520                              <1>         ;     BX += 2;
 12521                              <1>         ;    }
 12522                              <1>         ; }
 12523                              <1> 
 12524 00003F6D 66AD                <1> 	lodsw	; enable (status, enabled=1, disabled=0)
 12525 00003F6F 66BACE01            <1> 	mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 12526                              <1> 	; 23/01/2021
 12527 00003F73 6683E001            <1> 	and	ax, 1 ; VBE_DISPI_ENABLED
 12528 00003F77 750B                <1> 	jnz	short vbe_bfn_rvs_1
 12529                              <1> 	; ax = 0
 12530                              <1> 	; VBE_DISPI_DISABLED
 12531                              <1> vbe_bfn_rvs_0:
 12532                              <1> 	; enable (disable) dispi
 12533                              <1> 	; dx = 01CEh ; VBE_DISPI_IOPORT_INDEX
 12534                              <1> 	; ah = 0
 12535 00003F79 50                  <1> 	push	eax
 12536 00003F7A B004                <1> 	mov	al, 04h	; VBE_DISPI_INDEX_ENABLE
 12537 00003F7C 66EF                <1> 	out	dx, ax
 12538                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 12539 00003F7E FEC2                <1> 	inc	dl
 12540 00003F80 58                  <1> 	pop	eax
 12541 00003F81 66EF                <1> 	out	dx, ax ; enable (or disable)
 12542 00003F83 C3                  <1> 	retn
 12543                              <1> vbe_bfn_rvs_1:
 12544                              <1> 	; VBE_DISPI_ENABLED
 12545                              <1> 
 12546                              <1> 	; from VBE_DISPI_INDEX_XRES
 12547                              <1> 	;   to VBE_DISPI_INDEX_BPP	
 12548                              <1> 
 12549 00003F84 B503                <1>  	mov	ch, 3
 12550 00003F86 28C0                <1> 	sub	al, al ; 0 ; VBE_DISPI_INDEX_XRES - 1
 12551                              <1> 	; ax = 0
 12552                              <1> 
 12553 00003F88 E80B000000          <1> 	call	vbe_bfn_rvs_2
 12554                              <1> 
 12555                              <1>         ;outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
 12556                              <1> 	;outw(VBE_DISPI_IOPORT_DATA, enable);
 12557                              <1> 
 12558                              <1> 	; 23/01/2021
 12559 00003F8D B001                <1> 	mov	al, 1 ; VBE_DISPI_ENABLED
 12560                              <1> 	; ax = 1
 12561 00003F8F E8E5FFFFFF          <1> 	call	vbe_bfn_rvs_0
 12562                              <1> 
 12563                              <1> 	; from VBE_DISPI_INDEX_BANK
 12564                              <1> 	;   to VBE_DISPI_INDEX_Y_OFFSET
 12565                              <1> 
 12566 00003F94 B505                <1> 	mov	ch, 5
 12567                              <1> 	; 23/01/2021
 12568 00003F96 B004                <1> 	mov	al, 4  ; VBE_DISPI_INDEX_BANK - 1
 12569                              <1> 	; ax = 4
 12570                              <1> vbe_bfn_rvs_2:
 12571 00003F98 FEC0                <1> 	inc	al ; from VBE_DISPI_INDEX_XRES
 12572                              <1> 		     ; to VBE_DISPI_INDEX_BPP	
 12573                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 12574                              <1> 	;mov	dl, 0CEh
 12575 00003F9A 66EF                <1> 	out	dx, ax
 12576 00003F9C 50                  <1> 	push	eax
 12577                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 12578 00003F9D FEC2                <1> 	inc	dl ; 1CFh
 12579 00003F9F 66AD                <1> 	lodsw
 12580 00003FA1 66EF                <1> 	out	dx, ax
 12581 00003FA3 58                  <1> 	pop	eax
 12582 00003FA4 FECA                <1> 	dec	dl ; 1CEh
 12583 00003FA6 FECD                <1> 	dec	ch
 12584 00003FA8 75EE                <1> 	jnz	short vbe_bfn_rvs_2		
 12585 00003FAA C3                  <1> 	retn
 12586                              <1> 
 12587                              <1> ; ---------------------------------------------------------
 12588                              <1>  
 12589                              <1> dispi_set_enable:
 12590                              <1> 	; 23/11/2020
 12591                              <1> 	; Input:
 12592                              <1> 	;	ax = VBE_DISPI_ENABLED = 1
 12593                              <1> 	;	     or VBE_DISPI_DISABLED = 0
 12594                              <1> 	;
 12595                              <1> 	; Modified registers: none
 12596                              <1> 	
 12597                              <1> 	;push	edx
 12598                              <1> 	;push	eax
 12599                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 12600                              <1> 	;mov	ax, 04h	  ; VBE_DISPI_INDEX_ENABLE
 12601                              <1> 	;out	dx, ax
 12602                              <1> 	;pop	eax
 12603                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 12604                              <1> 	;;mov	dl, 0CFh
 12605                              <1> 	;inc	dl
 12606                              <1> 	;out	dx, ax
 12607                              <1> 	;pop	edx
 12608                              <1> 	;retn
 12609                              <1> 
 12610                              <1> 	; 25/11/2020
 12611                              <1> 	; Modified registers: edx
 12612                              <1> 	;push	edx
 12613 00003FAB 66BA0400            <1> 	mov	dx, 04h ; VBE_DISPI_INDEX_ENABLE
 12614                              <1> 	;call	dispi_set_parms
 12615                              <1> 	;pop	edx
 12616                              <1> 	;retn
 12617                              <1> 	;;jmp	short dispi_set_parms
 12618                              <1> 
 12619                              <1> dispi_set_parms:
 12620                              <1> 	; 25/11/2020
 12621                              <1> 	; Input:
 12622                              <1> 	;	ax = data
 12623                              <1> 	;	dx = vbe dispi register index
 12624                              <1> 	;
 12625                              <1> 	; Modified registers: edx
 12626                              <1> 
 12627 00003FAF 50                  <1> 	push	eax
 12628 00003FB0 6689D0              <1> 	mov	ax, dx
 12629 00003FB3 66BACE01            <1> 	mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 12630 00003FB7 66EF                <1> 	out	dx, ax
 12631 00003FB9 58                  <1> 	pop	eax
 12632                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 12633                              <1> 	;mov	dl, 0CFh
 12634 00003FBA FEC2                <1> 	inc	dl
 12635 00003FBC 66EF                <1> 	out	dx, ax
 12636 00003FBE C3                  <1> 	retn
 12637                              <1> 
 12638                              <1> dispi_set_bpp:
 12639                              <1> 	; 25/11/2020
 12640                              <1> 	; Input:
 12641                              <1> 	;	ax = Bits per pixel value
 12642                              <1> 	;	     (8,16,24,32)
 12643                              <1> 	;
 12644                              <1> 	; Modified registers: none
 12645                              <1> 
 12646                              <1> 	;push	edx
 12647                              <1> 	;push	eax
 12648                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 12649                              <1> 	;mov	ax, 03h	  ; VBE_DISPI_INDEX_BPP
 12650                              <1> 	;out	dx, ax
 12651                              <1> 	;pop	eax
 12652                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 12653                              <1> 	;;mov	dl, 0CFh
 12654                              <1> 	;inc	dl
 12655                              <1> 	;out	dx, ax
 12656                              <1> 	;pop	edx
 12657                              <1> 	;retn
 12658                              <1> 
 12659                              <1> 	; 25/11/2020
 12660                              <1> 	; Modified registers: edx
 12661                              <1> 	;push	edx
 12662 00003FBF 66BA0300            <1> 	mov	dx, 03h ; VBE_DISPI_INDEX_BPP
 12663                              <1> 	;call	dispi_set_parms
 12664                              <1> 	;pop	edx
 12665                              <1> 	;retn
 12666 00003FC3 EBEA                <1> 	jmp	short dispi_set_parms
 12667                              <1> 
 12668                              <1> dispi_set_xres:
 12669                              <1> 	; 25/11/2020
 12670                              <1> 	; Input:
 12671                              <1> 	;	ax = X resolution (screen witdh)
 12672                              <1> 	;	     (320,640,800,1024,1280,1920)
 12673                              <1> 	;
 12674                              <1> 	; Modified registers: none
 12675                              <1> 
 12676                              <1> 	;push	edx
 12677                              <1> 	;push	eax
 12678                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 12679                              <1> 	;mov	ax, 01h	  ; VBE_DISPI_INDEX_XRES
 12680                              <1> 	;out	dx, ax
 12681                              <1> 	;pop	eax
 12682                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 12683                              <1> 	;;mov	dl, 0CFh
 12684                              <1> 	;inc	dl
 12685                              <1> 	;out	dx, ax
 12686                              <1> 	;pop	edx
 12687                              <1> 	;retn
 12688                              <1> 
 12689                              <1> 	; 25/11/2020
 12690                              <1> 	; Modified registers: edx
 12691                              <1> 	;push	edx
 12692 00003FC5 66BA0100            <1> 	mov	dx, 01h ; VBE_DISPI_INDEX_XRES
 12693                              <1> 	;call	dispi_set_parms
 12694                              <1> 	;pop	edx
 12695                              <1> 	;retn
 12696 00003FC9 EBE4                <1> 	jmp	short dispi_set_parms
 12697                              <1> 
 12698                              <1> dispi_set_yres:
 12699                              <1> 	; 25/11/2020
 12700                              <1> 	; Input:
 12701                              <1> 	;	ax = Y resolution (screen height)
 12702                              <1> 	;	     (200,400,600,720,768,1080)
 12703                              <1> 	;
 12704                              <1> 	; Modified registers: none
 12705                              <1> 
 12706                              <1> 	;push	edx
 12707                              <1> 	;push	eax
 12708                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 12709                              <1> 	;mov	ax, 02h	  ; VBE_DISPI_INDEX_YRES
 12710                              <1> 	;out	dx, ax
 12711                              <1> 	;pop	eax
 12712                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 12713                              <1> 	;;mov	dl, 0CFh
 12714                              <1> 	;inc	dl
 12715                              <1> 	;out	dx, ax
 12716                              <1> 	;pop	edx
 12717                              <1> 	;retn
 12718                              <1> 
 12719                              <1> 	; 25/11/2020
 12720                              <1> 	; Modified registers: edx
 12721                              <1> 	;push	edx
 12722 00003FCB 66BA0200            <1> 	mov	dx, 02h  ; VBE_DISPI_INDEX_YRES
 12723                              <1> 	;call	dispi_set_parms
 12724                              <1> 	;pop	edx
 12725                              <1> 	;retn
 12726 00003FCF EBDE                <1> 	jmp	short dispi_set_parms
 12727                              <1> 
 12728                              <1> dispi_set_bank:
 12729                              <1> 	; 25/11/2020
 12730                              <1> 	; Input:
 12731                              <1> 	;	ax = video memory bank number
 12732                              <1> 	;
 12733                              <1> 	; Modified registers: none
 12734                              <1> 
 12735                              <1> 	;push	edx
 12736                              <1> 	;push	eax
 12737                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 12738                              <1> 	;mov	ax, 05h	  ; VBE_DISPI_INDEX_BANK
 12739                              <1> 	;out	dx, ax
 12740                              <1> 	;pop	eax
 12741                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 12742                              <1> 	;;mov	dl, 0CFh
 12743                              <1> 	;inc	dl
 12744                              <1> 	;out	dx, ax
 12745                              <1> 	;pop	edx
 12746                              <1> 	;retn
 12747                              <1> 	
 12748                              <1> 	; 25/11/2020
 12749                              <1> 	; Modified registers: edx
 12750                              <1> 	;push	edx
 12751 00003FD1 66BA0500            <1> 	mov	dx, 05h  ; VBE_DISPI_INDEX_BANK
 12752                              <1> 	;call	dispi_set_parms
 12753                              <1> 	;pop	edx
 12754                              <1> 	;retn
 12755 00003FD5 EBD8                <1> 	jmp	short dispi_set_parms
 12756                              <1> 
 12757                              <1> dispi_get_enable:
 12758                              <1> 	; 27/11/2020
 12759                              <1> 	; Input:
 12760                              <1> 	;	none
 12761                              <1> 	; Output:
 12762                              <1> 	;	ax = vbe dispi status
 12763                              <1> 	;
 12764                              <1> 	; Modified registers: eax
 12765                              <1> 	
 12766                              <1> 	;push	edx
 12767                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 12768                              <1> 	;mov	ax, 04h	  ; VBE_DISPI_INDEX_ENABLE
 12769                              <1> 	;out	dx, ax
 12770                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 12771                              <1> 	;;mov	dl, 0CFh
 12772                              <1> 	;inc	dl
 12773                              <1> 	;in	ax, dx
 12774                              <1> 	;pop	edx
 12775                              <1> 	;retn
 12776                              <1> 
 12777                              <1> 	; 27/11/2020
 12778                              <1> 	; Modified registers: eax, edx
 12779                              <1> 	;push	edx
 12780 00003FD7 66B80400            <1> 	mov	ax, 04h ; VBE_DISPI_INDEX_ENABLE
 12781                              <1> 	;call	dispi_get_parms
 12782                              <1> 	;pop	edx
 12783                              <1> 	;retn
 12784                              <1> 	;;jmp	short dispi_get_parms
 12785                              <1> 
 12786                              <1> dispi_get_parms:
 12787                              <1> 	; 25/11/2020
 12788                              <1> 	; Input:
 12789                              <1> 	;	ax = vbe dispi register index
 12790                              <1> 	; output:
 12791                              <1> 	;	ax = data
 12792                              <1> 	;
 12793                              <1> 	; Modified registers: eax, edx
 12794                              <1> 
 12795 00003FDB 66BACE01            <1> 	mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 12796 00003FDF 66EF                <1> 	out	dx, ax
 12797                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 12798                              <1> 	;mov	dl, 0CFh
 12799 00003FE1 FEC2                <1> 	inc	dl
 12800 00003FE3 66ED                <1> 	in	ax, dx
 12801 00003FE5 C3                  <1> 	retn
 12802                              <1> 
 12803                              <1> vga_compat_setup:
 12804                              <1> 	; 26/11/2020
 12805                              <1> 	; 25/11/2020
 12806                              <1> 	; VGA compatibility setup
 12807                              <1> 	; (vbe.c, 02/01/2020, vruppert)
 12808                              <1> 	;
 12809                              <1> 	; Input:
 12810                              <1> 	;	none
 12811                              <1> 	;
 12812                              <1> 	; Modified registers: eax, edx
 12813                              <1> 	
 12814                              <1> 	; 26/11/2020
 12815                              <1>   	;push	eax
 12816                              <1>   	;push	edx
 12817                              <1> 
 12818                              <1>   	; set CRT X resolution
 12819 00003FE6 66BACE01            <1>   	mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
 12820 00003FEA 66B80100            <1>   	mov	ax, 01h  ; VBE_DISPI_INDEX_XRES
 12821 00003FEE 66EF                <1>   	out	dx, ax
 12822                              <1>   	;mov	dx, 1CFh ; VBE_DISPI_IOPORT_DATA
 12823 00003FF0 FEC2                <1>   	inc	dl
 12824 00003FF2 66ED                <1> 	in	ax, dx
 12825 00003FF4 50                  <1> 	push	eax
 12826 00003FF5 66BAD403            <1> 	mov	dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
 12827 00003FF9 66B81100            <1>   	mov	ax, 0011h ; Vertical retrace end register
 12828 00003FFD 66EF                <1>   	out	dx, ax
 12829                              <1>   	;pop	eax
 12830                              <1>   	;push	eax
 12831 00003FFF 8B0424              <1>   	mov	eax, [esp]
 12832 00004002 66C1E803            <1> 	shr	ax, 3 ; / 8 for pixel to character
 12833 00004006 6648                <1>   	dec	ax  ; - 1 (EGA or VGA?)
 12834 00004008 88C4                <1>   	mov	ah, al
 12835 0000400A B001                <1>   	mov	al, 01h ; Horizontal display end register
 12836 0000400C 66EF                <1>   	out	dx, ax
 12837 0000400E 58                  <1>   	pop	eax
 12838                              <1> 
 12839 0000400F E8B0000000          <1> 	call	vga_set_virt_width
 12840                              <1> 
 12841                              <1>   	; set CRT Y resolution
 12842 00004014 66BACE01            <1>   	mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
 12843 00004018 66B80200            <1>   	mov	ax, 02h  ; VBE_DISPI_INDEX_YRES
 12844 0000401C 66EF                <1>   	out	dx, ax
 12845                              <1>   	;mov	dx, 1CFh ; VBE_DISPI_IOPORT_DATA
 12846 0000401E FEC2                <1>   	inc	dl
 12847 00004020 66ED                <1> 	in	ax, dx
 12848 00004022 50                  <1> 	push	eax
 12849 00004023 66BAD403            <1> 	mov	dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
 12850 00004027 88C4                <1>   	mov	ah, al
 12851 00004029 B012                <1> 	mov	al, 12h ; Vertical display end register
 12852 0000402B 66EF                <1>   	out	dx, ax
 12853 0000402D 58                  <1>   	pop	eax
 12854 0000402E B007                <1>   	mov	al, 07h	; Overflow register
 12855 00004030 EE                  <1>   	out	dx, al
 12856 00004031 6642                <1>   	inc	dx
 12857 00004033 EC                  <1>   	in	al, dx ; read overflow register
 12858 00004034 24BD                <1>   	and	al, 0BDh ; clear VDE 9th and 10th bits	
 12859 00004036 F6C401              <1>   	test	ah, 01h
 12860 00004039 7402                <1>   	jz	short bit8_clear
 12861 0000403B 0C02                <1>   	or	al, 02h ; VDE 9th bit (bit 8) in bit 1
 12862                              <1> bit8_clear:
 12863 0000403D F6C402              <1>   	test	ah, 02h
 12864 00004040 7402                <1>   	jz	short bit9_clear
 12865 00004042 0C40                <1>   	or	al, 40h ; VDE 10th bit (bit 9) in bit 6
 12866                              <1> bit9_clear:
 12867 00004044 EE                  <1>   	out	dx, al
 12868                              <1> 
 12869                              <1>   	; other settings
 12870 00004045 66BAD403            <1>  	mov	dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
 12871 00004049 66B80900            <1>   	mov	ax, 0009h ; Maximum scan line register
 12872 0000404D 66EF                <1>   	out	dx, ax	; Reset
 12873 0000404F B017                <1>   	mov	al, 17h ; Mode control register		
 12874 00004051 EE                  <1>   	out	dx, al
 12875                              <1>  	;mov	dx, 3D5h ; VGAREG_VGA_CRTC_DATA
 12876 00004052 FEC2                <1>   	inc	dl
 12877 00004054 EC                  <1> 	in	al, dx	; Read mode control register
 12878 00004055 0C03                <1>   	or	al, 03h ; Set SRS and CMS bits
 12879 00004057 EE                  <1>   	out	dx, al 
 12880 00004058 66BADA03            <1>   	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 12881 0000405C EC                  <1>   	in	al, dx	 ; clear flip-flop
 12882 0000405D 66BAC003            <1>   	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 12883 00004061 B010                <1>   	mov	al, 10h	; Mode control register
 12884 00004063 EE                  <1>   	out	dx, al
 12885                              <1> 	;mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
 12886 00004064 FEC2                <1> 	inc	dl
 12887 00004066 EC                  <1> 	in	al, dx
 12888 00004067 0C01                <1> 	or	al, 01h ; select graphics mode
 12889                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 12890 00004069 FECA                <1> 	dec	dl
 12891 0000406B EE                  <1> 	out	dx, al ; Write to mode control register
 12892 0000406C B020                <1> 	mov	al, 20h ; Palette RAM <-> display memory
 12893 0000406E EE                  <1> 	out	dx, al ; Write to attribute addr register
 12894 0000406F 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
 12895 00004073 66B80605            <1> 	mov	ax, 0506h ; Misc. register, graph, mm 1
 12896 00004077 66EF                <1> 	out	dx, ax
 12897 00004079 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
 12898 0000407D 66B8020F            <1> 	mov	ax, 0F02h ; Map mask register, all planes
 12899 00004081 66EF                <1> 	out	dx, ax
 12900                              <1> 
 12901                              <1>   	; settings for >= 8bpp
 12902                              <1> 
 12903                              <1> 	;mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
 12904                              <1> 	;mov	ax, 03h ; VBE_DISPI_INDEX_BPP
 12905                              <1> 	;out	dx, ax
 12906                              <1> 	;;mov	dx, 1CFh ; VBE_DISPI_IOPORT_DATA
 12907                              <1> 	;inc	dl
 12908                              <1> 	;in	ax, dx
 12909                              <1> 	;cmp	al, 08h  ; < 8 bits per pixel
 12910                              <1> 	;jb	short vga_compat_end
 12911                              <1> 
 12912 00004083 66BAD403            <1> 	mov	dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
 12913 00004087 B014                <1> 	mov	al, 14h  ; Underline location register
 12914 00004089 EE                  <1> 	out	dx, al
 12915                              <1> 	;mov	dx, 3D5h ; VGAREG_VGA_CRTC_DATA
 12916 0000408A FEC2                <1> 	inc	dl
 12917 0000408C EC                  <1> 	in	al, dx	
 12918 0000408D 0C40                <1> 	or	al, 40h	 ; enable double word mode
 12919 0000408F EE                  <1> 	out	dx, al
 12920 00004090 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 12921 00004094 EC                  <1> 	in	al, dx	 ; clear flip-flop
 12922 00004095 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 12923 00004099 B010                <1> 	mov	al, 10h	 ; Mode control register
 12924 0000409B EE                  <1> 	out	dx, al
 12925                              <1> 	;mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
 12926 0000409C FEC2                <1> 	inc	dl
 12927 0000409E EC                  <1> 	in	al, dx
 12928 0000409F 0C40                <1> 	or	al, 40h  ; Pixel clock select is 1
 12929                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 12930 000040A1 FECA                <1> 	dec	dl
 12931 000040A3 EE                  <1> 	out	dx, al	 ; update mode control reggister
 12932 000040A4 B020                <1> 	mov	al, 20h	 ; select display memory as PAS	
 12933 000040A6 EE                  <1> 	out	dx, al
 12934 000040A7 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
 12935 000040AB B004                <1> 	mov	al, 04h	; Memory mode register
 12936 000040AD EE                  <1> 	out	dx, al
 12937                              <1> 	;mov	dx, 3C5h ; VGAREG_SEQU_DATA
 12938 000040AE FEC2                <1> 	inc	dl
 12939 000040B0 EC                  <1> 	in	al, dx
 12940 000040B1 0C08                <1> 	or	al, 08h	; enable chain four
 12941 000040B3 EE                  <1> 	out	dx, al
 12942 000040B4 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
 12943 000040B8 B005                <1> 	mov	al, 05h	 ; Mode register	
 12944 000040BA EE                  <1> 	out	dx, al
 12945                              <1> 	;mov	dx, 3CFh ; VGAREG_GRDC_DATA
 12946 000040BB FEC2                <1> 	inc	dl
 12947 000040BD EC                  <1> 	in	al, dx	
 12948 000040BE 249F                <1> 	and	al, 9Fh	 ; clear shift register 
 12949 000040C0 0C40                <1> 	or	al, 40h  ; set shift register to 2
 12950 000040C2 EE                  <1> 	out	dx, al
 12951                              <1> 
 12952                              <1> vga_compat_end:
 12953                              <1>   	;pop	edx
 12954                              <1>   	;pop	eax
 12955 000040C3 C3                  <1> 	retn
 12956                              <1> 
 12957                              <1> vga_set_virt_width:
 12958                              <1> 	; 27/11/2020
 12959                              <1> 	; 25/11/2020
 12960                              <1> 	; (vbe.c, 02/01/2020, vruppert)
 12961                              <1> 	;
 12962                              <1> 	; Input:
 12963                              <1> 	;	AX = resolution (screen width)
 12964                              <1> 	;
 12965                              <1> 	; Modified registers: eax, edx
 12966                              <1> 
 12967                              <1>   	;;push	ebx
 12968                              <1>   	;push	edx
 12969                              <1> 	;push	eax
 12970                              <1>   	;mov	ebx, eax
 12971                              <1>   	;call	dispi_get_bpp ; bits per pixel
 12972                              <1> 	;cmp	al, 4
 12973                              <1> 	;ja	short set_width_svga  ; 8, 16, 24, 32 
 12974                              <1> 	;shr	bx, 1
 12975                              <1> ;set_width_svga:
 12976                              <1> 	;shr	bx, 3
 12977                              <1> 	;mov	eax, [esp]
 12978 000040C4 66C1E803            <1> 	shr	ax, 3	; / 8, bytes per row
 12979 000040C8 66BAD403            <1> 	mov	dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
 12980                              <1> 	;mov	ah, bl	; 
 12981 000040CC 88C4                <1> 	mov	ah, al	; width in bytes
 12982 000040CE B013                <1> 	mov	al, 13h	; offset register
 12983 000040D0 66EF                <1> 	out	dx, ax	; index (3D4h) and data (3D5h)
 12984                              <1> 	;pop	eax
 12985                              <1> 	;pop  	edx
 12986                              <1> 	;;pop	ebx
 12987 000040D2 C3                  <1> 	retn
 12988                              <1> 
 12989                              <1> ; 24/11/2020
 12990                              <1> 
 12991                              <1> struc bmi ; BOCHS/PLEX86 MODE INFO structure/table 
 12992 00000000 ????                <1>  .mode:	  resw 1
 12993 00000002 ????                <1>  .width:  resw 1
 12994 00000004 ????                <1>  .height: resw 1
 12995 00000006 ????                <1>  .depth:  resw 1
 12996                              <1>  .size:	
 12997                              <1> endstruc
 12998                              <1> 
 12999                              <1> ; 24/11/2020
 13000                              <1> struc MODEINFO
 13001 00000000 ????                <1>  .mode:			resw 1  ; 1XXh
 13002 00000002 ????                <1>  .ModeAttributes:	resw 1
 13003 00000004 ??                  <1>  .WinAAttributes:	resb 1
 13004 00000005 ??                  <1>  .WinBAttributes:	resb 1	; = 0
 13005 00000006 ????                <1>  .WinGranularity:	resw 1
 13006 00000008 ????                <1>  .WinSize:		resw 1
 13007 0000000A ????                <1>  .WinASegment:		resw 1
 13008 0000000C ????                <1>  .WinBSegment:		resw 1	; = 0
 13009 0000000E ????????            <1>  .WinFuncPtr:		resd 1	; = 0
 13010 00000012 ????                <1>  .BytesPerScanLine:	resw 1
 13011 00000014 ????                <1>  .XResolution:		resw 1
 13012 00000016 ????                <1>  .YResolution:		resw 1
 13013 00000018 ??                  <1>  .XCharSize:		resb 1
 13014 00000019 ??                  <1>  .YCharSize:		resb 1
 13015 0000001A ??                  <1>  .NumberOfPlanes: 	resb 1
 13016 0000001B ??                  <1>  .BitsPerPixel:		resb 1
 13017 0000001C ??                  <1>  .NumberOfBanks:	resb 1
 13018 0000001D ??                  <1>  .MemoryModel:		resb 1
 13019 0000001E ??                  <1>  .BankSize:		resb 1	; = 0
 13020 0000001F ??                  <1>  .NumberOfImagePages: 	resb 1
 13021 00000020 ??                  <1>  .Reserved_page:	resb 1	; = 0
 13022 00000021 ??                  <1>  .RedMaskSize:		resb 1
 13023 00000022 ??                  <1>  .RedFieldPosition: 	resb 1
 13024 00000023 ??                  <1>  .GreenMaskSize:	resb 1
 13025 00000024 ??                  <1>  .GreenFieldPosition: 	resb 1
 13026 00000025 ??                  <1>  .BlueMaskSize:		resb 1
 13027 00000026 ??                  <1>  .BlueFieldPosition: 	resb 1
 13028 00000027 ??                  <1>  .RsvdMaskSize:		resb 1
 13029 00000028 ??                  <1>  .RsvdFieldPosition: 	resb 1
 13030 00000029 ??                  <1>  .DirectColorModeInfo: 	resb 1
 13031 0000002A ????????            <1>  .PhysBasePtr:		resd 1
 13032 0000002E ????????            <1>  .OffScreenMemOffset: 	resd 1	; = 0
 13033 00000032 ????                <1>  .OffScreenMemSize: 	resw 1	; = 0
 13034 00000034 ????                <1>  .LinBytesPerScanLine: 	resw 1
 13035 00000036 ??                  <1>  .BnkNumberOfPages: 	resb 1
 13036 00000037 ??                  <1>  .LinNumberOfPages: 	resb 1
 13037 00000038 ??                  <1>  .LinRedMaskSize:	resb 1
 13038 00000039 ??                  <1>  .LinRedFieldPosition1: resb 1
 13039 0000003A ??                  <1>  .LinGreenMaskSize1: 	resb 1
 13040 0000003B ??                  <1>  .LinGreenFieldPosition:resb 1
 13041 0000003C ??                  <1>  .LinBlueMaskSize: 	resb 1
 13042 0000003D ??                  <1>  .LinBlueFieldPosition:	resb 1
 13043 0000003E ??                  <1>  .LinRsvdMaskSize: 	resb 1
 13044 0000003F ??                  <1>  .LinRsvdFieldPosition:	resb 1
 13045 00000040 ????????            <1>  .MaxPixelClock:	resd 1	; = 0
 13046                              <1> .size:
 13047                              <1> endstruc
 13048                              <1> 
 13049                              <1> ; 10/12/2020
 13050                              <1> struc LFBINFO
 13051 00000000 ????                <1>  .mode:			resw 1  ; 1XXh
 13052 00000002 ????????            <1>  .LFB_addr:		resd 1
 13053 00000006 ????????            <1>  .LFB_size:		resd 1
 13054 0000000A ????                <1>  .X_res:		resw 1
 13055 0000000C ????                <1>  .Y_res:		resw 1
 13056 0000000E ??                  <1>  .bpp:			resb 1
 13057 0000000F ??                  <1>  .reserved:		resb 1
 13058                              <1> .size:	; 16 bytes
 13059                              <1> endstruc
 13060                              <1> 
 13061                              <1> set_mode_info_list:
 13062                              <1> 	; 14/12/2020
 13063                              <1> 	; 11/12/2020
 13064                              <1> 	; 24/11/2020
 13065                              <1> 	; (vbetables-gen.c)
 13066                              <1> 	; Input:
 13067                              <1> 	;	BX = VBE mode (including bochs special modes) 
 13068                              <1> 	; Output:
 13069                              <1> 	;	;;EAX = MODE_INFO_LIST address
 13070                              <1> 	;	EAX = 0 ; 11/12/2020
 13071                              <1> 	;	ESI = MODE_INFO_LIST address ; 11/12/2020
 13072                              <1> 	;	(if mode is not found, ESI = 0)
 13073                              <1> 	;
 13074                              <1> 	; Modified registers: eax, ebx, ecx, edx, esi, edi 
 13075                              <1> 
 13076 000040D3 BE[66730000]        <1> 	mov	esi, b_vbe_modes ; bochs mode info base table
 13077 000040D8 BF[3A120300]        <1> 	mov	edi, MODE_INFO_LIST ; mode info list (4F01h)
 13078                              <1> sml_0:
 13079 000040DD 66AD                <1> 	lodsw	
 13080 000040DF 6639D8              <1> 	cmp	ax, bx ; is mode number same ?
 13081 000040E2 7410                <1> 	je	short sml_1 ; yes
 13082 000040E4 AD                  <1> 	lodsd
 13083 000040E5 66AD                <1> 	lodsw	
 13084 000040E7 81FE[26740000]      <1> 	cmp	esi, end_of_b_vbe_modes
 13085 000040ED 72EE                <1> 	jb	short sml_0
 13086                              <1> 	; not found
 13087 000040EF 31C0                <1> 	xor	eax, eax ; 0
 13088                              <1> 	; 11/12/2020
 13089 000040F1 31F6                <1> 	xor	esi, esi
 13090 000040F3 C3                  <1> 	retn
 13091                              <1> sml_1:
 13092 000040F4 66AB                <1> 	stosw	; mode
 13093 000040F6 AD                  <1> 	lodsd	; width, height
 13094                              <1> 	; 14/12/2020
 13095 000040F7 89C1                <1> 	mov	ecx, eax
 13096 000040F9 50                  <1> 	push	eax ; ***
 13097 000040FA 29C0                <1> 	sub	eax, eax ; clear high word of eax
 13098 000040FC 66AD                <1> 	lodsw	; depth
 13099 000040FE 50                  <1> 	push	eax ; **
 13100                              <1> 
 13101                              <1> 	;add	al, 7 ; only for 15 bit colors (not used here)
 13102 000040FF C0E803              <1> 	shr	al, 3 ; / 8
 13103                              <1> 	; 14/12/2020
 13104 00004102 66F7E1              <1> 	mul	cx  ; pitch = width * ((depth+7)/8)
 13105                              <1> 		; ax = pitch
 13106 00004105 50                  <1> 	push	eax ; * ; high word of eax = 0
 13107 00004106 C1E910              <1> 	shr	ecx, 16
 13108                              <1> 	;mul	cx
 13109                              <1> 	;mov	cx, ax
 13110 00004109 31D2                <1> 	xor	edx, edx  ; clear high word of edx
 13111 0000410B F7E1                <1> 	mul	ecx ; height * pitch
 13112 0000410D 89C1                <1> 	mov	ecx, eax
 13113 0000410F B800000001          <1> 	mov	eax, VBE_DISPI_TOTAL_VIDEO_MEMORY_MB * 1024 * 1024
 13114 00004114 F7F1                <1> 	div	ecx
 13115                              <1> 		; eax = pages = vram_size / (height*pitch)
 13116                              <1> 	
 13117                              <1> 	;mov	cx, ax
 13118 00004116 89C1                <1> 	mov	ecx, eax ; pages 
 13119                              <1> 		
 13120 00004118 66B89B00            <1> 	mov	ax, MODE_ATTRIBUTES
 13121 0000411C 66AB                <1> 	stosw	; ModeAttributes
 13122 0000411E B007                <1> 	mov	al, WINA_ATTRIBUTES
 13123 00004120 AA                  <1> 	stosb	; WinAAttributes
 13124 00004121 30C0                <1> 	xor	al, al ; WinBAttributes = 0
 13125 00004123 AA                  <1> 	stosb
 13126 00004124 66B84000            <1> 	mov	ax, VBE_DISPI_BANK_SIZE_KB
 13127 00004128 66AB                <1> 	stosw	; WinGranularity
 13128 0000412A 66AB                <1> 	stosw	; WinSize
 13129 0000412C 66B800A0            <1> 	mov	ax, VGAMEM_GRAPH
 13130 00004130 66AB                <1> 	stosw	; WinASegment
 13131 00004132 29C0                <1> 	sub	eax, eax
 13132 00004134 66AB                <1> 	stosw	; WinBSegment = 0
 13133 00004136 AB                  <1> 	stosd	; WinFuncPtr = 0
 13134                              <1> 
 13135 00004137 58                  <1> 	pop	eax ; * ; pitch
 13136 00004138 89C3                <1> 	mov	ebx, eax  ; high word of ebx = 0 ; 14/12/2020
 13137 0000413A 66AB                <1> 	stosw	; BytesPerScanLine
 13138                              <1> 
 13139 0000413C 5A                  <1> 	pop	edx ; ** ; depth (bits per pixel)
 13140 0000413D 58                  <1> 	pop	eax ; *** width, height
 13141                              <1> 
 13142                              <1>  	; // Mandatory information for VBE 1.2 and above
 13143                              <1> 
 13144 0000413E 66AB                <1> 	stosw	; XResolution (width)
 13145 00004140 C1E810              <1> 	shr	eax, 16
 13146 00004143 50                  <1> 	push	eax ; **** height
 13147 00004144 66AB                <1> 	stosw	; YResolution (height)
 13148 00004146 B008                <1> 	mov	al, 8
 13149 00004148 AA                  <1>  	stosb	; XCharSize  ; char width
 13150 00004149 B010                <1> 	mov	al, 16
 13151 0000414B AA                  <1> 	stosb	; YCharSize  ; char height
 13152 0000414C B001                <1> 	mov	al, 1
 13153 0000414E AA                  <1> 	stosb	; NumberOfPlanes
 13154                              <1> 	;movzx	eax, dl
 13155 0000414F 88D0                <1> 	mov	al, dl ; eax <= 32
 13156 00004151 AA                  <1> 	stosb	; BitsPerPixel
 13157                              <1> 	; Number of banks = (height * pitch + 65535) / 65536
 13158 00004152 58                  <1> 	pop	eax ; **** ; height
 13159                              <1> 	; 14/12/2020
 13160 00004153 52                  <1> 	push	edx ; ***** ; depth ; edx <= 32
 13161 00004154 F7E3                <1> 	mul	ebx  ; pitch (ebx) * height (eax)
 13162                              <1> 	;mov	edx, [esp] ; *****
 13163                              <1> 	;mov	dl, [esp] ; *****
 13164 00004156 05FFFF0000          <1> 	add	eax, 65535
 13165 0000415B C1E810              <1> 	shr	eax, 16 ; / 65536 ; <= 127 ; 14/12/2020
 13166 0000415E AA                  <1> 	stosb	; NumberOfBanks
 13167                              <1> 	; 14/12/2020
 13168                              <1> 	;cmp	dl, 8 ; 8 bits per pixel
 13169 0000415F 803C2408            <1> 	cmp	byte [esp], 8
 13170 00004163 7704                <1> 	ja	short sml_2
 13171 00004165 B004                <1> 	mov	al, VBE_MEMORYMODEL_PACKED_PIXEL
 13172 00004167 EB02                <1> 	jmp	short sml_3
 13173                              <1> sml_2:
 13174                              <1> 	; 16, 24, 32 bits per pixel
 13175 00004169 B006                <1> 	mov	al, VBE_MEMORYMODEL_DIRECT_COLOR
 13176                              <1> sml_3:
 13177 0000416B AA                  <1> 	stosb
 13178 0000416C 30C0                <1> 	xor	al, al ; 0
 13179 0000416E AA                  <1> 	stosb	; BankSize = 0
 13180 0000416F 49                  <1> 	dec	ecx ; pages - 1
 13181                              <1> 	; NumberOfImagePages = 262 for 320x200x8 mode
 13182                              <1> 	;;mov	ax, 255
 13183                              <1> 	; 14/12/2020
 13184                              <1> 	;mov	al, 255
 13185 00004170 FEC8                <1> 	dec	al ; 255
 13186 00004172 39C1                <1> 	cmp	ecx, eax ; ecx <= 261, eax = 255 
 13187                              <1> 	;cmp	cx, ax
 13188 00004174 7302                <1> 	jnb	short sml_4
 13189 00004176 88C8                <1> 	mov	al, cl	 
 13190                              <1> sml_4:
 13191 00004178 AA                  <1> 	stosb	; NumberOfImagePages (1 byte)
 13192 00004179 28C0                <1> 	sub	al, al
 13193 0000417B AA                  <1> 	stosb	; Reserved_page = 0
 13194 0000417C 58                  <1> 	pop	eax ; ***** ; depth
 13195 0000417D 88C1                <1> 	mov	cl, al
 13196                              <1> 	; eax < = 32
 13197 0000417F 2C08                <1> 	sub	al, 8 ; 8->0, 16->8, 24->16, 32->24
 13198 00004181 BE[26740000]        <1> 	mov	esi, direct_color_fields
 13199 00004186 01C6                <1> 	add	esi, eax
 13200 00004188 56                  <1> 	push	esi ; ******
 13201 00004189 AD                  <1> 	lodsd	; RedMaskSize (AL), RedFieldPosition (AH)
 13202                              <1> 	     	; GreenMaskSize (16), GreenFieldPosition (24)
 13203 0000418A AB                  <1> 	stosd
 13204 0000418B AD                  <1> 	lodsd	; BlueMaskSize (AL), BlueFieldPosition (AH)
 13205                              <1> 	     	; RsvdMaskSize (16), RsvdFieldPosition (24)
 13206 0000418C AB                  <1> 	stosd
 13207 0000418D 5E                  <1> 	pop	esi ; ******
 13208                              <1> 
 13209 0000418E 30C0                <1> 	xor	al, al ; 0
 13210 00004190 80F920              <1> 	cmp	cl, 32
 13211 00004193 7202                <1> 	jb	short sml_5
 13212 00004195 B002                <1> 	mov	al, VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
 13213                              <1> sml_5: 
 13214 00004197 AA                  <1> 	stosb	; DirectColorModeInfo
 13215                              <1> 
 13216                              <1> 	; // Mandatory information for VBE 2.0 and above
 13217                              <1> 
 13218 00004198 B8000000E0          <1> 	mov	eax, VBE_DISPI_LFB_PHYSICAL_ADDRESS
 13219 0000419D AB                  <1> 	stosd	; PhysBasePtr
 13220 0000419E 29C0                <1> 	sub	eax, eax
 13221 000041A0 AB                  <1> 	stosd	; OffScreenMemOffset = 0
 13222 000041A1 66AB                <1> 	stosw	; OffScreenMemSize = 0
 13223                              <1> 
 13224                              <1> 	;// Mandatory information for VBE 3.0 and above
 13225                              <1> 
 13226                              <1> 	; ebx = pitch
 13227 000041A3 6689D8              <1> 	mov	ax, bx
 13228                              <1> 	;stosw
 13229                              <1> 
 13230                              <1> 	;xor	al, al
 13231                              <1>      	;stosb	; BnkNumberOfPages = 0
 13232                              <1>      	;stosb	; LinNumberOfPages = 0
 13233                              <1> 
 13234 000041A6 AB                  <1> 	stosd	; pitch (word), 0 (byte), 0 (byte)  
 13235                              <1> 
 13236 000041A7 AD                  <1> 	lodsd	; LinRedMaskSize (AL), LinRedFieldPosition (AH)
 13237                              <1> 	     	; LinGreenMaskSize (16), LinGreenFieldPosition (24)
 13238 000041A8 AB                  <1> 	stosd
 13239 000041A9 AD                  <1> 	lodsd	; LinBlueMaskSize (AL), LinBlueFieldPosition (AH)
 13240                              <1> 	     	; LinRsvdMaskSize (16), LinRsvdFieldPosition (24)
 13241 000041AA AB                  <1> 	stosd
 13242                              <1> 
 13243 000041AB 29C0                <1> 	sub	eax, eax
 13244 000041AD AB                  <1> 	stosd	; MaxPixelClock = 0
 13245                              <1> 
 13246                              <1> 	;mov	eax, MODE_INFO_LIST
 13247                              <1> 	; 11/12/2020
 13248 000041AE BE[3A120300]        <1> 	mov	esi, MODE_INFO_LIST
 13249                              <1> 	
 13250 000041B3 C3                  <1> 	retn	
 13251                              <1> 
 13252                              <1> ; end of set_mode_info_list ; edi = set_mode_info_list + 68
 13253                              <1> 
 13254                              <1> pci_get_lfb_addr:
 13255                              <1> 	; 11/12/2020
 13256                              <1> 	; Get linear frame buffer base from PCI
 13257                              <1> 	; (vgabios.c, 02/01/2020, vruppert)
 13258                              <1> 	;
 13259                              <1> 	; Input:
 13260                              <1> 	;	ax = PCI device vendor id
 13261                              <1> 	; Output:
 13262                              <1> 	;	ax  = LFB address (high 16 bit) (zf=0)
 13263                              <1> 	;	eax = 0 -> not found (error) (zf=1)
 13264                              <1> 	;
 13265                              <1> 	; Modified registers: eax
 13266                              <1> 
 13267 000041B4 53                  <1> 	push	ebx
 13268 000041B5 51                  <1> 	push	ecx
 13269 000041B6 52                  <1> 	push	edx
 13270                              <1> 	;
 13271 000041B7 89C3                <1> 	mov	ebx, eax
 13272 000041B9 31C9                <1> 	xor	ecx, ecx
 13273 000041BB 28D2                <1> 	sub	dl, dl	; mov dl, 0
 13274 000041BD E842000000          <1> 	call	pci_read_reg
 13275 000041C2 6683F8FF            <1> 	cmp	ax, 0FFFFh
 13276 000041C6 7417                <1> 	je	short pci_get_lfb_addr_fail
 13277                              <1> pci_get_lfb_addr_next_dev:
 13278 000041C8 28D2                <1> 	sub	dl, dl ; mov dl, 0
 13279 000041CA E835000000          <1> 	call	pci_read_reg
 13280 000041CF 6639D8              <1> 	cmp	ax, bx	; check vendor
 13281 000041D2 740F                <1> 	je	short pci_get_lfb_addr_found
 13282 000041D4 6683C108            <1> 	add	cx, 08h
 13283 000041D8 6681F90002          <1> 	cmp	cx, 200h ; search bus 0 and 1
 13284 000041DD 72E9                <1> 	jb	short pci_get_lfb_addr_next_dev
 13285                              <1> pci_get_lfb_addr_fail:
 13286 000041DF 31C0                <1> 	xor	eax, eax ; no LFB
 13287                              <1> 	; zf = 1
 13288 000041E1 EB1D                <1> 	jmp	short pci_get_lfb_addr_return
 13289                              <1> pci_get_lfb_addr_found:
 13290 000041E3 B210                <1> 	mov	dl, 10h	; I/O space 0
 13291 000041E5 E81A000000          <1> 	call	pci_read_reg
 13292 000041EA 66A9F1FF            <1> 	test	ax, 0FFF1h
 13293 000041EE 740D                <1> 	jz	short pci_get_lfb_addr_success
 13294 000041F0 B214                <1> 	mov	dl, 14h ; I/O space 1
 13295 000041F2 E80D000000          <1> 	call	pci_read_reg
 13296 000041F7 66A9F1FF            <1> 	test	ax, 0FFF1h
 13297 000041FB 75E2                <1> 	jnz	short pci_get_lfb_addr_fail
 13298                              <1> pci_get_lfb_addr_success:
 13299 000041FD C1E810              <1> 	shr	eax, 16 ; LFB address (hw)
 13300                              <1> 	; zf = 0
 13301                              <1> pci_get_lfb_addr_return:
 13302 00004200 5A                  <1> 	pop	edx
 13303 00004201 59                  <1> 	pop	ecx
 13304 00004202 5B                  <1> 	pop	ebx
 13305 00004203 C3                  <1> 	retn
 13306                              <1> 
 13307                              <1> pci_read_reg:
 13308                              <1> 	; 11/12/2020
 13309                              <1> 	; Read PCI register
 13310                              <1> 	; (vgabios.c, 02/01/2020, vruppert)
 13311                              <1> 	;
 13312                              <1> 	; Input:
 13313                              <1> 	;	cx = device/function
 13314                              <1> 	;	dl = register
 13315                              <1> 	; Output:
 13316                              <1> 	;	eax = value
 13317                              <1> 	;
 13318                              <1> 	; Modified registers: eax, edx
 13319                              <1> 
 13320 00004204 B800008000          <1> 	mov	eax, 00800000h 
 13321 00004209 6689C8              <1> 	mov	ax, cx
 13322 0000420C C1E008              <1> 	shl	eax, 8
 13323 0000420F 88D0                <1> 	mov	al, dl
 13324 00004211 66BAF80C            <1> 	mov	dx, 0CF8h
 13325 00004215 EF                  <1>  	out	dx, eax
 13326 00004216 80C204              <1> 	add	dl, 4 ; mov dx, 0CFCh
 13327 00004219 ED                  <1> 	in	eax, dx
 13328 0000421A C3                  <1> 	retn
 13329                              <1> 
 13330                              <1> %endif
 13331                              <1> 
 13332                              <1> ; -----------
 13333                              <1> 
 13334                              <1> %if 0
 13335                              <1> 
 13336                              <1> mode_info_find_mode:
 13337                              <1> 	; 25/11/2020
 13338                              <1> 	; Input:
 13339                              <1> 	;	bx = VESA VBE2 video mode (+ bochs extensions)
 13340                              <1> 	; Output:
 13341                              <1> 	;	esi = mode info address (for BX input)
 13342                              <1> 	;	esi = 0 -> not found
 13343                              <1> 	;
 13344                              <1> 	; Modified registers: eax, esi
 13345                              <1> 
 13346                              <1> 	xor	eax, eax
 13347                              <1> 	mov	esi, MODE_INFO_LIST
 13348                              <1> mifm_1:
 13349                              <1> 	mov	ax, [esi]
 13350                              <1> 	cmp	ax, bx
 13351                              <1> 	je	short mifm_2
 13352                              <1> 	add	esi, MODEINFO.size ; add esi, 68
 13353                              <1> 	cmp	esi, VBE_VESA_MODE_END_OF_LIST
 13354                              <1> 	jb	short mifm_1
 13355                              <1> 	; not found
 13356                              <1> 	sub	esi, esi ; 0
 13357                              <1> mifm_2
 13358                              <1> 	retn
 13359                              <1> 
 13360                              <1> dispi_get_bpp:
 13361                              <1> 	; 28/11/2020
 13362                              <1> 	; Input:
 13363                              <1> 	;	none
 13364                              <1> 	; Output:
 13365                              <1> 	;	al = Bits per pixel
 13366                              <1> 	;	     (8,16,24,32)
 13367                              <1> 	;	ah = Bytes per pixel
 13368                              <1> 	;	     (1,2,3,4)	
 13369                              <1> 	;
 13370                              <1> 	; Modified registers: none
 13371                              <1> 
 13372                              <1> 	;push	edx
 13373                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 13374                              <1> 	;mov	ax, 03h	  ; VBE_DISPI_INDEX_BPP
 13375                              <1> 	;out	dx, ax
 13376                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 13377                              <1> 	;;mov	dl, 0CFh
 13378                              <1> 	;inc	dl
 13379                              <1> 	;in	ax, dx
 13380                              <1> 	;mov	ah, al
 13381                              <1> 	;shr	ah, 3 ; / 8
 13382                              <1> 	;;test	al, 7 ; 15 bit graphics mode
 13383                              <1>  	;;jz	short get_bpp_noinc
 13384                              <1> 	;;inc	ah
 13385                              <1> ;;get_bpp_noinc:
 13386                              <1> 	;pop	edx
 13387                              <1> 	;retn
 13388                              <1> 
 13389                              <1> 	; 28/11/2020
 13390                              <1> 	; Modified registers: edx
 13391                              <1> 	;push	edx
 13392                              <1> 	mov	dx, 03h ; VBE_DISPI_INDEX_BPP
 13393                              <1> 	call	dispi_get_parms
 13394                              <1> 	;pop	edx
 13395                              <1> 	;retn
 13396                              <1> 	mov	ah, al
 13397                              <1> 	shr	ah, 3 ; / 8
 13398                              <1> 	;test	al, 7 ; 15 bit graphips mode
 13399                              <1>  	;jz	short get_bpp_noinc
 13400                              <1> 	;inc	ah
 13401                              <1> ;get_bpp_noinc:
 13402                              <1> 	;pop	edx
 13403                              <1> 	retn
 13404                              <1> 
 13405                              <1> restore_vesa_video_state:
 13406                              <1> 	; 14/01/2021
 13407                              <1> 	; 06/12/2020
 13408                              <1> 	; Input:
 13409                              <1> 	;	[vbe3stbufsize] <= 32 ; <= 32*64 bytes
 13410                              <1> 	; Output:
 13411                              <1> 	;	AX = 004Fh (successed)
 13412                              <1> 	;
 13413                              <1> 	;	eax = 0 -> buffer size problem
 13414                              <1> 	;	eax > 0 and ax <> 004Fh -> failed
 13415                              <1> 	;
 13416                              <1> 	; Modified regs: eax, ebx, ecx, edx, esi, edi 
 13417                              <1> 
 13418                              <1> 	;movzx	ecx, word [vbe3stbufsize]  
 13419                              <1> 	;cmp	cx, 32 ; 32 * 64 bytes
 13420                              <1> 	;ja	short r_v_b_s_fail
 13421                              <1> 
 13422                              <1> 	movzx	ecx, byte [vbe3stbufsize]; <=32	
 13423                              <1> 	shl	cx, 4 ; dword count for movsd
 13424                              <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; destination
 13425                              <1> 					; (vbe3 pmi buff)
 13426                              <1> 	mov	esi, VBE3VIDEOSTATE ; source (kernel buff)
 13427                              <1> 	rep	movsd	
 13428                              <1> 
 13429                              <1> 	mov	ax, 4F04h
 13430                              <1> 	mov	dl, 02h ; restore
 13431                              <1> 	;mov	cx, 0Fh
 13432                              <1> 	mov	cl, 0Fh
 13433                              <1> 	xor 	ebx, ebx ; points to VBE3SAVERESTOREBLOCK
 13434                              <1> 	jmp	short int10h_32bit_pmi
 13435                              <1> 
 13436                              <1> ;s_v_b_s_fail:
 13437                              <1> ;r_v_b_s_fail:
 13438                              <1> ;	xor	eax, eax
 13439                              <1> ;	retn
 13440                              <1> 
 13441                              <1> save_vesa_video_state:
 13442                              <1> 	; 14/01/2021
 13443                              <1> 	; 06/12/2020
 13444                              <1> 	; Input:
 13445                              <1> 	;	[vbe3stbufsize] <= 32 ; <= 32*64 bytes
 13446                              <1> 	; Output:
 13447                              <1> 	;	AX = 004Fh (successed)
 13448                              <1> 	;
 13449                              <1> 	;	eax = 0 -> buffer size problem
 13450                              <1> 	;	eax > 0 and ax <> 004Fh -> failed
 13451                              <1> 	;
 13452                              <1> 	; Modified regs: eax, ebx, ecx, edx, esi, edi 
 13453                              <1> 
 13454                              <1> 	;cmp	word [vbe33stbufsize], 32  
 13455                              <1> 	;			; 32 * 64 bytes
 13456                              <1> 	;ja	short s_v_b_s_fail
 13457                              <1> 
 13458                              <1> 	mov	ax, 4F04h
 13459                              <1> 	mov	dl, 01h ; save
 13460                              <1> 	;mov	cx, 0Fh
 13461                              <1> 	mov	cl, 0Fh
 13462                              <1> 	xor 	ebx, ebx ; points to VBE3SAVERESTOREBLOCK
 13463                              <1> 
 13464                              <1> 	call	int10h_32bit_pmi
 13465                              <1> 
 13466                              <1> 	movzx	ecx, byte [vbe3stbufsize]; <=32	
 13467                              <1> 	shl	cx, 4 ; dword count for movsd
 13468                              <1> 	mov	esi, VBE3SAVERESTOREBLOCK ; destination
 13469                              <1> 					; (vbe3 pmi buff)
 13470                              <1> 	mov	edi, VBE3VIDEOSTATE ; source (kernel buff)
 13471                              <1> 	rep	movsd	
 13472                              <1> 	retn
 13473                              <1> 
 13474                              <1> dispi_set_bank_farcall:
 13475                              <1> 	; 11/12/2020
 13476                              <1> 	; (This may be 'sysvideo' function, later)
 13477                              <1> 	;
 13478                              <1> 	; Input: 
 13479                              <1> 	;	bx = 0000h, set bank number
 13480                              <1> 	;	   = 0100h, get bank number
 13481                              <1> 	;	dx = bank number (if bx = 0)	
 13482                              <1> 	; Output:
 13483                              <1> 	;	dx = bank number
 13484                              <1> 		 	
 13485                              <1> 	cmp	bx, 0100h
 13486                              <1> 	je	short dispi_set_bank_farcall_get
 13487                              <1> 	or	bx, bx
 13488                              <1> 	jnz	dispi_set_bank_farcall_error
 13489                              <1> 	mov	ax, dx
 13490                              <1> 	push	dx
 13491                              <1> 	push	ax
 13492                              <1> 	mov	ax, VBE_DISPI_INDEX_BANK
 13493                              <1> 	mov	dx, VBE_DISPI_IOPORT_INDEX
 13494                              <1> 	out	dx, ax
 13495                              <1> 	pop	ax
 13496                              <1> 	mov	dx, VBE_DISPI_IOPORT_DATA
 13497                              <1> 	out	dx, ax
 13498                              <1> 	in	ax, dx
 13499                              <1> 	pop	dx
 13500                              <1> 	cmp	dx, ax
 13501                              <1> 	jne	short dispi_set_bank_farcall_error
 13502                              <1> 	mov	ax, 004Fh
 13503                              <1> 	retn	; retf for real mode far call
 13504                              <1> dispi_set_bank_farcall_get:
 13505                              <1> 	mov	ax, VBE_DISPI_INDEX_BANK
 13506                              <1> 	mov	dx, VBE_DISPI_IOPORT_INDEX
 13507                              <1> 	out	dx, ax
 13508                              <1> 	mov	dx, VBE_DISPI_IOPORT_DATA
 13509                              <1> 	in	ax, dx
 13510                              <1> 	mov	dx, ax
 13511                              <1> 	retn	; retf for real mode far call
 13512                              <1> dispi_set_bank_farcall_error:
 13513                              <1> 	mov	ax, 014Fh
 13514                              <1> 	retn	; retf for real mode far call
 13515                              <1> 
 13516                              <1> %endif
 13517                              <1> 
 13518                              <1> ; % include 'vidata.s' ; VIDEO DATA
 13519                              <1> 
 13520                              <1> ; /// End Of VIDEO FUNCTIONS ///
  2663                                  
  2664                                  setup_rtc_int:
  2665                                  ; source: http://wiki.osdev.org/RTC
  2666 0000421B FA                      	cli		; disable interrupts
  2667                                  	; default int frequency is 1024 Hz (Lower 4 bits of register A is 0110b or 6)
  2668                                  	; in order to change this ...
  2669                                  	; frequency  = 32768 >> (rate-1) --> 32768 >> 5 = 1024
  2670                                  	; (rate must be above 2 and not over 15)
  2671                                  	; new rate = 15 --> 32768 >> (15-1) = 2 Hz
  2672 0000421C B08A                    	mov	al, 8Ah 
  2673 0000421E E670                    	out	70h, al ; set index to register A, disable NMI
  2674 00004220 90                      	nop
  2675 00004221 E471                    	in	al, 71h ; get initial value of register A
  2676 00004223 88C4                    	mov 	ah, al
  2677 00004225 80E4F0                  	and	ah, 0F0h
  2678 00004228 B08A                    	mov	al, 8Ah 
  2679 0000422A E670                    	out	70h, al ; reset index to register A
  2680 0000422C 88E0                    	mov	al, ah
  2681 0000422E 0C0F                    	or	al, 0Fh	; new rate (0Fh -> 15)
  2682 00004230 E671                    	out	71h, al ; write only our rate to A. Note, rate is the bottom 4 bits. 
  2683                                  	; enable RTC interrupt
  2684 00004232 B08B                    	mov	al, 8Bh ;
  2685 00004234 E670                    	out	70h, al ; select register B and disable NMI
  2686 00004236 90                      	nop
  2687 00004237 E471                    	in	al, 71h ; read the current value of register B
  2688 00004239 88C4                    	mov	ah, al  ;
  2689 0000423B B08B                    	mov 	al, 8Bh ;
  2690 0000423D E670                    	out	70h, al ; set the index again (a read will reset the index to register B)	
  2691 0000423F 88E0                    	mov	al, ah  ;
  2692 00004241 0C40                    	or	al, 40h ;
  2693 00004243 E671                    	out	71h, al ; write the previous value ORed with 0x40. This turns on bit 6 of register B
  2694 00004245 FB                      	sti
  2695 00004246 C3                      	retn
  2696                                  
  2697                                  ; Write memory information
  2698                                  ; 29/01/2016
  2699                                  ; 06/11/2014
  2700                                  ; 14/08/2015 
  2701                                  memory_info:	
  2702 00004247 A1[348A0100]            	mov	eax, [memory_size] ; in pages
  2703 0000424C 50                      	push	eax
  2704 0000424D C1E00C                  	shl	eax, 12		   ; in bytes
  2705 00004250 BB0A000000              	mov	ebx, 10
  2706 00004255 89D9                    	mov	ecx, ebx	   ; 10
  2707 00004257 BE[B94C0100]            	mov	esi, mem_total_b_str	
  2708 0000425C E8D7000000              	call	bintdstr
  2709 00004261 58                      	pop	eax
  2710 00004262 B107                    	mov	cl, 7
  2711 00004264 BE[DD4C0100]            	mov	esi, mem_total_p_str
  2712 00004269 E8CA000000              	call	bintdstr	
  2713                                  	; 14/08/2015
  2714 0000426E E8E2000000              	call	calc_free_mem
  2715                                  	; edx = calculated free pages
  2716                                  	; ecx = 0
  2717 00004273 A1[388A0100]            	mov 	eax, [free_pages]
  2718 00004278 39D0                    	cmp	eax, edx ; calculated free mem value 
  2719                                  		; and initial free mem value are same or not?
  2720 0000427A 751D                    	jne 	short pmim ; print mem info with '?' if not
  2721 0000427C 52                      	push 	edx ; free memory in pages	
  2722                                  	;mov 	eax, edx
  2723 0000427D C1E00C                  	shl	eax, 12 ; convert page count
  2724                                  			; to byte count
  2725 00004280 B10A                    	mov	cl, 10
  2726 00004282 BE[FD4C0100]            	mov	esi, free_mem_b_str
  2727 00004287 E8AC000000              	call	bintdstr
  2728 0000428C 58                      	pop	eax
  2729 0000428D B107                    	mov	cl, 7
  2730 0000428F BE[214D0100]            	mov	esi, free_mem_p_str
  2731 00004294 E89F000000              	call	bintdstr
  2732                                  pmim:
  2733 00004299 BE[A74C0100]            	mov	esi, msg_memory_info
  2734                                  	;
  2735 0000429E B407                    	mov	ah, 07h ; Black background, 
  2736                                  			; light gray forecolor
  2737                                  print_kmsg: ; 29/01/2016
  2738 000042A0 8825[5F8A0100]          	mov	[ccolor], ah
  2739                                  pkmsg_loop:
  2740 000042A6 AC                      	lodsb
  2741 000042A7 08C0                    	or	al, al
  2742 000042A9 7410                    	jz	short pkmsg_ok
  2743 000042AB 56                      	push	esi
  2744                                  	; 13/05/2016
  2745 000042AC 0FB61D[5F8A0100]        	movzx	ebx, byte [ccolor]
  2746                                  			; Video page 0 (bh=0)
  2747 000042B3 E84DE0FFFF              	call	_write_tty
  2748 000042B8 5E                      	pop	esi
  2749 000042B9 EBEB                    	jmp	short pkmsg_loop
  2750                                  pkmsg_ok:
  2751 000042BB C3                      	retn
  2752                                  
  2753                                  ; 19/12/2020
  2754                                  ; temporary
  2755                                  ; Write default liner frame buffer address
  2756                                  ;
  2757                                  default_lfb_info:	
  2758 000042BC 66A1[EB0E0000]          	mov	ax, [def_LFB_addr] ; high word
  2759 000042C2 E829000000              	call	wordtohex
  2760 000042C7 A3[794D0100]            	mov	dword [lfb_addr_str], eax
  2761 000042CC BE[624D0100]            	mov	esi, msg_lfb_addr
  2762 000042D1 B40F                    	mov	ah, 0Fh ; Black background, 
  2763                                  			; white forecolor
  2764 000042D3 EBCB                    	jmp	short print_kmsg
  2765                                  
  2766                                  ; Convert binary number to hexadecimal string
  2767                                  ; 10/05/2015  
  2768                                  ; dsectpm.s (28/02/2015)
  2769                                  ; Retro UNIX 386 v1 - Kernel v0.2.0.6  
  2770                                  ; 01/12/2014
  2771                                  ; 25/11/2014
  2772                                  ;
  2773                                  bytetohex:
  2774                                  	; INPUT ->
  2775                                  	; 	AL = byte (binary number)
  2776                                  	; OUTPUT ->
  2777                                  	;	AX = hexadecimal string
  2778                                  	;
  2779 000042D5 53                      	push	ebx
  2780 000042D6 31DB                    	xor	ebx, ebx
  2781 000042D8 88C3                    	mov	bl, al
  2782 000042DA C0EB04                  	shr	bl, 4
  2783 000042DD 8A9B[27430000]          	mov	bl, [ebx+hexchrs] 	 	
  2784 000042E3 86D8                    	xchg	bl, al
  2785 000042E5 80E30F                  	and	bl, 0Fh
  2786 000042E8 8AA3[27430000]          	mov	ah, [ebx+hexchrs] 
  2787 000042EE 5B                      	pop	ebx	
  2788 000042EF C3                      	retn
  2789                                  
  2790                                  wordtohex:
  2791                                  	; INPUT ->
  2792                                  	; 	AX = word (binary number)
  2793                                  	; OUTPUT ->
  2794                                  	;	EAX = hexadecimal string
  2795                                  	;
  2796 000042F0 53                      	push	ebx
  2797 000042F1 31DB                    	xor	ebx, ebx
  2798 000042F3 86E0                    	xchg	ah, al
  2799 000042F5 6650                    	push	ax
  2800 000042F7 88E3                    	mov	bl, ah
  2801 000042F9 C0EB04                  	shr	bl, 4
  2802 000042FC 8A83[27430000]          	mov	al, [ebx+hexchrs] 	 	
  2803 00004302 88E3                    	mov	bl, ah
  2804 00004304 80E30F                  	and	bl, 0Fh
  2805 00004307 8AA3[27430000]          	mov	ah, [ebx+hexchrs]
  2806 0000430D C1E010                  	shl	eax, 16
  2807 00004310 6658                    	pop	ax
  2808 00004312 5B                      	pop	ebx
  2809 00004313 EBC0                    	jmp	short bytetohex
  2810                                  	;mov	bl, al
  2811                                  	;shr	bl, 4
  2812                                  	;mov	bl, [ebx+hexchrs] 	 	
  2813                                  	;xchg	bl, al	 	
  2814                                  	;and	bl, 0Fh
  2815                                  	;mov	ah, [ebx+hexchrs] 
  2816                                  	;pop	ebx	
  2817                                  	;retn
  2818                                  
  2819                                  dwordtohex:
  2820                                  	; INPUT ->
  2821                                  	; 	EAX = dword (binary number)
  2822                                  	; OUTPUT ->
  2823                                  	;	EDX:EAX = hexadecimal string
  2824                                  	;
  2825 00004315 50                      	push	eax
  2826 00004316 C1E810                  	shr	eax, 16
  2827 00004319 E8D2FFFFFF              	call	wordtohex
  2828 0000431E 89C2                    	mov	edx, eax
  2829 00004320 58                      	pop	eax
  2830 00004321 E8CAFFFFFF              	call	wordtohex
  2831 00004326 C3                      	retn
  2832                                  
  2833                                  ; 10/05/2015
  2834                                  hex_digits:
  2835                                  hexchrs:
  2836 00004327 303132333435363738-     	db '0123456789ABCDEF'
  2836 00004330 39414243444546     
  2837                                  ; 19/01/2021 - VESA EDID ready flag (4Fh)
  2838 00004337 00                      edid:	db 0
  2839                                  
  2840                                  ; Convert binary number to decimal/numeric string
  2841                                  ; 06/11/2014
  2842                                  ; Temporary Code
  2843                                  ;
  2844                                  
  2845                                  bintdstr:
  2846                                  	; EAX = binary number
  2847                                  	; ESI = decimal/numeric string address
  2848                                  	; EBX = divisor (10)
  2849                                  	; ECX = string length (<=10)
  2850 00004338 01CE                    	add	esi, ecx
  2851                                  btdstr0:
  2852 0000433A 4E                      	dec	esi
  2853 0000433B 31D2                    	xor	edx, edx
  2854 0000433D F7F3                    	div	ebx
  2855 0000433F 80C230                  	add	dl, 30h
  2856 00004342 8816                    	mov	[esi], dl
  2857 00004344 FEC9                    	dec	cl
  2858 00004346 740C                    	jz	short btdstr2 ; 08/09/2016
  2859 00004348 09C0                    	or	eax, eax
  2860 0000434A 75EE                    	jnz	short btdstr0
  2861                                  btdstr1:
  2862 0000434C 4E                      	dec	esi
  2863 0000434D C60620                          mov     byte [esi], 20h ; blank space
  2864 00004350 FEC9                    	dec	cl
  2865 00004352 75F8                    	jnz	short btdstr1
  2866                                  btdstr2:
  2867 00004354 C3                      	retn
  2868                                  
  2869                                  ; Calculate free memory pages on M.A.T.
  2870                                  ; 06/11/2014
  2871                                  ; Temporary Code
  2872                                  ;
  2873                                  
  2874                                  calc_free_mem:
  2875 00004355 31D2                    	xor	edx, edx
  2876                                  	;xor	ecx, ecx
  2877 00004357 668B0D[488A0100]        	mov	cx, [mat_size] ; in pages
  2878 0000435E C1E10A                  	shl	ecx, 10	; 1024 dwords per page
  2879 00004361 BE00001000              	mov	esi, MEM_ALLOC_TBL
  2880                                  cfm0:
  2881 00004366 AD                      	lodsd
  2882 00004367 51                      	push	ecx
  2883 00004368 B920000000              	mov	ecx, 32
  2884                                  cfm1:
  2885 0000436D D1E8                    	shr	eax, 1
  2886 0000436F 7301                    	jnc	short cfm2
  2887 00004371 42                      	inc	edx
  2888                                  cfm2:
  2889 00004372 E2F9                    	loop	cfm1
  2890 00004374 59                      	pop	ecx
  2891 00004375 E2EF                    	loop	cfm0
  2892 00004377 C3                      	retn
  2893                                  
  2894                                  %include 'diskio.s'  ; 07/03/2015
  2895                              <1> ; ****************************************************************************
  2896                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.2 - diskio.s
  2897                              <1> ; ----------------------------------------------------------------------------
  2898                              <1> ; Last Update: 30/08/2020
  2899                              <1> ; ----------------------------------------------------------------------------
  2900                              <1> ; Beginning: 24/01/2016
  2901                              <1> ; ----------------------------------------------------------------------------
  2902                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
  2903                              <1> ; ----------------------------------------------------------------------------
  2904                              <1> ; Turkish Rational DOS
  2905                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
  2906                              <1> ;
  2907                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
  2908                              <1> ; diskio.inc (22/08/2015)
  2909                              <1> ;
  2910                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
  2911                              <1> ; ****************************************************************************
  2912                              <1> 
  2913                              <1> ; Retro UNIX 386 v1 Kernel - DISKIO.INC
  2914                              <1> ; Last Modification: 22/08/2015
  2915                              <1> ; 	(Initialized Disk Parameters Data is in 'DISKDATA.INC') 
  2916                              <1> ; 	(Uninitialized Disk Parameters Data is in 'DISKBSS.INC') 
  2917                              <1> 
  2918                              <1> ; DISK I/O SYSTEM - Erdogan Tan (Retro UNIX 386 v1 project)
  2919                              <1> 
  2920                              <1> ; ///////// DISK I/O SYSTEM ///////////////
  2921                              <1> 
  2922                              <1> ; 06/02/2015
  2923                              <1> diskette_io:
  2924 00004378 F8                  <1> 	clc ; 20/07/2020
  2925 00004379 9C                  <1> 	pushfd
  2926 0000437A 0E                  <1> 	push 	cs
  2927 0000437B E809000000          <1> 	call 	DISKETTE_IO_1
  2928 00004380 C3                  <1> 	retn
  2929                              <1> 	
  2930                              <1> ;;;;;; DISKETTE I/O ;;;;;;;;;;;;;;;;;;;; 06/02/2015 ;;;
  2931                              <1> ;//////////////////////////////////////////////////////
  2932                              <1> 
  2933                              <1> ; DISKETTE I/O - Erdogan Tan (Retro UNIX 386 v1 project)
  2934                              <1> ; 20/02/2015
  2935                              <1> ; 06/02/2015 (unix386.s)
  2936                              <1> ; 16/12/2014 - 02/01/2015 (dsectrm2.s)
  2937                              <1> ;
  2938                              <1> ; Code (DELAY) modifications - AWARD BIOS 1999 (ADISK.EQU, COMMON.MAC)
  2939                              <1> ;
  2940                              <1> ; ADISK.EQU
  2941                              <1> 
  2942                              <1> ;----- Wait control constants 
  2943                              <1> 
  2944                              <1> ;amount of time to wait while RESET is active.
  2945                              <1> 
  2946                              <1> WAITCPU_RESET_ON	EQU	21		;Reset on must last at least 14us
  2947                              <1> 						;at 250 KBS xfer rate.
  2948                              <1> 						;see INTEL MCS, 1985, pg. 5-456
  2949                              <1> 
  2950                              <1> WAITCPU_FOR_STATUS	EQU	100		;allow 30 microseconds for
  2951                              <1> 						;status register to become valid
  2952                              <1> 						;before re-reading.
  2953                              <1> 
  2954                              <1> ;After sending a byte to NEC, status register may remain
  2955                              <1> ;incorrectly set for 24 us.
  2956                              <1> 
  2957                              <1> WAITCPU_RQM_LOW		EQU	24		;number of loops to check for
  2958                              <1> 						;RQM low.
  2959                              <1> 
  2960                              <1> ; COMMON.MAC
  2961                              <1> ;
  2962                              <1> ;	Timing macros
  2963                              <1> ;
  2964                              <1> 
  2965                              <1> %macro 		SIODELAY 0 			; SHORT IODELAY
  2966                              <1> 		jmp short $+2
  2967                              <1> %endmacro		
  2968                              <1> 
  2969                              <1> %macro		IODELAY  0			; NORMAL IODELAY
  2970                              <1> 		jmp short $+2
  2971                              <1> 		jmp short $+2
  2972                              <1> %endmacro
  2973                              <1> 
  2974                              <1> %macro		NEWIODELAY 0
  2975                              <1> 		out	0ebh,al
  2976                              <1> %endmacro 
  2977                              <1> 
  2978                              <1> ; (According to) AWARD BIOS 1999 - ATORGS.ASM (dw -> equ, db -> equ)
  2979                              <1> ;;; WAIT_FOR_MEM
  2980                              <1> ;WAIT_FDU_INT_LO	equ	017798		; 2.5 secs in 30 micro units.
  2981                              <1> ;WAIT_FDU_INT_HI	equ	1
  2982                              <1> WAIT_FDU_INT_LH		equ	83334		; 27/02/2015 (2.5 seconds waiting)
  2983                              <1> ;;; WAIT_FOR_PORT
  2984                              <1> ;WAIT_FDU_SEND_LO	equ	16667		; .5 secons in 30 us units.
  2985                              <1> ;WAIT_FDU_SEND_HI	equ	0
  2986                              <1> WAIT_FDU_SEND_LH	equ 	16667		; 27/02/2015	
  2987                              <1> ;Time to wait while waiting for each byte of NEC results = .5
  2988                              <1> ;seconds.  .5 seconds = 500,000 micros.  500,000/30 = 16,667.
  2989                              <1> ;WAIT_FDU_RESULTS_LO	equ	16667		; .5 seconds in 30 micro units.
  2990                              <1> ;WAIT_FDU_RESULTS_HI	equ	0
  2991                              <1> WAIT_FDU_RESULTS_LH	equ	16667  ; 27/02/2015
  2992                              <1> ;;; WAIT_REFRESH
  2993                              <1> ;amount of time to wait for head settle, per unit in parameter
  2994                              <1> ;table = 1 ms.
  2995                              <1> WAIT_FDU_HEAD_SETTLE	equ	33		; 1 ms in 30 micro units.
  2996                              <1> 
  2997                              <1> 
  2998                              <1> ; //////////////// DISKETTE I/O ////////////////
  2999                              <1> 
  3000                              <1> ; 11/12/2014 (copy from IBM PC-XT Model 286 BIOS - POSTEQU.INC)
  3001                              <1> 
  3002                              <1> ;----------------------------------------
  3003                              <1> ;	EQUATES USED BY POST AND BIOS	:
  3004                              <1> ;----------------------------------------
  3005                              <1> 
  3006                              <1> ;--------- 8042 KEYBOARD INTERFACE AND DIAGNOSTIC CONTROL REGISTERS ------------
  3007                              <1> ;PORT_A		EQU	060H		; 8042 KEYBOARD SCAN CODE/CONTROL PORT
  3008                              <1> ;PORT_B		EQU	061H		; PORT B READ/WRITE DIAGNOSTIC REGISTER
  3009                              <1> ;REFRESH_BIT	EQU	00010000B	; REFRESH TEST BIT
  3010                              <1> 
  3011                              <1> ;----------------------------------------
  3012                              <1> ;	CMOS EQUATES FOR THIS SYSTEM	:
  3013                              <1> ;-------------------------------------------------------------------------------
  3014                              <1> ;CMOS_PORT	EQU	070H		; I/O ADDRESS OF CMOS ADDRESS PORT
  3015                              <1> ;CMOS_DATA	EQU	071H		; I/O ADDRESS OF CMOS DATA PORT
  3016                              <1> ;NMI		EQU	10000000B	; DISABLE NMI INTERRUPTS MASK -
  3017                              <1> 					;  HIGH BIT OF CMOS LOCATION ADDRESS
  3018                              <1> 
  3019                              <1> ;---------- CMOS TABLE LOCATION ADDRESS'S ## -----------------------------------
  3020                              <1> CMOS_DISKETTE	EQU	010H		; DISKETTE DRIVE TYPE BYTE	      ;
  3021                              <1> ;		EQU	011H		; - RESERVED			      ;C
  3022                              <1> CMOS_DISK	EQU	012H		; FIXED DISK TYPE BYTE		      ;H
  3023                              <1> ;		EQU	013H		; - RESERVED			      ;E
  3024                              <1> CMOS_EQUIP	EQU	014H		; EQUIPMENT WORD LOW BYTE	      ;C
  3025                              <1> 
  3026                              <1> ;---------- DISKETTE EQUATES ---------------------------------------------------
  3027                              <1> INT_FLAG	EQU	10000000B	; INTERRUPT OCCURRENCE FLAG
  3028                              <1> DSK_CHG 	EQU	10000000B	; DISKETTE CHANGE FLAG MASK BIT
  3029                              <1> DETERMINED	EQU	00010000B	; SET STATE DETERMINED IN STATE BITS
  3030                              <1> HOME		EQU	00010000B	; TRACK 0 MASK
  3031                              <1> SENSE_DRV_ST	EQU	00000100B	; SENSE DRIVE STATUS COMMAND
  3032                              <1> TRK_SLAP	EQU	030H		; CRASH STOP (48 TPI DRIVES)
  3033                              <1> QUIET_SEEK	EQU	00AH		; SEEK TO TRACK 10
  3034                              <1> ;MAX_DRV 	EQU	2		; MAX NUMBER OF DRIVES
  3035                              <1> HD12_SETTLE	EQU	15		; 1.2 M HEAD SETTLE TIME
  3036                              <1> HD320_SETTLE	EQU	20		; 320 K HEAD SETTLE TIME
  3037                              <1> MOTOR_WAIT	EQU	37		; 2 SECONDS OF COUNTS FOR MOTOR TURN OFF
  3038                              <1> 
  3039                              <1> ;---------- DISKETTE ERRORS ----------------------------------------------------
  3040                              <1> ;TIME_OUT	EQU	080H		; ATTACHMENT FAILED TO RESPOND
  3041                              <1> ;BAD_SEEK	EQU	040H		; SEEK OPERATION FAILED
  3042                              <1> BAD_NEC 	EQU	020H		; DISKETTE CONTROLLER HAS FAILED
  3043                              <1> BAD_CRC 	EQU	010H		; BAD CRC ON DISKETTE READ
  3044                              <1> MED_NOT_FND	EQU	00CH		; MEDIA TYPE NOT FOUND
  3045                              <1> DMA_BOUNDARY	EQU	009H		; ATTEMPT TO DMA ACROSS 64K BOUNDARY
  3046                              <1> BAD_DMA 	EQU	008H		; DMA OVERRUN ON OPERATION
  3047                              <1> MEDIA_CHANGE	EQU	006H		; MEDIA REMOVED ON DUAL ATTACH CARD
  3048                              <1> RECORD_NOT_FND	EQU	004H		; REQUESTED SECTOR NOT FOUND
  3049                              <1> WRITE_PROTECT	EQU	003H		; WRITE ATTEMPTED ON WRITE PROTECT DISK
  3050                              <1> BAD_ADDR_MARK	EQU	002H		; ADDRESS MARK NOT FOUND
  3051                              <1> BAD_CMD 	EQU	001H		; BAD COMMAND PASSED TO DISKETTE I/O
  3052                              <1> 
  3053                              <1> ;---------- DISK CHANGE LINE EQUATES -------------------------------------------
  3054                              <1> NOCHGLN 	EQU	001H		; NO DISK CHANGE LINE AVAILABLE
  3055                              <1> CHGLN		EQU	002H		; DISK CHANGE LINE AVAILABLE
  3056                              <1> 
  3057                              <1> ;---------- MEDIA/DRIVE STATE INDICATORS ---------------------------------------
  3058                              <1> TRK_CAPA	EQU	00000001B	; 80 TRACK CAPABILITY
  3059                              <1> FMT_CAPA	EQU	00000010B	; MULTIPLE FORMAT CAPABILITY (1.2M)
  3060                              <1> DRV_DET 	EQU	00000100B	; DRIVE DETERMINED
  3061                              <1> MED_DET 	EQU	00010000B	; MEDIA DETERMINED BIT
  3062                              <1> DBL_STEP	EQU	00100000B	; DOUBLE STEP BIT
  3063                              <1> RATE_MSK	EQU	11000000B	; MASK FOR CLEARING ALL BUT RATE
  3064                              <1> RATE_500	EQU	00000000B	; 500 KBS DATA RATE
  3065                              <1> RATE_300	EQU	01000000B	; 300 KBS DATA RATE
  3066                              <1> RATE_250	EQU	10000000B	; 250 KBS DATA RATE
  3067                              <1> STRT_MSK	EQU	00001100B	; OPERATION START RATE MASK
  3068                              <1> SEND_MSK	EQU	11000000B	; MASK FOR SEND RATE BITS
  3069                              <1> 
  3070                              <1> ;---------- MEDIA/DRIVE STATE INDICATORS COMPATIBILITY -------------------------
  3071                              <1> M3D3U		EQU	00000000B	; 360 MEDIA/DRIVE NOT ESTABLISHED
  3072                              <1> M3D1U		EQU	00000001B	; 360 MEDIA,1.2DRIVE NOT ESTABLISHED
  3073                              <1> M1D1U		EQU	00000010B	; 1.2 MEDIA/DRIVE NOT ESTABLISHED
  3074                              <1> MED_UNK 	EQU	00000111B	; NONE OF THE ABOVE
  3075                              <1> 
  3076                              <1> ;---------- INTERRUPT EQUATES --------------------------------------------------
  3077                              <1> ;EOI		EQU	020H		; END OF INTERRUPT COMMAND TO 8259
  3078                              <1> ;INTA00		EQU	020H		; 8259 PORT
  3079                              <1> INTA01		EQU	021H		; 8259 PORT
  3080                              <1> INTB00		EQU	0A0H		; 2ND 8259
  3081                              <1> INTB01		EQU	0A1H		;
  3082                              <1> 
  3083                              <1> ;-------------------------------------------------------------------------------
  3084                              <1> DMA08		EQU	008H		; DMA STATUS REGISTER PORT ADDRESS
  3085                              <1> DMA		EQU	000H		; DMA CH.0 ADDRESS REGISTER PORT ADDRESS
  3086                              <1> DMA18		EQU	0D0H		; 2ND DMA STATUS PORT ADDRESS
  3087                              <1> DMA1		EQU	0C0H		; 2ND DMA CH.0 ADDRESS REGISTER ADDRESS
  3088                              <1> ;-------------------------------------------------------------------------------
  3089                              <1> ;TIMER		EQU	040H		; 8254 TIMER - BASE ADDRESS
  3090                              <1> 
  3091                              <1> ;-------------------------------------------------------------------------------
  3092                              <1> DMA_PAGE	EQU	081H		; START OF DMA PAGE REGISTERS
  3093                              <1> 
  3094                              <1> ; 06/02/2015 (unix386.s, protected mode modifications)
  3095                              <1> ; (unix386.s <-- dsectrm2.s)
  3096                              <1> ; 11/12/2014 (copy from IBM PC-XT Model 286 BIOS - DSEG.INC)
  3097                              <1> 
  3098                              <1> ; 27/05/2016 - TRDOS 386 (TRDOS v2.0)
  3099                              <1> ; 10/12/2014
  3100                              <1> ;
  3101                              <1> ;int40h:
  3102                              <1> ;	pushf
  3103                              <1> ;	push 	cs
  3104                              <1> ;	;cli
  3105                              <1> ;	call 	DISKETTE_IO_1
  3106                              <1> ;	retn
  3107                              <1> 
  3108                              <1> ; DSKETTE ----- 04/21/86 DISKETTE BIOS
  3109                              <1> ; (IBM PC XT Model 286 System BIOS Source Code, 04-21-86)
  3110                              <1> ;
  3111                              <1> 
  3112                              <1> ;-- INT13H ---------------------------------------------------------------------
  3113                              <1> ; DISKETTE I/O
  3114                              <1> ;	THIS INTERFACE PROVIDES ACCESS TO THE 5 1/4 INCH 360 KB,
  3115                              <1> ;	1.2 MB, 720 KB AND 1.44 MB DISKETTE DRIVES.
  3116                              <1> ; INPUT
  3117                              <1> ;	(AH) =  00H RESET DISKETTE SYSTEM
  3118                              <1> ;		HARD RESET TO NEC, PREPARE COMMAND, RECALIBRATE REQUIRED
  3119                              <1> ;		ON ALL DRIVES
  3120                              <1> ;------------------------------------------------------------------------------- 
  3121                              <1> ;	(AH)= 01H  READ THE STATUS OF THE SYSTEM INTO (AH)
  3122                              <1> ;		@DISKETTE_STATUS FROM LAST OPERATION IS USED
  3123                              <1> ;-------------------------------------------------------------------------------
  3124                              <1> ;	REGISTERS FOR READ/WRITE/VERIFY/FORMAT
  3125                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED)
  3126                              <1> ;	(DH) - HEAD NUMBER (0-1 ALLOWED, NOT VALUE CHECKED)
  3127                              <1> ;	(CH) - TRACK NUMBER (NOT VALUE CHECKED)
  3128                              <1> ;		MEDIA	DRIVE	TRACK NUMBER
  3129                              <1> ;		320/360	320/360	    0-39
  3130                              <1> ;		320/360	1.2M	    0-39
  3131                              <1> ;		1.2M	1.2M	    0-79
  3132                              <1> ;		720K	720K	    0-79
  3133                              <1> ;		1.44M	1.44M	    0-79	
  3134                              <1> ;	(CL) - 	SECTOR NUMBER (NOT VALUE CHECKED, NOT USED FOR FORMAT)
  3135                              <1> ;		MEDIA	DRIVE	SECTOR NUMBER
  3136                              <1> ;		320/360	320/360	     1-8/9
  3137                              <1> ;		320/360	1.2M	     1-8/9
  3138                              <1> ;		1.2M	1.2M	     1-15
  3139                              <1> ;		720K	720K	     1-9
  3140                              <1> ;		1.44M	1.44M	     1-18		
  3141                              <1> ;	(AL)	NUMBER OF SECTORS (NOT VALUE CHECKED)
  3142                              <1> ;		MEDIA	DRIVE	MAX NUMBER OF SECTORS
  3143                              <1> ;		320/360	320/360	        8/9
  3144                              <1> ;		320/360	1.2M	        8/9
  3145                              <1> ;		1.2M	1.2M		15
  3146                              <1> ;		720K	720K		9
  3147                              <1> ;		1.44M	1.44M		18
  3148                              <1> ;
  3149                              <1> ;	(ES:BX) - ADDRESS OF BUFFER (NOT REQUIRED FOR VERIFY)
  3150                              <1> ;
  3151                              <1> ;-------------------------------------------------------------------------------
  3152                              <1> ;	(AH)= 02H  READ THE DESIRED SECTORS INTO MEMORY
  3153                              <1> ;-------------------------------------------------------------------------------
  3154                              <1> ;	(AH)= 03H  WRITE THE DESIRED SECTORS FROM MEMORY
  3155                              <1> ;-------------------------------------------------------------------------------
  3156                              <1> ;	(AH)= 04H  VERIFY THE DESIRED SECTORS
  3157                              <1> ;-------------------------------------------------------------------------------
  3158                              <1> ;	(AH)= 05H  FORMAT THE DESIRED TRACK
  3159                              <1> ;		(ES,BX) MUST POINT TO THE COLLECTION OF DESIRED ADDRESS FIELDS
  3160                              <1> ;		FOR THE	TRACK. EACH FIELD IS COMPOSED OF 4 BYTES, (C,H,R,N),
  3161                              <1> ;		WHERE C = TRACK NUMBER, H=HEAD NUMBER, R = SECTOR NUMBER, 
  3162                              <1> ;		N= NUMBER OF BYTES PER SECTOR (00=128,01=256,02=512,03=1024),
  3163                              <1> ;		THERE MUST BE ONE ENTRY FOR EVERY SECTOR ON THE TRACK.
  3164                              <1> ;		THIS INFORMATION IS USED TO FIND THE REQUESTED SECTOR DURING 
  3165                              <1> ;		READ/WRITE ACCESS.
  3166                              <1> ;		PRIOR TO FORMATTING A DISKETTE, IF THERE EXISTS MORE THAN
  3167                              <1> ;		ONE SUPPORTED MEDIA FORMAT TYPE WITHIN THE DRIVE IN QUESTION,
  3168                              <1> ;		THEN "SET DASD TYPE" (INT 13H, AH = 17H) OR 'SET MEDIA TYPE'
  3169                              <1> ;		(INT 13H, AH =  18H) MUST BE CALLED TO SET THE DISKETTE TYPE
  3170                              <1> ;		THAT IS TO BE FORMATTED. IF "SET DASD TYPE" OR "SET MEDIA TYPE"
  3171                              <1> ;		IS NOT CALLED, THE FORMAT ROUTINE WILL ASSUME THE 
  3172                              <1> ;		MEDIA FORMAT TO BE THE MAXIMUM CAPACITY OF THE DRIVE.
  3173                              <1> ;
  3174                              <1> ;		THESE PARAMETERS OF DISK BASE MUST BE CHANGED IN ORDER TO
  3175                              <1> ;		FORMAT THE FOLLOWING MEDIAS:
  3176                              <1> ;		---------------------------------------------
  3177                              <1> ;		: MEDIA  :     DRIVE      : PARM 1 : PARM 2 :
  3178                              <1> ;		---------------------------------------------
  3179                              <1> ;		: 320K	 : 320K/360K/1.2M :  50H   :   8    :
  3180                              <1> ;		: 360K	 : 320K/360K/1.2M :  50H   :   9    :
  3181                              <1> ;		: 1.2M	 : 1.2M           :  54H   :  15    :
  3182                              <1> ;		: 720K	 : 720K/1.44M     :  50H   :   9    :
  3183                              <1> ;		: 1.44M	 : 1.44M          :  6CH   :  18    :		  	
  3184                              <1> ;		---------------------------------------------
  3185                              <1> ;		NOTES: - PARM 1 = GAP LENGTH FOR FORMAT
  3186                              <1> ;		       - PARM 2 = EOT (LAST SECTOR ON TRACK)
  3187                              <1> ;		       - DISK BASE IS POINTED BY DISK POINTER LOCATED
  3188                              <1> ;			 AT ABSOLUTE ADDRESS 0:78.
  3189                              <1> ;		       - WHEN FORMAT OPERATIONS ARE COMPLETE, THE PARAMETERS
  3190                              <1> ;			 SHOULD BE RESTORED TO THEIR RESPECTIVE INITIAL VALUES.			
  3191                              <1> ;-------------------------------------------------------------------------------
  3192                              <1> ;	(AH) = 08H READ DRIVE PARAMETERS
  3193                              <1> ;	REGISTERS
  3194                              <1> ;	  INPUT
  3195                              <1> ;	    (DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED)
  3196                              <1> ;	     ** 27/05/2016 - TRDOS 386 (TRDOS v2.0) **	
  3197                              <1> ;            ** EBX = Buffer address for floppy disk parameters table **
  3198                              <1> ;	  OUTPUT
  3199                              <1> ;	    (ES:DI) POINTS TO DRIVE PARAMETER TABLE
  3200                              <1> ; 	    *** TRDOS 386 note: floppy disk parameter table (16 bytes)
  3201                              <1> ;	    will be returned to user in EBX, buffer address *** 27/05/2016 ***		
  3202                              <1> ;					
  3203                              <1> ;	    (CH) - LOW ORDER 8 OF 10 BITS MAXIMUM NUMBER OF TRACKS
  3204                              <1> ;	    (CL) - BITS 7 & 6 - HIGH ORDER TWO BITS OF MAXIMUM TRACKS
  3205                              <1> ;	           BITS 5 THRU 0 - MAXIMUM SECTORS PER TRACK
  3206                              <1> ;	    (DH) - MAXIMUM HEAD NUMBER
  3207                              <1> ;	    (DL) - NUMBER OF DISKETTE DRIVES INSTALLED
  3208                              <1> ;	    (BH) - 0
  3209                              <1> ;	    (BL) - BITS 7 THRU 4 - 0
  3210                              <1> ;	           BITS 3 THRU 0 - VALID DRIVE TYPE VALUE IN CMOS
  3211                              <1> ;	    (AX) - 0
  3212                              <1> ;	 UNDER THE FOLLOWING CIRCUMSTANCES:
  3213                              <1> ;	    (1) THE DRIVE NUMBER IS INVALID,
  3214                              <1> ;	    (2) THE DRIVE TYPE IS UNKNOWN AND CMOS IS NOT PRESENT, 
  3215                              <1> ;	    (3) THE DRIVE TYPE IS UNKNOWN AND CMOS IS BAD,
  3216                              <1> ;	    (4) OR THE DRIVE TYPE IS UNKNOWN AND THE CMOS DRIVE TYPE IS INVALID
  3217                              <1> ;	    THEN ES,AX,BX,CX,DH,DI=0 ; DL=NUMBER OF DRIVES. 
  3218                              <1> ;	    IF NO DRIVES ARE PRESENT THEN: ES,AX,BX,CX,DX,DI=0.
  3219                              <1> ;	    @DISKETTE_STATUS = 0 AND CY IS RESET.
  3220                              <1> ;-------------------------------------------------------------------------------
  3221                              <1> ;	(AH)= 15H  READ DASD TYPE
  3222                              <1> ;	OUTPUT REGISTERS
  3223                              <1> ;	(AH) - ON RETURN IF CARRY FLAG NOT SET, OTHERWISE ERROR	
  3224                              <1> ;		00 - DRIVE NOT PRESENT	
  3225                              <1> ;		01 - DISKETTE, NO CHANGE LINE AVAILABLE
  3226                              <1> ;		02 - DISKETTE, CHANGE LINE AVAILABLE	
  3227                              <1> ;		03 - RESERVED (FIXED DISK)
  3228                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED)
  3229                              <1> ;-------------------------------------------------------------------------------
  3230                              <1> ;	(AH)= 16H  DISK CHANGE LINE STATUS
  3231                              <1> ;	OUTPUT REGISTERS
  3232                              <1> ;	(AH) - 00 - DISK CHANGE LINE NOT ACTIVE	
  3233                              <1> ;	       06 - DISK CHANGE LINE ACTIVE & CARRY BIT ON
  3234                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED)
  3235                              <1> ;-------------------------------------------------------------------------------
  3236                              <1> ;	(AH)= 17H  SET DASD TYPE FOR FORMAT
  3237                              <1> ;	INPUT REGISTERS
  3238                              <1> ;	(AL) -	00 - NOT USED	
  3239                              <1> ;		01 - DISKETTE 320/360K IN 360K DRIVE	
  3240                              <1> ;		02 - DISKETTE 360K IN 1.2M DRIVE
  3241                              <1> ;		03 - DISKETTE 1.2M IN 1.2M DRIVE
  3242                              <1> ;		04 - DISKETTE 720K IN 720K DRIVE
  3243                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED:
  3244                              <1> ;	       (DO NOT USE WHEN DISKETTE ATTACH CARD USED)
  3245                              <1> ;-------------------------------------------------------------------------------
  3246                              <1> ;	(AH)= 18H  SET MEDIA TYPE FOR FORMAT
  3247                              <1> ;	INPUT REGISTERS
  3248                              <1> ;	(CH) - LOW ORDER 8 OF 10 BITS MAXIMUM TRACKS
  3249                              <1> ;	(CL) - BITS 7 & 6 - HIGH ORDER TWO BITS OF MAXIMUM TRACKS
  3250                              <1> ;	       BITS 5 THRU 0 - MAXIMUM SECTORS PER TRACK
  3251                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHACKED)
  3252                              <1> ;	OUTPUT REGISTERS:
  3253                              <1> ;	(ES:DI) - POINTER TO DRIVE PARAMETERS TABLE FOR THIS MEDIA TYPE,
  3254                              <1> ;		  UNCHANGED IF (AH) IS NON-ZERO
  3255                              <1> ;	(AH) - 00H, CY = 0, TRACK AND SECTORS/TRACK COMBINATION IS SUPPORTED
  3256                              <1> ;	     - 01H, CY = 1, FUNCTION IS NOT AVAILABLE
  3257                              <1> ;	     - 0CH, CY = 1, TRACK AND SECTORS/TRACK COMBINATION IS NOT SUPPORTED
  3258                              <1> ;	     - 80H, CY = 1, TIME OUT (DISKETTE NOT PRESENT)		
  3259                              <1> ;-------------------------------------------------------------------------------
  3260                              <1> ;	DISK CHANGE STATUS IS ONLY CHECKED WHEN A MEDIA SPECIFIED IS OTHER
  3261                              <1> ;	THAN 360 KB DRIVE. IF THE DISK CHANGE LINE IS FOUND TO BE
  3262                              <1> ;	ACTIVE THE FOLLOWING ACTIONS TAKE PLACE:
  3263                              <1> ;		ATTEMPT TO RESET DISK CHANGE LINE TO INACTIVE STATE. 
  3264                              <1> ;		IF ATTEMPT SUCCEEDS SET DASD TYPE FOR FORMAT AND RETURN DISK 
  3265                              <1> ;		CHANGE ERROR CODE
  3266                              <1> ;		IF ATTEMPT FAILS RETURN TIMEOUT ERROR CODE AND SET DASD TYPE 
  3267                              <1> ;		TO A PREDETERMINED STATE INDICATING MEDIA TYPE UNKNOWN.
  3268                              <1> ;	IF THE DISK CHANGE LINE IN INACTIVE PERFORM SET DASD TYPE FOR FORMAT.
  3269                              <1> ;
  3270                              <1> ; DATA VARIABLE -- @DISK_POINTER
  3271                              <1> ;	DOUBLE WORD POINTER TO THE CURRENT SET OF DISKETTE PARAMETERS
  3272                              <1> ;-------------------------------------------------------------------------------
  3273                              <1> ; OUTPUT FOR ALL FUNCTIONS
  3274                              <1> ;	AH = STATUS OF OPERATION
  3275                              <1> ;		STATUS BITS ARE DEFINED IN THE EQUATES FOR @DISKETTE_STATUS
  3276                              <1> ;		VARIABLE IN THE DATA SEGMENT OF THIS MODULE
  3277                              <1> ;	CY = 0	SUCCESSFUL OPERATION (AH=0 ON RETURN, EXCEPT FOR READ DASD
  3278                              <1> ;		TYPE AH=(15)).
  3279                              <1> ;	CY = 1	FAILED OPERATION (AH HAS ERROR REASON)
  3280                              <1> ;	FOR READ/WRITE/VERIFY
  3281                              <1> ;		DS,BX,DX,CX PRESERVED
  3282                              <1> ;	NOTE: IF AN ERROR IS REPORTED BY THE DISKETTE CODE, THE APPROPRIATE 
  3283                              <1> ;		ACTION IS TO RESET THE DISKETTE, THEN RETRY THE OPERATION.
  3284                              <1> ;		ON READ ACCESSES, NO MOTOR START DELAY IS TAKEN, SO THAT 
  3285                              <1> ;		THREE RETRIES ARE REQUIRED ON READS TO ENSURE THAT THE 
  3286                              <1> ;		PROBLEM IS NOT DUE TO MOTOR START-UP.
  3287                              <1> ;-------------------------------------------------------------------------------
  3288                              <1> ;
  3289                              <1> ; DISKETTE STATE MACHINE - ABSOLUTE ADDRESS 40:90 (DRIVE A) & 91 (DRIVE B)
  3290                              <1> ;
  3291                              <1> ;   -----------------------------------------------------------------
  3292                              <1> ;   |       |       |       |       |       |       |       |       |
  3293                              <1> ;   |   7   |   6   |   5   |   4   |   3   |   2   |   1   |   0   |
  3294                              <1> ;   |       |       |       |       |       |       |       |       |
  3295                              <1> ;   -----------------------------------------------------------------
  3296                              <1> ;	|	|	|	|	|	|	|	|
  3297                              <1> ;	|	|	|	|	|	-----------------
  3298                              <1> ;	|	|	|	|	|		|
  3299                              <1> ;	|	|	|	|    RESERVED		|
  3300                              <1> ;	|	|	|	|		  PRESENT STATE
  3301                              <1> ;	|	|	|	|	000: 360K IN 360K DRIVE UNESTABLISHED
  3302                              <1> ;	|	|	|	|	001: 360K IN 1.2M DRIVE UNESTABLISHED
  3303                              <1> ;	|	|	|	|	010: 1.2M IN 1.2M DRIVE UNESTABLISHED
  3304                              <1> ;	|	|	|	|	011: 360K IN 360K DRIVE ESTABLISHED
  3305                              <1> ;	|	|	|	|	100: 360K IN 1.2M DRIVE ESTABLISHED
  3306                              <1> ;	|	|	|	|	101: 1.2M IN 1.2M DRIVE ESTABLISHED
  3307                              <1> ;	|	|	|	|	110: RESERVED
  3308                              <1> ;	|	|	|	|	111: NONE OF THE ABOVE
  3309                              <1> ;	|	|	|	|
  3310                              <1> ;	|	|	|	------>	MEDIA/DRIVE ESTABLISHED
  3311                              <1> ;	|	|	|
  3312                              <1> ;	|	|	-------------->	DOUBLE STEPPING REQUIRED (360K IN 1.2M
  3313                              <1> ;	|	|			DRIVE)
  3314                              <1> ;	|	|
  3315                              <1> ;	------------------------------>	DATA TRANSFER RATE FOR THIS DRIVE:
  3316                              <1> ;
  3317                              <1> ;						00: 500 KBS
  3318                              <1> ;						01: 300 KBS
  3319                              <1> ;						10: 250 KBS
  3320                              <1> ;						11: RESERVED
  3321                              <1> ;
  3322                              <1> ;
  3323                              <1> ;-------------------------------------------------------------------------------
  3324                              <1> ; STATE OPERATION STARTED - ABSOLUTE ADDRESS 40:92 (DRIVE A) & 93 (DRIVE B)
  3325                              <1> ;-------------------------------------------------------------------------------
  3326                              <1> ; PRESENT CYLINDER NUMBER - ABSOLUTE ADDRESS 40:94 (DRIVE A) & 95 (DRIVE B)
  3327                              <1> ;-------------------------------------------------------------------------------
  3328                              <1> 
  3329                              <1> struc MD
  3330 00000000 ??                  <1> 	.SPEC1		resb	1	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
  3331 00000001 ??                  <1> 	.SPEC2		resb	1	; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
  3332 00000002 ??                  <1> 	.OFF_TIM	resb	1	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
  3333 00000003 ??                  <1> 	.BYT_SEC	resb	1	; 512 BYTES/SECTOR
  3334 00000004 ??                  <1> 	.SEC_TRK	resb	1	; EOT (LAST SECTOR ON TRACK)
  3335 00000005 ??                  <1> 	.GAP		resb	1	; GAP LENGTH
  3336 00000006 ??                  <1> 	.DTL		resb	1	; DTL
  3337 00000007 ??                  <1> 	.GAP3		resb	1	; GAP LENGTH FOR FORMAT
  3338 00000008 ??                  <1> 	.FIL_BYT	resb	1	; FILL BYTE FOR FORMAT
  3339 00000009 ??                  <1> 	.HD_TIM		resb	1	; HEAD SETTLE TIME (MILLISECONDS)
  3340 0000000A ??                  <1> 	.STR_TIM	resb	1	; MOTOR START TIME (1/8 SECONDS)
  3341 0000000B ??                  <1> 	.MAX_TRK	resb	1	; MAX. TRACK NUMBER
  3342 0000000C ??                  <1> 	.RATE		resb	1	; DATA TRANSFER RATE
  3343                              <1> endstruc
  3344                              <1> 
  3345                              <1> BIT7OFF	EQU	7FH
  3346                              <1> BIT7ON	EQU	80H
  3347                              <1> 
  3348                              <1> ; 30/08/2020 - TRDOS 386 v2
  3349                              <1> 
  3350                              <1> ;;int13h: ; 16/02/2015
  3351                              <1> ;; 16/02/2015 - 21/02/2015
  3352                              <1> int40h:
  3353 00004381 9C                  <1> 	pushfd
  3354 00004382 0E                  <1> 	push 	cs
  3355 00004383 E801000000          <1> 	call 	DISKETTE_IO_1
  3356 00004388 C3                  <1> 	retn	
  3357                              <1> 
  3358                              <1> DISKETTE_IO_1:
  3359                              <1> 
  3360 00004389 FB                  <1> 	STI				; INTERRUPTS BACK ON
  3361 0000438A 55                  <1> 	PUSH	eBP			; USER REGISTER
  3362 0000438B 57                  <1> 	PUSH	eDI			; USER REGISTER
  3363 0000438C 52                  <1> 	PUSH	eDX			; HEAD #, DRIVE # OR USER REGISTER
  3364 0000438D 53                  <1> 	PUSH	eBX			; BUFFER OFFSET PARAMETER OR REGISTER
  3365 0000438E 51                  <1> 	PUSH	eCX			; TRACK #-SECTOR # OR USER REGISTER
  3366 0000438F 89E5                <1> 	MOV	eBP,eSP			; BP     => PARAMETER LIST DEP. ON AH
  3367                              <1> 					; [BP]   = SECTOR #
  3368                              <1> 					; [BP+1] = TRACK #
  3369                              <1> 					; [BP+2] = BUFFER OFFSET
  3370                              <1> 					; FOR RETURN OF DRIVE PARAMETERS:
  3371                              <1> 					; CL/[BP] = BITS 7&6 HI BITS OF MAX CYL
  3372                              <1> 					; 	    BITS 0-5 MAX SECTORS/TRACK
  3373                              <1> 					; CH/[BP+1] = LOW 8 BITS OF MAX CYL.
  3374                              <1> 					; BL/[BP+2] = BITS 7-4 = 0
  3375                              <1> 					;	      BITS 3-0 = VALID CMOS TYPE
  3376                              <1> 					; BH/[BP+3] = 0
  3377                              <1> 					; DL/[BP+4] = # DRIVES INSTALLED
  3378                              <1> 					; DH/[BP+5] = MAX HEAD #
  3379                              <1> 					; DI/[BP+6] = OFFSET TO DISK BASE
  3380 00004391 06                  <1> 	push	es ; 06/02/2015	
  3381 00004392 1E                  <1> 	PUSH	DS			; BUFFER SEGMENT PARM OR USER REGISTER
  3382 00004393 56                  <1> 	PUSH	eSI			; USER REGISTERS
  3383                              <1> 	;CALL	DDS			; SEGMENT OF BIOS DATA AREA TO DS
  3384                              <1> 	;mov	cx, cs
  3385                              <1> 	;mov	ds, cx
  3386 00004394 66B91000            <1> 	mov	cx, KDATA
  3387 00004398 8ED9                <1>         mov     ds, cx
  3388 0000439A 8EC1                <1>         mov     es, cx
  3389                              <1> 
  3390                              <1> 	;CMP	AH,(FNC_TAE-FNC_TAB)/2	; CHECK FOR > LARGEST FUNCTION
  3391 0000439C 80FC19              <1> 	cmp	ah,(FNC_TAE-FNC_TAB)/4  ; 18/02/2015
  3392 0000439F 7202                <1> 	JB	short OK_FUNC		; FUNCTION OK
  3393 000043A1 B414                <1> 	MOV	AH,14H			; REPLACE WITH KNOWN INVALID FUNCTION
  3394                              <1> OK_FUNC:
  3395 000043A3 80FC01              <1> 	CMP	AH,1			; RESET OR STATUS ?
  3396 000043A6 760C                <1> 	JBE	short OK_DRV		; IF RESET OR STATUS DRIVE ALWAYS OK
  3397 000043A8 80FC08              <1> 	CMP	AH,8			; READ DRIVE PARMS ?
  3398 000043AB 7407                <1> 	JZ	short OK_DRV		; IF SO DRIVE CHECKED LATER
  3399 000043AD 80FA01              <1> 	CMP	DL,1			; DRIVES 0 AND 1 OK
  3400 000043B0 7602                <1> 	JBE	short OK_DRV		; IF 0 OR 1 THEN JUMP
  3401 000043B2 B414                <1> 	MOV	AH,14H			; REPLACE WITH KNOWN INVALID FUNCTION
  3402                              <1> OK_DRV:
  3403 000043B4 31C9                <1> 	xor	ecx, ecx
  3404                              <1> 	;mov	esi, ecx ; 08/02/2015
  3405 000043B6 89CF                <1> 	mov	edi, ecx ; 08/02/2015
  3406 000043B8 88E1                <1> 	MOV	CL,AH			; CL = FUNCTION
  3407                              <1> 	;XOR	CH,CH			; CX = FUNCTION
  3408                              <1> 	;SHL	CL, 1			; FUNCTION TIMES 2
  3409 000043BA C0E102              <1> 	SHL	CL, 2 ; 20/02/2015	; FUNCTION TIMES 4 (for 32 bit offset)
  3410 000043BD BB[F5430000]        <1> 	MOV	eBX,FNC_TAB		; LOAD START OF FUNCTION TABLE
  3411 000043C2 01CB                <1> 	ADD	eBX,eCX			; ADD OFFSET INTO TABLE => ROUTINE
  3412 000043C4 88F4                <1> 	MOV	AH,DH			; AX = HEAD #,# OF SECTORS OR DASD TYPE
  3413 000043C6 30F6                <1> 	XOR	DH,DH			; DX = DRIVE #
  3414 000043C8 6689C6              <1> 	MOV	SI,AX			; SI = HEAD #,# OF SECTORS OR DASD TYPE
  3415 000043CB 6689D7              <1> 	MOV     DI,DX                   ; DI = DRIVE #
  3416                              <1> 	;
  3417                              <1> 	; 11/12/2014
  3418 000043CE 8815[FD6D0000]      <1>         mov     [cfd], dl               ; current floppy drive (for 'GET_PARM')        
  3419                              <1> 	;
  3420 000043D4 8A25[B88A0100]      <1> 	MOV	AH, [DSKETTE_STATUS]	; LOAD STATUS TO AH FOR STATUS FUNCTION
  3421 000043DA C605[B88A0100]00    <1> 	MOV	byte [DSKETTE_STATUS],0	; INITIALIZE FOR ALL OTHERS
  3422                              <1> 
  3423                              <1> ;	THROUGHOUT THE DISKETTE BIOS, THE FOLLOWING INFORMATION IS CONTAINED IN
  3424                              <1> ;	THE FOLLOWING MEMORY LOCATIONS AND REGISTERS. NOT ALL DISKETTE BIOS
  3425                              <1> ;	FUNCTIONS REQUIRE ALL OF THESE PARAMETERS.
  3426                              <1> ;
  3427                              <1> ;		DI	: DRIVE #
  3428                              <1> ;		SI-HI	: HEAD #
  3429                              <1> ;		SI-LOW	: # OF SECTORS OR DASD TYPE FOR FORMAT
  3430                              <1> ;		ES	: BUFFER SEGMENT
  3431                              <1> ;		[BP]	: SECTOR #
  3432                              <1> ;		[BP+1]	: TRACK #
  3433                              <1> ;		[BP+2]	: BUFFER OFFSET
  3434                              <1> ;
  3435                              <1> ;	ACROSS CALLS TO SUBROUTINES THE CARRY FLAG (CY=1), WHERE INDICATED IN 
  3436                              <1> ;	SUBROUTINE PROLOGUES, REPRESENTS AN EXCEPTION RETURN (NORMALLY AN ERROR 
  3437                              <1> ;	CONDITION). IN MOST CASES, WHEN CY = 1, @DSKETTE_STATUS CONTAINS THE 
  3438                              <1> ;	SPECIFIC ERROR CODE.
  3439                              <1> ;
  3440                              <1> 					; (AH) = @DSKETTE_STATUS
  3441 000043E1 FF13                <1> 	CALL	dWORD [eBX]		; CALL THE REQUESTED FUNCTION
  3442 000043E3 5E                  <1> 	POP	eSI			; RESTORE ALL REGISTERS
  3443 000043E4 1F                  <1> 	POP	DS
  3444 000043E5 07                  <1> 	pop	es	; 06/02/2015
  3445 000043E6 59                  <1> 	POP	eCX
  3446 000043E7 5B                  <1> 	POP	eBX
  3447 000043E8 5A                  <1> 	POP	eDX
  3448 000043E9 5F                  <1> 	POP	eDI
  3449 000043EA 89E5                <1> 	MOV	eBP, eSP
  3450 000043EC 50                  <1> 	PUSH	eAX
  3451 000043ED 9C                  <1> 	PUSHFd
  3452 000043EE 58                  <1> 	POP	eAX
  3453                              <1> 	;MOV	[BP+6], AX
  3454 000043EF 89450C              <1> 	mov	[ebp+12], eax  ; 18/02/2015, flags
  3455 000043F2 58                  <1> 	POP	eAX
  3456 000043F3 5D                  <1> 	POP	eBP
  3457 000043F4 CF                  <1> 	IRETd
  3458                              <1> 
  3459                              <1> ;-------------------------------------------------------------------------------
  3460                              <1> ; DW --> dd (06/02/2015)
  3461 000043F5 [59440000]          <1> FNC_TAB	dd	DSK_RESET		; AH = 00H; RESET
  3462 000043F9 [D2440000]          <1> 	dd	DSK_STATUS		; AH = 01H; STATUS
  3463 000043FD [E3440000]          <1> 	dd	DSK_READ		; AH = 02H; READ
  3464 00004401 [F4440000]          <1> 	dd	DSK_WRITE		; AH = 03H; WRITE
  3465 00004405 [05450000]          <1> 	dd	DSK_VERF		; AH = 04H; VERIFY
  3466 00004409 [16450000]          <1> 	dd	DSK_FORMAT		; AH = 05H; FORMAT
  3467 0000440D [9B450000]          <1> 	dd	FNC_ERR			; AH = 06H; INVALID
  3468 00004411 [9B450000]          <1> 	dd	FNC_ERR			; AH = 07H; INVALID
  3469 00004415 [A8450000]          <1> 	dd	DSK_PARMS		; AH = 08H; READ DRIVE PARAMETERS
  3470 00004419 [9B450000]          <1> 	dd	FNC_ERR			; AH = 09H; INVALID
  3471 0000441D [9B450000]          <1> 	dd	FNC_ERR			; AH = 0AH; INVALID
  3472 00004421 [9B450000]          <1> 	dd	FNC_ERR			; AH = 0BH; INVALID
  3473 00004425 [9B450000]          <1> 	dd	FNC_ERR			; AH = 0CH; INVALID
  3474 00004429 [9B450000]          <1> 	dd	FNC_ERR			; AH = 0DH; INVALID
  3475 0000442D [9B450000]          <1> 	dd	FNC_ERR			; AH = 0EH; INVALID
  3476 00004431 [9B450000]          <1> 	dd	FNC_ERR			; AH = 0FH; INVALID
  3477 00004435 [9B450000]          <1> 	dd	FNC_ERR			; AH = 10H; INVALID
  3478 00004439 [9B450000]          <1> 	dd	FNC_ERR			; AH = 11H; INVALID
  3479 0000443D [9B450000]          <1> 	dd	FNC_ERR			; AH = 12H; INVALID
  3480 00004441 [9B450000]          <1> 	dd	FNC_ERR			; AH = 13H; INVALID
  3481 00004445 [9B450000]          <1> 	dd	FNC_ERR			; AH = 14H; INVALID
  3482 00004449 [98460000]          <1> 	dd	DSK_TYPE		; AH = 15H; READ DASD TYPE
  3483 0000444D [C8460000]          <1> 	dd	DSK_CHANGE		; AH = 16H; CHANGE STATUS
  3484 00004451 [02470000]          <1> 	dd	FORMAT_SET		; AH = 17H; SET DASD TYPE
  3485 00004455 [85470000]          <1> 	dd	SET_MEDIA		; AH = 18H; SET MEDIA TYPE	
  3486                              <1> FNC_TAE EQU     $                       ; END
  3487                              <1> 
  3488                              <1> ;-------------------------------------------------------------------------------
  3489                              <1> ; DISK_RESET	(AH = 00H)	
  3490                              <1> ;		RESET THE DISKETTE SYSTEM.
  3491                              <1> ;
  3492                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  3493                              <1> ;-------------------------------------------------------------------------------
  3494                              <1> DSK_RESET:
  3495 00004459 66BAF203            <1> 	MOV	DX,03F2H		; ADAPTER CONTROL PORT
  3496 0000445D FA                  <1> 	CLI				; NO INTERRUPTS
  3497 0000445E A0[B68A0100]        <1> 	MOV	AL,[MOTOR_STATUS]	; GET DIGITAL OUTPUT REGISTER REFLECTION
  3498 00004463 243F                <1> 	AND	AL,00111111B		; KEEP SELECTED AND MOTOR ON BITS
  3499 00004465 C0C004              <1> 	ROL	AL,4			; MOTOR VALUE TO HIGH NIBBLE
  3500                              <1> 					; DRIVE SELECT TO LOW NIBBLE
  3501 00004468 0C08                <1> 	OR	AL,00001000B		; TURN ON INTERRUPT ENABLE
  3502 0000446A EE                  <1> 	OUT	DX,AL			; RESET THE ADAPTER
  3503 0000446B C605[B58A0100]00    <1> 	MOV	byte [SEEK_STATUS],0	; SET RECALIBRATE REQUIRED ON ALL DRIVES
  3504                              <1> 	;JMP	$+2			; WAIT FOR I/O
  3505                              <1> 	;JMP	$+2			; WAIT FOR I/O (TO INSURE MINIMUM
  3506                              <1> 					;      PULSE WIDTH)
  3507                              <1> 	; 19/12/2014
  3508                              <1> 	NEWIODELAY
  2975 00004472 E6EB                <2>  out 0ebh,al
  3509                              <1> 
  3510                              <1> 	; 17/12/2014 
  3511                              <1> 	; AWARD BIOS 1999 - RESETDRIVES (ADISK.ASM)
  3512 00004474 B915000000          <1> 	mov	ecx, WAITCPU_RESET_ON	; cx = 21 -- Min. 14 micro seconds !?
  3513                              <1> wdw1:
  3514                              <1> 	NEWIODELAY   ; 27/02/2015
  2975 00004479 E6EB                <2>  out 0ebh,al
  3515 0000447B E2FC                <1> 	loop	wdw1
  3516                              <1> 	;
  3517 0000447D 0C04                <1> 	OR	AL,00000100B		; TURN OFF RESET BIT
  3518 0000447F EE                  <1> 	OUT	DX,AL			; RESET THE ADAPTER
  3519                              <1> 	; 16/12/2014
  3520                              <1> 	IODELAY
  2970 00004480 EB00                <2>  jmp short $+2
  2971 00004482 EB00                <2>  jmp short $+2
  3521                              <1> 	;
  3522                              <1> 	;STI				; ENABLE THE INTERRUPTS
  3523 00004484 E8590C0000          <1> 	CALL	WAIT_INT		; WAIT FOR THE INTERRUPT
  3524 00004489 723E                <1> 	JC	short DR_ERR		; IF ERROR, RETURN IT
  3525 0000448B 66B9C000            <1> 	MOV	CX,11000000B		; CL = EXPECTED @NEC_STATUS
  3526                              <1> NXT_DRV:
  3527 0000448F 6651                <1> 	PUSH	CX			; SAVE FOR CALL
  3528 00004491 B8[C7440000]        <1> 	MOV	eAX, DR_POP_ERR 	; LOAD NEC_OUTPUT ERROR ADDRESS
  3529 00004496 50                  <1> 	PUSH	eAX			; "
  3530 00004497 B408                <1> 	MOV	AH,08H			; SENSE INTERRUPT STATUS COMMAND
  3531 00004499 E8370B0000          <1> 	CALL	NEC_OUTPUT
  3532 0000449E 58                  <1> 	POP	eAX			; THROW AWAY ERROR RETURN
  3533 0000449F E86E0C0000          <1> 	CALL	RESULTS			; READ IN THE RESULTS
  3534 000044A4 6659                <1> 	POP	CX			; RESTORE AFTER CALL
  3535 000044A6 7221                <1> 	JC	short DR_ERR		; ERROR RETURN
  3536 000044A8 3A0D[B98A0100]      <1> 	CMP	CL, [NEC_STATUS]	; TEST FOR DRIVE READY TRANSITION
  3537 000044AE 7519                <1> 	JNZ	short DR_ERR		; EVERYTHING OK
  3538 000044B0 FEC1                <1> 	INC	CL			; NEXT EXPECTED @NEC_STATUS
  3539 000044B2 80F9C3              <1> 	CMP	CL,11000011B		; ALL POSSIBLE DRIVES CLEARED
  3540 000044B5 76D8                <1> 	JBE	short NXT_DRV		; FALL THRU IF 11000100B OR >
  3541                              <1> 	;
  3542 000044B7 E886030000          <1> 	CALL	SEND_SPEC		; SEND SPECIFY COMMAND TO NEC
  3543                              <1> RESBAC:
  3544 000044BC E83A090000          <1> 	CALL	SETUP_END		; VARIOUS CLEANUPS
  3545 000044C1 6689F3              <1> 	MOV	BX,SI			; GET SAVED AL TO BL
  3546 000044C4 88D8                <1> 	MOV	AL,BL			; PUT BACK FOR RETURN
  3547 000044C6 C3                  <1> 	RETn		
  3548                              <1> DR_POP_ERR:
  3549 000044C7 6659                <1> 	POP	CX			; CLEAR STACK
  3550                              <1> DR_ERR:
  3551 000044C9 800D[B88A0100]20    <1> 	OR	byte [DSKETTE_STATUS],BAD_NEC ; SET ERROR CODE
  3552 000044D0 EBEA                <1> 	JMP	SHORT RESBAC		; RETURN FROM RESET
  3553                              <1> 
  3554                              <1> ;-------------------------------------------------------------------------------
  3555                              <1> ; DISK_STATUS	(AH = 01H)
  3556                              <1> ;	DISKETTE STATUS.
  3557                              <1> ;
  3558                              <1> ; ON ENTRY:	AH : STATUS OF PREVIOUS OPERATION
  3559                              <1> ;
  3560                              <1> ; ON EXIT:	AH, @DSKETTE_STATUS, CY REFLECT STATUS OF PREVIOUS OPERATION.
  3561                              <1> ;-------------------------------------------------------------------------------
  3562                              <1> DSK_STATUS:
  3563 000044D2 8825[B88A0100]      <1> 	MOV	[DSKETTE_STATUS],AH	; PUT BACK FOR SETUP END
  3564 000044D8 E81E090000          <1> 	CALL	SETUP_END		; VARIOUS CLEANUPS
  3565 000044DD 6689F3              <1> 	MOV	BX,SI			; GET SAVED AL TO BL
  3566 000044E0 88D8                <1> 	MOV	AL,BL			; PUT BACK FOR RETURN
  3567 000044E2 C3                  <1> 	RETn		
  3568                              <1> 
  3569                              <1> ;-------------------------------------------------------------------------------
  3570                              <1> ; DISK_READ	(AH = 02H)	
  3571                              <1> ;	DISKETTE READ.
  3572                              <1> ;
  3573                              <1> ; ON ENTRY:	DI	: DRIVE #
  3574                              <1> ;		SI-HI	: HEAD #
  3575                              <1> ;		SI-LOW	: # OF SECTORS
  3576                              <1> ;		ES	: BUFFER SEGMENT
  3577                              <1> ;		[BP]	: SECTOR #
  3578                              <1> ;		[BP+1]	: TRACK #
  3579                              <1> ;		[BP+2]	: BUFFER OFFSET
  3580                              <1> ;
  3581                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  3582                              <1> ;-------------------------------------------------------------------------------
  3583                              <1> 
  3584                              <1> ; 06/02/2015, ES:BX -> EBX (unix386.s)
  3585                              <1> 
  3586                              <1> DSK_READ:
  3587 000044E3 8025[B68A0100]7F    <1> 	AND	byte [MOTOR_STATUS],01111111B ; INDICATE A READ OPERATION
  3588 000044EA 66B846E6            <1> 	MOV	AX,0E646H		; AX = NEC COMMAND, DMA COMMAND
  3589 000044EE E859040000          <1> 	CALL	RD_WR_VF		; COMMON READ/WRITE/VERIFY
  3590 000044F3 C3                  <1> 	RETn
  3591                              <1> 
  3592                              <1> ;-------------------------------------------------------------------------------
  3593                              <1> ; DISK_WRITE	(AH = 03H)
  3594                              <1> ;	DISKETTE WRITE.
  3595                              <1> ;
  3596                              <1> ; ON ENTRY:	DI	: DRIVE #
  3597                              <1> ;		SI-HI	: HEAD #
  3598                              <1> ;		SI-LOW	: # OF SECTORS
  3599                              <1> ;		ES	: BUFFER SEGMENT
  3600                              <1> ;		[BP]	: SECTOR #
  3601                              <1> ;		[BP+1]	: TRACK #
  3602                              <1> ;		[BP+2]	: BUFFER OFFSET
  3603                              <1> ;
  3604                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  3605                              <1> ;-------------------------------------------------------------------------------
  3606                              <1> 
  3607                              <1> ; 06/02/2015, ES:BX -> EBX (unix386.s)
  3608                              <1> 
  3609                              <1> DSK_WRITE:
  3610 000044F4 66B84AC5            <1> 	MOV	AX,0C54AH		; AX = NEC COMMAND, DMA COMMAND
  3611 000044F8 800D[B68A0100]80    <1>         OR      byte [MOTOR_STATUS],10000000B ; INDICATE WRITE OPERATION
  3612 000044FF E848040000          <1> 	CALL	RD_WR_VF		; COMMON READ/WRITE/VERIFY
  3613 00004504 C3                  <1> 	RETn
  3614                              <1> 
  3615                              <1> ;-------------------------------------------------------------------------------
  3616                              <1> ; DISK_VERF	(AH = 04H)
  3617                              <1> ;	DISKETTE VERIFY.
  3618                              <1> ;
  3619                              <1> ; ON ENTRY:	DI	: DRIVE #
  3620                              <1> ;		SI-HI	: HEAD #
  3621                              <1> ;		SI-LOW	: # OF SECTORS
  3622                              <1> ;		ES	: BUFFER SEGMENT
  3623                              <1> ;		[BP]	: SECTOR #
  3624                              <1> ;		[BP+1]	: TRACK #
  3625                              <1> ;		[BP+2]	: BUFFER OFFSET
  3626                              <1> ;
  3627                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  3628                              <1> ;-------------------------------------------------------------------------------
  3629                              <1> DSK_VERF:
  3630 00004505 8025[B68A0100]7F    <1> 	AND	byte [MOTOR_STATUS],01111111B ; INDICATE A READ OPERATION
  3631 0000450C 66B842E6            <1> 	MOV	AX,0E642H		; AX = NEC COMMAND, DMA COMMAND
  3632 00004510 E837040000          <1> 	CALL	RD_WR_VF		; COMMON READ/WRITE/VERIFY
  3633 00004515 C3                  <1> 	RETn
  3634                              <1> 
  3635                              <1> ;-------------------------------------------------------------------------------
  3636                              <1> ; DISK_FORMAT	(AH = 05H)
  3637                              <1> ;	DISKETTE FORMAT.
  3638                              <1> ;
  3639                              <1> ; ON ENTRY:	DI	: DRIVE #
  3640                              <1> ;		SI-HI	: HEAD #
  3641                              <1> ;		SI-LOW	: # OF SECTORS
  3642                              <1> ;		ES	: BUFFER SEGMENT
  3643                              <1> ;		[BP]	: SECTOR #
  3644                              <1> ;		[BP+1]	: TRACK #
  3645                              <1> ;		[BP+2]	: BUFFER OFFSET
  3646                              <1> ;		@DISK_POINTER POINTS TO THE PARAMETER TABLE OF THIS DRIVE
  3647                              <1> ;
  3648                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  3649                              <1> ;-------------------------------------------------------------------------------
  3650                              <1> DSK_FORMAT:
  3651 00004516 E870030000          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
  3652 0000451B E86C050000          <1> 	CALL	FMT_INIT		; ESTABLISH STATE IF UNESTABLISHED
  3653 00004520 800D[B68A0100]80    <1>         OR      byte [MOTOR_STATUS], 10000000B ; INDICATE WRITE OPERATION
  3654 00004527 E8B4050000          <1> 	CALL	MED_CHANGE		; CHECK MEDIA CHANGE AND RESET IF SO
  3655 0000452C 725D                <1>         JC      short FM_DON            ; MEDIA CHANGED, SKIP
  3656 0000452E E80F030000          <1> 	CALL	SEND_SPEC		; SEND SPECIFY COMMAND TO NEC
  3657 00004533 E81A060000          <1> 	CALL	CHK_LASTRATE		; ZF=1 ATTEMPT RATE IS SAME AS LAST RATE
  3658 00004538 7405                <1>         JZ      short FM_WR             ; YES, SKIP SPECIFY COMMAND
  3659 0000453A E8F1050000          <1> 	CALL	SEND_RATE		; SEND DATA RATE TO CONTROLLER
  3660                              <1> FM_WR:
  3661 0000453F E8A7060000          <1> 	CALL	FMTDMA_SET		; SET UP THE DMA FOR FORMAT
  3662 00004544 7245                <1>         JC      short FM_DON            ; RETURN WITH ERROR
  3663 00004546 B44D                <1> 	MOV	AH,04DH			; ESTABLISH THE FORMAT COMMAND
  3664 00004548 E804070000          <1> 	CALL	NEC_INIT		; INITIALIZE THE NEC
  3665 0000454D 723C                <1>         JC      short FM_DON            ; ERROR - EXIT
  3666 0000454F B8[8B450000]        <1>         MOV     eAX, FM_DON             ; LOAD ERROR ADDRESS
  3667 00004554 50                  <1> 	PUSH	eAX			; PUSH NEC_OUT ERROR RETURN
  3668 00004555 B203                <1> 	MOV	DL,3			; BYTES/SECTOR VALUE TO NEC
  3669 00004557 E873090000          <1> 	CALL	GET_PARM
  3670 0000455C E8740A0000          <1> 	CALL	NEC_OUTPUT
  3671 00004561 B204                <1> 	MOV	DL,4			; SECTORS/TRACK VALUE TO NEC
  3672 00004563 E867090000          <1> 	CALL	GET_PARM
  3673 00004568 E8680A0000          <1> 	CALL	NEC_OUTPUT
  3674 0000456D B207                <1> 	MOV	DL,7			; GAP LENGTH VALUE TO NEC
  3675 0000456F E85B090000          <1> 	CALL	GET_PARM
  3676 00004574 E85C0A0000          <1> 	CALL	NEC_OUTPUT
  3677 00004579 B208                <1> 	MOV	DL,8			; FILLER BYTE TO NEC
  3678 0000457B E84F090000          <1> 	CALL	GET_PARM
  3679 00004580 E8500A0000          <1> 	CALL	NEC_OUTPUT
  3680 00004585 58                  <1> 	POP	eAX			; THROW AWAY ERROR
  3681 00004586 E844070000          <1> 	CALL	NEC_TERM		; TERMINATE, RECEIVE STATUS, ETC,
  3682                              <1> FM_DON:
  3683 0000458B E82C030000          <1> 	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  3684 00004590 E866080000          <1> 	CALL	SETUP_END		; VARIOUS CLEANUPS
  3685 00004595 6689F3              <1> 	MOV	BX,SI			; GET SAVED AL TO BL
  3686 00004598 88D8                <1> 	MOV	AL,BL			; PUT BACK FOR RETURN
  3687 0000459A C3                  <1> 	RETn
  3688                              <1> 
  3689                              <1> ;-------------------------------------------------------------------------------
  3690                              <1> ; FNC_ERR
  3691                              <1> ;	INVALID FUNCTION REQUESTED OR INVALID DRIVE: 
  3692                              <1> ;	SET BAD COMMAND IN STATUS.
  3693                              <1> ;
  3694                              <1> ; ON EXIT: 	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  3695                              <1> ;-------------------------------------------------------------------------------
  3696                              <1> FNC_ERR:				; INVALID FUNCTION REQUEST
  3697 0000459B 6689F0              <1> 	MOV	AX,SI			; RESTORE AL
  3698 0000459E B401                <1> 	MOV	AH,BAD_CMD		; SET BAD COMMAND ERROR
  3699 000045A0 8825[B88A0100]      <1> 	MOV	[DSKETTE_STATUS],AH	; STORE IN DATA AREA
  3700 000045A6 F9                  <1> 	STC				; SET CARRY INDICATING ERROR
  3701 000045A7 C3                  <1> 	RETn
  3702                              <1> 
  3703                              <1> ; 30/08/2020
  3704                              <1> ; 29/08/2020
  3705                              <1> ; 01/06/2016
  3706                              <1> ; 28/05/2016
  3707                              <1> ; 27/05/2016 - TRDOS 386 (TRDOS v.2.0)
  3708                              <1> ;-------------------------------------------------------------------------------
  3709                              <1> ; DISK_PARMS	(AH = 08H)	
  3710                              <1> ;	READ DRIVE PARAMETERS.
  3711                              <1> ;
  3712                              <1> ; ON ENTRY:	DI : DRIVE #
  3713                              <1> ;		; 27/05/2016
  3714                              <1> ;		EBX = Buffer Address for floppy disk parameters table (16 bytes)
  3715                              <1> ;
  3716                              <1> ; ON EXIT:	CL/[BP]   = BITS 7 & 6 HI 2 BITS OF MAX CYLINDER
  3717                              <1> ;		            BITS 0-5 MAX SECTORS/TRACK
  3718                              <1> ;		CH/[BP+1] = LOW 8 BITS OF MAX CYLINDER
  3719                              <1> ;		BL/[BP+2] = BITS 7-4 = 0
  3720                              <1> ;		            BITS 3-0 = VALID CMOS DRIVE TYPE
  3721                              <1> ;		BH/[BP+3] = 0
  3722                              <1> ;		DL/[BP+4] = # DRIVES INSTALLED (VALUE CHECKED)
  3723                              <1> ;		DH/[BP+5] = MAX HEAD #
  3724                              <1> ;	     ** 27/05/2016 - TRDOS 386 (TRDOS v2.0) **	
  3725                              <1> ;            ** EBX = Buffer address for floppy disk parameters table **
  3726                              <1> ;		;DI/[BP+6] = OFFSET TO DISK_BASE
  3727                              <1> ;		;ES        = SEGMENT OF DISK_BASE
  3728                              <1> ;
  3729                              <1> ;		AX        = 0
  3730                              <1> ;
  3731                              <1> ;		NOTE : THE ABOVE INFORMATION IS STORED IN THE USERS STACK AT
  3732                              <1> ;		       THE LOCATIONS WHERE THE MAIN ROUTINE WILL POP THEM
  3733                              <1> ;		       INTO THE APPROPRIATE REGISTERS BEFORE RETURNING TO THE
  3734                              <1> ;		       CALLER.
  3735                              <1> ;-------------------------------------------------------------------------------
  3736                              <1> DSK_PARMS:
  3737 000045A8 E8DE020000          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH,
  3738                              <1>      ;	MOV	WORD [BP+2],0		; DRIVE TYPE = 0
  3739                              <1>      ;  MOV     AX, [EQUIP_FLAG]        ; LOAD EQUIPMENT FLAG FOR # DISKETTES
  3740                              <1>      ;  AND     AL,11000001B            ; KEEP DISKETTE DRIVE BITS
  3741                              <1>      ;  MOV     DL,2                    ; DISKETTE DRIVES = 2
  3742                              <1>      ;  CMP     AL,01000001B            ; 2 DRIVES INSTALLED ?
  3743                              <1>      ;  JZ      short STO_DL            ; IF YES JUMP
  3744                              <1>      ;  DEC     DL                      ; DISKETTE DRIVES = 1
  3745                              <1>      ;  CMP     AL,00000001B            ; 1 DRIVE INSTALLED ?
  3746                              <1>      ;  JNZ     short NON_DRV           ; IF NO JUMP
  3747 000045AD 29D2                <1> 	sub	edx, edx
  3748 000045AF 66A1[0E6E0000]      <1> 	mov     ax, [fd0_type]
  3749 000045B5 6621C0              <1> 	and     ax, ax
  3750 000045B8 0F849B000000        <1>         jz      NON_DRV
  3751 000045BE FEC2                <1> 	inc     dl
  3752 000045C0 20E4                <1> 	and     ah, ah
  3753 000045C2 7402                <1> 	jz      short STO_DL
  3754 000045C4 FEC2                <1> 	inc     dl
  3755                              <1> STO_DL:
  3756                              <1> 	; 30/08/2020
  3757 000045C6 6639FA              <1> 	cmp	dx, di
  3758 000045C9 0F868A000000        <1> 	jna	NON_DRV
  3759                              <1> 	;
  3760                              <1> 	;MOV	[BP+4],DL		; STORE NUMBER OF DRIVES
  3761 000045CF 895508              <1> 	mov	[ebp+8], edx ; 20/02/2015	 	
  3762 000045D2 6683FF01            <1> 	CMP	DI,1			; CHECK FOR VALID DRIVE
  3763                              <1> 	;JA	short NON_DRV1		; DRIVE INVALID
  3764 000045D6 0F8780000000        <1> 	ja	NON_DRV1 ; 29/08/2020
  3765                              <1> 	;MOV	BYTE [BP+5],1		; MAXIMUM HEAD NUMBER =	1
  3766 000045DC C6450901            <1> 	mov	byte [ebp+9], 1  ; 20/02/2015	
  3767 000045E0 E8E1080000          <1> 	CALL	CMOS_TYPE		; RETURN DRIVE TYPE IN AL
  3768                              <1> 	;;20/02/2015
  3769                              <1> 	;;JC	short CHK_EST		; IF CMOS BAD CHECKSUM ESTABLISHED
  3770                              <1> 	;;OR	AL,AL			; TEST FOR NO DRIVE TYPE
  3771 000045E5 740F                <1> 	JZ	short CHK_EST		; JUMP IF SO
  3772 000045E7 E82B020000          <1> 	CALL	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
  3773 000045EC 7208                <1> 	JC	short CHK_EST		; TYPE NOT IN TABLE (POSSIBLE BAD CMOS)
  3774                              <1> 	;MOV	[BP+2],AL		; STORE VALID CMOS DRIVE TYPE
  3775                              <1>         ;mov	[ebp+4], al ; 06/02/2015
  3776 000045EE 8A4B04              <1> 	MOV     CL, [eBX+MD.SEC_TRK]     ; GET SECTOR/TRACK
  3777 000045F1 8A6B0B              <1>         MOV     CH, [eBX+MD.MAX_TRK]     ; GET MAX. TRACK NUMBER
  3778 000045F4 EB36                <1> 	JMP	SHORT STO_CX		; CMOS GOOD, USE CMOS
  3779                              <1> CHK_EST:
  3780 000045F6 8AA7[C58A0100]      <1> 	MOV	AH, [DSK_STATE+eDI]	; LOAD STATE FOR THIS DRIVE
  3781 000045FC F6C410              <1> 	TEST	AH,MED_DET		; CHECK FOR ESTABLISHED STATE
  3782 000045FF 745B                <1> 	JZ	short NON_DRV1		; CMOS BAD/INVALID OR UNESTABLISHED
  3783                              <1> USE_EST:
  3784 00004601 80E4C0              <1> 	AND	AH,RATE_MSK		; ISOLATE STATE
  3785 00004604 80FC80              <1> 	CMP	AH,RATE_250		; RATE 250 ?
  3786 00004607 757B                <1> 	JNE	short USE_EST2		; NO, GO CHECK OTHER RATE
  3787                              <1> 
  3788                              <1> ;-----	DATA RATE IS 250 KBS, TRY 360 KB TABLE FIRST
  3789                              <1> 
  3790 00004609 B001                <1> 	MOV	AL,01			; DRIVE TYPE 1 (360KB)
  3791 0000460B E807020000          <1> 	CALL	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
  3792 00004610 8A4B04              <1>         MOV     CL, [eBX+MD.SEC_TRK]    ; GET SECTOR/TRACK
  3793 00004613 8A6B0B              <1>         MOV     CH, [eBX+MD.MAX_TRK]    ; GET MAX. TRACK NUMBER
  3794 00004616 F687[C58A0100]01    <1> 	TEST	byte [DSK_STATE+eDI],TRK_CAPA ; 80 TRACK ?
  3795 0000461D 740D                <1> 	JZ	short STO_CX		; MUST BE 360KB DRIVE 
  3796                              <1> 
  3797                              <1> ;-----	IT IS 1.44 MB DRIVE
  3798                              <1> 
  3799                              <1> PARM144:
  3800 0000461F B004                <1> 	MOV	AL,04			; DRIVE TYPE 4 (1.44MB)
  3801 00004621 E8F1010000          <1> 	CALL	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
  3802 00004626 8A4B04              <1>         MOV     CL, [eBX+MD.SEC_TRK]    ; GET SECTOR/TRACK
  3803 00004629 8A6B0B              <1>         MOV     CH, [eBX+MD.MAX_TRK]    ; GET MAX. TRACK NUMBER
  3804                              <1> STO_CX:
  3805 0000462C 894D00              <1> 	MOV	[eBP],eCX		; SAVE POINTER IN STACK FOR RETURN
  3806                              <1> ES_DI:
  3807                              <1> 	;MOV	[BP+6],BX		; ADDRESS OF MEDIA/DRIVE PARM TABLE 
  3808                              <1> 	;mov	[ebp+12], ebx ; 06/02/2015
  3809                              <1> 	;MOV	AX,CS			; SEGMENT MEDIA/DRIVE PARAMETER TABLE
  3810                              <1> 	;MOV	ES,AX			; ES IS SEGMENT OF TABLE
  3811                              <1> 	;
  3812                              <1> 	; 28/05/2016
  3813                              <1> 	; 27/05/2016
  3814                              <1> 	; return floppy disk parameters table to user
  3815                              <1> 	; in user's buffer, which is pointed by EBX
  3816                              <1> 	;
  3817 0000462F 57                  <1> 	push	edi
  3818 00004630 8B7D04              <1> 	mov	edi, [ebp+4]  		; ebx (input), user's buffer address
  3819                              <1> 	; 29/08/2020
  3820 00004633 09FF                <1> 	or	edi, edi
  3821 00004635 7417                <1> 	jz	short no_copy_fdpt
  3822                              <1> 	;
  3823 00004637 0FB6C0              <1> 	movzx	eax, al
  3824 0000463A 894504              <1>         mov	[ebp+4], eax   ; ebx	; drive type (for floppy drives)
  3825                              <1> 	; 01/06/2016 (INT 33h, disk type return for floppy disks, in BL)
  3826 0000463D A3[BC960100]        <1> 	mov	[user_buffer], eax	; 01/06/2016 (overwrite ebx return value)
  3827                              <1> 	;(INT 33h, Function 08h will replace user's buffer addr with disk type!)
  3828                              <1> 	;
  3829 00004642 89DE                <1> 	mov	esi, ebx 		; floppy disk parameter table (16 bytes)
  3830 00004644 B910000000          <1> 	mov	ecx, 16 ; 16 bytes
  3831 00004649 E816D50000          <1>         call    transfer_to_user_buffer ; trdosk6.s (16/05/2016)
  3832                              <1> no_copy_fdpt:
  3833 0000464E 5F                  <1> 	pop	edi	
  3834                              <1> DP_OUT:
  3835 0000464F E868020000          <1> 	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  3836 00004654 6631C0              <1> 	XOR	AX,AX			; CLEAR
  3837 00004657 F8                  <1> 	CLC
  3838 00004658 C3                  <1> 	RETn
  3839                              <1> 
  3840                              <1> ;-----	NO DRIYE PRESENT HANDLER
  3841                              <1> 
  3842                              <1> NON_DRV:
  3843                              <1> 	;MOV	BYTE [BP+4],0		; CLEAR NUMBER OF DRIVES
  3844 00004659 895508              <1> 	mov	[ebp+8], edx ; 0 ; 20/02/2015
  3845                              <1> NON_DRV1:
  3846 0000465C 6681FF8000          <1> 	CMP	DI,80H			; CHECK FOR FIXED MEDIA TYPE REQUEST
  3847 00004661 720C                <1> 	JB	short NON_DRV2		; CONTINUE IF NOT REQUEST FALL THROUGH
  3848                              <1> 
  3849                              <1> ;-----	FIXED DISK REQUEST FALL THROUGH ERROR
  3850                              <1> 	
  3851 00004663 E854020000          <1> 	CALL	XLAT_OLD		; ELSE TRANSLATE TO COMPATIBLE MODE
  3852 00004668 6689F0              <1> 	MOV	AX,SI			; RESTORE AL
  3853 0000466B B401                <1> 	MOV	AH,BAD_CMD		; SET BAD COMMAND ERROR
  3854 0000466D F9                  <1> 	STC
  3855 0000466E C3                  <1> 	RETn
  3856                              <1> 
  3857                              <1> NON_DRV2:
  3858                              <1> 	;XOR	AX,AX			; CLEAR PARMS IF NO DRIVES OR CMOS BAD
  3859 0000466F 31C0                <1> 	xor	eax, eax	
  3860 00004671 66894500            <1> 	MOV	[eBP],AX		; TRACKS, SECTORS/TRACK = 0
  3861                              <1> 	;MOV	[BP+5],AH		; HEAD = 0
  3862 00004675 886509              <1> 	mov	[ebp+9], ah ; 06/02/2015
  3863                              <1> 	;MOV	[BP+6],AX		; OFFSET TO DISK_BASE = 0
  3864 00004678 89450C              <1> 	mov	[ebp+12], eax
  3865                              <1> 	;;MOV	ES,AX			; ES IS SEGMENT OF TABLE
  3866                              <1> 	;JMP	SHORT DP_OUT
  3867                              <1> 
  3868                              <1> 	; 30/08/2020
  3869 0000467B E83C020000          <1> 	call	XLAT_OLD
  3870                              <1> 	;mov	ah, NOT_RDY ; drive not ready
  3871 00004680 B407                <1> 	mov	ah, INIT_FAIL ; DRIVE PARAMETER ACTIVITY FAILED 
  3872 00004682 F9                  <1> 	stc	; cf -> 1, ah = 'drive not ready' error code
  3873 00004683 C3                  <1> 	retn		
  3874                              <1> 
  3875                              <1> ;-----	DATA RATE IS EITHER 300 KBS OR 500 KBS, TRY 1.2 MB TABLE FIRST
  3876                              <1> 
  3877                              <1> USE_EST2:
  3878 00004684 B002                <1> 	MOV	AL,02			; DRIVE TYPE 2 (1.2MB)
  3879 00004686 E88C010000          <1> 	CALL	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
  3880 0000468B 8A4B04              <1>         MOV     CL, [eBX+MD.SEC_TRK]    ; GET SECTOR/TRACK
  3881 0000468E 8A6B0B              <1>         MOV     CH, [eBX+MD.MAX_TRK]    ; GET MAX. TRACK NUMBER
  3882 00004691 80FC40              <1> 	CMP	AH,RATE_300		; RATE 300 ?
  3883 00004694 7496                <1> 	JZ	short STO_CX		; MUST BE 1.2MB DRIVE
  3884 00004696 EB87                <1> 	JMP	SHORT PARM144		; ELSE, IT IS 1.44MB DRIVE 
  3885                              <1> 
  3886                              <1> ; 30/08/2020
  3887                              <1> 
  3888                              <1> ;-------------------------------------------------------------------------------
  3889                              <1> ; DISK_TYPE (AH = 15H)	
  3890                              <1> ;	THIS ROUTINE RETURNS THE TYPE OF MEDIA INSTALLED.
  3891                              <1> ;
  3892                              <1> ;  ON ENTRY:	DI = DRIVE #
  3893                              <1> ;
  3894                              <1> ;  ON EXIT:	AH = DRIVE TYPE, CY=0
  3895                              <1> ;-------------------------------------------------------------------------------
  3896                              <1> DSK_TYPE:
  3897 00004698 E8EE010000          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
  3898 0000469D 8A87[C58A0100]      <1> 	MOV	AL,[DSK_STATE+eDI]	; GET PRESENT STATE INFORMATION
  3899 000046A3 08C0                <1> 	OR	AL,AL			; CHECK FOR NO DRIVE
  3900 000046A5 7418                <1> 	JZ	short NO_DRV
  3901 000046A7 B401                <1> 	MOV	AH,NOCHGLN		; NO CHANGE LINE FOR 40 TRACK DRIVE
  3902 000046A9 A801                <1> 	TEST	AL,TRK_CAPA		; IS THIS DRIVE AN 80 TRACK DRIVE?
  3903 000046AB 7402                <1> 	JZ	short DT_BACK		; IF NO JUMP
  3904 000046AD B402                <1> 	MOV	AH,CHGLN		; CHANGE LINE FOR 80 TRACK DRIVE
  3905                              <1> DT_BACK:
  3906 000046AF 6650                <1> 	PUSH	AX			; SAVE RETURN VALUE
  3907 000046B1 E806020000          <1> 	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  3908 000046B6 6658                <1> 	POP	AX			; RESTORE RETURN VALUE
  3909 000046B8 F8                  <1> 	CLC				; NO ERROR
  3910 000046B9 6689F3              <1> 	MOV	BX,SI			; GET SAVED AL TO BL
  3911 000046BC 88D8                <1> 	MOV	AL,BL			; PUT BACK FOR RETURN
  3912 000046BE C3                  <1> 	RETn
  3913                              <1> NO_DRV:	
  3914                              <1> 	;XOR	AH,AH			; NO DRIVE PRESENT OR UNKNOWN
  3915                              <1> 	;JMP	SHORT DT_BACK
  3916                              <1> 	
  3917                              <1> 	; 30/08/2020
  3918 000046BF E8F8010000          <1> 	call	XLAT_OLD
  3919 000046C4 29C0                <1> 	sub	eax, eax
  3920 000046C6 F9                  <1> 	stc	; cf = 1 -> drive not ready, ah = 0 (disk type = 0)
  3921 000046C7 C3                  <1> 	retn
  3922                              <1> 
  3923                              <1> ;-------------------------------------------------------------------------------
  3924                              <1> ; DISK_CHANGE	(AH = 16H)
  3925                              <1> ;	THIS ROUTINE RETURNS THE STATE OF THE DISK CHANGE LINE.
  3926                              <1> ;
  3927                              <1> ; ON ENTRY:	DI = DRIVE #
  3928                              <1> ;
  3929                              <1> ; ON EXIT:	AH = @DSKETTE_STATUS
  3930                              <1> ;		     00 - DISK CHANGE LINE INACTIVE, CY = 0
  3931                              <1> ;		     06 - DISK CHANGE LINE ACTIVE, CY = 1
  3932                              <1> ;-------------------------------------------------------------------------------
  3933                              <1> DSK_CHANGE:
  3934 000046C8 E8BE010000          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
  3935 000046CD 8A87[C58A0100]      <1> 	MOV	AL, [DSK_STATE+eDI]	; GET MEDIA STATE INFORMATION
  3936 000046D3 08C0                <1> 	OR	AL,AL			; DRIVE PRESENT ?
  3937 000046D5 7422                <1> 	JZ	short DC_NON		; JUMP IF NO DRIVE
  3938 000046D7 A801                <1> 	TEST	AL,TRK_CAPA		; 80 TRACK DRIVE ?
  3939 000046D9 7407                <1> 	JZ	short SETIT		; IF SO , CHECK CHANGE LINE
  3940                              <1> DC0:
  3941 000046DB E88D0A0000          <1>         CALL    READ_DSKCHNG            ; GO CHECK STATE OF DISK CHANGE LINE
  3942 000046E0 7407                <1> 	JZ	short FINIS		; CHANGE LINE NOT ACTIVE
  3943                              <1> 
  3944 000046E2 C605[B88A0100]06    <1> SETIT:	MOV	byte [DSKETTE_STATUS], MEDIA_CHANGE ; INDICATE MEDIA REMOVED
  3945                              <1> 
  3946 000046E9 E8CE010000          <1> FINIS:	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  3947 000046EE E808070000          <1> 	CALL	SETUP_END		; VARIOUS CLEANUPS
  3948 000046F3 6689F3              <1> 	MOV	BX,SI			; GET SAVED AL TO BL
  3949 000046F6 88D8                <1> 	MOV	AL,BL			; PUT BACK FOR RETURN
  3950 000046F8 C3                  <1> 	RETn
  3951                              <1> DC_NON:
  3952 000046F9 800D[B88A0100]80    <1> 	OR	byte [DSKETTE_STATUS], TIME_OUT ; SET TIMEOUT, NO DRIVE
  3953 00004700 EBE7                <1> 	JMP	SHORT FINIS
  3954                              <1> 
  3955                              <1> ;-------------------------------------------------------------------------------
  3956                              <1> ; FORMAT_SET	(AH = 17H)
  3957                              <1> ;	THIS ROUTINE IS USED TO ESTABLISH THE TYPE OF MEDIA TO BE USED
  3958                              <1> ;	FOR THE FOLLOWING FORMAT OPERATION.
  3959                              <1> ;
  3960                              <1> ; ON ENTRY:	SI LOW = DASD TYPE FOR FORMAT
  3961                              <1> ;		DI     = DRIVE #
  3962                              <1> ;
  3963                              <1> ; ON EXIT:	@DSKETTE_STATUS REFLECTS STATUS
  3964                              <1> ;		AH = @DSKETTE_STATUS
  3965                              <1> ;		CY = 1 IF ERROR
  3966                              <1> ;-------------------------------------------------------------------------------
  3967                              <1> FORMAT_SET:
  3968 00004702 E884010000          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
  3969 00004707 6656                <1> 	PUSH	SI			; SAVE DASD TYPE
  3970 00004709 6689F0              <1> 	MOV	AX,SI			; AH = ? , AL , DASD TYPE
  3971 0000470C 30E4                <1> 	XOR	AH,AH			; AH , 0 , AL , DASD TYPE
  3972 0000470E 6689C6              <1> 	MOV	SI,AX			; SI = DASD TYPE
  3973 00004711 80A7[C58A0100]0F    <1> 	AND	byte [DSK_STATE+eDI], ~(MED_DET+DBL_STEP+RATE_MSK) ; CLEAR STATE
  3974 00004718 664E                <1> 	DEC	SI			; CHECK FOR 320/360K MEDIA & DRIVE
  3975 0000471A 7509                <1> 	JNZ	short NOT_320		; BYPASS IF NOT
  3976 0000471C 808F[C58A0100]90    <1> 	OR	byte [DSK_STATE+eDI], MED_DET+RATE_250 ; SET TO 320/360
  3977 00004723 EB48                <1> 	JMP	SHORT S0
  3978                              <1> 
  3979                              <1> NOT_320:
  3980 00004725 E8B6030000          <1> 	CALL	MED_CHANGE		; CHECK FOR TIME_OUT
  3981 0000472A 803D[B88A0100]80    <1> 	CMP	byte [DSKETTE_STATUS], TIME_OUT
  3982 00004731 743A                <1> 	JZ	short S0		; IF TIME OUT TELL CALLER
  3983                              <1> S3:
  3984 00004733 664E                <1> 	DEC	SI			; CHECK FOR 320/360K IN 1.2M DRIVE
  3985 00004735 7509                <1> 	JNZ	short NOT_320_12	; BYPASS IF NOT
  3986 00004737 808F[C58A0100]70    <1> 	OR	byte [DSK_STATE+eDI], MED_DET+DBL_STEP+RATE_300 ; SET STATE
  3987 0000473E EB2D                <1> 	JMP	SHORT S0
  3988                              <1> 
  3989                              <1> NOT_320_12:
  3990 00004740 664E                <1> 	DEC	SI			; CHECK FOR 1.2M MEDIA IN 1.2M DRIVE
  3991 00004742 7509                <1> 	JNZ	short NOT_12		; BYPASS IF NOT
  3992 00004744 808F[C58A0100]10    <1> 	OR	byte [DSK_STATE+eDI], MED_DET+RATE_500 ; SET STATE VARIABLE
  3993 0000474B EB20                <1> 	JMP	SHORT S0		; RETURN TO CALLER
  3994                              <1> 
  3995                              <1> NOT_12:	
  3996 0000474D 664E                <1> 	DEC	SI			; CHECK FOR SET DASD TYPE 04
  3997 0000474F 752B                <1> 	JNZ	short FS_ERR		; BAD COMMAND EXIT IF NOT VALID TYPE
  3998                              <1> 
  3999 00004751 F687[C58A0100]04    <1> 	TEST	byte [DSK_STATE+eDI], DRV_DET ; DRIVE DETERMINED ?
  4000 00004758 740B                <1> 	JZ	short ASSUME		; IF STILL NOT DETERMINED ASSUME
  4001 0000475A B050                <1> 	MOV	AL,MED_DET+RATE_300
  4002 0000475C F687[C58A0100]02    <1>         TEST    byte [DSK_STATE+eDI], FMT_CAPA ; MULTIPLE FORMAT CAPABILITY ?
  4003 00004763 7502                <1> 	JNZ	short OR_IT_IN		; IF 1.2 M THEN DATA RATE 300
  4004                              <1> 
  4005                              <1> ASSUME:
  4006 00004765 B090                <1> 	MOV	AL,MED_DET+RATE_250	; SET UP
  4007                              <1> 
  4008                              <1> OR_IT_IN:
  4009 00004767 0887[C58A0100]      <1> 	OR	[DSK_STATE+eDI], AL	; OR IN THE CORRECT STATE
  4010                              <1> S0:
  4011 0000476D E84A010000          <1> 	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  4012 00004772 E884060000          <1> 	CALL	SETUP_END		; VARIOUS CLEANUPS
  4013 00004777 665B                <1> 	POP	BX			; GET SAVED AL TO BL
  4014 00004779 88D8                <1> 	MOV	AL,BL			; PUT BACK FOR RETURN
  4015 0000477B C3                  <1> 	RETn
  4016                              <1> 
  4017                              <1> FS_ERR:
  4018 0000477C C605[B88A0100]01    <1> 	MOV	byte [DSKETTE_STATUS], BAD_CMD ; UNKNOWN STATE,BAD COMMAND
  4019 00004783 EBE8                <1> 	JMP	SHORT S0
  4020                              <1> 
  4021                              <1> ;-------------------------------------------------------------------------------
  4022                              <1> ; SET_MEDIA	(AH = 18H)
  4023                              <1> ;	THIS ROUTINE SETS THE TYPE OF MEDIA AND DATA RATE 
  4024                              <1> ;	TO BE USED FOR THE FOLLOWING FORMAT OPERATION.
  4025                              <1> ;
  4026                              <1> ; ON ENTRY:
  4027                              <1> ;	[BP]	= SECTOR PER TRACK
  4028                              <1> ;	[BP+1]	= TRACK #
  4029                              <1> ;	DI	= DRIVE #
  4030                              <1> ;
  4031                              <1> ; ON EXIT:
  4032                              <1> ;	@DSKETTE_STATUS REFLECTS STATUS
  4033                              <1> ;	IF NO ERROR:
  4034                              <1> ;		AH = 0
  4035                              <1> ;		CY = 0
  4036                              <1> ;		ES = SEGMENT OF MEDIA/DRIVE PARAMETER TABLE
  4037                              <1> ;		DI/[BP+6] = OFFSET OF MEDIA/DRIVE PARAMETER TABLE
  4038                              <1> ;	IF ERROR:	
  4039                              <1> ;		AH = @DSKETTE_STATUS
  4040                              <1> ;		CY = 1
  4041                              <1> ;-------------------------------------------------------------------------------
  4042                              <1> SET_MEDIA:
  4043 00004785 E801010000          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
  4044 0000478A F687[C58A0100]01    <1>         TEST    byte [DSK_STATE+eDI], TRK_CAPA ; CHECK FOR CHANGE LINE AVAILABLE
  4045 00004791 7415                <1> 	JZ	short SM_CMOS		; JUMP IF 40 TRACK DRIVE
  4046 00004793 E848030000          <1> 	CALL	MED_CHANGE		; RESET CHANGE LINE
  4047 00004798 803D[B88A0100]80    <1> 	CMP	byte [DSKETTE_STATUS], TIME_OUT ; IF TIME OUT TELL CALLER
  4048 0000479F 746B                <1> 	JE	short SM_RTN
  4049 000047A1 C605[B88A0100]00    <1> 	MOV	byte [DSKETTE_STATUS], 0 ; CLEAR STATUS
  4050                              <1> SM_CMOS:
  4051 000047A8 E819070000          <1> 	CALL	CMOS_TYPE		; RETURN DRIVE TYPE IN (AL)
  4052                              <1> 	;;20/02/2015
  4053                              <1> 	;;JC	short MD_NOT_FND	; ERROR IN CMOS
  4054                              <1> 	;;OR	AL,AL			; TEST FOR NO DRIVE
  4055 000047AD 745D                <1> 	JZ	short SM_RTN		; RETURN IF SO
  4056 000047AF E863000000          <1> 	CALL	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
  4057 000047B4 7231                <1> 	JC	short MD_NOT_FND	; TYPE NOT IN TABLE (BAD CMOS)
  4058 000047B6 57                  <1> 	PUSH	eDI			; SAVE REG.
  4059 000047B7 31DB                <1> 	XOR	eBX,eBX			; BX = INDEX TO DR. TYPE TABLE
  4060 000047B9 B906000000          <1> 	MOV	eCX,DR_CNT		; CX = LOOP COUNT
  4061                              <1> DR_SEARCH:
  4062 000047BE 8AA3[886D0000]      <1> 	MOV	AH, [DR_TYPE+eBX]	; GET DRIVE TYPE
  4063 000047C4 80E47F              <1> 	AND	AH,BIT7OFF		; MASK OUT MSB
  4064 000047C7 38E0                <1> 	CMP	AL,AH			; DRIVE TYPE MATCH ?
  4065 000047C9 7516                <1> 	JNE	short NXT_MD		; NO, CHECK NEXT DRIVE TYPE
  4066                              <1> DR_FND:
  4067 000047CB 8BBB[896D0000]      <1> 	MOV	eDI, [DR_TYPE+eBX+1] 	; DI = MEDIA/DRIVE PARAM TABLE
  4068                              <1> MD_SEARCH:
  4069 000047D1 8A6704              <1>         MOV     AH, [eDI+MD.SEC_TRK]    ; GET SECTOR/TRACK
  4070 000047D4 386500              <1> 	CMP	[eBP],AH		; MATCH?
  4071 000047D7 7508                <1> 	JNE	short NXT_MD		; NO, CHECK NEXT MEDIA
  4072 000047D9 8A670B              <1>         MOV     AH, [eDI+MD.MAX_TRK]    ; GET MAX. TRACK #
  4073 000047DC 386501              <1> 	CMP 	[eBP+1],AH		; MATCH?
  4074 000047DF 740F                <1> 	JE	short MD_FND		; YES, GO GET RATE
  4075                              <1> NXT_MD:
  4076                              <1> 	;ADD	BX,3			; CHECK NEXT DRIVE TYPE
  4077 000047E1 83C305              <1>         add	ebx, 5 ; 18/02/2015
  4078 000047E4 E2D8                <1> 	LOOP    DR_SEARCH
  4079 000047E6 5F                  <1> 	POP	eDI			; RESTORE REG.
  4080                              <1> MD_NOT_FND:
  4081 000047E7 C605[B88A0100]0C    <1> 	MOV	byte [DSKETTE_STATUS], MED_NOT_FND ; ERROR, MEDIA TYPE NOT FOUND
  4082 000047EE EB1C                <1> 	JMP	SHORT SM_RTN		; RETURN
  4083                              <1> MD_FND:
  4084 000047F0 8A470C              <1>         MOV     AL, [eDI+MD.RATE]       ; GET RATE
  4085 000047F3 3C40                <1> 	CMP	AL,RATE_300		; DOUBLE STEP REQUIRED FOR RATE 300
  4086 000047F5 7502                <1> 	JNE	short MD_SET
  4087 000047F7 0C20                <1> 	OR	AL,DBL_STEP
  4088                              <1> MD_SET:
  4089                              <1> 	;MOV	[BP+6],DI		; SAVE TABLE POINTER IN STACK
  4090 000047F9 897D0C              <1> 	mov	[ebp+12], edi ; 18/02/2015
  4091 000047FC 0C10                <1> 	OR	AL,MED_DET		; SET MEDIA ESTABLISHED
  4092 000047FE 5F                  <1> 	POP	eDI
  4093 000047FF 80A7[C58A0100]0F    <1> 	AND	byte [DSK_STATE+eDI], ~(MED_DET+DBL_STEP+RATE_MSK) ; CLEAR STATE
  4094 00004806 0887[C58A0100]      <1> 	OR	[DSK_STATE+eDI], AL
  4095                              <1> 	;MOV	AX, CS			; SEGMENT OF MEDIA/DRIVE PARAMETER TABLE
  4096                              <1> 	;MOV	ES, AX			; ES IS SEGMENT OF TABLE
  4097                              <1> SM_RTN:
  4098 0000480C E8AB000000          <1> 	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  4099 00004811 E8E5050000          <1> 	CALL	SETUP_END		; VARIOUS CLEANUPS
  4100 00004816 C3                  <1> 	RETn
  4101                              <1> 
  4102                              <1> ;----------------------------------------------------------------
  4103                              <1> ; DR_TYPE_CHECK							:
  4104                              <1> ;	CHECK IF THE GIVEN DRIVE TYPE IN REGISTER (AL)		:
  4105                              <1> ;	IS SUPPORTED IN BIOS DRIVE TYPE TABLE			:
  4106                              <1> ; ON ENTRY:							:
  4107                              <1> ;	AL = DRIVE TYPE						:
  4108                              <1> ; ON EXIT:							:
  4109                              <1> ;	CS = SEGMENT MEDIA/DRIVE PARAMETER TABLE (CODE)		:
  4110                              <1> ;	CY = 0 	DRIVE TYPE SUPPORTED				:
  4111                              <1> ;	     BX = OFFSET TO MEDIA/DRIVE PARAMETER TABLE		:
  4112                              <1> ;	CY = 1	DRIVE TYPE NOT SUPPORTED 			:
  4113                              <1> ; REGISTERS ALTERED: eBX						:
  4114                              <1> ;----------------------------------------------------------------		
  4115                              <1> DR_TYPE_CHECK:
  4116 00004817 6650                <1> 	PUSH	AX			
  4117 00004819 51                  <1> 	PUSH	eCX
  4118 0000481A 31DB                <1> 	XOR	eBX,eBX			; BX = INDEX TO DR_TYPE TABLE
  4119 0000481C B906000000          <1> 	MOV	eCX,DR_CNT		; CX = LOOP COUNT
  4120                              <1> TYPE_CHK:	
  4121 00004821 8AA3[886D0000]      <1> 	MOV	AH,[DR_TYPE+eBX]	; GET DRIVE TYPE
  4122 00004827 38E0                <1> 	CMP	AL,AH			; DRIVE TYPE MATCH?
  4123 00004829 740D                <1> 	JE	short DR_TYPE_VALID	; YES, RETURN WITH CARRY RESET
  4124                              <1> 	;ADD	BX,3			; CHECK NEXT DRIVE TYPE
  4125 0000482B 83C305              <1>         add	ebx, 5	; 16/02/2015 (32 bit address modification)
  4126 0000482E E2F1                <1> 	LOOP    TYPE_CHK
  4127                              <1> 	;
  4128 00004830 BB[E76D0000]        <1> 	mov	ebx, MD_TBL6		; 1.44MB fd parameter table
  4129                              <1> 					; Default for GET_PARM (11/12/2014)
  4130                              <1> 	;
  4131 00004835 F9                  <1> 	STC				; DRIVE TYPE NOT FOUND IN TABLE
  4132 00004836 EB06                <1> 	JMP	SHORT TYPE_RTN
  4133                              <1> DR_TYPE_VALID:
  4134 00004838 8B9B[896D0000]      <1> 	MOV	eBX,[DR_TYPE+eBX+1] 	; BX = MEDIA TABLE
  4135                              <1> TYPE_RTN:
  4136 0000483E 59                  <1> 	POP	eCX
  4137 0000483F 6658                <1> 	POP	AX
  4138 00004841 C3                  <1> 	RETn	
  4139                              <1> 		
  4140                              <1> ;----------------------------------------------------------------
  4141                              <1> ; SEND_SPEC							:
  4142                              <1> ;	SEND THE SPECIFY COMMAND TO CONTROLLER USING DATA FROM	:
  4143                              <1> ;	THE DRIVE PARAMETER TABLE POINTED BY @DISK_POINTER	:
  4144                              <1> ; ON ENTRY:	@DISK_POINTER = DRIVE PARAMETER TABLE		:
  4145                              <1> ; ON EXIT:	NONE						:	
  4146                              <1> ; REGISTERS ALTERED: CX, DX					:
  4147                              <1> ;----------------------------------------------------------------		
  4148                              <1> SEND_SPEC:
  4149 00004842 50                  <1> 	PUSH	eAX			; SAVE AX
  4150 00004843 B8[69480000]        <1> 	MOV	eAX, SPECBAC		; LOAD ERROR ADDRESS
  4151 00004848 50                  <1> 	PUSH	eAX			; PUSH NEC_OUT ERROR RETURN
  4152 00004849 B403                <1> 	MOV	AH,03H			; SPECIFY COMMAND
  4153 0000484B E885070000          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE COMMAND
  4154 00004850 28D2                <1> 	SUB	DL,DL			; FIRST SPECIFY BYTE
  4155 00004852 E878060000          <1> 	CALL	GET_PARM		; GET PARAMETER TO AH
  4156 00004857 E879070000          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE COMMAND
  4157 0000485C B201                <1> 	MOV	DL,1			; SECOND SPECIFY BYTE
  4158 0000485E E86C060000          <1> 	CALL	GET_PARM		; GET PARAMETER TO AH
  4159 00004863 E86D070000          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE COMMAND
  4160 00004868 58                  <1> 	POP	eAX			; POP ERROR RETURN
  4161                              <1> SPECBAC:
  4162 00004869 58                  <1> 	POP	eAX			; RESTORE ORIGINAL AX VALUE
  4163 0000486A C3                  <1> 	RETn
  4164                              <1> 
  4165                              <1> ;----------------------------------------------------------------
  4166                              <1> ; SEND_SPEC_MD							:
  4167                              <1> ;	SEND THE SPECIFY COMMAND TO CONTROLLER USING DATA FROM	:
  4168                              <1> ;	THE MEDIA/DRIVE PARAMETER TABLE POINTED BY (CS:BX)	:
  4169                              <1> ; ON ENTRY:	CS:BX = MEDIA/DRIVE PARAMETER TABLE		:
  4170                              <1> ; ON EXIT:	NONE						:	
  4171                              <1> ; REGISTERS ALTERED: AX						:
  4172                              <1> ;----------------------------------------------------------------		
  4173                              <1> SEND_SPEC_MD:
  4174 0000486B 50                  <1> 	PUSH	eAX			; SAVE RATE DATA
  4175 0000486C B8[89480000]        <1> 	MOV	eAX, SPEC_ESBAC		; LOAD ERROR ADDRESS
  4176 00004871 50                  <1> 	PUSH	eAX			; PUSH NEC_OUT ERROR RETURN
  4177 00004872 B403                <1> 	MOV	AH,03H			; SPECIFY COMMAND
  4178 00004874 E85C070000          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE COMMAND
  4179 00004879 8A23                <1>         MOV     AH, [eBX+MD.SPEC1]      ; GET 1ST SPECIFY BYTE
  4180 0000487B E855070000          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE COMMAND
  4181 00004880 8A6301              <1>         MOV     AH, [eBX+MD.SPEC2]      ; GET SECOND SPECIFY BYTE
  4182 00004883 E84D070000          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE COMMAND
  4183 00004888 58                  <1> 	POP	eAX			; POP ERROR RETURN
  4184                              <1> SPEC_ESBAC:
  4185 00004889 58                  <1> 	POP	eAX			; RESTORE ORIGINAL AX VALUE
  4186 0000488A C3                  <1> 	RETn
  4187                              <1> 
  4188                              <1> ;-------------------------------------------------------------------------------
  4189                              <1> ; XLAT_NEW  
  4190                              <1> ;	TRANSLATES DISKETTE STATE LOCATIONS FROM COMPATIBLE
  4191                              <1> ;	MODE TO NEW ARCHITECTURE.
  4192                              <1> ;
  4193                              <1> ; ON ENTRY:	DI = DRIVE #
  4194                              <1> ;-------------------------------------------------------------------------------
  4195                              <1> XLAT_NEW:
  4196 0000488B 83FF01              <1> 	CMP	eDI,1				; VALID DRIVE
  4197 0000488E 7725                <1> 	JA	short XN_OUT			; IF INVALID BACK
  4198 00004890 80BF[C58A0100]00    <1> 	CMP	byte [DSK_STATE+eDI], 0		; NO DRIVE ?
  4199 00004897 741D                <1> 	JZ	short DO_DET			; IF NO DRIVE ATTEMPT DETERMINE
  4200 00004899 6689F9              <1> 	MOV	CX,DI				; CX = DRIVE NUMBER
  4201 0000489C C0E102              <1> 	SHL	CL,2				; CL = SHIFT COUNT, A=0, B=4
  4202 0000489F A0[C48A0100]        <1> 	MOV	AL, [HF_CNTRL]			; DRIVE INFORMATION
  4203 000048A4 D2C8                <1> 	ROR	AL,CL				; TO LOW NIBBLE
  4204 000048A6 2407                <1> 	AND	AL,DRV_DET+FMT_CAPA+TRK_CAPA	; KEEP DRIVE BITS
  4205 000048A8 80A7[C58A0100]F8    <1>         AND     byte [DSK_STATE+eDI], ~(DRV_DET+FMT_CAPA+TRK_CAPA)
  4206 000048AF 0887[C58A0100]      <1> 	OR	[DSK_STATE+eDI], AL		; UPDATE DRIVE STATE
  4207                              <1> XN_OUT:
  4208 000048B5 C3                  <1> 	RETn
  4209                              <1> DO_DET:
  4210 000048B6 E8BF080000          <1> 	CALL	DRIVE_DET			; TRY TO DETERMINE
  4211 000048BB C3                  <1> 	RETn
  4212                              <1> 
  4213                              <1> ;-------------------------------------------------------------------------------
  4214                              <1> ; XLAT_OLD 
  4215                              <1> ;	TRANSLATES DISKETTE STATE LOCATIONS FROM NEW
  4216                              <1> ;	ARCHITECTURE TO COMPATIBLE MODE.
  4217                              <1> ;
  4218                              <1> ; ON ENTRY:	DI = DRIVE
  4219                              <1> ;-------------------------------------------------------------------------------
  4220                              <1> XLAT_OLD:
  4221 000048BC 83FF01              <1> 	CMP	eDI,1			; VALID DRIVE ?
  4222                              <1>         ;JA     short XO_OUT            ; IF INVALID BACK
  4223 000048BF 0F8786000000        <1>         ja      XO_OUT
  4224 000048C5 80BF[C58A0100]00    <1>         CMP	byte [DSK_STATE+eDI],0	; NO DRIVE ?
  4225 000048CC 747D                <1> 	JZ	short XO_OUT		; IF NO DRIVE TRANSLATE DONE
  4226                              <1> 
  4227                              <1> ;-----	TEST FOR SAVED DRIVE INFORMATION ALREADY SET
  4228                              <1> 
  4229 000048CE 6689F9              <1> 	MOV	CX,DI			; CX = DRIVE NUMBER
  4230 000048D1 C0E102              <1> 	SHL	CL,2			; CL = SHIFT COUNT, A=0, B=4
  4231 000048D4 B402                <1> 	MOV	AH,FMT_CAPA		; LOAD MULTIPLE DATA RATE BIT MASK
  4232 000048D6 D2CC                <1> 	ROR	AH,CL			; ROTATE BY MASK
  4233 000048D8 8425[C48A0100]      <1> 	TEST	[HF_CNTRL], AH		; MULTIPLE-DATA RATE DETERMINED ?
  4234 000048DE 751C                <1> 	JNZ	short SAVE_SET		; IF SO, NO NEED TO RE-SAVE
  4235                              <1> 
  4236                              <1> ;-----	ERASE DRIVE BITS IN @HF_CNTRL FOR THIS DRIVE
  4237                              <1> 
  4238 000048E0 B407                <1> 	MOV	AH,DRV_DET+FMT_CAPA+TRK_CAPA ; MASK TO KEEP
  4239 000048E2 D2CC                <1> 	ROR	AH,CL			; FIX MASK TO KEEP
  4240 000048E4 F6D4                <1> 	NOT	AH			; TRANSLATE MASK
  4241 000048E6 2025[C48A0100]      <1> 	AND	[HF_CNTRL], AH		; KEEP BITS FROM OTHER DRIVE INTACT
  4242                              <1> 
  4243                              <1> ;-----	ACCESS CURRENT DRIVE BITS AND STORE IN @HF_CNTRL
  4244                              <1> 
  4245 000048EC 8A87[C58A0100]      <1> 	MOV	AL, [DSK_STATE+eDI]	; ACCESS STATE
  4246 000048F2 2407                <1> 	AND	AL,DRV_DET+FMT_CAPA+TRK_CAPA ; KEEP DRIVE BITS
  4247 000048F4 D2C8                <1> 	ROR	AL,CL			; FIX FOR THIS DRIVE
  4248 000048F6 0805[C48A0100]      <1> 	OR	[HF_CNTRL], AL		; UPDATE SAVED DRIVE STATE
  4249                              <1> 
  4250                              <1> ;-----	TRANSLATE TO COMPATIBILITY MODE
  4251                              <1> 
  4252                              <1> SAVE_SET:
  4253 000048FC 8AA7[C58A0100]      <1> 	MOV	AH, [DSK_STATE+eDI]	; ACCESS STATE
  4254 00004902 88E7                <1> 	MOV	BH,AH			; TO BH FOR LATER
  4255 00004904 80E4C0              <1> 	AND	AH,RATE_MSK		; KEEP ONLY RATE
  4256 00004907 80FC00              <1> 	CMP	AH,RATE_500		; RATE 500 ?
  4257 0000490A 7410                <1> 	JZ	short CHK_144		; YES 1.2/1.2 OR 1.44/1.44
  4258 0000490C B001                <1> 	MOV	AL,M3D1U		; AL = 360 IN 1.2 UNESTABLISHED
  4259 0000490E 80FC40              <1> 	CMP	AH,RATE_300		; RATE 300 ?
  4260 00004911 7518                <1> 	JNZ	short CHK_250		; NO, 360/360, 720/720 OR 720/1.44
  4261 00004913 F6C720              <1> 	TEST	BH,DBL_STEP		; CHECK FOR DOUBLE STEP
  4262 00004916 751F                <1> 	JNZ	short TST_DET		; MUST BE 360 IN 1.2
  4263                              <1> UNKNO:
  4264 00004918 B007                <1> 	MOV	AL,MED_UNK		; NONE OF THE ABOVE
  4265 0000491A EB22                <1> 	JMP	SHORT AL_SET		; PROCESS COMPLETE
  4266                              <1> CHK_144:
  4267 0000491C E8A5050000          <1> 	CALL	CMOS_TYPE		; RETURN DRIVE TYPE IN (AL)
  4268                              <1> 	;;20/02/2015
  4269                              <1> 	;;JC	short UNKNO		; ERROR, SET 'NONE OF ABOVE'
  4270 00004921 74F5                <1> 	jz	short UNKNO ;; 20/02/2015
  4271 00004923 3C02                <1> 	CMP	AL,2			; 1.2MB DRIVE ?
  4272 00004925 75F1                <1> 	JNE	short UNKNO		; NO, GO SET 'NONE OF ABOVE'
  4273 00004927 B002                <1> 	MOV	AL,M1D1U		; AL = 1.2 IN 1.2 UNESTABLISHED
  4274 00004929 EB0C                <1> 	JMP	SHORT TST_DET
  4275                              <1> CHK_250:
  4276 0000492B B000                <1> 	MOV	AL,M3D3U		; AL = 360 IN 360 UNESTABLISHED
  4277 0000492D 80FC80              <1> 	CMP	AH,RATE_250		; RATE 250 ?
  4278 00004930 75E6                <1> 	JNZ	short UNKNO		; IF SO FALL IHRU
  4279 00004932 F6C701              <1> 	TEST	BH,TRK_CAPA		; 80 TRACK CAPABILITY ?
  4280 00004935 75E1                <1> 	JNZ	short UNKNO		; IF SO JUMP, FALL THRU TEST DET
  4281                              <1> TST_DET:
  4282 00004937 F6C710              <1> 	TEST	BH,MED_DET		; DETERMINED ?
  4283 0000493A 7402                <1> 	JZ	short AL_SET		; IF NOT THEN SET
  4284 0000493C 0403                <1> 	ADD	AL,3			; MAKE DETERMINED/ESTABLISHED
  4285                              <1> AL_SET:
  4286 0000493E 80A7[C58A0100]F8    <1> 	AND	byte [DSK_STATE+eDI], ~(DRV_DET+FMT_CAPA+TRK_CAPA) ; CLEAR DRIVE
  4287 00004945 0887[C58A0100]      <1> 	OR	[DSK_STATE+eDI], AL	; REPLACE WITH COMPATIBLE MODE
  4288                              <1> XO_OUT:
  4289 0000494B C3                  <1> 	RETn
  4290                              <1> 
  4291                              <1> ;-------------------------------------------------------------------------------
  4292                              <1> ; RD_WR_VF
  4293                              <1> ;	COMMON READ, WRITE AND VERIFY: 
  4294                              <1> ;	MAIN LOOP FOR STATE RETRIES.
  4295                              <1> ;
  4296                              <1> ; ON ENTRY:	AH = READ/WRITE/VERIFY NEC PARAMETER
  4297                              <1> ;		AL = READ/WRITE/VERIFY DMA PARAMETER
  4298                              <1> ;
  4299                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  4300                              <1> ;-------------------------------------------------------------------------------
  4301                              <1> RD_WR_VF:
  4302 0000494C 6650                <1> 	PUSH	AX			; SAVE DMA, NEC PARAMETERS
  4303 0000494E E838FFFFFF          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
  4304 00004953 E8F3000000          <1> 	CALL	SETUP_STATE		; INITIALIZE START AND END RATE
  4305 00004958 6658                <1> 	POP	AX			; RESTORE READ/WRITE/VERIFY
  4306                              <1> DO_AGAIN:
  4307 0000495A 6650                <1> 	PUSH	AX			; SAVE READ/WRITE/VERIFY PARAMETER
  4308 0000495C E87F010000          <1> 	CALL	MED_CHANGE		; MEDIA CHANGE AND RESET IF CHANGED
  4309 00004961 6658                <1> 	POP	AX			; RESTORE READ/WRITE/VERIFY
  4310 00004963 0F82C9000000        <1>         JC      RWV_END                 ; MEDIA CHANGE ERROR OR TIME-OUT
  4311                              <1> RWV:
  4312 00004969 6650                <1> 	PUSH	AX			; SAVE READ/WRITE/VERIFY PARAMETER
  4313 0000496B 8AB7[C58A0100]      <1> 	MOV	DH, [DSK_STATE+eDI]	; GET RATE STATE OF THIS DRIVE
  4314 00004971 80E6C0              <1> 	AND	DH,RATE_MSK		; KEEP ONLY RATE
  4315 00004974 E84D050000          <1> 	CALL	CMOS_TYPE		; RETURN DRIVE TYPE IN AL (AL)
  4316                              <1> 	;;20/02/2015
  4317                              <1> 	;;JC	short RWV_ASSUME	; ERROR IN CMOS
  4318 00004979 7451                <1> 	jz	short RWV_ASSUME ; 20/02/2015
  4319 0000497B 3C01                <1> 	CMP	AL,1			; 40 TRACK DRIVE?
  4320 0000497D 750D                <1> 	JNE	short RWV_1		; NO, BYPASS CMOS VALIDITY CHECK
  4321 0000497F F687[C58A0100]01    <1> 	TEST	byte [DSK_STATE+eDI], TRK_CAPA ; CHECK FOR 40 TRACK DRIVE
  4322 00004986 7413                <1> 	JZ	short RWV_2		; YES, CMOS IS CORRECT
  4323 00004988 B002                <1> 	MOV	AL,2			; CHANGE TO 1.2M
  4324 0000498A EB0F                <1> 	JMP	SHORT RWV_2
  4325                              <1> RWV_1:
  4326 0000498C 720D                <1> 	JB	short RWV_2		; NO DRIVE SPECIFIED, CONTINUE
  4327 0000498E F687[C58A0100]01    <1> 	TEST    byte [DSK_STATE+eDI], TRK_CAPA ; IS IT REALLY 40 TRACK?
  4328 00004995 7504                <1> 	JNZ	short RWV_2		; NO, 80 TRACK
  4329 00004997 B001                <1> 	MOV	AL,1			; IT IS 40 TRACK, FIX CMOS VALUE
  4330 00004999 EB04                <1> 	jmp	short rwv_3
  4331                              <1> RWV_2:
  4332 0000499B 08C0                <1> 	OR	AL,AL			; TEST FOR NO DRIVE
  4333 0000499D 742D                <1> 	JZ	short RWV_ASSUME	; ASSUME TYPE, USE MAX TRACK
  4334                              <1> rwv_3:
  4335 0000499F E873FEFFFF          <1> 	CALL	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL.
  4336 000049A4 7226                <1> 	JC	short RWV_ASSUME	; TYPE NOT IN TABLE (BAD CMOS)
  4337                              <1> 
  4338                              <1> ;-----	SEARCH FOR MEDIA/DRIVE PARAMETER TABLE
  4339                              <1> 
  4340 000049A6 57                  <1> 	PUSH	eDI			; SAVE DRIVE #
  4341 000049A7 31DB                <1> 	XOR	eBX,eBX			; BX = INDEX TO DR_TYPE TABLE
  4342 000049A9 B906000000          <1> 	MOV	eCX,DR_CNT		; CX = LOOP COUNT
  4343                              <1> RWV_DR_SEARCH:
  4344 000049AE 8AA3[886D0000]      <1> 	MOV	AH, [DR_TYPE+eBX]	; GET DRIVE TYPE
  4345 000049B4 80E47F              <1> 	AND	AH,BIT7OFF		; MASK OUT MSB
  4346 000049B7 38E0                <1> 	CMP	AL,AH			; DRIVE TYPE MATCH?
  4347 000049B9 750B                <1> 	JNE	short RWV_NXT_MD	; NO, CHECK NEXT DRIVE TYPE
  4348                              <1> RWV_DR_FND:
  4349 000049BB 8BBB[896D0000]      <1> 	MOV	eDI, [DR_TYPE+eBX+1] 	; DI = MEDIA/DRIVE PARAMETER TABLE
  4350                              <1> RWV_MD_SEARH:
  4351 000049C1 3A770C              <1>         CMP     DH, [eDI+MD.RATE]       ; MATCH?
  4352 000049C4 741B                <1> 	JE	short RWV_MD_FND	; YES, GO GET 1ST SPECIFY BYTE
  4353                              <1> RWV_NXT_MD:
  4354                              <1> 	;ADD	BX,3			; CHECK NEXT DRIVE TYPE
  4355 000049C6 83C305              <1> 	add	eBX, 5
  4356 000049C9 E2E3                <1> 	LOOP	RWV_DR_SEARCH
  4357 000049CB 5F                  <1> 	POP	eDI			; RESTORE DRIVE #
  4358                              <1> 
  4359                              <1> ;-----	ASSUME PRIMARY DRIVE IS INSTALLED AS SHIPPED
  4360                              <1> 
  4361                              <1> RWV_ASSUME:
  4362 000049CC BB[A66D0000]        <1> 	MOV	eBX, MD_TBL1		; POINT TO 40 TRACK 250 KBS
  4363 000049D1 F687[C58A0100]01    <1> 	TEST 	byte [DSK_STATE+eDI], TRK_CAPA ; TEST FOR 80 TRACK
  4364 000049D8 740A                <1> 	JZ	short RWV_MD_FND1	; MUST BE 40 TRACK
  4365 000049DA BB[C06D0000]        <1> 	MOV	eBX, MD_TBL3		; POINT TO 80 TRACK 500 KBS
  4366 000049DF EB03                <1> 	JMP	short RWV_MD_FND1	; GO SPECIFY PARAMTERS
  4367                              <1> 
  4368                              <1> ;-----	CS:BX POINTS TO MEDIA/DRIVE PARAMETER TABLE
  4369                              <1> 	 			
  4370                              <1> RWV_MD_FND:
  4371 000049E1 89FB                <1> 	MOV	eBX,eDI			; BX = MEDIA/DRIVE PARAMETER TABLE
  4372 000049E3 5F                  <1> 	POP	eDI			; RESTORE DRIVE #
  4373                              <1> 	
  4374                              <1> ;-----	SEND THE SPECIFY COMMAND TO THE CONTROLLER
  4375                              <1> 
  4376                              <1> RWV_MD_FND1:
  4377 000049E4 E882FEFFFF          <1> 	CALL	SEND_SPEC_MD
  4378 000049E9 E864010000          <1> 	CALL	CHK_LASTRATE		; ZF=1 ATTEMP RATE IS SAME AS LAST RATE
  4379 000049EE 7405                <1> 	JZ	short RWV_DBL		; YES,SKIP SEND RATE COMMAND
  4380 000049F0 E83B010000          <1> 	CALL	SEND_RATE		; SEND DATA RATE TO NEC
  4381                              <1> RWV_DBL:
  4382 000049F5 53                  <1> 	PUSH	eBX			; SAVE MEDIA/DRIVE PARAM TBL ADDRESS
  4383 000049F6 E822040000          <1> 	CALL	SETUP_DBL		; CHECK FOR DOUBLE STEP
  4384 000049FB 5B                  <1> 	POP	eBX			; RESTORE ADDRESS
  4385 000049FC 7226                <1> 	JC	short CHK_RET		; ERROR FROM READ ID, POSSIBLE RETRY
  4386 000049FE 6658                <1> 	POP	AX			; RESTORE NEC, DMA COMMAND
  4387 00004A00 6650                <1> 	PUSH	AX			; SAVE NEC COMMAND
  4388 00004A02 53                  <1> 	PUSH	eBX			; SAVE MEDIA/DRIVE PARAM TBL ADDRESS
  4389 00004A03 E861010000          <1> 	CALL	DMA_SETUP		; SET UP THE DMA
  4390 00004A08 5B                  <1> 	POP	eBX 
  4391 00004A09 6658                <1> 	POP	AX			; RESTORE NEC COMMAND
  4392 00004A0B 722F                <1> 	JC	short RWV_BAC		; CHECK FOR DMA BOUNDARY ERROR
  4393 00004A0D 6650                <1> 	PUSH	AX			; SAVE NEC COMMAND
  4394 00004A0F 53                  <1> 	PUSH	eBX			; SAVE MEDIA/DRIVE PARAM TBL ADDRESS
  4395 00004A10 E83C020000          <1> 	CALL	NEC_INIT		; INITIALIZE NEC
  4396 00004A15 5B                  <1> 	POP	eBX			; RESTORE ADDRESS
  4397 00004A16 720C                <1> 	JC	short CHK_RET		; ERROR - EXIT
  4398 00004A18 E866020000          <1> 	CALL	RWV_COM			; OP CODE COMMON TO READ/WRITE/VERIFY
  4399 00004A1D 7205                <1> 	JC	short CHK_RET		; ERROR - EXIT
  4400 00004A1F E8AB020000          <1> 	CALL	NEC_TERM		; TERMINATE, GET STATUS, ETC.
  4401                              <1> CHK_RET:
  4402 00004A24 E84A030000          <1> 	CALL	RETRY			; CHECK FOR, SETUP RETRY
  4403 00004A29 6658                <1> 	POP	AX			; RESTORE READ/WRITE/VERIFY PARAMETER
  4404 00004A2B 7305                <1> 	JNC	short RWV_END		; CY = 0 NO RETRY
  4405 00004A2D E928FFFFFF          <1>         JMP     DO_AGAIN                ; CY = 1 MEANS RETRY
  4406                              <1> RWV_END:
  4407 00004A32 E8F4020000          <1> 	CALL	DSTATE			; ESTABLISH STATE IF SUCCESSFUL
  4408 00004A37 E887030000          <1> 	CALL	NUM_TRANS		; AL = NUMBER TRANSFERRED
  4409                              <1> RWV_BAC:				; BAD DMA ERROR ENTRY
  4410 00004A3C 6650                <1> 	PUSH	AX			; SAVE NUMBER TRANSFERRED
  4411 00004A3E E879FEFFFF          <1> 	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  4412 00004A43 6658                <1> 	POP	AX			; RESTORE NUMBER TRANSFERRED
  4413 00004A45 E8B1030000          <1> 	CALL	SETUP_END		; VARIOUS CLEANUPS
  4414 00004A4A C3                  <1> 	RETn
  4415                              <1> 
  4416                              <1> ;-------------------------------------------------------------------------------
  4417                              <1> ; SETUP_STATE:	INITIALIZES START AND END RATES.
  4418                              <1> ;-------------------------------------------------------------------------------
  4419                              <1> SETUP_STATE:
  4420 00004A4B F687[C58A0100]10    <1> 	TEST	byte [DSK_STATE+eDI], MED_DET ; MEDIA DETERMINED ?
  4421 00004A52 7537                <1> 	JNZ	short J1C		; NO STATES IF DETERMINED
  4422 00004A54 66B84000            <1>         MOV     AX,(RATE_500*256)+RATE_300  ; AH = START RATE, AL = END RATE
  4423 00004A58 F687[C58A0100]04    <1> 	TEST	byte [DSK_STATE+eDI],DRV_DET ; DRIVE ?
  4424 00004A5F 740D                <1> 	JZ	short AX_SET		; DO NOT KNOW DRIVE
  4425 00004A61 F687[C58A0100]02    <1> 	TEST	byte [DSK_STATE+eDI], FMT_CAPA ; MULTI-RATE?
  4426 00004A68 7504                <1> 	JNZ	short AX_SET		; JUMP IF YES
  4427 00004A6A 66B88080            <1>         MOV     AX,RATE_250*257         ; START A END RATE 250 FOR 360 DRIVE
  4428                              <1> AX_SET:	
  4429 00004A6E 80A7[C58A0100]1F    <1> 	AND	byte [DSK_STATE+eDI], ~(RATE_MSK+DBL_STEP) ; TURN OFF THE RATE
  4430 00004A75 08A7[C58A0100]      <1> 	OR	[DSK_STATE+eDI], AH	; RATE FIRST TO TRY
  4431 00004A7B 8025[C08A0100]F3    <1> 	AND	byte [LASTRATE], ~STRT_MSK ; ERASE LAST TO TRY RATE BITS
  4432 00004A82 C0C804              <1> 	ROR	AL,4			; TO OPERATION LAST RATE LOCATION
  4433 00004A85 0805[C08A0100]      <1> 	OR	[LASTRATE], AL		; LAST RATE
  4434                              <1> J1C:	
  4435 00004A8B C3                  <1> 	RETn
  4436                              <1> 
  4437                              <1> ;-------------------------------------------------------------------------------
  4438                              <1> ;  FMT_INIT: ESTABLISH STATE IF UNESTABLISHED AT FORMAT TIME.
  4439                              <1> ;-------------------------------------------------------------------------------
  4440                              <1> FMT_INIT:
  4441 00004A8C F687[C58A0100]10    <1> 	TEST	byte [DSK_STATE+eDI], MED_DET ; IS MEDIA ESTABLISHED
  4442 00004A93 7546                <1> 	JNZ	short F1_OUT		; IF SO RETURN
  4443 00004A95 E82C040000          <1> 	CALL	CMOS_TYPE		; RETURN DRIVE TYPE IN AL
  4444                              <1> 	;; 20/02/2015
  4445                              <1> 	;;JC	short CL_DRV		; ERROR IN CMOS ASSUME NO DRIVE
  4446 00004A9A 7440                <1> 	jz	short CL_DRV ;; 20/02/2015
  4447 00004A9C FEC8                <1> 	DEC	AL			; MAKE ZERO ORIGIN
  4448                              <1> 	;;JS	short CL_DRV		; NO DRIVE IF AL 0
  4449 00004A9E 8AA7[C58A0100]      <1> 	MOV	AH, [DSK_STATE+eDI]	; AH = CURRENT STATE
  4450 00004AA4 80E40F              <1> 	AND	AH, ~(MED_DET+DBL_STEP+RATE_MSK) ; CLEAR
  4451 00004AA7 08C0                <1> 	OR	AL,AL			; CHECK FOR 360
  4452 00004AA9 7505                <1> 	JNZ	short N_360		; IF 360 WILL BE 0
  4453 00004AAB 80CC90              <1> 	OR	AH,MED_DET+RATE_250	; ESTABLISH MEDIA
  4454 00004AAE EB25                <1> 	JMP	SHORT SKP_STATE		; SKIP OTHER STATE PROCESSING
  4455                              <1> N_360:	
  4456 00004AB0 FEC8                <1> 	DEC	AL			; 1.2 M DRIVE
  4457 00004AB2 7505                <1> 	JNZ	short N_12		; JUMP IF NOT
  4458                              <1> F1_RATE:
  4459 00004AB4 80CC10              <1> 	OR	AH,MED_DET+RATE_500	; SET FORMAT RATE
  4460 00004AB7 EB1C                <1> 	JMP	SHORT SKP_STATE		; SKIP OTHER STATE PROCESSING
  4461                              <1> N_12:	
  4462 00004AB9 FEC8                <1> 	DEC	AL			; CHECK FOR TYPE 3
  4463 00004ABB 750F                <1> 	JNZ	short N_720		; JUMP IF NOT
  4464 00004ABD F6C404              <1> 	TEST	AH,DRV_DET		; IS DRIVE DETERMINED
  4465 00004AC0 7410                <1> 	JZ	short ISNT_12		; TREAT AS NON 1.2 DRIVE
  4466 00004AC2 F6C402              <1> 	TEST	AH,FMT_CAPA		; IS 1.2M
  4467 00004AC5 740B                <1> 	JZ	short ISNT_12		; JUMP IF NOT
  4468 00004AC7 80CC50              <1> 	OR	AH,MED_DET+RATE_300	; RATE 300
  4469 00004ACA EB09                <1> 	JMP	SHORT SKP_STATE		; CONTINUE
  4470                              <1> N_720:
  4471 00004ACC FEC8                <1> 	DEC	AL			; CHECK FOR TYPE 4
  4472 00004ACE 750C                <1> 	JNZ	short CL_DRV		; NO DRIVE, CMOS BAD
  4473 00004AD0 EBE2                <1> 	JMP	SHORT F1_RATE
  4474                              <1> ISNT_12: 
  4475 00004AD2 80CC90              <1> 	OR	AH,MED_DET+RATE_250	; MUST BE RATE 250
  4476                              <1> 
  4477                              <1> SKP_STATE:
  4478 00004AD5 88A7[C58A0100]      <1> 	MOV	[DSK_STATE+eDI], AH	; STORE AWAY
  4479                              <1> F1_OUT:
  4480 00004ADB C3                  <1> 	RETn
  4481                              <1> CL_DRV:	
  4482 00004ADC 30E4                <1> 	XOR	AH,AH			; CLEAR STATE
  4483 00004ADE EBF5                <1> 	JMP	SHORT SKP_STATE		; SAVE IT
  4484                              <1> 
  4485                              <1> ;-------------------------------------------------------------------------------
  4486                              <1> ; MED_CHANGE	
  4487                              <1> ;	CHECKS FOR MEDIA CHANGE, RESETS MEDIA CHANGE, 
  4488                              <1> ;	CHECKS MEDIA CHANGE AGAIN.
  4489                              <1> ;
  4490                              <1> ; ON EXIT:	CY = 1 MEANS MEDIA CHANGE OR TIMEOUT
  4491                              <1> ;		@DSKETTE_STATUS = ERROR CODE
  4492                              <1> ;-------------------------------------------------------------------------------
  4493                              <1> MED_CHANGE:
  4494 00004AE0 E888060000          <1> 	CALL	READ_DSKCHNG		; READ DISK CHANCE LINE STATE
  4495 00004AE5 7447                <1> 	JZ	short MC_OUT		; BYPASS HANDLING DISK CHANGE LINE
  4496 00004AE7 80A7[C58A0100]EF    <1> 	AND	byte [DSK_STATE+eDI], ~MED_DET ; CLEAR STATE FOR THIS DRIVE
  4497                              <1> 
  4498                              <1> ;	THIS SEQUENCE ENSURES WHENEVER A DISKETTE IS CHANGED THAT
  4499                              <1> ;	ON THE NEXT OPERATION THE REQUIRED MOTOR START UP TIME WILL
  4500                              <1> ;	BE WAITED. (DRIVE MOTOR MAY GO OFF UPON DOOR OPENING).
  4501                              <1> 
  4502 00004AEE 6689F9              <1> 	MOV	CX,DI			; CL = DRIVE 0
  4503 00004AF1 B001                <1> 	MOV	AL,1			; MOTOR ON BIT MASK
  4504 00004AF3 D2E0                <1> 	SHL	AL,CL			; TO APPROPRIATE POSITION
  4505 00004AF5 F6D0                <1> 	NOT	AL			; KEEP ALL BUT MOTOR ON
  4506 00004AF7 FA                  <1> 	CLI				; NO INTERRUPTS
  4507 00004AF8 2005[B68A0100]      <1> 	AND	[MOTOR_STATUS], AL	; TURN MOTOR OFF INDICATOR
  4508 00004AFE FB                  <1> 	STI				; INTERRUPTS ENABLED
  4509 00004AFF E810040000          <1> 	CALL	MOTOR_ON		; TURN MOTOR ON
  4510                              <1> 
  4511                              <1> ;-----	THIS SEQUENCE OF SEEKS IS USED TO RESET DISKETTE CHANGE SIGNAL
  4512                              <1> 
  4513 00004B04 E850F9FFFF          <1> 	CALL	DSK_RESET		; RESET NEC
  4514 00004B09 B501                <1> 	MOV	CH,01H			; MOVE TO CYLINDER 1
  4515 00004B0B E8FF040000          <1> 	CALL	SEEK			; ISSUE SEEK
  4516 00004B10 30ED                <1> 	XOR	CH,CH			; MOVE TO CYLINDER 0
  4517 00004B12 E8F8040000          <1> 	CALL	SEEK			; ISSUE SEEK
  4518 00004B17 C605[B88A0100]06    <1> 	MOV	byte [DSKETTE_STATUS], MEDIA_CHANGE ; STORE IN STATUS
  4519                              <1> OK1:
  4520 00004B1E E84A060000          <1> 	CALL	READ_DSKCHNG		; CHECK MEDIA CHANGED AGAIN
  4521 00004B23 7407                <1> 	JZ	short OK2		; IF ACTIVE, NO DISKETTE, TIMEOUT
  4522                              <1> OK4:
  4523 00004B25 C605[B88A0100]80    <1> 	MOV	byte [DSKETTE_STATUS], TIME_OUT ; TIMEOUT IF DRIVE EMPTY
  4524                              <1> OK2:		
  4525 00004B2C F9                  <1> 	STC				; MEDIA CHANGED, SET CY
  4526 00004B2D C3                  <1> 	RETn
  4527                              <1> MC_OUT:
  4528 00004B2E F8                  <1> 	CLC				; NO MEDIA CHANGED, CLEAR CY
  4529 00004B2F C3                  <1> 	RETn
  4530                              <1> 
  4531                              <1> ;-------------------------------------------------------------------------------
  4532                              <1> ; SEND_RATE
  4533                              <1> ;	SENDS DATA RATE COMMAND TO NEC
  4534                              <1> ; ON ENTRY:	DI = DRIVE #
  4535                              <1> ; ON EXIT:	NONE
  4536                              <1> ; REGISTERS ALTERED: DX
  4537                              <1> ;-------------------------------------------------------------------------------
  4538                              <1> SEND_RATE:
  4539 00004B30 6650                <1> 	PUSH	AX			; SAVE REG.
  4540 00004B32 8025[C08A0100]3F    <1> 	AND	byte [LASTRATE], ~SEND_MSK ; ELSE CLEAR LAST RATE ATTEMPTED
  4541 00004B39 8A87[C58A0100]      <1> 	MOV	AL, [DSK_STATE+eDI]	; GET RATE STATE OF THIS DRIVE
  4542 00004B3F 24C0                <1> 	AND	AL,SEND_MSK		; KEEP ONLY RATE BITS
  4543 00004B41 0805[C08A0100]      <1> 	OR	[LASTRATE], AL		; SAVE NEW RATE FOR NEXT CHECK
  4544 00004B47 C0C002              <1> 	ROL	AL,2			; MOVE TO BIT OUTPUT POSITIONS
  4545 00004B4A 66BAF703            <1> 	MOV	DX,03F7H		; OUTPUT NEW DATA RATE
  4546 00004B4E EE                  <1> 	OUT	DX,AL
  4547 00004B4F 6658                <1> 	POP	AX			; RESTORE REG.
  4548 00004B51 C3                  <1> 	RETn
  4549                              <1> 
  4550                              <1> ;-------------------------------------------------------------------------------
  4551                              <1> ; CHK_LASTRATE
  4552                              <1> ;	CHECK PREVIOUS DATE RATE SNT TO THE CONTROLLER.
  4553                              <1> ; ON ENTRY:
  4554                              <1> ;	DI = DRIVE #
  4555                              <1> ; ON EXIT:
  4556                              <1> ;	ZF =  1 DATA RATE IS THE SAME AS THE LAST RATE SENT TO NEC
  4557                              <1> ;	ZF =  0 DATA RATE IS DIFFERENT FROM LAST RATE
  4558                              <1> ; REGISTERS ALTERED: DX
  4559                              <1> ;-------------------------------------------------------------------------------
  4560                              <1> CHK_LASTRATE:
  4561 00004B52 6650                <1> 	PUSH	AX			; SAVE REG
  4562 00004B54 2225[C08A0100]      <1> 	AND	AH, [LASTRATE]		; GET LAST DATA RATE SELECTED
  4563 00004B5A 8A87[C58A0100]      <1> 	MOV	AL, [DSK_STATE+eDI]	; GET RATE STATE OF THIS DRIVE
  4564 00004B60 6625C0C0            <1>         AND     AX, SEND_MSK*257        ; KEEP ONLY RATE BITS OF BOTH
  4565 00004B64 38E0                <1> 	CMP	AL, AH			; COMPARE TO PREVIOUSLY TRIED
  4566                              <1> 					; ZF = 1 RATE IS THE SAME
  4567 00004B66 6658                <1> 	POP	AX			; RESTORE REG.
  4568 00004B68 C3                  <1> 	RETn
  4569                              <1> 
  4570                              <1> ;-------------------------------------------------------------------------------
  4571                              <1> ; DMA_SETUP
  4572                              <1> ;	THIS ROUTINE SETS UP THE DMA FOR READ/WRITE/VERIFY OPERATIONS.
  4573                              <1> ;
  4574                              <1> ; ON ENTRY:	AL = DMA COMMAND
  4575                              <1> ;
  4576                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  4577                              <1> ;-------------------------------------------------------------------------------
  4578                              <1> 
  4579                              <1> ; SI = Head #, # of Sectors or DASD Type
  4580                              <1> 
  4581                              <1> ; 22/08/2015
  4582                              <1> ; 08/02/2015 - Protected Mode Modification
  4583                              <1> ; 06/02/2015 - 07/02/2015
  4584                              <1> ; NOTE: Buffer address must be in 1st 16MB of Physical Memory (24 bit limit).
  4585                              <1> ; (DMA Addres = Physical Address)
  4586                              <1> ; (Retro UNIX 386 v1 Kernel/System Mode Virtual Address = Physical Address)
  4587                              <1> ;
  4588                              <1> 
  4589                              <1> 
  4590                              <1> ; 04/02/2016 (clc)
  4591                              <1> ; 20/02/2015 modification (source: AWARD BIOS 1999, DMA_SETUP)
  4592                              <1> ; 16/12/2014 (IODELAY)
  4593                              <1> 
  4594                              <1> DMA_SETUP:
  4595                              <1> 
  4596                              <1> ;; 20/02/2015
  4597 00004B69 8B5504              <1> 	mov	edx, [ebp+4] 		; Buffer address
  4598 00004B6C F7C2000000FF        <1> 	test	edx, 0FF000000h		; 16 MB limit (22/08/2015, bugfix)
  4599 00004B72 756E                <1> 	jnz	short dma_bnd_err_stc
  4600                              <1> 	;
  4601 00004B74 6650                <1> 	push	ax			; DMA command
  4602 00004B76 52                  <1> 	push	edx			; *
  4603 00004B77 B203                <1> 	mov	dl, 3			; GET BYTES/SECTOR PARAMETER
  4604 00004B79 E851030000          <1> 	call	GET_PARM		; 
  4605 00004B7E 88E1                <1> 	mov	cl, ah 			; SHIFT COUNT (0=128, 1=256, 2=512 ETC)
  4606 00004B80 6689F0              <1> 	mov	ax, si			; Sector count
  4607 00004B83 88C4                <1> 	mov	ah, al			; AH =  # OF SECTORS
  4608 00004B85 28C0                <1> 	sub	al, al			; AL = 0, AX = # SECTORS * 256
  4609 00004B87 66D1E8              <1> 	shr	ax, 1			; AX = # SECTORS * 128
  4610 00004B8A 66D3E0              <1> 	shl	ax, cl			; SHIFT BY PARAMETER VALUE
  4611 00004B8D 6648                <1> 	dec	ax			; -1 FOR DMA VALUE
  4612 00004B8F 6689C1              <1> 	mov	cx, ax
  4613 00004B92 5A                  <1> 	pop	edx			; *
  4614 00004B93 6658                <1> 	pop	ax
  4615 00004B95 3C42                <1> 	cmp	al, 42h
  4616 00004B97 7507                <1>         jne     short NOT_VERF
  4617 00004B99 BA0000FF00          <1> 	mov	edx, 0FF0000h
  4618 00004B9E EB08                <1> 	jmp	short J33
  4619                              <1> NOT_VERF:
  4620 00004BA0 6601CA              <1> 	add	dx, cx			; check for overflow
  4621 00004BA3 723E                <1> 	jc	short dma_bnd_err
  4622                              <1> 	;
  4623 00004BA5 6629CA              <1> 	sub	dx, cx			; Restore start address
  4624                              <1> J33:
  4625 00004BA8 FA                  <1> 	CLI				; DISABLE INTERRUPTS DURING DMA SET-UP
  4626 00004BA9 E60C                <1> 	OUT	DMA+12,AL		; SET THE FIRST/LA5T F/F
  4627                              <1> 	IODELAY				; WAIT FOR I/O
  2970 00004BAB EB00                <2>  jmp short $+2
  2971 00004BAD EB00                <2>  jmp short $+2
  4628 00004BAF E60B                <1> 	OUT	DMA+11,AL		; OUTPUT THE MODE BYTE
  4629 00004BB1 89D0                <1> 	mov	eax, edx		; Buffer address
  4630 00004BB3 E604                <1> 	OUT	DMA+4,AL		; OUTPUT LOW ADDRESS
  4631                              <1> 	IODELAY				; WAIT FOR I/O
  2970 00004BB5 EB00                <2>  jmp short $+2
  2971 00004BB7 EB00                <2>  jmp short $+2
  4632 00004BB9 88E0                <1> 	MOV	AL,AH
  4633 00004BBB E604                <1> 	OUT	DMA+4,AL		; OUTPUT HIGH ADDRESS
  4634 00004BBD C1E810              <1> 	shr	eax, 16
  4635                              <1> 	IODELAY				; I/O WAIT STATE
  2970 00004BC0 EB00                <2>  jmp short $+2
  2971 00004BC2 EB00                <2>  jmp short $+2
  4636 00004BC4 E681                <1> 	OUT	081H,AL			; OUTPUT highest BITS TO PAGE REGISTER
  4637                              <1> 	IODELAY
  2970 00004BC6 EB00                <2>  jmp short $+2
  2971 00004BC8 EB00                <2>  jmp short $+2
  4638 00004BCA 6689C8              <1> 	mov	ax, cx			; Byte count - 1
  4639 00004BCD E605                <1> 	OUT	DMA+5,AL		; LOW BYTE OF COUNT
  4640                              <1> 	IODELAY				; WAIT FOR I/O
  2970 00004BCF EB00                <2>  jmp short $+2
  2971 00004BD1 EB00                <2>  jmp short $+2
  4641 00004BD3 88E0                <1> 	MOV	AL, AH
  4642 00004BD5 E605                <1> 	OUT	DMA+5,AL		; HIGH BYTE OF COUNT
  4643                              <1> 	IODELAY
  2970 00004BD7 EB00                <2>  jmp short $+2
  2971 00004BD9 EB00                <2>  jmp short $+2
  4644 00004BDB FB                  <1> 	STI				; RE-ENABLE INTERRUPTS
  4645 00004BDC B002                <1> 	MOV	AL, 2			; MODE FOR 8237
  4646 00004BDE E60A                <1> 	OUT	DMA+10, AL		; INITIALIZE THE DISKETTE CHANNEL
  4647                              <1> 
  4648 00004BE0 F8                  <1> 	clc	; 04/02/2016
  4649 00004BE1 C3                  <1> 	retn
  4650                              <1> 
  4651                              <1> dma_bnd_err_stc:
  4652 00004BE2 F9                  <1> 	stc
  4653                              <1> dma_bnd_err:
  4654 00004BE3 C605[B88A0100]09    <1> 	MOV	byte [DSKETTE_STATUS], DMA_BOUNDARY ; SET ERROR
  4655 00004BEA C3                  <1> 	RETn				; CY SET BY ABOVE IF ERROR
  4656                              <1> 
  4657                              <1> ;; 16/12/2014
  4658                              <1> ;;	CLI				; DISABLE INTERRUPTS DURING DMA SET-UP
  4659                              <1> ;;	OUT	DMA+12,AL		; SET THE FIRST/LA5T F/F
  4660                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  4661                              <1> ;;	IODELAY
  4662                              <1> ;; 	OUT	DMA+11,AL		; OUTPUT THE MODE BYTE
  4663                              <1> ;;	;SIODELAY
  4664                              <1> ;;      ;CMP	AL, 42H			; DMA VERIFY COMMAND
  4665                              <1> ;;      ;JNE	short NOT_VERF		; NO
  4666                              <1> ;;      ;XOR	AX, AX			; START ADDRESS
  4667                              <1> ;;      ;JMP	SHORT J33
  4668                              <1> ;;;NOT_VERF:	
  4669                              <1> ;;	;MOV	AX,ES			; GET THE ES VALUE
  4670                              <1> ;;	;ROL	AX,4			; ROTATE LEFT
  4671                              <1> ;;	;MOV	CH,AL			; GET HIGHEST NIBBLE OF ES TO CH
  4672                              <1> ;;	;AND	AL,11110000B		; ZERO THE LOW NIBBLE FROM SEGMENT
  4673                              <1> ;;	;ADD	AX,[BP+2]		; TEST FOR CARRY FROM ADDITION
  4674                              <1> ;;	mov	eax, [ebp+4] ; 06/02/2015	
  4675                              <1> ;;	;JNC	short J33
  4676                              <1> ;;	;INC	CH			; CARRY MEANS HIGH 4 BITS MUST BE INC
  4677                              <1> ;;;J33:
  4678                              <1> ;;	PUSH	eAX			; SAVE START ADDRESS
  4679                              <1> ;;	OUT	DMA+4,AL		; OUTPUT LOW ADDRESS
  4680                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  4681                              <1> ;;	IODELAY
  4682                              <1> ;;	MOV	AL,AH
  4683                              <1> ;;	OUT	DMA+4,AL		; OUTPUT HIGH ADDRESS
  4684                              <1> ;;	shr	eax, 16	     ; 07/02/2015
  4685                              <1> ;;	;MOV	AL,CH			; GET HIGH 4 BITS
  4686                              <1> ;;	;JMP	$+2			; I/O WAIT STATE
  4687                              <1> ;;	IODELAY
  4688                              <1> ;;	;AND	AL,00001111B
  4689                              <1> ;;	OUT	081H,AL			; OUTPUT HIGH 4 BITS TO PAGE REGISTER
  4690                              <1> ;;	;SIODELAY
  4691                              <1> ;;
  4692                              <1> ;;;----- DETERMINE COUNT
  4693                              <1> ;;	sub	eax, eax ; 08/02/2015
  4694                              <1> ;;	MOV	AX, SI			; AL =  # OF SECTORS
  4695                              <1> ;;	XCHG	AL, AH			; AH =  # OF SECTORS
  4696                              <1> ;;	SUB	AL, AL			; AL = 0, AX = # SECTORS * 256
  4697                              <1> ;;	SHR	AX, 1			; AX = # SECTORS * 128
  4698                              <1> ;;	PUSH	AX			; SAVE # OF SECTORS * 128
  4699                              <1> ;;	MOV	DL, 3			; GET BYTES/SECTOR PARAMETER
  4700                              <1> ;;	CALL	GET_PARM		; "
  4701                              <1> ;;	MOV	CL,AH			; SHIFT COUNT (0=128, 1=256, 2=512 ETC)
  4702                              <1> ;;	POP	AX			; AX = # SECTORS * 128
  4703                              <1> ;;	SHL	AX,CL			; SHIFT BY PARAMETER VALUE
  4704                              <1> ;;	DEC	AX			; -1 FOR DMA VALUE
  4705                              <1> ;;	PUSH	eAX  ; 08/02/2015	; SAVE COUNT VALUE
  4706                              <1> ;;	OUT	DMA+5,AL		; LOW BYTE OF COUNT
  4707                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  4708                              <1> ;;	IODELAY
  4709                              <1> ;;	MOV	AL, AH
  4710                              <1> ;;	OUT	DMA+5,AL		; HIGH BYTE OF COUNT
  4711                              <1> ;;	;IODELAY
  4712                              <1> ;;	STI				; RE-ENABLE INTERRUPTS
  4713                              <1> ;;	POP	eCX  ; 08/02/2015 	; RECOVER COUNT VALUE
  4714                              <1> ;;	POP	eAX  ; 08/02/2015	; RECOVER ADDRESS VALUE
  4715                              <1> ;;	;ADD	AX, CX			; ADD, TEST FOR 64K OVERFLOW
  4716                              <1> ;;	add	ecx, eax ; 08/02/2015
  4717                              <1> ;;	MOV	AL, 2			; MODE FOR 8237
  4718                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  4719                              <1> ;;	SIODELAY
  4720                              <1> ;;	OUT	DMA+10, AL		; INITIALIZE THE DISKETTE CHANNEL
  4721                              <1> ;;	;JNC	short NO_BAD		; CHECK FOR ERROR
  4722                              <1> ;;	jc	short dma_bnd_err ; 08/02/2015
  4723                              <1> ;;	and	ecx, 0FFF00000h ; 16 MB limit
  4724                              <1> ;;	jz	short NO_BAD
  4725                              <1> ;;dma_bnd_err:
  4726                              <1> ;;	MOV	byte [DSKETTE_STATUS], DMA_BOUNDARY ; SET ERROR
  4727                              <1> ;;NO_BAD:
  4728                              <1> ;;	RETn				; CY SET BY ABOVE IF ERROR
  4729                              <1> 
  4730                              <1> ;-------------------------------------------------------------------------------
  4731                              <1> ; FMTDMA_SET
  4732                              <1> ;	THIS ROUTINE SETS UP THE DMA CONTROLLER FOR A FORMAT OPERATION.
  4733                              <1> ;
  4734                              <1> ; ON ENTRY:	NOTHING REQUIRED
  4735                              <1> ;
  4736                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  4737                              <1> ;-------------------------------------------------------------------------------
  4738                              <1> 
  4739                              <1> FMTDMA_SET:
  4740                              <1> ;; 20/02/2015 modification	
  4741 00004BEB 8B5504              <1> 	mov	edx, [ebp+4] 		; Buffer address
  4742 00004BEE F7C20000F0FF        <1> 	test	edx, 0FFF00000h		; 16 MB limit
  4743 00004BF4 75EC                <1> 	jnz	short dma_bnd_err_stc
  4744                              <1> 	;
  4745 00004BF6 6652                <1> 	push	dx			; *
  4746 00004BF8 B204                <1> 	mov	DL, 4			; SECTORS/TRACK VALUE IN PARM TABLE
  4747 00004BFA E8D0020000          <1> 	call	GET_PARM		; "
  4748 00004BFF 88E0                <1> 	mov	al, ah			; AL = SECTORS/TRACK VALUE
  4749 00004C01 28E4                <1> 	sub	ah, ah			; AX = SECTORS/TRACK VALUE
  4750 00004C03 66C1E002            <1> 	shl	ax, 2			; AX = SEC/TRK * 4 (OFFSET C,H,R,N)
  4751 00004C07 6648                <1> 	dec	ax			; -1 FOR DMA VALUE
  4752 00004C09 6689C1              <1> 	mov	cx, ax
  4753 00004C0C 665A                <1> 	pop	dx			; *
  4754 00004C0E 6601CA              <1> 	add	dx, cx			; check for overflow
  4755 00004C11 72D0                <1> 	jc	short dma_bnd_err
  4756                              <1> 	;
  4757 00004C13 6629CA              <1> 	sub	dx, cx			; Restore start address
  4758                              <1> 	;
  4759 00004C16 B04A                <1> 	MOV	AL, 04AH		; WILL WRITE TO THE DISKETTE
  4760 00004C18 FA                  <1> 	CLI				; DISABLE INTERRUPTS DURING DMA SET-UP
  4761 00004C19 E60C                <1> 	OUT	DMA+12,AL		; SET THE FIRST/LA5T F/F
  4762                              <1> 	IODELAY				; WAIT FOR I/O
  2970 00004C1B EB00                <2>  jmp short $+2
  2971 00004C1D EB00                <2>  jmp short $+2
  4763 00004C1F E60B                <1> 	OUT	DMA+11,AL		; OUTPUT THE MODE BYTE
  4764 00004C21 89D0                <1> 	mov	eax, edx		; Buffer address
  4765 00004C23 E604                <1> 	OUT	DMA+4,AL		; OUTPUT LOW ADDRESS
  4766                              <1> 	IODELAY				; WAIT FOR I/O
  2970 00004C25 EB00                <2>  jmp short $+2
  2971 00004C27 EB00                <2>  jmp short $+2
  4767 00004C29 88E0                <1> 	MOV	AL,AH
  4768 00004C2B E604                <1> 	OUT	DMA+4,AL		; OUTPUT HIGH ADDRESS
  4769 00004C2D C1E810              <1> 	shr	eax, 16
  4770                              <1> 	IODELAY				; I/O WAIT STATE
  2970 00004C30 EB00                <2>  jmp short $+2
  2971 00004C32 EB00                <2>  jmp short $+2
  4771 00004C34 E681                <1> 	OUT	081H,AL			; OUTPUT highest BITS TO PAGE REGISTER
  4772                              <1> 	IODELAY
  2970 00004C36 EB00                <2>  jmp short $+2
  2971 00004C38 EB00                <2>  jmp short $+2
  4773 00004C3A 6689C8              <1> 	mov	ax, cx			; Byte count - 1
  4774 00004C3D E605                <1> 	OUT	DMA+5,AL		; LOW BYTE OF COUNT
  4775                              <1> 	IODELAY				; WAIT FOR I/O
  2970 00004C3F EB00                <2>  jmp short $+2
  2971 00004C41 EB00                <2>  jmp short $+2
  4776 00004C43 88E0                <1> 	MOV	AL, AH
  4777 00004C45 E605                <1> 	OUT	DMA+5,AL		; HIGH BYTE OF COUNT
  4778                              <1> 	IODELAY
  2970 00004C47 EB00                <2>  jmp short $+2
  2971 00004C49 EB00                <2>  jmp short $+2
  4779 00004C4B FB                  <1> 	STI				; RE-ENABLE INTERRUPTS
  4780 00004C4C B002                <1> 	MOV	AL, 2			; MODE FOR 8237
  4781 00004C4E E60A                <1> 	OUT	DMA+10, AL		; INITIALIZE THE DISKETTE CHANNEL
  4782 00004C50 C3                  <1> 	retn
  4783                              <1> 
  4784                              <1> ;; 08/02/2015 - Protected Mode Modification
  4785                              <1> ;;	MOV	AL, 04AH		; WILL WRITE TO THE DISKETTE
  4786                              <1> ;;	CLI				; DISABLE INTERRUPTS DURING DMA SET-UP
  4787                              <1> ;;	OUT	DMA+12,AL		; SET THE FIRST/LA5T F/F
  4788                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  4789                              <1> ;;	IODELAY
  4790                              <1> ;;	OUT	DMA+11,AL		; OUTPUT THE MODE BYTE
  4791                              <1> ;;	;MOV	AX,ES			; GET THE ES VALUE
  4792                              <1> ;;	;ROL	AX,4			; ROTATE LEFT
  4793                              <1> ;;	;MOV	CH,AL			; GET HIGHEST NIBBLE OF ES TO CH
  4794                              <1> ;;	;AND	AL,11110000B		; ZERO THE LOW NIBBLE FROM SEGMENT
  4795                              <1> ;;	;ADD	AX,[BP+2]		; TEST FOR CARRY FROM ADDITION
  4796                              <1> ;;	;JNC	short J33A
  4797                              <1> ;;	;INC	CH			; CARRY MEANS HIGH 4 BITS MUST BE INC
  4798                              <1> ;;	mov	eax, [ebp+4] ; 08/02/2015
  4799                              <1> ;;;J33A:
  4800                              <1> ;;	PUSH	eAX ; 08/02/2015	; SAVE START ADDRESS
  4801                              <1> ;;	OUT	DMA+4,AL		; OUTPUT LOW ADDRESS
  4802                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  4803                              <1> ;;	IODELAY
  4804                              <1> ;;	MOV	AL,AH
  4805                              <1> ;;	OUT	DMA+4,AL		; OUTPUT HIGH ADDRESS
  4806                              <1> ;;	shr 	eax, 16 ; 08/02/2015
  4807                              <1> ;;	;MOV	AL,CH			; GET HIGH 4 BITS
  4808                              <1> ;;	;JMP	$+2			; I/O WAIT STATE
  4809                              <1> ;;	IODELAY
  4810                              <1> ;;	;AND	AL,00001111B
  4811                              <1> ;;	OUT	081H,AL			; OUTPUT HIGH 4 BITS TO PAGE REGISTER
  4812                              <1> ;;
  4813                              <1> ;;;----- DETERMINE COUNT
  4814                              <1> ;;	sub	eax, eax ; 08/02/2015
  4815                              <1> ;;	MOV	DL, 4			; SECTORS/TRACK VALUE IN PARM TABLE
  4816                              <1> ;;	CALL	GET_PARM		; "
  4817                              <1> ;;	XCHG	AL, AH			; AL = SECTORS/TRACK VALUE
  4818                              <1> ;;	SUB	AH, AH			; AX = SECTORS/TRACK VALUE
  4819                              <1> ;;	SHL	AX, 2			; AX = SEC/TRK * 4 (OFFSET C,H,R,N)
  4820                              <1> ;;	DEC	AX			; -1 FOR DMA VALUE
  4821                              <1> ;;	PUSH	eAX 	; 08/02/2015	; SAVE # OF BYTES TO BE TRANSFERED
  4822                              <1> ;;	OUT	DMA+5,AL		; LOW BYTE OF COUNT
  4823                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  4824                              <1> ;;	IODELAY
  4825                              <1> ;;	MOV	AL, AH
  4826                              <1> ;;	OUT	DMA+5,AL		; HIGH BYTE OF COUNT
  4827                              <1> ;;	STI				; RE-ENABLE INTERRUPTS
  4828                              <1> ;;	POP	eCX	; 08/02/2015	; RECOVER COUNT VALUE
  4829                              <1> ;;	POP	eAX	; 08/02/2015	; RECOVER ADDRESS VALUE
  4830                              <1> ;;	;ADD	AX, CX			; ADD, TEST FOR 64K OVERFLOW
  4831                              <1> ;;	add	ecx, eax ; 08/02/2015
  4832                              <1> ;;	MOV	AL, 2			; MODE FOR 8237
  4833                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  4834                              <1> ;;	SIODELAY
  4835                              <1> ;;	OUT	DMA+10, AL		; INITIALIZE THE DISKETTE CHANNEL
  4836                              <1> ;;	;JNC	short FMTDMA_OK		; CHECK FOR ERROR
  4837                              <1> ;;	jc	short fmtdma_bnd_err ; 08/02/2015
  4838                              <1> ;;	and	ecx, 0FFF00000h  ; 16 MB limit
  4839                              <1> ;;	jz	short FMTDMA_OK
  4840                              <1> ;;	stc	; 20/02/2015
  4841                              <1> ;;fmtdma_bnd_err:
  4842                              <1> ;;	MOV	byte [DSKETTE_STATUS], DMA_BOUNDARY ; SET ERROR
  4843                              <1> ;;FMTDMA_OK:
  4844                              <1> ;;	RETn				; CY SET BY ABOVE IF ERROR
  4845                              <1> 
  4846                              <1> ;-------------------------------------------------------------------------------
  4847                              <1> ; NEC_INIT	
  4848                              <1> ;	THIS ROUTINE SEEKS TO THE REQUESTED TRACK AND INITIALIZES
  4849                              <1> ;	THE NEC FOR THE READ/WRITE/VERIFY/FORMAT OPERATION.
  4850                              <1> ;
  4851                              <1> ; ON ENTRY:	AH = NEC COMMAND TO BE PERFORMED
  4852                              <1> ;
  4853                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  4854                              <1> ;-------------------------------------------------------------------------------
  4855                              <1> NEC_INIT:
  4856 00004C51 6650                <1> 	PUSH	AX			; SAVE NEC COMMAND
  4857 00004C53 E8BC020000          <1> 	CALL	MOTOR_ON		; TURN MOTOR ON FOR SPECIFIC DRIVE
  4858                              <1> 
  4859                              <1> ;-----	DO THE SEEK OPERATION
  4860                              <1> 
  4861 00004C58 8A6D01              <1> 	MOV	CH,[eBP+1]		; CH = TRACK #
  4862 00004C5B E8AF030000          <1> 	CALL	SEEK			; MOVE TO CORRECT TRACK
  4863 00004C60 6658                <1> 	POP	AX			; RECOVER COMMAND
  4864 00004C62 721E                <1> 	JC	short ER_1		; ERROR ON SEEK
  4865 00004C64 BB[824C0000]        <1> 	MOV	eBX, ER_1		; LOAD ERROR ADDRESS
  4866 00004C69 53                  <1> 	PUSH	eBX			; PUSH NEC_OUT ERROR RETURN
  4867                              <1> 
  4868                              <1> ;-----	SEND OUT THE PARAMETERS TO THE CONTROLLER
  4869                              <1> 
  4870 00004C6A E866030000          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE OPERATION COMMAND
  4871 00004C6F 6689F0              <1> 	MOV	AX,SI			; AH = HEAD #
  4872 00004C72 89FB                <1> 	MOV	eBX,eDI			; BL = DRIVE #
  4873 00004C74 C0E402              <1> 	SAL	AH,2			; MOVE IT TO BIT 2
  4874 00004C77 80E404              <1> 	AND	AH,00000100B		; ISOLATE THAT BIT
  4875 00004C7A 08DC                <1> 	OR	AH,BL			; OR IN THE DRIVE NUMBER
  4876 00004C7C E854030000          <1> 	CALL	NEC_OUTPUT		; FALL THRU CY SET IF ERROR
  4877 00004C81 5B                  <1> 	POP	eBX			; THROW AWAY ERROR RETURN
  4878                              <1> ER_1:
  4879 00004C82 C3                  <1> 	RETn
  4880                              <1> 
  4881                              <1> ;-------------------------------------------------------------------------------
  4882                              <1> ; RWV_COM
  4883                              <1> ;	THIS ROUTINE SENDS PARAMETERS TO THE NEC SPECIFIC TO THE 
  4884                              <1> ;	READ/WRITE/VERIFY OPERATIONS.
  4885                              <1> ;
  4886                              <1> ; ON ENTRY:	CS:BX = ADDRESS OF MEDIA/DRIVE PARAMETER TABLE
  4887                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  4888                              <1> ;-------------------------------------------------------------------------------
  4889                              <1> RWV_COM:
  4890 00004C83 B8[CE4C0000]        <1> 	MOV	eAX, ER_2		; LOAD ERROR ADDRESS
  4891 00004C88 50                  <1> 	PUSH	eAX			; PUSH NEC_OUT ERROR RETURN
  4892 00004C89 8A6501              <1> 	MOV	AH,[eBP+1]		; OUTPUT TRACK #
  4893 00004C8C E844030000          <1> 	CALL	NEC_OUTPUT
  4894 00004C91 6689F0              <1> 	MOV	AX,SI			; OUTPUT HEAD #
  4895 00004C94 E83C030000          <1> 	CALL	NEC_OUTPUT
  4896 00004C99 8A6500              <1>         MOV     AH,[eBP]                ; OUTPUT SECTOR #
  4897 00004C9C E834030000          <1> 	CALL	NEC_OUTPUT
  4898 00004CA1 B203                <1> 	MOV	DL,3			; BYTES/SECTOR PARAMETER FROM BLOCK
  4899 00004CA3 E827020000          <1> 	CALL	GET_PARM 		; ... TO THE NEC
  4900 00004CA8 E828030000          <1> 	CALL	NEC_OUTPUT		; OUTPUT TO CONTROLLER
  4901 00004CAD B204                <1> 	MOV	DL,4			; EOT PARAMETER FROM BLOCK
  4902 00004CAF E81B020000          <1> 	CALL	GET_PARM 		; ... TO THE NEC
  4903 00004CB4 E81C030000          <1> 	CALL	NEC_OUTPUT		; OUTPUT TO CONTROLLER
  4904 00004CB9 8A6305              <1>         MOV     AH, [eBX+MD.GAP]        ; GET GAP LENGTH
  4905                              <1> _R15:
  4906 00004CBC E814030000          <1> 	CALL	NEC_OUTPUT
  4907 00004CC1 B206                <1> 	MOV	DL,6			; DTL PARAMETER PROM BLOCK
  4908 00004CC3 E807020000          <1> 	CALL	GET_PARM		;  TO THE NEC
  4909 00004CC8 E808030000          <1> 	CALL	NEC_OUTPUT		; OUTPUT TO CONTROLLER
  4910 00004CCD 58                  <1> 	POP	eAX			; THROW AWAY ERROR EXIT
  4911                              <1> ER_2:
  4912 00004CCE C3                  <1> 	RETn
  4913                              <1> 
  4914                              <1> ;-------------------------------------------------------------------------------
  4915                              <1> ; NEC_TERM
  4916                              <1> ;	THIS ROUTINE WAITS FOR THE OPERATION THEN ACCEPTS THE STATUS 
  4917                              <1> ;	FROM THE NEC FOR THE READ/WRITE/VERIFY/FORWAT OPERATION.
  4918                              <1> ;
  4919                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  4920                              <1> ;-------------------------------------------------------------------------------
  4921                              <1> NEC_TERM:
  4922                              <1> 
  4923                              <1> ;-----	LET THE OPERATION HAPPEN
  4924                              <1> 
  4925 00004CCF 56                  <1> 	PUSH	eSI			; SAVE HEAD #, # OF SECTORS
  4926 00004CD0 E80D040000          <1> 	CALL	WAIT_INT		; WAIT FOR THE INTERRUPT
  4927 00004CD5 9C                  <1> 	PUSHF
  4928 00004CD6 E837040000          <1> 	CALL	RESULTS			; GET THE NEC STATUS
  4929 00004CDB 724B                <1> 	JC	short SET_END_POP
  4930 00004CDD 9D                  <1> 	POPF
  4931 00004CDE 723E                <1> 	JC	short SET_END		; LOOK FOR ERROR
  4932                              <1> 
  4933                              <1> ;-----	CHECK THE RESULTS RETURNED BY THE CONTROLLER
  4934                              <1> 
  4935 00004CE0 FC                  <1> 	CLD				; SET THE CORRECT DIRECTION
  4936 00004CE1 BE[B98A0100]        <1> 	MOV	eSI, NEC_STATUS		; POINT TO STATUS FIELD
  4937 00004CE6 AC                  <1> 	lodsb				; GET ST0
  4938 00004CE7 24C0                <1> 	AND	AL,11000000B		; TEST FOR NORMAL TERMINATION
  4939 00004CE9 7433                <1> 	JZ	short SET_END
  4940 00004CEB 3C40                <1> 	CMP	AL,01000000B		; TEST FOR ABNORMAL TERMINATION
  4941 00004CED 7527                <1> 	JNZ	short J18		; NOT ABNORMAL, BAD NEC
  4942                              <1> 
  4943                              <1> ;-----	ABNORMAL TERMINATION, FIND OUT WHY
  4944                              <1> 
  4945 00004CEF AC                  <1> 	lodsb				; GET ST1
  4946 00004CF0 D0E0                <1> 	SAL	AL,1			; TEST FOR EDT FOUND
  4947 00004CF2 B404                <1> 	MOV	AH,RECORD_NOT_FND
  4948 00004CF4 7222                <1> 	JC	short J19
  4949 00004CF6 C0E002              <1> 	SAL	AL,2
  4950 00004CF9 B410                <1> 	MOV	AH,BAD_CRC
  4951 00004CFB 721B                <1> 	JC	short J19
  4952 00004CFD D0E0                <1> 	SAL	AL,1			; TEST FOR DMA OVERRUN
  4953 00004CFF B408                <1> 	MOV	AH,BAD_DMA
  4954 00004D01 7215                <1> 	JC	short J19
  4955 00004D03 C0E002              <1> 	SAL	AL,2			; TEST FOR RECORD NOT FOUND
  4956 00004D06 B404                <1> 	MOV	AH,RECORD_NOT_FND
  4957 00004D08 720E                <1> 	JC	short J19
  4958 00004D0A D0E0                <1> 	SAL	AL,1
  4959 00004D0C B403                <1> 	MOV	AH,WRITE_PROTECT	; TEST FOR WRITE_PROTECT
  4960 00004D0E 7208                <1> 	JC	short J19
  4961 00004D10 D0E0                <1> 	SAL	AL,1			; TEST MISSING ADDRESS MARK
  4962 00004D12 B402                <1> 	MOV	AH,BAD_ADDR_MARK
  4963 00004D14 7202                <1> 	JC	short J19
  4964                              <1> 
  4965                              <1> ;----- 	NEC MUST HAVE FAILED
  4966                              <1> J18:
  4967 00004D16 B420                <1> 	MOV	AH,BAD_NEC
  4968                              <1> J19:
  4969 00004D18 0825[B88A0100]      <1> 	OR	[DSKETTE_STATUS], AH
  4970                              <1> SET_END:
  4971 00004D1E 803D[B88A0100]01    <1> 	CMP	byte [DSKETTE_STATUS], 1 ; SET ERROR CONDITION
  4972 00004D25 F5                  <1> 	CMC
  4973 00004D26 5E                  <1> 	POP	eSI
  4974 00004D27 C3                  <1> 	RETn				; RESTORE HEAD #, # OF SECTORS
  4975                              <1> 
  4976                              <1> SET_END_POP:
  4977 00004D28 9D                  <1> 	POPF
  4978 00004D29 EBF3                <1> 	JMP	SHORT SET_END
  4979                              <1> 
  4980                              <1> ;-------------------------------------------------------------------------------
  4981                              <1> ; DSTATE:	ESTABLISH STATE UPON SUCCESSFUL OPERATION.
  4982                              <1> ;-------------------------------------------------------------------------------
  4983                              <1> DSTATE:
  4984 00004D2B 803D[B88A0100]00    <1> 	CMP	byte [DSKETTE_STATUS],0	; CHECK FOR ERROR
  4985 00004D32 753E                <1> 	JNZ	short SETBAC		    ; IF ERROR JUMP
  4986 00004D34 808F[C58A0100]10    <1> 	OR	byte [DSK_STATE+eDI],MED_DET ; NO ERROR, MARK MEDIA AS DETERMINED
  4987 00004D3B F687[C58A0100]04    <1> 	TEST	byte [DSK_STATE+eDI],DRV_DET ; DRIVE DETERMINED ?
  4988 00004D42 752E                <1> 	JNZ	short SETBAC		; IF DETERMINED NO TRY TO DETERMINE
  4989 00004D44 8A87[C58A0100]      <1> 	MOV	AL,[DSK_STATE+eDI]	; LOAD STATE
  4990 00004D4A 24C0                <1> 	AND	AL,RATE_MSK		; KEEP ONLY RATE
  4991 00004D4C 3C80                <1> 	CMP	AL,RATE_250		; RATE 250 ?
  4992 00004D4E 751B                <1> 	JNE	short M_12		; NO, MUST BE 1.2M OR 1.44M DRIVE
  4993                              <1> 
  4994                              <1> ;----- 	CHECK IF IT IS 1.44M
  4995                              <1> 
  4996 00004D50 E871010000          <1> 	CALL	CMOS_TYPE		; RETURN DRIVE TYPE IN (AL)
  4997                              <1> 	;;20/02/2015
  4998                              <1> 	;;JC	short M_12		; CMOS BAD
  4999 00004D55 7414                <1> 	jz	short M_12 ;; 20/02/2015
  5000 00004D57 3C04                <1> 	CMP	AL, 4			; 1.44MB DRIVE ?
  5001 00004D59 7410                <1> 	JE	short M_12		; YES
  5002                              <1> M_720:
  5003 00004D5B 80A7[C58A0100]FD    <1> 	AND	byte [DSK_STATE+eDI], ~FMT_CAPA ; TURN OFF FORMAT CAPABILITY
  5004 00004D62 808F[C58A0100]04    <1> 	OR	byte [DSK_STATE+eDI],DRV_DET  ; MARK DRIVE DETERMINED
  5005 00004D69 EB07                <1> 	JMP	SHORT SETBAC		; BACK
  5006                              <1> M_12:	
  5007 00004D6B 808F[C58A0100]06    <1> 	OR	byte [DSK_STATE+eDI],DRV_DET+FMT_CAPA 
  5008                              <1> 					; TURN ON DETERMINED & FMT CAPA
  5009                              <1> SETBAC:
  5010 00004D72 C3                  <1> 	RETn
  5011                              <1> 
  5012                              <1> ;-------------------------------------------------------------------------------
  5013                              <1> ; RETRY	
  5014                              <1> ;	DETERMINES WHETHER A RETRY IS NECESSARY. 
  5015                              <1> ;	IF RETRY IS REQUIRED THEN STATE INFORMATION IS UPDATED FOR RETRY.
  5016                              <1> ;
  5017                              <1> ; ON EXIT:	CY = 1 FOR RETRY, CY = 0 FOR NO RETRY
  5018                              <1> ;-------------------------------------------------------------------------------
  5019                              <1> RETRY:
  5020 00004D73 803D[B88A0100]00    <1> 	CMP	byte [DSKETTE_STATUS],0	; GET STATUS OF OPERATION
  5021 00004D7A 7445                <1> 	JZ	short NO_RETRY		; SUCCESSFUL OPERATION
  5022 00004D7C 803D[B88A0100]80    <1> 	CMP	byte [DSKETTE_STATUS],TIME_OUT ; IF TIME OUT NO RETRY
  5023 00004D83 743C                <1> 	JZ	short NO_RETRY
  5024 00004D85 8AA7[C58A0100]      <1> 	MOV	AH,[DSK_STATE+eDI]	; GET MEDIA STATE OF DRIVE
  5025 00004D8B F6C410              <1> 	TEST	AH,MED_DET		; ESTABLISHED/DETERMINED ?
  5026 00004D8E 7531                <1> 	JNZ	short NO_RETRY		; IF ESTABLISHED STATE THEN TRUE ERROR
  5027 00004D90 80E4C0              <1> 	AND	AH,RATE_MSK		; ISOLATE RATE
  5028 00004D93 8A2D[C08A0100]      <1> 	MOV	CH,[LASTRATE]		; GET START OPERATION STATE
  5029 00004D99 C0C504              <1> 	ROL	CH,4			; TO CORRESPONDING BITS
  5030 00004D9C 80E5C0              <1> 	AND	CH,RATE_MSK		; ISOLATE RATE BITS
  5031 00004D9F 38E5                <1> 	CMP	CH,AH			; ALL RATES TRIED
  5032 00004DA1 741E                <1> 	JE	short NO_RETRY		; IF YES, THEN TRUE ERROR
  5033                              <1> 
  5034                              <1> ;	SETUP STATE INDICATOR FOR RETRY ATTEMPT TO NEXT RATE
  5035                              <1> ;	 00000000B (500) -> 10000000B	(250)
  5036                              <1> ;	 10000000B (250) -> 01000000B	(300)
  5037                              <1> ;	 01000000B (300) -> 00000000B	(500)
  5038                              <1> 
  5039 00004DA3 80FC01              <1> 	CMP	AH,RATE_500+1		; SET CY FOR RATE 500
  5040 00004DA6 D0DC                <1> 	RCR	AH,1			; TO NEXT STATE
  5041 00004DA8 80E4C0              <1> 	AND	AH,RATE_MSK		; KEEP ONLY RATE BITS
  5042 00004DAB 80A7[C58A0100]1F    <1> 	AND	byte [DSK_STATE+eDI], ~(RATE_MSK+DBL_STEP)
  5043                              <1> 					; RATE, DBL STEP OFF
  5044 00004DB2 08A7[C58A0100]      <1> 	OR	[DSK_STATE+eDI],AH	; TURN ON NEW RATE
  5045 00004DB8 C605[B88A0100]00    <1> 	MOV	byte [DSKETTE_STATUS],0	; RESET STATUS FOR RETRY
  5046 00004DBF F9                  <1> 	STC				; SET CARRY FOR RETRY
  5047 00004DC0 C3                  <1> 	RETn				; RETRY RETURN
  5048                              <1> 
  5049                              <1> NO_RETRY:
  5050 00004DC1 F8                  <1> 	CLC				; CLEAR CARRY NO RETRY
  5051 00004DC2 C3                  <1> 	RETn				; NO RETRY RETURN
  5052                              <1> 
  5053                              <1> ;-------------------------------------------------------------------------------
  5054                              <1> ; NUM_TRANS
  5055                              <1> ;	THIS ROUTINE CALCULATES THE NUMBER OF SECTORS THAT WERE
  5056                              <1> ;	ACTUALLY TRANSFERRED TO/FROM THE DISKETTE.
  5057                              <1> ;
  5058                              <1> ; ON ENTRY:	[BP+1] = TRACK
  5059                              <1> ;		SI-HI  = HEAD
  5060                              <1> ;		[BP]   = START SECTOR
  5061                              <1> ;
  5062                              <1> ; ON EXIT:	AL = NUMBER ACTUALLY TRANSFERRED
  5063                              <1> ;-------------------------------------------------------------------------------
  5064                              <1> NUM_TRANS:
  5065 00004DC3 30C0                <1> 	XOR	AL,AL			; CLEAR FOR ERROR
  5066 00004DC5 803D[B88A0100]00    <1> 	CMP	byte [DSKETTE_STATUS],0	; CHECK FOR ERROR
  5067 00004DCC 752C                <1> 	JNZ	NT_OUT			; IF ERROR 0 TRANSFERRED
  5068 00004DCE B204                <1> 	MOV	DL,4			; SECTORS/TRACK OFFSET TO DL
  5069 00004DD0 E8FA000000          <1> 	CALL	GET_PARM		; AH = SECTORS/TRACK
  5070 00004DD5 8A1D[BE8A0100]      <1> 	MOV	BL, [NEC_STATUS+5]	; GET ENDING SECTOR
  5071 00004DDB 6689F1              <1> 	MOV	CX,SI			; CH = HEAD # STARTED
  5072 00004DDE 3A2D[BD8A0100]      <1> 	CMP	CH, [NEC_STATUS+4]	; GET HEAD ENDED UP ON
  5073 00004DE4 750D                <1> 	JNZ	DIF_HD			; IF ON SAME HEAD, THEN NO ADJUST
  5074 00004DE6 8A2D[BC8A0100]      <1> 	MOV	CH, [NEC_STATUS+3]	; GET TRACK ENDED UP ON
  5075 00004DEC 3A6D01              <1> 	CMP	CH,[eBP+1]		; IS IT ASKED FOR TRACK
  5076 00004DEF 7404                <1> 	JZ	short SAME_TRK		; IF SAME TRACK NO INCREASE
  5077 00004DF1 00E3                <1> 	ADD	BL,AH			; ADD SECTORS/TRACK
  5078                              <1> DIF_HD:
  5079 00004DF3 00E3                <1> 	ADD	BL,AH			; ADD SECTORS/TRACK
  5080                              <1> SAME_TRK:
  5081 00004DF5 2A5D00              <1> 	SUB	BL,[eBP]		; SUBTRACT START FROM END
  5082 00004DF8 88D8                <1> 	MOV	AL,BL			; TO AL
  5083                              <1> NT_OUT:
  5084 00004DFA C3                  <1> 	RETn
  5085                              <1> 
  5086                              <1> ;-------------------------------------------------------------------------------
  5087                              <1> ; SETUP_END
  5088                              <1> ;	RESTORES @MOTOR_COUNT TO PARAMETER PROVIDED IN TABLE 
  5089                              <1> ;	AND LOADS @DSKETTE_STATUS TO AH, AND SETS CY.
  5090                              <1> ;
  5091                              <1> ; ON EXIT:
  5092                              <1> ;	AH, @DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  5093                              <1> ;-------------------------------------------------------------------------------
  5094                              <1> SETUP_END:
  5095 00004DFB B202                <1> 	MOV	DL,2			; GET THE MOTOR WAIT PARAMETER
  5096 00004DFD 6650                <1> 	PUSH	AX			; SAVE NUMBER TRANSFERRED
  5097 00004DFF E8CB000000          <1> 	CALL	GET_PARM
  5098 00004E04 8825[B78A0100]      <1> 	MOV	[MOTOR_COUNT],AH	; STORE UPON RETURN
  5099 00004E0A 6658                <1> 	POP	AX			; RESTORE NUMBER TRANSFERRED
  5100 00004E0C 8A25[B88A0100]      <1> 	MOV	AH, [DSKETTE_STATUS]	; GET STATUS OF OPERATION
  5101 00004E12 08E4                <1> 	OR	AH,AH			; CHECK FOR ERROR
  5102 00004E14 7402                <1> 	JZ	short NUN_ERR		; NO ERROR
  5103 00004E16 30C0                <1> 	XOR	AL,AL			; CLEAR NUMBER RETURNED
  5104                              <1> NUN_ERR: 
  5105 00004E18 80FC01              <1> 	CMP	AH,1			; SET THE CARRY FLAG TO INDICATE
  5106 00004E1B F5                  <1> 	CMC				; SUCCESS OR FAILURE
  5107 00004E1C C3                  <1> 	RETn
  5108                              <1> 
  5109                              <1> ;-------------------------------------------------------------------------------
  5110                              <1> ; SETUP_DBL
  5111                              <1> ;	CHECK DOUBLE STEP.
  5112                              <1> ;
  5113                              <1> ; ON ENTRY :	DI = DRIVE
  5114                              <1> ;
  5115                              <1> ; ON EXIT :	CY = 1 MEANS ERROR
  5116                              <1> ;-------------------------------------------------------------------------------
  5117                              <1> SETUP_DBL:
  5118 00004E1D 8AA7[C58A0100]      <1> 	MOV	AH, [DSK_STATE+eDI]	; ACCESS STATE
  5119 00004E23 F6C410              <1> 	TEST	AH,MED_DET		; ESTABLISHED STATE ?
  5120 00004E26 757E                <1> 	JNZ	short NO_DBL			; IF ESTABLISHED THEN DOUBLE DONE
  5121                              <1> 
  5122                              <1> ;-----	CHECK FOR TRACK 0 TO SPEED UP ACKNOWLEDGE OF UNFORMATTED DISKETTE
  5123                              <1> 
  5124 00004E28 C605[B58A0100]00    <1> 	MOV	byte [SEEK_STATUS],0	; SET RECALIBRATE REQUIRED ON ALL DRIVES
  5125 00004E2F E8E0000000          <1> 	CALL	MOTOR_ON		; ENSURE MOTOR STAY ON
  5126 00004E34 B500                <1> 	MOV	CH,0			; LOAD TRACK 0
  5127 00004E36 E8D4010000          <1> 	CALL	SEEK			; SEEK TO TRACK 0
  5128 00004E3B E868000000          <1> 	CALL	READ_ID			; READ ID FUNCTION
  5129 00004E40 7249                <1> 	JC	short SD_ERR		; IF ERROR NO TRACK 0
  5130                              <1> 
  5131                              <1> ;-----	INITIALIZE START AND MAX TRACKS (TIMES 2 FOR BOTH HEADS)
  5132                              <1> 
  5133 00004E42 66B95004            <1> 	MOV	CX,0450H 		; START, MAX TRACKS
  5134 00004E46 F687[C58A0100]01    <1> 	TEST	byte [DSK_STATE+eDI],TRK_CAPA ; TEST FOR 80 TRACK CAPABILITY
  5135 00004E4D 7402                <1> 	JZ	short CNT_OK		; IF NOT COUNT IS SETUP
  5136 00004E4F B1A0                <1> 	MOV	CL,0A0H			; MAXIMUM TRACK 1.2 MB
  5137                              <1> 
  5138                              <1> ;	ATTEMPT READ ID OF ALL TRACKS, ALL HEADS UNTIL SUCCESS; UPON SUCCESS,
  5139                              <1> ;	MUST SEE IF ASKED FOR TRACK IN SINGLE STEP MODE = TRACK ID READ; IF NOT
  5140                              <1> ;	THEN SET DOUBLE STEP ON.
  5141                              <1> 
  5142                              <1> CNT_OK:
  5143 00004E51 C605[B78A0100]FF    <1>         MOV     byte [MOTOR_COUNT], 0FFH ; ENSURE MOTOR STAYS ON FOR OPERATION 
  5144 00004E58 6651                <1> 	PUSH	CX			; SAVE TRACK, COUNT
  5145 00004E5A C605[B88A0100]00    <1> 	MOV	byte [DSKETTE_STATUS],0	; CLEAR STATUS, EXPECT ERRORS
  5146 00004E61 6631C0              <1> 	XOR	AX,AX			; CLEAR AX
  5147 00004E64 D0ED                <1> 	SHR	CH,1			; HALVE TRACK, CY = HEAD
  5148 00004E66 C0D003              <1> 	RCL	AL,3			; AX = HEAD IN CORRECT BIT
  5149 00004E69 6650                <1> 	PUSH	AX			; SAVE HEAD
  5150 00004E6B E89F010000          <1> 	CALL	SEEK			; SEEK TO TRACK
  5151 00004E70 6658                <1> 	POP	AX			; RESTORE HEAD
  5152 00004E72 6609C7              <1> 	OR	DI,AX			; DI = HEAD OR'ED DRIVE
  5153 00004E75 E82E000000          <1> 	CALL	READ_ID			; READ ID HEAD 0
  5154 00004E7A 9C                  <1> 	PUSHF				; SAVE RETURN FROM READ_ID
  5155 00004E7B 6681E7FB00          <1> 	AND	DI,11111011B		; TURN OFF HEAD 1 BIT
  5156 00004E80 9D                  <1> 	POPF				; RESTORE ERROR RETURN
  5157 00004E81 6659                <1> 	POP	CX			; RESTORE COUNT
  5158 00004E83 7308                <1> 	JNC	short DO_CHK		; IF OK, ASKED = RETURNED TRACK ?
  5159 00004E85 FEC5                <1> 	INC	CH			; INC FOR NEXT TRACK
  5160 00004E87 38CD                <1> 	CMP	CH,CL			; REACHED MAXIMUM YET
  5161 00004E89 75C6                <1> 	JNZ	short CNT_OK		; CONTINUE TILL ALL TRIED
  5162                              <1> 
  5163                              <1> ;-----	FALL THRU, READ ID FAILED FOR ALL TRACKS
  5164                              <1> 
  5165                              <1> SD_ERR:	
  5166 00004E8B F9                  <1> 	STC				; SET CARRY FOR ERROR
  5167 00004E8C C3                  <1> 	RETn				; SETUP_DBL ERROR EXIT
  5168                              <1> 
  5169                              <1> DO_CHK:
  5170 00004E8D 8A0D[BC8A0100]      <1> 	MOV	CL, [NEC_STATUS+3]	; LOAD RETURNED TRACK
  5171 00004E93 888F[C98A0100]      <1> 	MOV	[DSK_TRK+eDI], CL	; STORE TRACK NUMBER
  5172 00004E99 D0ED                <1> 	SHR	CH,1			; HALVE TRACK
  5173 00004E9B 38CD                <1> 	CMP	CH,CL			; IS IT THE SAME AS ASKED FOR TRACK
  5174 00004E9D 7407                <1> 	JZ	short NO_DBL		; IF SAME THEN NO DOUBLE STEP
  5175 00004E9F 808F[C58A0100]20    <1> 	OR	byte [DSK_STATE+eDI],DBL_STEP ; TURN ON DOUBLE STEP REQUIRED
  5176                              <1> NO_DBL:
  5177 00004EA6 F8                  <1> 	CLC				; CLEAR ERROR FLAG
  5178 00004EA7 C3                  <1> 	RETn
  5179                              <1> 
  5180                              <1> ;-------------------------------------------------------------------------------
  5181                              <1> ; READ_ID
  5182                              <1> ;	READ ID FUNCTION.
  5183                              <1> ;
  5184                              <1> ; ON ENTRY:	DI : BIT 2 = HEAD; BITS 1,0 = DRIVE
  5185                              <1> ;
  5186                              <1> ; ON EXIT: 	DI : BIT 2 IS RESET, BITS 1,0 = DRIVE
  5187                              <1> ;		@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  5188                              <1> ;-------------------------------------------------------------------------------
  5189                              <1> READ_ID:
  5190 00004EA8 B8[C54E0000]        <1> 	MOV	eAX, ER_3		; MOVE NEC OUTPUT ERROR ADDRESS
  5191 00004EAD 50                  <1> 	PUSH	eAX
  5192 00004EAE B44A                <1> 	MOV	AH,4AH			; READ ID COMMAND
  5193 00004EB0 E820010000          <1> 	CALL	NEC_OUTPUT		; TO CONTROLLER
  5194 00004EB5 6689F8              <1> 	MOV	AX,DI			; DRIVE # TO AH, HEAD 0
  5195 00004EB8 88C4                <1> 	MOV	AH,AL
  5196 00004EBA E816010000          <1> 	CALL	NEC_OUTPUT		; TO CONTROLLER
  5197 00004EBF E80BFEFFFF          <1> 	CALL	NEC_TERM		; WAIT FOR OPERATION, GET STATUS
  5198 00004EC4 58                  <1> 	POP	eAX			; THROW AWAY ERROR ADDRESS
  5199                              <1> ER_3:
  5200 00004EC5 C3                  <1> 	RETn
  5201                              <1> 
  5202                              <1> ;-------------------------------------------------------------------------------
  5203                              <1> ; CMOS_TYPE
  5204                              <1> ;	RETURNS DISKETTE TYPE FROM CMOS
  5205                              <1> ;
  5206                              <1> ; ON ENTRY:	DI = DRIVE #
  5207                              <1> ;
  5208                              <1> ; ON EXIT:	AL = TYPE; CY REFLECTS STATUS
  5209                              <1> ;-------------------------------------------------------------------------------
  5210                              <1> 
  5211                              <1> CMOS_TYPE: ; 11/12/2014
  5212 00004EC6 8A87[0E6E0000]      <1> mov	al, [eDI+fd0_type]
  5213 00004ECC 20C0                <1> and 	al, al ; 18/12/2014
  5214 00004ECE C3                  <1> retn
  5215                              <1> 
  5216                              <1> ;CMOS_TYPE:
  5217                              <1> ;	MOV	AL, CMOS_DIAG		; CMOS DIAGNOSTIC STATUS BYTE ADDRESS
  5218                              <1> ;	CALL	CMOS_READ		; GET CMOS STATUS
  5219                              <1> ;	TEST	AL,BAD_BAT+BAD_CKSUM	; BATTERY GOOD AND CHECKSUM VALID
  5220                              <1> ;	STC				; SET CY = 1 INDICATING ERROR FOR RETURN
  5221                              <1> ;	JNZ	short BAD_CM		; ERROR IF EITHER BIT ON
  5222                              <1> ;	MOV	AL,CMOS_DISKETTE	; ADDRESS OF DISKETTE BYTE IN CMOS
  5223                              <1> ;	CALL	CMOS_READ		; GET DISKETTE BYTE
  5224                              <1> ;	OR	DI,DI			; SEE WHICH DRIVE IN QUESTION
  5225                              <1> ;	JNZ	short TB		; IF DRIVE 1, DATA IN LOW NIBBLE
  5226                              <1> ;	ROR	AL,4			; EXCHANGE NIBBLES IF SECOND DRIVE
  5227                              <1> ;TB:
  5228                              <1> ;	AND	AL,0FH			; KEEP ONLY DRIVE DATA, RESET CY, 0
  5229                              <1> ;BAD_CM:
  5230                              <1> ;	RETn				; CY, STATUS OF READ
  5231                              <1> 
  5232                              <1> ;-------------------------------------------------------------------------------
  5233                              <1> ; GET_PARM
  5234                              <1> ;	THIS ROUTINE FETCHES THE INDEXED POINTER FROM THE DISK_BASE
  5235                              <1> ;	BLOCK POINTED TO BY THE DATA VARIABLE @DISK_POINTER. A BYTE FROM
  5236                              <1> ;	THAT TABLE IS THEN MOVED INTO AH, THE INDEX OF THAT BYTE BEING
  5237                              <1> ;	THE PARAMETER IN DL.
  5238                              <1> ;
  5239                              <1> ; ON ENTRY:	DL = INDEX OF BYTE TO BE FETCHED
  5240                              <1> ;
  5241                              <1> ; ON EXIT:	AH = THAT BYTE FROM BLOCK
  5242                              <1> ;		AL,DH DESTROYED
  5243                              <1> ;-------------------------------------------------------------------------------
  5244                              <1> GET_PARM:
  5245                              <1> 	;PUSH	DS
  5246 00004ECF 56                  <1> 	PUSH	eSI
  5247                              <1>     	;SUB	AX,AX			; DS = 0, BIOS DATA AREA
  5248                              <1>     	;MOV	DS,AX
  5249                              <1> 	;;mov	ax, cs
  5250                              <1> 	;;mov	ds, ax
  5251                              <1> 	; 08/02/2015 (protected mode modifications, bx -> ebx)
  5252 00004ED0 87D3                <1> 	XCHG	eDX,eBX			; BL = INDEX
  5253                              <1> 	;SUB	BH,BH			; BX = INDEX
  5254 00004ED2 81E3FF000000        <1> 	and	ebx, 0FFh
  5255                              <1>     	;LDS	SI, [DISK_POINTER]	; POINT TO BLOCK
  5256                              <1> 	;
  5257                              <1> 	; 17/12/2014
  5258 00004ED8 66A1[FD6D0000]      <1> 	mov	ax, [cfd] ; current (AL) and previous fd (AH)
  5259 00004EDE 38E0                <1> 	cmp	al, ah
  5260 00004EE0 7425                <1> 	je	short gpndc
  5261 00004EE2 A2[FE6D0000]        <1> 	mov	[pfd], al ; current drive -> previous drive
  5262 00004EE7 53                  <1> 	push	ebx ; 08/02/2015
  5263 00004EE8 88C3                <1> 	mov	bl, al 
  5264                              <1> 	; 11/12/2014
  5265 00004EEA 8A83[0E6E0000]      <1> 	mov	al, [eBX+fd0_type]	; Drive type (0,1,2,3,4)
  5266                              <1> 	; 18/12/2014
  5267 00004EF0 20C0                <1> 	and	al, al
  5268 00004EF2 7507                <1> 	jnz	short gpdtc
  5269 00004EF4 BB[E76D0000]        <1> 	mov	ebx, MD_TBL6		; 1.44 MB param. tbl. (default)
  5270 00004EF9 EB05                <1>         jmp     short gpdpu
  5271                              <1> gpdtc:	
  5272 00004EFB E817F9FFFF          <1> 	call	DR_TYPE_CHECK
  5273                              <1> 	; cf = 1 -> eBX points to 1.44MB fd parameter table (default)
  5274                              <1> gpdpu:
  5275 00004F00 891D[846D0000]      <1> 	mov	[DISK_POINTER], ebx
  5276 00004F06 5B                  <1> 	pop	ebx
  5277                              <1> gpndc:
  5278 00004F07 8B35[846D0000]      <1> 	mov	esi, [DISK_POINTER] ; 08/02/2015, si -> esi
  5279 00004F0D 8A241E              <1> 	MOV	AH, [eSI+eBX]		; GET THE WORD
  5280 00004F10 87D3                <1> 	XCHG	eDX,eBX			; RESTORE BX
  5281 00004F12 5E                  <1> 	POP	eSI
  5282                              <1> 	;POP	DS
  5283 00004F13 C3                  <1> 	RETn
  5284                              <1> 
  5285                              <1> ;-------------------------------------------------------------------------------
  5286                              <1> ; MOTOR_ON
  5287                              <1> ;	TURN MOTOR ON AND WAIT FOR MOTOR START UP TIME. THE @MOTOR_COUNT
  5288                              <1> ;	IS REPLACED WITH A SUFFICIENTLY HIGH NUMBER (0FFH) TO ENSURE
  5289                              <1> ;	THAT THE MOTOR DOES NOT GO OFF DURING THE OPERATION. IF THE
  5290                              <1> ;	MOTOR NEEDED TO BE TURNED ON, THE MULTI-TASKING HOOK FUNCTION
  5291                              <1> ;	(AX=90FDH, INT 15) IS CALLED TELLING THE OPERATING SYSTEM
  5292                              <1> ;	THAT THE BIOS IS ABOUT TO WAIT FOR MOTOR START UP. IF THIS
  5293                              <1> ;	FUNCTION RETURNS WITH CY = 1, IT MEANS THAT THE MINIMUM WAIT
  5294                              <1> ;	HAS BEEN COMPLETED. AT THIS POINT A CHECK IS MADE TO ENSURE
  5295                              <1> ;	THAT THE MOTOR WASN'T TURNED OFF BY THE TIMER. IF THE HOOK DID
  5296                              <1> ;	NOT WAIT, THE WAIT FUNCTION (AH=086H) IS CALLED TO WAIT THE
  5297                              <1> ;	PRESCRIBED AMOUNT OF TIME. IF THE CARRY FLAG IS SET ON RETURN,
  5298                              <1> ;	IT MEANS THAT THE FUNCTION IS IN USE AND DID NOT PERFORM THE
  5299                              <1> ;	WAIT. A TIMER 1 WAIT LOOP WILL THEN DO THE WAIT.
  5300                              <1> ;
  5301                              <1> ; ON ENTRY:	DI = DRIVE #
  5302                              <1> ; ON EXIT:	AX,CX,DX DESTROYED
  5303                              <1> ;-------------------------------------------------------------------------------
  5304                              <1> MOTOR_ON:
  5305 00004F14 53                  <1> 	PUSH	eBX			; SAVE REG.
  5306 00004F15 E82A000000          <1> 	CALL	TURN_ON			; TURN ON MOTOR
  5307 00004F1A 7226                <1> 	JC	short MOT_IS_ON		; IF CY=1 NO WAIT
  5308 00004F1C E89BF9FFFF          <1> 	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  5309 00004F21 E865F9FFFF          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH,
  5310                              <1> 	;CALL	TURN_ON 		; CHECK AGAIN IF MOTOR ON
  5311                              <1> 	;JC	MOT_IS_ON		; IF NO WAIT MEANS IT IS ON
  5312                              <1> M_WAIT:
  5313 00004F26 B20A                <1> 	MOV	DL,10			; GET THE MOTOR WAIT PARAMETER
  5314 00004F28 E8A2FFFFFF          <1> 	CALL	GET_PARM
  5315                              <1> 	;MOV	AL,AH			; AL = MOTOR WAIT PARAMETER
  5316                              <1> 	;XOR	AH,AH			; AX = MOTOR WAIT PARAMETER
  5317                              <1> 	;CMP	AL,8			; SEE IF AT LEAST A SECOND IS SPECIFIED
  5318 00004F2D 80FC08              <1> 	cmp	ah, 8
  5319                              <1> 	;JAE	short GP2		; IF YES, CONTINUE
  5320 00004F30 7702                <1> 	ja	short J13
  5321                              <1> 	;MOV	AL,8			; ONE SECOND WAIT FOR MOTOR START UP
  5322 00004F32 B408                <1> 	mov	ah, 8
  5323                              <1> 
  5324                              <1> ;-----	AS CONTAINS NUMBER OF 1/8 SECONDS (125000 MICROSECONDS) TO WAIT
  5325                              <1> GP2:	
  5326                              <1> ;----- 	FOLLOWING LOOPS REQUIRED WHEN RTC WAIT FUNCTION IS ALREADY IN USE
  5327                              <1> J13:					; WAIT FOR 1/8 SECOND PER (AL)
  5328 00004F34 B95E200000          <1> 	MOV	eCX,8286		; COUNT FOR 1/8 SECOND AT 15.085737 US
  5329 00004F39 E810D5FFFF          <1> 	CALL	WAITF			; GO TO FIXED WAIT ROUTINE
  5330                              <1> 	;DEC	AL			; DECREMENT TIME VALUE
  5331 00004F3E FECC                <1> 	dec	ah
  5332 00004F40 75F2                <1> 	JNZ	short J13		; ARE WE DONE YET
  5333                              <1> MOT_IS_ON:
  5334 00004F42 5B                  <1> 	POP	eBX			; RESTORE REG.
  5335 00004F43 C3                  <1> 	RETn
  5336                              <1> 
  5337                              <1> ;-------------------------------------------------------------------------------
  5338                              <1> ; TURN_ON
  5339                              <1> ;	TURN MOTOR ON AND RETURN WAIT STATE.
  5340                              <1> ;
  5341                              <1> ; ON ENTRY:	DI = DRIVE #
  5342                              <1> ;
  5343                              <1> ; ON EXIT:	CY = 0 MEANS WAIT REQUIRED
  5344                              <1> ;		CY = 1 MEANS NO WAIT REQUIRED
  5345                              <1> ;		AX,BX,CX,DX DESTROYED
  5346                              <1> ;-------------------------------------------------------------------------------
  5347                              <1> TURN_ON:
  5348 00004F44 89FB                <1> 	MOV	eBX,eDI			; BX = DRIVE #
  5349 00004F46 88D9                <1> 	MOV	CL,BL			; CL = DRIVE #
  5350 00004F48 C0C304              <1> 	ROL	BL,4			; BL = DRIVE SELECT
  5351 00004F4B FA                  <1> 	CLI				; NO INTERRUPTS WHILE DETERMINING STATUS
  5352 00004F4C C605[B78A0100]FF    <1> 	MOV	byte [MOTOR_COUNT],0FFH	; ENSURE MOTOR STAYS ON FOR OPERATION
  5353 00004F53 A0[B68A0100]        <1> 	MOV	AL, [MOTOR_STATUS]	; GET DIGITAL OUTPUT REGISTER REFLECTION
  5354 00004F58 2430                <1> 	AND	AL,00110000B		; KEEP ONLY DRIVE SELECT BITS
  5355 00004F5A B401                <1> 	MOV	AH,1			; MASK FOR DETERMINING MOTOR BIT
  5356 00004F5C D2E4                <1> 	SHL	AH,CL			; AH = MOTOR ON, A=00000001, B=00000010
  5357                              <1> 
  5358                              <1> ;  AL = DRIVE SELECT FROM @MOTOR_STATUS
  5359                              <1> ;  BL = DRIVE SELECT DESIRED
  5360                              <1> ;  AH = MOTOR ON MASK DESIRED
  5361                              <1> 
  5362 00004F5E 38D8                <1> 	CMP	AL,BL			; REQUESTED DRIVE ALREADY SELECTED ?
  5363 00004F60 7508                <1> 	JNZ	short TURN_IT_ON	; IF NOT SELECTED JUMP
  5364 00004F62 8425[B68A0100]      <1> 	TEST	AH, [MOTOR_STATUS]	; TEST MOTOR ON BIT
  5365 00004F68 7535                <1> 	JNZ	short NO_MOT_WAIT	; JUMP IF MOTOR ON AND SELECTED
  5366                              <1> 
  5367                              <1> TURN_IT_ON:
  5368 00004F6A 08DC                <1> 	OR	AH,BL			; AH = DRIVE SELECT AND MOTOR ON
  5369 00004F6C 8A3D[B68A0100]      <1> 	MOV	BH,[MOTOR_STATUS]	; SAVE COPY OF @MOTOR_STATUS BEFORE
  5370 00004F72 80E70F              <1> 	AND	BH,00001111B		; KEEP ONLY MOTOR BITS
  5371 00004F75 8025[B68A0100]CF    <1> 	AND	byte [MOTOR_STATUS],11001111B ; CLEAR OUT DRIVE SELECT
  5372 00004F7C 0825[B68A0100]      <1> 	OR	[MOTOR_STATUS],AH	; OR IN DRIVE SELECTED AND MOTOR ON
  5373 00004F82 A0[B68A0100]        <1> 	MOV	AL,[MOTOR_STATUS]	; GET DIGITAL OUTPUT REGISTER REFLECTION
  5374 00004F87 88C3                <1> 	MOV	BL,AL			; BL=@MOTOR_STATUS AFTER, BH=BEFORE
  5375 00004F89 80E30F              <1> 	AND	BL,00001111B		; KEEP ONLY MOTOR BITS
  5376 00004F8C FB                  <1> 	STI				; ENABLE INTERRUPTS AGAIN
  5377 00004F8D 243F                <1> 	AND	AL,00111111B		; STRIP AWAY UNWANTED BITS
  5378 00004F8F C0C004              <1> 	ROL	AL,4			; PUT BITS IN DESIRED POSITIONS
  5379 00004F92 0C0C                <1> 	OR	AL,00001100B		; NO RESET, ENABLE DMA/INTERRUPT
  5380 00004F94 66BAF203            <1> 	MOV	DX,03F2H		; SELECT DRIVE AND TURN ON MOTOR
  5381 00004F98 EE                  <1> 	OUT	DX,AL
  5382 00004F99 38FB                <1> 	CMP	BL,BH			; NEW MOTOR TURNED ON ?
  5383                              <1> 	;JZ	short NO_MOT_WAIT	; NO WAIT REQUIRED IF JUST SELECT
  5384 00004F9B 7403                <1> 	je	short no_mot_w1 ; 27/02/2015 
  5385 00004F9D F8                  <1> 	CLC				; (re)SET CARRY MEANING WAIT
  5386 00004F9E C3                  <1> 	RETn
  5387                              <1> 
  5388                              <1> NO_MOT_WAIT:
  5389 00004F9F FB                  <1> 	sti
  5390                              <1> no_mot_w1: ; 27/02/2015
  5391 00004FA0 F9                  <1> 	STC				; SET NO WAIT REQUIRED
  5392                              <1> 	;STI				; INTERRUPTS BACK ON
  5393 00004FA1 C3                  <1> 	RETn
  5394                              <1> 
  5395                              <1> ;-------------------------------------------------------------------------------
  5396                              <1> ; HD_WAIT
  5397                              <1> ;	WAIT FOR HEAD SETTLE TIME.
  5398                              <1> ;
  5399                              <1> ; ON ENTRY:	DI = DRIVE #
  5400                              <1> ;
  5401                              <1> ; ON EXIT:	AX,BX,CX,DX DESTROYED
  5402                              <1> ;-------------------------------------------------------------------------------
  5403                              <1> HD_WAIT:
  5404 00004FA2 B209                <1> 	MOV	DL,9			; GET HEAD SETTLE PARAMETER
  5405 00004FA4 E826FFFFFF          <1> 	CALL	GET_PARM
  5406 00004FA9 08E4                <1> 	or	ah, ah	; 17/12/2014
  5407 00004FAB 7519                <1> 	jnz	short DO_WAT
  5408 00004FAD F605[B68A0100]80    <1>         TEST    byte [MOTOR_STATUS],10000000B ; SEE IF A WRITE OPERATION
  5409                              <1> 	;JZ	short ISNT_WRITE	; IF NOT, DO NOT ENFORCE ANY VALUES
  5410                              <1> 	;OR	AH,AH			; CHECK FOR ANY WAIT?
  5411                              <1> 	;JNZ	short DO_WAT		; IF THERE DO NOT ENFORCE
  5412 00004FB4 741E                <1> 	jz	short HW_DONE
  5413 00004FB6 B40F                <1> 	MOV	AH,HD12_SETTLE		; LOAD 1.2M HEAD SETTLE MINIMUM
  5414 00004FB8 8A87[C58A0100]      <1> 	MOV	AL,[DSK_STATE+eDI]	; LOAD STATE
  5415 00004FBE 24C0                <1> 	AND	AL,RATE_MSK		; KEEP ONLY RATE
  5416 00004FC0 3C80                <1> 	CMP	AL,RATE_250		; 1.2 M DRIVE ?
  5417 00004FC2 7502                <1> 	JNZ	short DO_WAT		; DEFAULT HEAD SETTLE LOADED
  5418                              <1> ;GP3:
  5419 00004FC4 B414                <1> 	MOV	AH,HD320_SETTLE		; USE 320/360 HEAD SETTLE
  5420                              <1> ;	JMP	SHORT DO_WAT
  5421                              <1> 
  5422                              <1> ;ISNT_WRITE:
  5423                              <1> ;	OR	AH,AH			; CHECK FOR NO WAIT
  5424                              <1> ;	JZ	short HW_DONE		; IF NOT WRITE AND 0 ITS OK
  5425                              <1> 
  5426                              <1> ;-----	AH CONTAINS NUMBER OF MILLISECONDS TO WAIT
  5427                              <1> DO_WAT:
  5428                              <1> ;	MOV	AL,AH			; AL = # MILLISECONDS
  5429                              <1> ;	;XOR	AH,AH			; AX = # MILLISECONDS
  5430                              <1> J29:					; 	1 MILLISECOND LOOP
  5431                              <1> 	;mov	cx, WAIT_FDU_HEAD_SETTLE ; 33 ; 1 ms in 30 micro units.
  5432 00004FC6 B942000000          <1> 	MOV	eCX,66			; COUNT AT 15.085737 US PER COUNT
  5433 00004FCB E87ED4FFFF          <1> 	CALL	WAITF			; DELAY FOR 1 MILLISECOND
  5434                              <1> 	;DEC	AL			; DECREMENT THE COUNT
  5435 00004FD0 FECC                <1> 	dec	ah
  5436 00004FD2 75F2                <1> 	JNZ	short J29		; DO AL MILLISECOND # OF TIMES
  5437                              <1> HW_DONE:
  5438 00004FD4 C3                  <1> 	RETn
  5439                              <1> 
  5440                              <1> ;-------------------------------------------------------------------------------
  5441                              <1> ; NEC_OUTPUT
  5442                              <1> ;	THIS ROUTINE SENDS A BYTE TO THE NEC CONTROLLER AFTER TESTING
  5443                              <1> ;	FOR CORRECT DIRECTION AND CONTROLLER READY THIS ROUTINE WILL
  5444                              <1> ;	TIME OUT IF THE BYTE IS NOT ACCEPTED WITHIN A REASONABLE AMOUNT
  5445                              <1> ;	OF TIME, SETTING THE DISKETTE STATUS ON COMPLETION.
  5446                              <1> ; 
  5447                              <1> ; ON ENTRY: 	AH = BYTE TO BE OUTPUT
  5448                              <1> ;
  5449                              <1> ; ON EXIT:	CY = 0  SUCCESS
  5450                              <1> ;		CY = 1  FAILURE -- DISKETTE STATUS UPDATED
  5451                              <1> ;		        IF A FAILURE HAS OCCURRED, THE RETURN IS MADE ONE LEVEL
  5452                              <1> ;		        HIGHER THAN THE CALLER OF NEC OUTPUT. THIS REMOVES THE
  5453                              <1> ;		        REQUIREMENT OF TESTING AFTER EVERY CALL OF NEC_OUTPUT.
  5454                              <1> ;		AX,CX,DX DESTROYED
  5455                              <1> ;-------------------------------------------------------------------------------
  5456                              <1> 
  5457                              <1> ; 09/12/2014 [Erdogan Tan] 
  5458                              <1> ;	(from 'PS2 Hardware Interface Tech. Ref. May 88', Page 09-05.)
  5459                              <1> ; Diskette Drive Controller Status Register (3F4h)
  5460                              <1> ;	This read only register facilitates the transfer of data between
  5461                              <1> ;	the system microprocessor and the controller.
  5462                              <1> ; Bit 7 - When set to 1, the Data register is ready to transfer data 
  5463                              <1> ;	  with the system micrprocessor.
  5464                              <1> ; Bit 6 - The direction of data transfer. If this bit is set to 0,
  5465                              <1> ;	  the transfer is to the controller.
  5466                              <1> ; Bit 5 - When this bit is set to 1, the controller is in the non-DMA mode.
  5467                              <1> ; Bit 4 - When this bit is set to 1, a Read or Write command is being executed.
  5468                              <1> ; Bit 3 - Reserved.
  5469                              <1> ; Bit 2 - Reserved.
  5470                              <1> ; Bit 1 - When this bit is set to 1, dskette drive 1 is in the seek mode.
  5471                              <1> ; Bit 0 - When this bit is set to 1, dskette drive 1 is in the seek mode.
  5472                              <1> 
  5473                              <1> ; Data Register (3F5h)
  5474                              <1> ; This read/write register passes data, commands and parameters, and provides
  5475                              <1> ; diskette status information.
  5476                              <1>   		
  5477                              <1> NEC_OUTPUT:
  5478                              <1> 	;PUSH	BX			; SAVE REG.
  5479 00004FD5 66BAF403            <1> 	MOV	DX,03F4H		; STATUS PORT
  5480                              <1> 	;MOV	BL,2			; HIGH ORDER COUNTER
  5481                              <1> 	;XOR	CX,CX			; COUNT FOR TIME OUT
  5482                              <1> 	; 16/12/2014
  5483                              <1> 	; waiting for (max.) 0.5 seconds
  5484                              <1>         ;;mov     byte [wait_count], 0 ;; 27/02/2015
  5485                              <1> 	;
  5486                              <1> 	; 17/12/2014
  5487                              <1> 	; Modified from AWARD BIOS 1999 - ADISK.ASM - SEND_COMMAND
  5488                              <1> 	;
  5489                              <1> 	;WAIT_FOR_PORT:	Waits for a bit at a port pointed to by DX to
  5490                              <1> 	;		go on.
  5491                              <1> 	;INPUT:
  5492                              <1> 	;	AH=Mask for isolation bits.
  5493                              <1> 	;	AL=pattern to look for.
  5494                              <1> 	;	DX=Port to test for
  5495                              <1> 	;	BH:CX=Number of memory refresh periods to delay.
  5496                              <1> 	;	     (normally 30 microseconds per period.)
  5497                              <1> 	;
  5498                              <1> 	;WFP_SHORT:  
  5499                              <1> 	;	Wait for port if refresh cycle is short (15-80 Us range).
  5500                              <1> 	;
  5501                              <1> 
  5502                              <1> ;	mov	bl, WAIT_FDU_SEND_HI+1	; 0+1
  5503                              <1> ;	mov	cx, WAIT_FDU_SEND_LO	; 16667
  5504 00004FD9 B91B410000          <1> 	mov	ecx, WAIT_FDU_SEND_LH   ; 16667 (27/02/2015)
  5505                              <1> ;
  5506                              <1> ;WFPS_OUTER_LP:
  5507                              <1> ;	;
  5508                              <1> ;WFPS_CHECK_PORT:
  5509                              <1> J23:
  5510 00004FDE EC                  <1> 	IN	AL,DX			; GET STATUS
  5511 00004FDF 24C0                <1> 	AND	AL,11000000B		; KEEP STATUS AND DIRECTION
  5512 00004FE1 3C80                <1> 	CMP	AL,10000000B		; STATUS 1 AND DIRECTION 0 ?
  5513 00004FE3 7418                <1> 	JZ	short J27		; STATUS AND DIRECTION OK
  5514                              <1> WFPS_HI:
  5515 00004FE5 E461                <1> 	IN	AL, PORT_B	;061h	; SYS1	; wait for hi to lo
  5516 00004FE7 A810                <1> 	TEST	AL,010H			; transition on memory
  5517 00004FE9 75FA                <1> 	JNZ	SHORT WFPS_HI		; refresh.
  5518                              <1> WFPS_LO:
  5519 00004FEB E461                <1> 	IN	AL, PORT_B		; SYS1
  5520 00004FED A810                <1> 	TEST	AL,010H
  5521 00004FEF 74FA                <1> 	JZ	SHORT WFPS_LO
  5522                              <1> 	;LOOP	SHORT WFPS_CHECK_PORT
  5523 00004FF1 E2EB                <1> 	loop	J23	; 27/02/2015
  5524                              <1> ;	;
  5525                              <1> ;	dec	bl
  5526                              <1> ;	jnz	short WFPS_OUTER_LP
  5527                              <1> ;	jmp	short WFPS_TIMEOUT	; fail
  5528                              <1> ;J23:
  5529                              <1> ;	IN	AL,DX			; GET STATUS
  5530                              <1> ;	AND	AL,11000000B		; KEEP STATUS AND DIRECTION
  5531                              <1> ;	CMP	AL,10000000B		; STATUS 1 AND DIRECTION 0 ?
  5532                              <1> ;	JZ	short J27		; STATUS AND DIRECTION OK
  5533                              <1> 	;LOOP	J23			; CONTINUE TILL CX EXHAUSTED
  5534                              <1> 	;DEC	BL			; DECREMENT COUNTER
  5535                              <1> 	;JNZ	short J23		; REPEAT TILL DELAY FINISHED, CX = 0
  5536                              <1>    
  5537                              <1> 	;;27/02/2015
  5538                              <1> 	;16/12/2014
  5539                              <1>         ;;cmp     byte [wait_count], 10   ; (10/18.2 seconds)
  5540                              <1> 	;;jb	short J23
  5541                              <1> 
  5542                              <1> ;WFPS_TIMEOUT:
  5543                              <1> 
  5544                              <1> ;-----	FALL THRU TO ERROR RETURN
  5545                              <1> 
  5546 00004FF3 800D[B88A0100]80    <1> 	OR	byte [DSKETTE_STATUS],TIME_OUT
  5547                              <1> 	;POP	BX			; RESTORE REG.
  5548 00004FFA 58                  <1> 	POP	eAX ; 08/02/2015	; DISCARD THE RETURN ADDRESS
  5549 00004FFB F9                  <1> 	STC				; INDICATE ERROR TO CALLER
  5550 00004FFC C3                  <1> 	RETn
  5551                              <1> 
  5552                              <1> ;-----	DIRECTION AND STATUS OK; OUTPUT BYTE
  5553                              <1> 
  5554                              <1> J27:	
  5555 00004FFD 88E0                <1> 	MOV	AL,AH			; GET BYTE TO OUTPUT
  5556 00004FFF 6642                <1> 	INC	DX			; DATA PORT = STATUS PORT + 1
  5557 00005001 EE                  <1> 	OUT	DX,AL			; OUTPUT THE BYTE
  5558                              <1> 	;;NEWIODELAY  ;; 27/02/2015
  5559                              <1> 	; 27/02/2015
  5560 00005002 9C                  <1> 	PUSHF				; SAVE FLAGS
  5561 00005003 B903000000          <1> 	MOV	eCX, 3			; 30 TO 45 MICROSECONDS WAIT FOR
  5562 00005008 E841D4FFFF          <1> 	CALL 	WAITF			; NEC FLAGS UPDATE CYCLE
  5563 0000500D 9D                  <1> 	POPF				; RESTORE FLAGS FOR EXIT
  5564                              <1> 	;POP	BX			; RESTORE REG
  5565 0000500E C3                  <1> 	RETn				; CY = 0 FROM TEST INSTRUCTION
  5566                              <1> 
  5567                              <1> ;-------------------------------------------------------------------------------
  5568                              <1> ; SEEK
  5569                              <1> ;	THIS ROUTINE WILL MOVE THE HEAD ON THE NAMED DRIVE TO THE NAMED
  5570                              <1> ;	TRACK. IF THE DRIVE HAS NOT BEEN ACCESSED SINCE THE DRIVE
  5571                              <1> ;	RESET COMMAND WAS ISSUED, THE DRIVE WILL BE RECALIBRATED.
  5572                              <1> ;
  5573                              <1> ; ON ENTRY:	DI = DRIVE #
  5574                              <1> ;		CH = TRACK #
  5575                              <1> ;
  5576                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION.
  5577                              <1> ;		AX,BX,CX DX DESTROYED
  5578                              <1> ;-------------------------------------------------------------------------------
  5579                              <1> SEEK:
  5580 0000500F 89FB                <1> 	MOV	eBX,eDI			; BX = DRIVE #
  5581 00005011 B001                <1> 	MOV	AL,1			; ESTABLISH MASK FOR RECALIBRATE TEST
  5582 00005013 86CB                <1> 	XCHG	CL,BL			; SET DRIVE VALULE INTO CL
  5583 00005015 D2C0                <1> 	ROL	AL,CL			; SHIFT MASK BY THE DRIVE VALUE
  5584 00005017 86CB                <1> 	XCHG	CL,BL			; RECOVER TRACK VALUE
  5585 00005019 8405[B58A0100]      <1> 	TEST	AL,[SEEK_STATUS]	; TEST FOR RECALIBRATE REQUIRED
  5586 0000501F 7526                <1> 	JNZ	short J28A		; JUMP IF RECALIBRATE NOT REQUIRED
  5587                              <1> 
  5588 00005021 0805[B58A0100]      <1> 	OR	[SEEK_STATUS],AL	; TURN ON THE NO RECALIBRATE BIT IN FLAG
  5589 00005027 E862000000          <1> 	CALL	RECAL			; RECALIBRATE DRIVE
  5590 0000502C 730E                <1> 	JNC	short AFT_RECAL		; RECALIBRATE DONE
  5591                              <1> 
  5592                              <1> ;-----	ISSUE RECALIBRATE FOR 80 TRACK DISKETTES
  5593                              <1> 
  5594 0000502E C605[B88A0100]00    <1> 	MOV	byte [DSKETTE_STATUS],0	; CLEAR OUT INVALID STATUS
  5595 00005035 E854000000          <1> 	CALL	RECAL			; RECALIBRATE DRIVE
  5596 0000503A 7251                <1> 	JC	short RB		; IF RECALIBRATE FAILS TWICE THEN ERROR
  5597                              <1> 
  5598                              <1> AFT_RECAL:
  5599 0000503C C687[C98A0100]00    <1>         MOV     byte [DSK_TRK+eDI],0    ; SAVE NEW CYLINDER AS PRESENT POSITION
  5600 00005043 08ED                <1> 	OR	CH,CH			; CHECK FOR SEEK TO TRACK 0
  5601 00005045 743F                <1> 	JZ	short DO_WAIT		; HEAD SETTLE, CY = 0 IF JUMP
  5602                              <1> 
  5603                              <1> ;-----	DRIVE IS IN SYNCHRONIZATION WITH CONTROLLER, SEEK TO TRACK
  5604                              <1> 
  5605 00005047 F687[C58A0100]20    <1> J28A:	TEST	byte [DSK_STATE+eDI],DBL_STEP ; CHECK FOR DOUBLE STEP REQUIRED
  5606 0000504E 7402                <1> 	JZ	short _R7		; SINGLE STEP REQUIRED BYPASS DOUBLE
  5607 00005050 D0E5                <1> 	SHL	CH,1			; DOUBLE NUMBER OF STEP TO TAKE
  5608                              <1> 
  5609 00005052 3AAF[C98A0100]      <1> _R7:	CMP	CH, [DSK_TRK+eDI]	; SEE IF ALREADY AT THE DESIRED TRACK
  5610 00005058 7433                <1> 	JE	short RB		; IF YES, DO NOT NEED TO SEEK
  5611                              <1> 
  5612 0000505A BA[8D500000]        <1> 	MOV	eDX, NEC_ERR		; LOAD RETURN ADDRESS
  5613 0000505F 52                  <1> 	PUSH	eDX ; (*)		; ON STACK FOR NEC OUTPUT ERROR
  5614 00005060 88AF[C98A0100]      <1> 	MOV	[DSK_TRK+eDI],CH	; SAVE NEW CYLINDER AS PRESENT POSITION
  5615 00005066 B40F                <1> 	MOV	AH,0FH			; SEEK COMMAND TO NEC
  5616 00005068 E868FFFFFF          <1> 	CALL	NEC_OUTPUT
  5617 0000506D 89FB                <1> 	MOV	eBX,eDI			; BX = DRIVE #
  5618 0000506F 88DC                <1> 	MOV	AH,BL			; OUTPUT DRIVE NUMBER
  5619 00005071 E85FFFFFFF          <1> 	CALL	NEC_OUTPUT
  5620 00005076 8AA7[C98A0100]      <1> 	MOV	AH, [DSK_TRK+eDI]	; GET CYLINDER NUMBER
  5621 0000507C E854FFFFFF          <1> 	CALL	NEC_OUTPUT
  5622 00005081 E829000000          <1> 	CALL	CHK_STAT_2		; ENDING INTERRUPT AND SENSE STATUS
  5623                              <1> 
  5624                              <1> ;-----	WAIT FOR HEAD SETTLE
  5625                              <1> 
  5626                              <1> DO_WAIT:
  5627 00005086 9C                  <1> 	PUSHF				; SAVE STATUS
  5628 00005087 E816FFFFFF          <1> 	CALL	HD_WAIT			; WAIT FOR HEAD SETTLE TIME
  5629 0000508C 9D                  <1> 	POPF				; RESTORE STATUS
  5630                              <1> RB:
  5631                              <1> NEC_ERR:
  5632                              <1> 	; 08/02/2015 (code trick here from original IBM PC/AT DISKETTE.ASM)
  5633                              <1> 	; (*) nec_err -> retn (push edx -> pop edx) -> nec_err -> retn
  5634 0000508D C3                  <1> 	RETn				; RETURN TO CALLER
  5635                              <1> 
  5636                              <1> ;-------------------------------------------------------------------------------
  5637                              <1> ; RECAL
  5638                              <1> ;	RECALIBRATE DRIVE
  5639                              <1> ;
  5640                              <1> ; ON ENTRY:	DI = DRIVE #
  5641                              <1> ;
  5642                              <1> ; ON EXIT:	CY REFLECTS STATUS OF OPERATION.
  5643                              <1> ;-------------------------------------------------------------------------------
  5644                              <1> RECAL:
  5645 0000508E 6651                <1> 	PUSH	CX
  5646 00005090 B8[AC500000]        <1> 	MOV	eAX, RC_BACK		; LOAD NEC_OUTPUT ERROR
  5647 00005095 50                  <1> 	PUSH	eAX
  5648 00005096 B407                <1> 	MOV	AH,07H			; RECALIBRATE COMMAND
  5649 00005098 E838FFFFFF          <1> 	CALL	NEC_OUTPUT
  5650 0000509D 89FB                <1> 	MOV	eBX,eDI			; BX = DRIVE #
  5651 0000509F 88DC                <1> 	MOV	AH,BL
  5652 000050A1 E82FFFFFFF          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE DRIVE NUMBER
  5653 000050A6 E804000000          <1> 	CALL	CHK_STAT_2		; GET THE INTERRUPT AND SENSE INT STATUS
  5654 000050AB 58                  <1> 	POP	eAX			; THROW AWAY ERROR
  5655                              <1> RC_BACK:
  5656 000050AC 6659                <1> 	POP	CX
  5657 000050AE C3                  <1> 	RETn
  5658                              <1> 
  5659                              <1> ;-------------------------------------------------------------------------------
  5660                              <1> ; CHK_STAT_2
  5661                              <1> ;	THIS ROUTINE HANDLES THE INTERRUPT RECEIVED AFTER RECALIBRATE,
  5662                              <1> ;	OR SEEK TO THE ADAPTER. THE INTERRUPT IS WAITED FOR, THE
  5663                              <1> ;	INTERRUPT STATUS SENSED, AND THE RESULT RETURNED TO THE CALLER.
  5664                              <1> ;
  5665                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION.
  5666                              <1> ;-------------------------------------------------------------------------------
  5667                              <1> CHK_STAT_2:
  5668 000050AF B8[D7500000]        <1>         MOV     eAX, CS_BACK            ; LOAD NEC_OUTPUT ERROR ADDRESS
  5669 000050B4 50                  <1> 	PUSH	eAX
  5670 000050B5 E828000000          <1> 	CALL	WAIT_INT		; WAIT FOR THE INTERRUPT
  5671 000050BA 721A                <1> 	JC	short J34		; IF ERROR, RETURN IT
  5672 000050BC B408                <1> 	MOV	AH,08H			; SENSE INTERRUPT STATUS COMMAND
  5673 000050BE E812FFFFFF          <1> 	CALL	NEC_OUTPUT
  5674 000050C3 E84A000000          <1> 	CALL	RESULTS			; READ IN THE RESULTS
  5675 000050C8 720C                <1> 	JC	short J34
  5676 000050CA A0[B98A0100]        <1> 	MOV	AL,[NEC_STATUS]		; GET THE FIRST STATUS BYTE
  5677 000050CF 2460                <1> 	AND	AL,01100000B		; ISOLATE THE BITS
  5678 000050D1 3C60                <1> 	CMP	AL,01100000B		; TEST FOR CORRECT VALUE
  5679 000050D3 7403                <1> 	JZ	short J35		; IF ERROR, GO MARK IT
  5680 000050D5 F8                  <1> 	CLC				; GOOD RETURN
  5681                              <1> J34:
  5682 000050D6 58                  <1> 	POP	eAX			; THROW AWAY ERROR RETURN
  5683                              <1> CS_BACK:
  5684 000050D7 C3                  <1> 	RETn
  5685                              <1> J35:
  5686 000050D8 800D[B88A0100]40    <1> 	OR	byte [DSKETTE_STATUS], BAD_SEEK
  5687 000050DF F9                  <1> 	STC				; ERROR RETURN CODE
  5688 000050E0 EBF4                <1> 	JMP	SHORT J34
  5689                              <1> 
  5690                              <1> ;-------------------------------------------------------------------------------
  5691                              <1> ; WAIT_INT
  5692                              <1> ;	THIS ROUTINE WAITS FOR AN INTERRUPT TO OCCUR A TIME OUT ROUTINE
  5693                              <1> ;	TAKES PLACE DURING THE WAIT, SO THAT AN ERROR MAY BE RETURNED
  5694                              <1> ;	IF THE DRIVE IS NOT READY.
  5695                              <1> ;
  5696                              <1> ; ON EXIT: 	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION.
  5697                              <1> ;-------------------------------------------------------------------------------
  5698                              <1> 
  5699                              <1> ; 17/12/2014
  5700                              <1> ; 2.5 seconds waiting !
  5701                              <1> ;(AWARD BIOS - 1999, WAIT_FDU_INT_LOW, WAIT_FDU_INT_HI)
  5702                              <1> ; amount of time to wait for completion interrupt from NEC.
  5703                              <1> 
  5704                              <1> 
  5705                              <1> WAIT_INT:
  5706 000050E2 FB                  <1> 	STI				; TURN ON INTERRUPTS, JUST IN CASE
  5707 000050E3 F8                  <1> 	CLC				; CLEAR TIMEOUT INDICATOR
  5708                              <1>        ;MOV	BL,10			; CLEAR THE COUNTERS
  5709                              <1>        ;XOR	CX,CX			; FOR 2 SECOND WAIT
  5710                              <1> 
  5711                              <1> 	; Modification from AWARD BIOS - 1999 (ATORGS.ASM, WAIT
  5712                              <1> 	;
  5713                              <1> 	;WAIT_FOR_MEM:	
  5714                              <1> 	;	Waits for a bit at a specified memory location pointed
  5715                              <1> 	;	to by ES:[DI] to become set.
  5716                              <1> 	;INPUT:
  5717                              <1> 	;	AH=Mask to test with.
  5718                              <1> 	;	ES:[DI] = memory location to watch.
  5719                              <1> 	;	BH:CX=Number of memory refresh periods to delay.
  5720                              <1> 	;	     (normally 30 microseconds per period.)
  5721                              <1> 
  5722                              <1> 	; waiting for (max.) 2.5 secs in 30 micro units.
  5723                              <1> ;	mov 	cx, WAIT_FDU_INT_LO		; 017798
  5724                              <1> ;;	mov 	bl, WAIT_FDU_INT_HI
  5725                              <1> ;	mov 	bl, WAIT_FDU_INT_HI + 1
  5726                              <1> 	; 27/02/2015
  5727 000050E4 B986450100          <1> 	mov 	ecx, WAIT_FDU_INT_LH	; 83334 (2.5 seconds)		
  5728                              <1> WFMS_CHECK_MEM:
  5729 000050E9 F605[B58A0100]80    <1> 	test	byte [SEEK_STATUS],INT_FLAG ; TEST FOR INTERRUPT OCCURRING
  5730 000050F0 7516                <1>         jnz     short J37
  5731                              <1> WFMS_HI:
  5732 000050F2 E461                <1> 	IN	AL,PORT_B  ; 061h	; SYS1, wait for lo to hi
  5733 000050F4 A810                <1> 	TEST	AL,010H			; transition on memory
  5734 000050F6 75FA                <1> 	JNZ	SHORT WFMS_HI		; refresh.
  5735                              <1> WFMS_LO:
  5736 000050F8 E461                <1> 	IN	AL,PORT_B		;SYS1
  5737 000050FA A810                <1> 	TEST	AL,010H
  5738 000050FC 74FA                <1> 	JZ	SHORT WFMS_LO
  5739 000050FE E2E9                <1>         LOOP    WFMS_CHECK_MEM
  5740                              <1> ;WFMS_OUTER_LP:
  5741                              <1> ;;	or	bl, bl			; check outer counter
  5742                              <1> ;;	jz	short J36A		; WFMS_TIMEOUT
  5743                              <1> ;	dec	bl
  5744                              <1> ;	jz	short J36A	
  5745                              <1> ;	jmp	short WFMS_CHECK_MEM
  5746                              <1> 
  5747                              <1> 	;17/12/2014
  5748                              <1> 	;16/12/2014
  5749                              <1> ;        mov     byte [wait_count], 0    ; Reset (INT 08H) counter
  5750                              <1> ;J36:
  5751                              <1> ;	TEST	byte [SEEK_STATUS],INT_FLAG ; TEST FOR INTERRUPT OCCURRING
  5752                              <1> ;	JNZ	short J37
  5753                              <1> 	;16/12/2014
  5754                              <1> 	;LOOP	J36			; COUNT DOWN WHILE WAITING
  5755                              <1> 	;DEC	BL			; SECOND LEVEL COUNTER
  5756                              <1> 	;JNZ	short J36
  5757                              <1> ;       cmp     byte [wait_count], 46   ; (46/18.2 seconds)
  5758                              <1> ;	jb	short J36
  5759                              <1> 
  5760                              <1> ;WFMS_TIMEOUT:
  5761                              <1> ;J36A:
  5762 00005100 800D[B88A0100]80    <1> 	OR	byte [DSKETTE_STATUS], TIME_OUT ; NOTHING HAPPENED
  5763 00005107 F9                  <1> 	STC				; ERROR RETURN
  5764                              <1> J37:
  5765 00005108 9C                  <1> 	PUSHF				; SAVE CURRENT CARRY
  5766 00005109 8025[B58A0100]7F    <1> 	AND	byte [SEEK_STATUS], ~INT_FLAG ; TURN OFF INTERRUPT FLAG
  5767 00005110 9D                  <1> 	POPF				; RECOVER CARRY
  5768 00005111 C3                  <1> 	RETn				; GOOD RETURN CODE
  5769                              <1> 
  5770                              <1> ;-------------------------------------------------------------------------------
  5771                              <1> ; RESULTS
  5772                              <1> ;	THIS ROUTINE WILL READ ANYTHING THAT THE NEC CONTROLLER RETURNS 
  5773                              <1> ;	FOLLOWING AN INTERRUPT.
  5774                              <1> ;
  5775                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION.
  5776                              <1> ;		AX,BX,CX,DX DESTROYED
  5777                              <1> ;-------------------------------------------------------------------------------
  5778                              <1> RESULTS:
  5779 00005112 57                  <1> 	PUSH	eDI
  5780 00005113 BF[B98A0100]        <1> 	MOV	eDI, NEC_STATUS		; POINTER TO DATA AREA
  5781 00005118 B307                <1> 	MOV	BL,7			; MAX STATUS BYTES
  5782 0000511A 66BAF403            <1> 	MOV	DX,03F4H		; STATUS PORT
  5783                              <1> 
  5784                              <1> ;-----	WAIT FOR REQUEST FOR MASTER
  5785                              <1> 
  5786                              <1> _R10: 
  5787                              <1> 	; 16/12/2014
  5788                              <1> 	; wait for (max) 0.5 seconds
  5789                              <1> 	;MOV	BH,2			; HIGH ORDER COUNTER
  5790                              <1> 	;XOR	CX,CX			; COUNTER
  5791                              <1> 
  5792                              <1> 	;Time to wait while waiting for each byte of NEC results = .5
  5793                              <1> 	;seconds.  .5 seconds = 500,000 micros.  500,000/30 = 16,667.
  5794                              <1> 	; 27/02/2015
  5795 0000511E B91B410000          <1> 	mov 	ecx, WAIT_FDU_RESULTS_LH ; 16667  
  5796                              <1> 	;mov	cx, WAIT_FDU_RESULTS_LO  ; 16667
  5797                              <1> 	;mov	bh, WAIT_FDU_RESULTS_HI+1 ; 0+1
  5798                              <1> 
  5799                              <1> WFPSR_OUTER_LP:
  5800                              <1> 	;
  5801                              <1> WFPSR_CHECK_PORT:
  5802                              <1> J39:					; WAIT FOR MASTER
  5803 00005123 EC                  <1> 	IN	AL,DX			; GET STATUS
  5804 00005124 24C0                <1> 	AND	AL,11000000B		; KEEP ONLY STATUS AND DIRECTION
  5805 00005126 3CC0                <1> 	CMP	AL,11000000B		; STATUS 1 AND DIRECTION 1 ?
  5806 00005128 7418                <1> 	JZ	short J42		; STATUS AND DIRECTION OK
  5807                              <1> WFPSR_HI:
  5808 0000512A E461                <1> 	IN	AL, PORT_B	;061h	; SYS1	; wait for hi to lo
  5809 0000512C A810                <1> 	TEST	AL,010H			; transition on memory
  5810 0000512E 75FA                <1> 	JNZ	SHORT WFPSR_HI		; refresh.
  5811                              <1> WFPSR_LO:
  5812 00005130 E461                <1> 	IN	AL, PORT_B		; SYS1
  5813 00005132 A810                <1> 	TEST	AL,010H
  5814 00005134 74FA                <1> 	JZ	SHORT WFPSR_LO
  5815 00005136 E2EB                <1>         LOOP    WFPSR_CHECK_PORT
  5816                              <1> 	;; 27/02/2015
  5817                              <1> 	;;dec	bh
  5818                              <1> 	;;jnz	short WFPSR_OUTER_LP
  5819                              <1> 	;jmp	short WFPSR_TIMEOUT	; fail
  5820                              <1> 
  5821                              <1> 	;;mov	byte [wait_count], 0
  5822                              <1> ;J39:					; WAIT FOR MASTER
  5823                              <1> ;	IN	AL,DX			; GET STATUS
  5824                              <1> ;	AND	AL,11000000B		; KEEP ONLY STATUS AND DIRECTION
  5825                              <1> ;	CMP	AL,11000000B		; STATUS 1 AND DIRECTION 1 ?
  5826                              <1> ;	JZ	short J42		; STATUS AND DIRECTION OK
  5827                              <1> 	;LOOP	J39			; LOOP TILL TIMEOUT
  5828                              <1> 	;DEC	BH			; DECREMENT HIGH ORDER COUNTER
  5829                              <1> 	;JNZ	short J39		; REPEAT TILL DELAY DONE
  5830                              <1> 	;
  5831                              <1> 	;;cmp	byte [wait_count], 10  ; (10/18.2 seconds)
  5832                              <1> 	;;jb	short J39	
  5833                              <1> 
  5834                              <1> ;WFPSR_TIMEOUT:
  5835 00005138 800D[B88A0100]80    <1> 	OR	byte [DSKETTE_STATUS],TIME_OUT
  5836 0000513F F9                  <1> 	STC				; SET ERROR RETURN
  5837 00005140 EB29                <1> 	JMP	SHORT POPRES		; POP REGISTERS AND RETURN
  5838                              <1> 
  5839                              <1> ;-----	READ IN THE STATUS
  5840                              <1> 
  5841                              <1> J42:
  5842 00005142 EB00                <1> 	JMP	$+2			; I/O DELAY
  5843 00005144 6642                <1> 	INC	DX			; POINT AT DATA PORT
  5844 00005146 EC                  <1> 	IN	AL,DX			; GET THE DATA
  5845                              <1> 	; 16/12/2014
  5846                              <1> 	NEWIODELAY
  2975 00005147 E6EB                <2>  out 0ebh,al
  5847 00005149 8807                <1>         MOV     [eDI],AL                ; STORE THE BYTE
  5848 0000514B 47                  <1> 	INC	eDI			; INCREMENT THE POINTER
  5849                              <1> 	; 16/12/2014
  5850                              <1> ;	push	cx
  5851                              <1> ;	mov	cx, 30
  5852                              <1> ;wdw2:
  5853                              <1> ;	NEWIODELAY
  5854                              <1> ;	loop	wdw2
  5855                              <1> ;	pop	cx
  5856                              <1> 
  5857 0000514C B903000000          <1> 	MOV	eCX,3			; MINIMUM 24 MICROSECONDS FOR NEC
  5858 00005151 E8F8D2FFFF          <1> 	CALL	WAITF			; WAIT 30 TO 45 MICROSECONDS
  5859 00005156 664A                <1> 	DEC	DX			; POINT AT STATUS PORT
  5860 00005158 EC                  <1> 	IN	AL,DX			; GET STATUS
  5861                              <1> 	; 16/12/2014
  5862                              <1> 	NEWIODELAY
  2975 00005159 E6EB                <2>  out 0ebh,al
  5863                              <1> 	;
  5864 0000515B A810                <1> 	TEST	AL,00010000B		; TEST FOR NEC STILL BUSY
  5865 0000515D 740C                <1> 	JZ	short POPRES		; RESULTS DONE ?
  5866                              <1> 
  5867 0000515F FECB                <1> 	DEC	BL			; DECREMENT THE STATUS COUNTER
  5868 00005161 75BB                <1>         JNZ     short _R10              ; GO BACK FOR MORE
  5869 00005163 800D[B88A0100]20    <1> 	OR	byte [DSKETTE_STATUS],BAD_NEC ; TOO MANY STATUS BYTES
  5870 0000516A F9                  <1> 	STC				; SET ERROR FLAG
  5871                              <1> 
  5872                              <1> ;-----	RESULT OPERATION IS DONE
  5873                              <1> POPRES:
  5874 0000516B 5F                  <1> 	POP	eDI
  5875 0000516C C3                  <1> 	RETn				; RETURN WITH CARRY SET
  5876                              <1> 
  5877                              <1> ;-------------------------------------------------------------------------------
  5878                              <1> ; READ_DSKCHNG
  5879                              <1> ;	READS THE STATE OF THE DISK CHANGE LINE.
  5880                              <1> ;
  5881                              <1> ; ON ENTRY:	DI = DRIVE #
  5882                              <1> ;
  5883                              <1> ; ON EXIT:	DI = DRIVE #
  5884                              <1> ;		ZF = 0 : DISK CHANGE LINE INACTIVE
  5885                              <1> ;		ZF = 1 : DISK CHANGE LINE ACTIVE
  5886                              <1> ;		AX,CX,DX DESTROYED
  5887                              <1> ;-------------------------------------------------------------------------------
  5888                              <1> READ_DSKCHNG:
  5889 0000516D E8A2FDFFFF          <1> 	CALL	MOTOR_ON		; TURN ON THE MOTOR IF OFF
  5890 00005172 66BAF703            <1> 	MOV	DX,03F7H		; ADDRESS DIGITAL INPUT REGISTER
  5891 00005176 EC                  <1> 	IN	AL,DX			; INPUT DIGITAL INPUT REGISTER
  5892 00005177 A880                <1> 	TEST	AL,DSK_CHG		; CHECK FOR DISK CHANGE LINE ACTIVE
  5893 00005179 C3                  <1> 	RETn				; RETURN TO CALLER WITH ZERO FLAG SET
  5894                              <1> 
  5895                              <1> ;-------------------------------------------------------------------------------
  5896                              <1> ; DRIVE_DET
  5897                              <1> ;	DETERMINES WHETHER DRIVE IS 80 OR 40 TRACKS AND
  5898                              <1> ;	UPDATES STATE INFORMATION ACCORDINGLY.
  5899                              <1> ; ON ENTRY:	DI = DRIVE #
  5900                              <1> ;-------------------------------------------------------------------------------
  5901                              <1> DRIVE_DET:
  5902 0000517A E895FDFFFF          <1> 	CALL	MOTOR_ON		; TURN ON MOTOR IF NOT ALREADY ON
  5903 0000517F E80AFFFFFF          <1> 	CALL	RECAL			; RECALIBRATE DRIVE
  5904 00005184 7251                <1> 	JC	short DD_BAC		; ASSUME NO DRIVE PRESENT
  5905 00005186 B530                <1> 	MOV	CH,TRK_SLAP		; SEEK TO TRACK 48
  5906 00005188 E882FEFFFF          <1> 	CALL	SEEK
  5907 0000518D 7248                <1> 	JC	short DD_BAC		; ERROR NO DRIVE
  5908 0000518F B50B                <1> 	MOV	CH,QUIET_SEEK+1		; SEEK TO TRACK 10
  5909                              <1> SK_GIN:
  5910 00005191 FECD                <1> 	DEC	CH			; DECREMENT TO NEXT TRACK
  5911 00005193 6651                <1> 	PUSH	CX			; SAVE TRACK
  5912 00005195 E875FEFFFF          <1> 	CALL	SEEK
  5913 0000519A 723C                <1> 	JC	short POP_BAC		; POP AND RETURN
  5914 0000519C B8[D8510000]        <1> 	MOV	eAX, POP_BAC		; LOAD NEC OUTPUT ERROR ADDRESS
  5915 000051A1 50                  <1> 	PUSH	eAX
  5916 000051A2 B404                <1> 	MOV	AH,SENSE_DRV_ST		; SENSE DRIVE STATUS COMMAND BYTE
  5917 000051A4 E82CFEFFFF          <1> 	CALL	NEC_OUTPUT		; OUTPUT TO NEC
  5918 000051A9 6689F8              <1> 	MOV	AX,DI			; AL = DRIVE
  5919 000051AC 88C4                <1> 	MOV	AH,AL			; AH = DRIVE
  5920 000051AE E822FEFFFF          <1> 	CALL	NEC_OUTPUT		; OUTPUT TO NEC
  5921 000051B3 E85AFFFFFF          <1> 	CALL	RESULTS			; GO GET STATUS
  5922 000051B8 58                  <1> 	POP	eAX			; THROW AWAY ERROR ADDRESS
  5923 000051B9 6659                <1> 	POP	CX			; RESTORE TRACK
  5924 000051BB F605[B98A0100]10    <1> 	TEST	byte [NEC_STATUS], HOME	; TRACK 0 ?
  5925 000051C2 74CD                <1> 	JZ	short SK_GIN		; GO TILL TRACK 0
  5926 000051C4 08ED                <1> 	OR	CH,CH			; IS HOME AT TRACK 0
  5927 000051C6 7408                <1> 	JZ	short IS_80		; MUST BE 80 TRACK DRIVE
  5928                              <1> 
  5929                              <1> ;	DRIVE IS A 360; SET DRIVE TO DETERMINED;
  5930                              <1> ;	SET MEDIA TO DETERMINED AT RATE 250.
  5931                              <1> 
  5932 000051C8 808F[C58A0100]94    <1> 	OR	byte [DSK_STATE+eDI], DRV_DET+MED_DET+RATE_250
  5933 000051CF C3                  <1> 	RETn				; ALL INFORMATION SET
  5934                              <1> IS_80:
  5935 000051D0 808F[C58A0100]01    <1> 	OR	byte [DSK_STATE+eDI], TRK_CAPA ; SETUP 80 TRACK CAPABILITY
  5936                              <1> DD_BAC:
  5937 000051D7 C3                  <1> 	RETn
  5938                              <1> POP_BAC:
  5939 000051D8 6659                <1> 	POP	CX			; THROW AWAY
  5940 000051DA C3                  <1> 	RETn
  5941                              <1> 
  5942                              <1> fdc_int:  
  5943                              <1> 	  ; 30/07/2015	
  5944                              <1> 	  ; 16/02/2015
  5945                              <1> ;int_0Eh: ; 11/12/2014
  5946                              <1> 
  5947                              <1> ;--- HARDWARE INT 0EH -- ( IRQ LEVEL  6 ) --------------------------------------
  5948                              <1> ; DISK_INT
  5949                              <1> ;	THIS ROUTINE HANDLES THE DISKETTE INTERRUPT.
  5950                              <1> ;
  5951                              <1> ; ON EXIT:	THE INTERRUPT FLAG IS SET IN @SEEK_STATUS.
  5952                              <1> ;-------------------------------------------------------------------------------
  5953                              <1> DISK_INT_1:
  5954                              <1> 
  5955 000051DB 6650                <1> 	PUSH	AX			; SAVE WORK REGISTER
  5956 000051DD 1E                  <1> 	push	ds
  5957 000051DE 66B81000            <1> 	mov	ax, KDATA
  5958 000051E2 8ED8                <1> 	mov 	ds, ax
  5959 000051E4 800D[B58A0100]80    <1>         OR      byte [SEEK_STATUS], INT_FLAG ; TURN ON INTERRUPT OCCURRED
  5960 000051EB B020                <1> 	MOV     AL,EOI                  ; END OF INTERRUPT MARKER
  5961 000051ED E620                <1> 	OUT	INTA00,AL		; INTERRUPT CONTROL PORT
  5962 000051EF 1F                  <1> 	pop	ds
  5963 000051F0 6658                <1> 	POP	AX			; RECOVER REGISTER
  5964 000051F2 CF                  <1> 	IRETd				; RETURN FROM INTERRUPT
  5965                              <1> 
  5966                              <1> ;-------------------------------------------------------------------------------
  5967                              <1> ; DSKETTE_SETUP
  5968                              <1> ;	THIS ROUTINE DOES A PRELIMINARY CHECK TO SEE WHAT TYPE OF
  5969                              <1> ;	DISKETTE DRIVES ARE ATTACH TO THE SYSTEM.
  5970                              <1> ;-------------------------------------------------------------------------------
  5971                              <1> 
  5972                              <1> ; 29/05/2016 - TRDOS 386 (TRDOS v2.0)
  5973                              <1> 
  5974                              <1> DSKETTE_SETUP:
  5975                              <1> 	;PUSH	AX			; SAVE REGISTERS
  5976                              <1> 	;PUSH	BX
  5977                              <1> 	;PUSH	CX
  5978 000051F3 52                  <1> 	PUSH	eDX
  5979                              <1> 	;PUSH	DI
  5980                              <1> 	;;PUSH	DS
  5981                              <1> 	; 14/12/2014
  5982                              <1> 	;mov	word [DISK_POINTER], MD_TBL6
  5983                              <1> 	;mov	[DISK_POINTER+2], cs
  5984                              <1> 	;
  5985                              <1> 	;OR	byte [RTC_WAIT_FLAG], 1	; NO RTC WAIT, FORCE USE OF LOOP
  5986 000051F4 31FF                <1> 	XOR	eDI,eDI			; INITIALIZE DRIVE POINTER
  5987 000051F6 66C705[C58A0100]00- <1> 	MOV	WORD [DSK_STATE],0	; INITIALIZE STATES
  5987 000051FE 00                  <1>
  5988 000051FF 8025[C08A0100]33    <1> 	AND	byte [LASTRATE],~(STRT_MSK+SEND_MSK) ; CLEAR START & SEND
  5989 00005206 800D[C08A0100]C0    <1> 	OR	byte [LASTRATE],SEND_MSK ; INITIALIZE SENT TO IMPOSSIBLE
  5990 0000520D C605[B58A0100]00    <1> 	MOV	byte [SEEK_STATUS],0	; INDICATE RECALIBRATE NEEDED
  5991 00005214 C605[B78A0100]00    <1> 	MOV	byte [MOTOR_COUNT],0	; INITIALIZE MOTOR COUNT
  5992 0000521B C605[B68A0100]00    <1> 	MOV	byte [MOTOR_STATUS],0	; INITIALIZE DRIVES TO OFF STATE
  5993 00005222 C605[B88A0100]00    <1> 	MOV	byte [DSKETTE_STATUS],0	; NO ERRORS
  5994                              <1> 	;
  5995                              <1> 	; 28/02/2015
  5996                              <1> 	;mov	word [cfd], 100h 
  5997 00005229 E82BF2FFFF          <1> 	call	DSK_RESET
  5998 0000522E 5A                  <1> 	pop	edx
  5999 0000522F F8                  <1> 	clc	; 29/05/2016
  6000 00005230 C3                  <1> 	retn
  6001                              <1> 
  6002                              <1> ;SUP0:
  6003                              <1> ;	CALL	DRIVE_DET		; DETERMINE DRIVE
  6004                              <1> ;	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  6005                              <1> ;	; 02/01/2015
  6006                              <1> ;	;INC	DI			; POINT TO NEXT DRIVE
  6007                              <1> ;	;CMP	DI,MAX_DRV		; SEE IF DONE
  6008                              <1> ;	;JNZ	short SUP0		; REPEAT FOR EACH ORIVE
  6009                              <1> ;       cmp     byte [fd1_type], 0	
  6010                              <1> ;	jna	short sup1
  6011                              <1> ;	or	di, di
  6012                              <1> ;	jnz	short sup1
  6013                              <1> ;	inc	di
  6014                              <1> ;       jmp     short SUP0
  6015                              <1> ;sup1:
  6016                              <1> ;	MOV	byte [SEEK_STATUS],0	; FORCE RECALIBRATE
  6017                              <1> ;	;AND	byte [RTC_WAIT_FLAG],0FEH ; ALLOW FOR RTC WAIT
  6018                              <1> ;	CALL	SETUP_END		; VARIOUS CLEANUPS
  6019                              <1> ;	;;POP	DS			; RESTORE CALLERS REGISTERS
  6020                              <1> ;	;POP	DI
  6021                              <1> ;	POP	eDX
  6022                              <1> ;	;POP	CX
  6023                              <1> ;	;POP	BX
  6024                              <1> ;	;POP	AX
  6025                              <1> ;	RETn
  6026                              <1> 
  6027                              <1> ;//////////////////////////////////////////////////////
  6028                              <1> ;; END OF DISKETTE I/O ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6029                              <1> ;
  6030                              <1> 
  6031                              <1> int13h: ; 21/02/2015
  6032 00005231 F8                  <1> 	clc ; 20/07/2020
  6033 00005232 9C                  <1> 	pushfd
  6034 00005233 0E                  <1> 	push 	cs
  6035 00005234 E848010000          <1> 	call 	DISK_IO
  6036 00005239 C3                  <1> 	retn
  6037                              <1> 
  6038                              <1> ;;;;;; DISK I/O ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21/02/2015 ;;;
  6039                              <1> ;/////////////////////////////////////////////////////////////////////
  6040                              <1> 
  6041                              <1> ; DISK I/O - Erdogan Tan (Retro UNIX 386 v1 project)
  6042                              <1> ; 18/02/2016
  6043                              <1> ; 17/02/2016
  6044                              <1> ; 23/02/2015
  6045                              <1> ; 21/02/2015 (unix386.s)
  6046                              <1> ; 22/12/2014 - 14/02/2015 (dsectrm2.s)
  6047                              <1> ;
  6048                              <1> ; Original Source Code:
  6049                              <1> ; DISK ----- 09/25/85 FIXED DISK BIOS
  6050                              <1> ; (IBM PC XT Model 286 System BIOS Source Code, 04-21-86)
  6051                              <1> ;
  6052                              <1> ; Modifications: by reference of AWARD BIOS 1999 (D1A0622) 
  6053                              <1> ;		 Source Code - ATORGS.ASM, AHDSK.ASM
  6054                              <1> ;
  6055                              <1> 
  6056                              <1> 
  6057                              <1> ;The wait for controller to be not busy is 10 seconds.
  6058                              <1> ;10,000,000 / 30 = 333,333.  333,333 decimal = 051615h
  6059                              <1> ;;WAIT_HDU_CTLR_BUSY_LO	equ	1615h		
  6060                              <1> ;;WAIT_HDU_CTLR_BUSY_HI	equ	  05h
  6061                              <1> WAIT_HDU_CTRL_BUSY_LH	equ	51615h	 ;21/02/2015		
  6062                              <1> 
  6063                              <1> ;The wait for controller to issue completion interrupt is 10 seconds.
  6064                              <1> ;10,000,000 / 30 = 333,333.  333,333 decimal = 051615h
  6065                              <1> ;;WAIT_HDU_INT_LO	equ	1615h
  6066                              <1> ;;WAIT_HDU_INT_HI	equ	  05h
  6067                              <1> WAIT_HDU_INT_LH		equ	51615h	; 21/02/2015
  6068                              <1> 
  6069                              <1> ;The wait for Data request on read and write longs is
  6070                              <1> ;2000 us. (?)
  6071                              <1> ;;WAIT_HDU_DRQ_LO	equ	1000	; 03E8h
  6072                              <1> ;;WAIT_HDU_DRQ_HI	equ	0
  6073                              <1> WAIT_HDU_DRQ_LH		equ	1000	; 21/02/2015
  6074                              <1> 
  6075                              <1> ; Port 61h (PORT_B)
  6076                              <1> SYS1		equ	61h	; PORT_B  (diskette.inc)
  6077                              <1> 
  6078                              <1> ; 23/12/2014
  6079                              <1> %define CMD_BLOCK       eBP-8  ; 21/02/2015
  6080                              <1> 
  6081                              <1> ; 30/08/2020 - TRDOS 386 v2
  6082                              <1> 
  6083                              <1> ;--- INT 13H -------------------------------------------------------------------
  6084                              <1> ;									       :
  6085                              <1> ; FIXED DISK I/O INTERFACE						       :
  6086                              <1> ;									       :
  6087                              <1> ;	THIS INTERFACE PROVIDES ACCESS TO 5 1/4" FIXED DISKS THROUGH           :
  6088                              <1> ;	THE IBM FIXED DISK CONTROLLER.					       :
  6089                              <1> ;									       :
  6090                              <1> ;	THE  BIOS  ROUTINES  ARE  MEANT  TO  BE  ACCESSED  THROUGH	       :
  6091                              <1> ;	SOFTWARE  INTERRUPTS  ONLY.    ANY  ADDRESSES  PRESENT	IN	       :
  6092                              <1> ;	THESE  LISTINGS  ARE  INCLUDED	 ONLY	FOR  COMPLETENESS,	       :
  6093                              <1> ;	NOT  FOR  REFERENCE.  APPLICATIONS   WHICH  REFERENCE  ANY	       :
  6094                              <1> ;	ABSOLUTE  ADDRESSES  WITHIN  THE  CODE	SEGMENTS  OF  BIOS	       :
  6095                              <1> ;	VIOLATE  THE  STRUCTURE  AND  DESIGN  OF  BIOS. 		       :
  6096                              <1> ;									       :
  6097                              <1> ;------------------------------------------------------------------------------:
  6098                              <1> ;									       :
  6099                              <1> ; INPUT  (AH)= HEX COMMAND VALUE					       :
  6100                              <1> ;									       :
  6101                              <1> ;	(AH)= 00H  RESET DISK (DL = 80H,81H) / DISKETTE 		       :
  6102                              <1> ;	(AH)= 01H  READ THE STATUS OF THE LAST DISK OPERATION INTO (AL)        :
  6103                              <1> ;		    NOTE: DL < 80H - DISKETTE				       :
  6104                              <1> ;			  DL > 80H - DISK				       :
  6105                              <1> ;	(AH)= 02H  READ THE DESIRED SECTORS INTO MEMORY 		       :
  6106                              <1> ;	(AH)= 03H  WRITE THE DESIRED SECTORS FROM MEMORY		       :
  6107                              <1> ;	(AH)= 04H  VERIFY THE DESIRED SECTORS				       :
  6108                              <1> ;	(AH)= 05H  FORMAT THE DESIRED TRACK				       :
  6109                              <1> ;	(AH)= 06H  UNUSED						       :
  6110                              <1> ;	(AH)= 07H  UNUSED						       :
  6111                              <1> ;	(AH)= 08H  RETURN THE CURRENT DRIVE PARAMETERS			       :
  6112                              <1> ;	(AH)= 09H  INITIALIZE DRIVE PAIR CHARACTERISTICS		       :
  6113                              <1> ;		    INTERRUPT 41 POINTS TO DATA BLOCK FOR DRIVE 0	       :
  6114                              <1> ;		    INTERRUPT 46 POINTS TO DATA BLOCK FOR DRIVE 1	       :
  6115                              <1> ;	(AH)= 0AH  READ LONG						       :
  6116                              <1> ;	(AH)= 0BH  WRITE LONG  (READ & WRITE LONG ENCOMPASS 512 + 4 BYTES ECC) :
  6117                              <1> ;	(AH)= 0CH  SEEK 						       :
  6118                              <1> ;	(AH)= 0DH  ALTERNATE DISK RESET (SEE DL)			       :
  6119                              <1> ;	(AH)= 0EH  UNUSED						       :
  6120                              <1> ;	(AH)= 0FH  UNUSED						       :
  6121                              <1> ;	(AH)= 10H  TEST DRIVE READY					       :
  6122                              <1> ;	(AH)= 11H  RECALIBRATE						       :
  6123                              <1> ;	(AH)= 12H  UNUSED						       :
  6124                              <1> ;	(AH)= 13H  UNUSED						       :
  6125                              <1> ;	(AH)= 14H  CONTROLLER INTERNAL DIAGNOSTIC			       :
  6126                              <1> ;	(AH)= 15H  READ DASD TYPE					       :
  6127                              <1> ;									       :
  6128                              <1> ;-------------------------------------------------------------------------------
  6129                              <1> ;									       :
  6130                              <1> ;	REGISTERS USED FOR FIXED DISK OPERATIONS			       :
  6131                              <1> ;									       :
  6132                              <1> ;		(DL)	-  DRIVE NUMBER     (80H-81H FOR DISK. VALUE CHECKED)  :
  6133                              <1> ;		(DH)	-  HEAD NUMBER	    (0-15 ALLOWED, NOT VALUE CHECKED)  :
  6134                              <1> ;		(CH)	-  CYLINDER NUMBER  (0-1023, NOT VALUE CHECKED)(SEE CL):
  6135                              <1> ;		(CL)	-  SECTOR NUMBER    (1-17, NOT VALUE CHECKED)	       :
  6136                              <1> ;									       :
  6137                              <1> ;			   NOTE: HIGH 2 BITS OF CYLINDER NUMBER ARE PLACED     :
  6138                              <1> ;				 IN THE HIGH 2 BITS OF THE CL REGISTER	       :
  6139                              <1> ;				 (10 BITS TOTAL)			       :
  6140                              <1> ;									       :
  6141                              <1> ;		(AL)	-  NUMBER OF SECTORS (MAXIMUM POSSIBLE RANGE 1-80H,    :
  6142                              <1> ;					      FOR READ/WRITE LONG 1-79H)       :
  6143                              <1> ;									       :
  6144                              <1> ;		(ES:BX) -  ADDRESS OF BUFFER FOR READS AND WRITES,	       :
  6145                              <1> ;			   (NOT REQUIRED FOR VERIFY)			       :
  6146                              <1> ;									       :
  6147                              <1> ;		FORMAT (AH=5) ES:BX POINTS TO A 512 BYTE BUFFER. THE FIRST     :
  6148                              <1> ;			   2*(SECTORS/TRACK) BYTES CONTAIN F,N FOR EACH SECTOR.:
  6149                              <1> ;			   F = 00H FOR A GOOD SECTOR			       :
  6150                              <1> ;			       80H FOR A BAD SECTOR			       :
  6151                              <1> ;			   N = SECTOR NUMBER				       :
  6152                              <1> ;			   FOR AN INTERLEAVE OF 2 AND 17 SECTORS/TRACK	       :
  6153                              <1> ;			   THE TABLE SHOULD BE: 			       :
  6154                              <1> ;									       :
  6155                              <1> ;		   DB	   00H,01H,00H,0AH,00H,02H,00H,0BH,00H,03H,00H,0CH     :
  6156                              <1> ;		   DB	   00H,04H,00H,0DH,00H,05H,00H,0EH,00H,06H,00H,0FH     :
  6157                              <1> ;		   DB	   00H,07H,00H,10H,00H,08H,00H,11H,00H,09H	       :
  6158                              <1> ;									       :
  6159                              <1> ;-------------------------------------------------------------------------------
  6160                              <1> 
  6161                              <1> ;-------------------------------------------------------------------------------
  6162                              <1> ; OUTPUT								       :
  6163                              <1> ;	AH = STATUS OF CURRENT OPERATION				       :
  6164                              <1> ;	     STATUS BITS ARE DEFINED IN THE EQUATES BELOW		       :
  6165                              <1> ;	CY = 0	SUCCESSFUL OPERATION (AH=0 ON RETURN)			       :
  6166                              <1> ;	CY = 1	FAILED OPERATION (AH HAS ERROR REASON)			       :
  6167                              <1> ;									       :
  6168                              <1> ;	NOTE:	ERROR 11H  INDICATES THAT THE DATA READ HAD A RECOVERABLE      :
  6169                              <1> ;		ERROR WHICH WAS CORRECTED BY THE ECC ALGORITHM.  THE DATA      :
  6170                              <1> ;		IS PROBABLY GOOD,   HOWEVER THE BIOS ROUTINE INDICATES AN      :
  6171                              <1> ;		ERROR TO ALLOW THE CONTROLLING PROGRAM A CHANCE TO DECIDE      :
  6172                              <1> ;		FOR ITSELF.  THE  ERROR  MAY  NOT  RECUR  IF  THE DATA IS      :
  6173                              <1> ;		REWRITTEN.						       :
  6174                              <1> ;									       :
  6175                              <1> ;	IF DRIVE PARAMETERS WERE REQUESTED (DL >= 80H), 		       :
  6176                              <1> ;	   INPUT:							       :
  6177                              <1> ;	     (DL) = DRIVE NUMBER					       :	
  6178                              <1> ;	     ; 27/05/2016 - TRDOS 386 (TRDOS v2.0)						       :	 	
  6179                              <1> ;	     EBX = Buffer address for fixed disk parameters table (32 bytes)   :
  6180                              <1> ;	   OUTPUT:							       :
  6181                              <1> ;	     (DL) = NUMBER OF CONSECUTIVE ACKNOWLEDGING DRIVES ATTACHED (1-2)  :
  6182                              <1> ;		    (CONTROLLER CARD ZERO TALLY ONLY)			       :
  6183                              <1> ;	     (DH) = MAXIMUM USEABLE VALUE FOR HEAD NUMBER		       :
  6184                              <1> ;	     (CH) = MAXIMUM USEABLE VALUE FOR CYLINDER NUMBER		       :
  6185                              <1> ;	     (CL) = MAXIMUM USEABLE VALUE FOR SECTOR NUMBER		       :
  6186                              <1> ;		    AND CYLINDER NUMBER HIGH BITS			       :
  6187                              <1> ;									       :
  6188                              <1> ;	IF READ DASD TYPE WAS REQUESTED,				       :
  6189                              <1> ;									       :
  6190                              <1> ;	AH = 0 - NOT PRESENT						       :
  6191                              <1> ;	     1 - DISKETTE - NO CHANGE LINE AVAILABLE			       :
  6192                              <1> ;	     2 - DISKETTE - CHANGE LINE AVAILABLE			       :
  6193                              <1> ;	     3 - FIXED DISK						       :
  6194                              <1> ;									       :
  6195                              <1> ;	CX,DX = NUMBER OF 512 BYTE BLOCKS WHEN AH = 3			       :
  6196                              <1> ;									       :
  6197                              <1> ;	REGISTERS WILL BE PRESERVED EXCEPT WHEN THEY ARE USED TO RETURN        :
  6198                              <1> ;	INFORMATION.							       :
  6199                              <1> ;									       :
  6200                              <1> ;	NOTE: IF AN ERROR IS REPORTED BY THE DISK CODE, THE APPROPRIATE        :
  6201                              <1> ;		ACTION IS TO RESET THE DISK, THEN RETRY THE OPERATION.	       :
  6202                              <1> ;									       :
  6203                              <1> ;-------------------------------------------------------------------------------
  6204                              <1> 
  6205                              <1> SENSE_FAIL	EQU	0FFH		; NOT IMPLEMENTED
  6206                              <1> NO_ERR		EQU	0E0H		; STATUS ERROR/ERROR REGISTER=0
  6207                              <1> WRITE_FAULT	EQU	0CCH		; WRITE FAULT ON SELECTED DRIVE
  6208                              <1> UNDEF_ERR	EQU	0BBH		; UNDEFINED ERROR OCCURRED
  6209                              <1> NOT_RDY 	EQU	0AAH		; DRIVE NOT READY
  6210                              <1> TIME_OUT	EQU	80H		; ATTACHMENT FAILED TO RESPOND
  6211                              <1> BAD_SEEK	EQU	40H		; SEEK OPERATION FAILED
  6212                              <1> BAD_CNTLR	EQU	20H		; CONTROLLER HAS FAILED
  6213                              <1> DATA_CORRECTED	EQU	11H		; ECC CORRECTED DATA ERROR
  6214                              <1> BAD_ECC 	EQU	10H		; BAD ECC ON DISK READ
  6215                              <1> BAD_TRACK	EQU	0BH		; NOT IMPLEMENTED
  6216                              <1> BAD_SECTOR	EQU	0AH		; BAD SECTOR FLAG DETECTED
  6217                              <1> ;DMA_BOUNDARY	EQU	09H		; DATA EXTENDS TOO FAR
  6218                              <1> INIT_FAIL	EQU	07H		; DRIVE PARAMETER ACTIVITY FAILED
  6219                              <1> BAD_RESET	EQU	05H		; RESET FAILED
  6220                              <1> ;RECORD_NOT_FND	EQU	04H		; REQUESTED SECTOR NOT FOUND
  6221                              <1> ;BAD_ADDR_MARK	EQU	02H		; ADDRESS MARK NOT FOUND
  6222                              <1> ;BAD_CMD 	EQU	01H		; BAD COMMAND PASSED TO DISK I/O
  6223                              <1> 
  6224                              <1> ;--------------------------------------------------------
  6225                              <1> ;							:
  6226                              <1> ; FIXED DISK PARAMETER TABLE				:
  6227                              <1> ;  -  THE TABLE IS COMPOSED OF A BLOCK DEFINED AS:	:
  6228                              <1> ;							:
  6229                              <1> ;  +0	(1 WORD) - MAXIMUM NUMBER OF CYLINDERS		:
  6230                              <1> ;  +2	(1 BYTE) - MAXIMUM NUMBER OF HEADS		:
  6231                              <1> ;  +3	(1 WORD) - NOT USED/SEE PC-XT			:
  6232                              <1> ;  +5	(1 WORD) - STARTING WRITE PRECOMPENSATION CYL	:
  6233                              <1> ;  +7	(1 BYTE) - MAXIMUM ECC DATA BURST LENGTH	:
  6234                              <1> ;  +8	(1 BYTE) - CONTROL BYTE 			:
  6235                              <1> ;		   BIT	  7 DISABLE RETRIES -OR-	:
  6236                              <1> ;		   BIT	  6 DISABLE RETRIES		:
  6237                              <1> ;		   BIT	  3 MORE THAN 8 HEADS		:
  6238                              <1> ;  +9	(3 BYTES)- NOT USED/SEE PC-XT			:
  6239                              <1> ; +12	(1 WORD) - LANDING ZONE 			:
  6240                              <1> ; +14	(1 BYTE) - NUMBER OF SECTORS/TRACK		:
  6241                              <1> ; +15	(1 BYTE) - RESERVED FOR FUTURE USE		:
  6242                              <1> ;							:
  6243                              <1> ;	 - TO DYNAMICALLY DEFINE A SET OF PARAMETERS	:
  6244                              <1> ;	   BUILD A TABLE FOR UP TO 15 TYPES AND PLACE	:
  6245                              <1> ;	   THE CORRESPONDING VECTOR INTO INTERRUPT 41	:
  6246                              <1> ;	   FOR DRIVE 0 AND INTERRUPT 46 FOR DRIVE 1.	:
  6247                              <1> ;							:
  6248                              <1> ;--------------------------------------------------------
  6249                              <1> 
  6250                              <1> ;--------------------------------------------------------
  6251                              <1> ;							:
  6252                              <1> ; HARDWARE SPECIFIC VALUES				:
  6253                              <1> ;							:
  6254                              <1> ;  -  CONTROLLER I/O PORT				:
  6255                              <1> ;							:
  6256                              <1> ;     > WHEN READ FROM: 				:
  6257                              <1> ;	HF_PORT+0 - READ DATA (FROM CONTROLLER TO CPU)	:
  6258                              <1> ;	HF_PORT+1 - GET ERROR REGISTER			:
  6259                              <1> ;	HF_PORT+2 - GET SECTOR COUNT			:
  6260                              <1> ;	HF_PORT+3 - GET SECTOR NUMBER			:
  6261                              <1> ;	HF_PORT+4 - GET CYLINDER LOW			:
  6262                              <1> ;	HF_PORT+5 - GET CYLINDER HIGH (2 BITS)		:
  6263                              <1> ;	HF_PORT+6 - GET SIZE/DRIVE/HEAD 		:
  6264                              <1> ;	HF_PORT+7 - GET STATUS REGISTER 		:
  6265                              <1> ;							:
  6266                              <1> ;     > WHEN WRITTEN TO:				:
  6267                              <1> ;	HF_PORT+0 - WRITE DATA (FROM CPU TO CONTROLLER) :
  6268                              <1> ;	HF_PORT+1 - SET PRECOMPENSATION CYLINDER	:
  6269                              <1> ;	HF_PORT+2 - SET SECTOR COUNT			:
  6270                              <1> ;	HF_PORT+3 - SET SECTOR NUMBER			:
  6271                              <1> ;	HF_PORT+4 - SET CYLINDER LOW			:
  6272                              <1> ;	HF_PORT+5 - SET CYLINDER HIGH (2 BITS)		:
  6273                              <1> ;	HF_PORT+6 - SET SIZE/DRIVE/HEAD 		:
  6274                              <1> ;	HF_PORT+7 - SET COMMAND REGISTER		:
  6275                              <1> ;							:
  6276                              <1> ;--------------------------------------------------------
  6277                              <1> 
  6278                              <1> ;HF_PORT 	EQU	01F0H	; DISK PORT
  6279                              <1> ;HF1_PORT	equ	0170h	
  6280                              <1> ;HF_REG_PORT	EQU	03F6H
  6281                              <1> ;HF1_REG_PORT	equ	0376h
  6282                              <1> 
  6283                              <1> HDC1_BASEPORT	equ	1F0h
  6284                              <1> HDC2_BASEPORT	equ	170h		
  6285                              <1> 
  6286                              <1> align 2
  6287                              <1> 
  6288                              <1> ;-----		STATUS REGISTER
  6289                              <1> 
  6290                              <1> ST_ERROR	EQU	00000001B	;
  6291                              <1> ST_INDEX	EQU	00000010B	;
  6292                              <1> ST_CORRCTD	EQU	00000100B	; ECC CORRECTION SUCCESSFUL
  6293                              <1> ST_DRQ		EQU	00001000B	;
  6294                              <1> ST_SEEK_COMPL	EQU	00010000B	; SEEK COMPLETE
  6295                              <1> ST_WRT_FLT	EQU	00100000B	; WRITE FAULT
  6296                              <1> ST_READY	EQU	01000000B	;
  6297                              <1> ST_BUSY 	EQU	10000000B	;
  6298                              <1> 
  6299                              <1> ;-----		ERROR REGISTER
  6300                              <1> 
  6301                              <1> ERR_DAM 	EQU	00000001B	; DATA ADDRESS MARK NOT FOUND
  6302                              <1> ERR_TRK_0	EQU	00000010B	; TRACK 0 NOT FOUND ON RECAL
  6303                              <1> ERR_ABORT	EQU	00000100B	; ABORTED COMMAND
  6304                              <1> ;		EQU	00001000B	; NOT USED
  6305                              <1> ERR_ID		EQU	00010000B	; ID NOT FOUND
  6306                              <1> ;		EQU	00100000B	; NOT USED
  6307                              <1> ERR_DATA_ECC	EQU	01000000B
  6308                              <1> ERR_BAD_BLOCK	EQU	10000000B
  6309                              <1> 
  6310                              <1> 
  6311                              <1> RECAL_CMD	EQU	00010000B	; DRIVE RECAL	(10H)
  6312                              <1> READ_CMD	EQU	00100000B	;	READ	(20H)
  6313                              <1> WRITE_CMD	EQU	00110000B	;	WRITE	(30H)
  6314                              <1> VERIFY_CMD	EQU	01000000B	;	VERIFY	(40H)
  6315                              <1> FMTTRK_CMD	EQU	01010000B	; FORMAT TRACK	(50H)
  6316                              <1> INIT_CMD	EQU	01100000B	;   INITIALIZE	(60H)
  6317                              <1> SEEK_CMD	EQU	01110000B	;	SEEK	(70H)
  6318                              <1> DIAG_CMD	EQU	10010000B	; DIAGNOSTIC	(90H)
  6319                              <1> SET_PARM_CMD	EQU	10010001B	; DRIVE PARMS	(91H)
  6320                              <1> NO_RETRIES	EQU	00000001B	; CHD MODIFIER	(01H)
  6321                              <1> ECC_MODE	EQU	00000010B	; CMD MODIFIER	(02H)
  6322                              <1> BUFFER_MODE	EQU	00001000B	; CMD MODIFIER	(08H)
  6323                              <1> 
  6324                              <1> ;MAX_FILE	EQU	2
  6325                              <1> ;S_MAX_FILE	EQU	2
  6326                              <1> MAX_FILE	equ	4		; 22/12/2014
  6327                              <1> S_MAX_FILE	equ	4		; 22/12/2014
  6328                              <1> 
  6329                              <1> DELAY_1 	EQU	25H		; DELAY FOR OPERATION COMPLETE
  6330                              <1> DELAY_2 	EQU	0600H		; DELAY FOR READY
  6331                              <1> DELAY_3 	EQU	0100H		; DELAY FOR DATA REQUEST
  6332                              <1> 
  6333                              <1> HF_FAIL 	EQU	08H		; CMOS FLAG IN BYTE 0EH
  6334                              <1> 
  6335                              <1> ;-----		COMMAND BLOCK REFERENCE
  6336                              <1> 
  6337                              <1> ;CMD_BLOCK      EQU     BP-8            ; @CMD_BLOCK REFERENCES BLOCK HEAD IN SS
  6338                              <1> 					;  (BP) POINTS TO COMMAND BLOCK TAIL
  6339                              <1> 					;	AS DEFINED BY THE "ENTER" PARMS
  6340                              <1> ; 19/12/2014
  6341                              <1> ORG_VECTOR	equ	4*13h		; INT 13h vector
  6342                              <1> DISK_VECTOR	equ	4*40h		; INT 40h vector (for floppy disks)
  6343                              <1> ;HDISK_INT	equ	4*76h		; Primary HDC - Hardware interrupt (IRQ14)
  6344                              <1> ;HDISK_INT1	equ	4*76h		; Primary HDC - Hardware interrupt (IRQ14)
  6345                              <1> ;HDISK_INT2	equ	4*77h		; Secondary HDC - Hardware interrupt (IRQ15)
  6346                              <1> ;HF_TBL_VEC	equ	4*41h		; Pointer to 1st fixed disk parameter table
  6347                              <1> ;HF1_TBL_VEC	equ	4*46h		; Pointer to 2nd fixed disk parameter table
  6348                              <1> 
  6349                              <1> align 2
  6350                              <1> 
  6351                              <1> ;----------------------------------------------------------------
  6352                              <1> ; FIXED DISK I/O SETUP						:
  6353                              <1> ;								:
  6354                              <1> ;  -  ESTABLISH TRANSFER VECTORS FOR THE FIXED DISK		:
  6355                              <1> ;  -  PERFORM POWER ON DIAGNOSTICS				:
  6356                              <1> ;     SHOULD AN ERROR OCCUR A "1701" MESSAGE IS DISPLAYED       :
  6357                              <1> ;								:
  6358                              <1> ;----------------------------------------------------------------
  6359                              <1> 
  6360                              <1> ; 29/05/2016 - TRDOS 386 (TRDOS v2.0)
  6361                              <1> 
  6362                              <1> DISK_SETUP:
  6363                              <1> 	;CLI
  6364                              <1> 	;;MOV	AX,ABS0 			; GET ABSOLUTE SEGMENT
  6365                              <1> 	;xor	ax,ax
  6366                              <1> 	;MOV	DS,AX				; SET SEGMENT REGISTER
  6367                              <1> 	;MOV	AX, [ORG_VECTOR] 		; GET DISKETTE VECTOR
  6368                              <1> 	;MOV	[DISK_VECTOR],AX		;  INTO INT 40H
  6369                              <1> 	;MOV	AX, [ORG_VECTOR+2]
  6370                              <1> 	;MOV	[DISK_VECTOR+2],AX
  6371                              <1> 	;MOV	word [ORG_VECTOR],DISK_IO	; FIXED DISK HANDLER
  6372                              <1> 	;MOV	[ORG_VECTOR+2],CS
  6373                              <1> 	; 1st controller (primary master, slave)   - IRQ 14
  6374                              <1> 	;;MOV	word [HDISK_INT],HD_INT		; FIXED DISK INTERRUPT
  6375                              <1> 	;mov	word [HDISK_INT1],HD_INT	;
  6376                              <1> 	;;MOV	[HDISK_INT+2],CS
  6377                              <1> 	;mov	[HDISK_INT1+2],CS
  6378                              <1> 	; 2nd controller (secondary master, slave) - IRQ 15
  6379                              <1> 	;mov	word [HDISK_INT2],HD1_INT	;
  6380                              <1> 	;mov	[HDISK_INT2+2],CS
  6381                              <1> 	;
  6382                              <1> 	;;MOV	word [HF_TBL_VEC],HD0_DPT	; PARM TABLE DRIVE 80
  6383                              <1> 	;;MOV	word [HF_TBL_VEC+2],DPT_SEGM
  6384                              <1> 	;;MOV	word [HF1_TBL_VEC],HD1_DPT	; PARM TABLE DRIVE 81
  6385                              <1> 	;;MOV	word [HF1_TBL_VEC+2],DPT_SEGM
  6386                              <1> 	;push	cs
  6387                              <1> 	;pop	ds
  6388                              <1> 	;mov	word [HDPM_TBL_VEC],HD0_DPT	; PARM TABLE DRIVE 80h
  6389                              <1> 	;mov	word [HDPM_TBL_VEC+2],DPT_SEGM
  6390 0000523A C705[D08A0100]0000- <1> 	mov 	dword [HDPM_TBL_VEC], (DPT_SEGM*16)+HD0_DPT
  6390 00005242 0900                <1>
  6391                              <1> 	;mov	word [HDPS_TBL_VEC],HD1_DPT	; PARM TABLE DRIVE 81h
  6392                              <1> 	;mov	word [HDPS_TBL_VEC+2],DPT_SEGM
  6393 00005244 C705[D48A0100]2000- <1> 	mov 	dword [HDPS_TBL_VEC], (DPT_SEGM*16)+HD1_DPT
  6393 0000524C 0900                <1>
  6394                              <1> 	;mov	word [HDSM_TBL_VEC],HD2_DPT	; PARM TABLE DRIVE 82h
  6395                              <1> 	;mov	word [HDSM_TBL_VEC+2],DPT_SEGM
  6396 0000524E C705[D88A0100]4000- <1> 	mov 	dword [HDSM_TBL_VEC], (DPT_SEGM*16)+HD2_DPT
  6396 00005256 0900                <1>
  6397                              <1> 	;mov	word [HDSS_TBL_VEC],HD3_DPT	; PARM TABLE DRIVE 83h
  6398                              <1> 	;mov	word [HDSS_TBL_VEC+2],DPT_SEGM
  6399 00005258 C705[DC8A0100]6000- <1> 	mov 	dword [HDSS_TBL_VEC], (DPT_SEGM*16)+HD3_DPT
  6399 00005260 0900                <1>
  6400                              <1> 	;
  6401                              <1> 	;;IN	AL,INTB01		; TURN ON SECOND INTERRUPT CHIP
  6402                              <1> 	;;;AND	AL,0BFH
  6403                              <1> 	;;and	al, 3Fh			; enable IRQ 14 and IRQ 15
  6404                              <1> 	;;;JMP	$+2
  6405                              <1> 	;;IODELAY
  6406                              <1> 	;;OUT	INTB01,AL
  6407                              <1> 	;;IODELAY
  6408                              <1> 	;;IN	AL,INTA01		; LET INTERRUPTS PASS THRU TO
  6409                              <1> 	;;AND	AL,0FBH 		;  SECOND CHIP
  6410                              <1> 	;;;JMP	$+2
  6411                              <1> 	;;IODELAY
  6412                              <1> 	;;OUT	INTA01,AL
  6413                              <1> 	;
  6414                              <1> 	;STI
  6415                              <1> 	;;PUSH	DS			; MOVE ABS0 POINTER TO
  6416                              <1> 	;;POP	ES			; EXTRA SEGMENT POINTER
  6417                              <1> 	;;;CALL	DDS			; ESTABLISH DATA SEGMENT
  6418                              <1> 	;;MOV	byte [DISK_STATUS1],0 	; RESET THE STATUS INDICATOR
  6419                              <1> 	;;MOV	byte [HF_NUM],0		; ZERO NUMBER OF FIXED DISKS
  6420                              <1> 	;;MOV	byte [CONTROL_BYTE],0
  6421                              <1> 	;;MOV	byte [PORT_OFF],0	; ZERO CARD OFFSET
  6422                              <1> 	; 20/12/2014 - private code by Erdogan Tan
  6423                              <1> 		      ; (out of original PC-AT, PC-XT BIOS code)
  6424                              <1> 	;mov	si, hd0_type
  6425 00005262 BE[106E0000]        <1> 	mov	esi, hd0_type
  6426                              <1> 	;mov	cx, 4
  6427 00005267 B904000000          <1> 	mov	ecx, 4
  6428                              <1> hde_l:
  6429 0000526C AC                  <1> 	lodsb
  6430 0000526D 3C80                <1> 	cmp	al, 80h			; 8?h = existing
  6431 0000526F 7206                <1> 	jb	short _L4
  6432 00005271 FE05[CC8A0100]      <1> 	inc	byte [HF_NUM]		; + 1 hard (fixed) disk drives
  6433                              <1> _L4: ; 26/02/2015
  6434 00005277 E2F3                <1> 	loop	hde_l	
  6435                              <1> ;_L4:					; 0 <= [HF_NUM] =< 4
  6436                              <1> ;L4:
  6437                              <1> 	; 
  6438                              <1> 	;; 31/12/2014 - cancel controller diagnostics here
  6439                              <1> 	;;;mov 	cx, 3  ; 26/12/2014 (Award BIOS 1999)
  6440                              <1> 	;;mov 	cl, 3
  6441                              <1> 	;;
  6442                              <1> 	;;MOV	DL,80H			; CHECK THE CONTROLLER
  6443                              <1> ;;hdc_dl:
  6444                              <1> 	;;MOV	AH,14H			; USE CONTROLLER DIAGNOSTIC COMMAND
  6445                              <1> 	;;INT	13H			; CALL BIOS WITH DIAGNOSTIC COMMAND
  6446                              <1> 	;;;JC	short CTL_ERRX		; DISPLAY ERROR MESSAGE IF BAD RETURN
  6447                              <1> 	;;;jc	short POD_DONE ;22/12/2014
  6448                              <1> 	;;jnc	short hdc_reset0
  6449                              <1> 	;;loop	hdc_dl
  6450                              <1> 	;;; 27/12/2014
  6451                              <1> 	;;stc
  6452                              <1> 	;;retn
  6453                              <1> 	;
  6454                              <1> ;;hdc_reset0:
  6455                              <1> 	; 18/01/2015
  6456 00005279 8A0D[CC8A0100]      <1> 	mov	cl, [HF_NUM]
  6457 0000527F 20C9                <1> 	and	cl, cl
  6458 00005281 740E                <1> 	jz	short POD_DONE
  6459                              <1> 	;
  6460 00005283 B27F                <1> 	mov	dl, 7Fh
  6461                              <1> hdc_reset1:
  6462 00005285 FEC2                <1> 	inc	dl
  6463                              <1> 	;; 31/12/2015
  6464                              <1> 	;;push	dx
  6465                              <1> 	;;push	cx
  6466                              <1> 	;;push	ds
  6467                              <1> 	;;sub	ax, ax
  6468                              <1> 	;;mov	ds, ax
  6469                              <1> 	;;MOV	AX, [TIMER_LOW]		; GET START TIMER COUNTS
  6470                              <1> 	;;pop	ds
  6471                              <1> 	;;MOV	BX,AX
  6472                              <1> 	;;ADD	AX,6*182		; 60 SECONDS* 18.2
  6473                              <1> 	;;MOV	CX,AX
  6474                              <1> 	;;mov	word [wait_count], 0	; 22/12/2014 (reset wait counter)
  6475                              <1> 	;;
  6476                              <1> 	;; 31/12/2014 - cancel HD_RESET_1
  6477                              <1> 	;;CALL	HD_RESET_1		; SET UP DRIVE 0, (1,2,3)
  6478                              <1> 	;;pop	cx
  6479                              <1> 	;;pop	dx
  6480                              <1> 	;;
  6481                              <1> 	; 18/01/2015
  6482 00005287 B40D                <1> 	mov	ah, 0Dh ; ALTERNATE RESET
  6483                              <1> 	;int	13h
  6484 00005289 E8A3FFFFFF          <1> 	call	int13h
  6485 0000528E E2F5                <1> 	loop	hdc_reset1
  6486 00005290 F8                  <1> 	clc 	; 29/05/2016
  6487                              <1> POD_DONE:
  6488 00005291 C3                  <1> 	RETn
  6489                              <1> 
  6490                              <1> ;;-----	POD_ERROR
  6491                              <1> 
  6492                              <1> ;;CTL_ERRX:
  6493                              <1> ;	;MOV	SI,OFFSET F1782 	; CONTROLLER ERROR
  6494                              <1> ;	;CALL	SET_FAIL		; DO NOT IPL FROM DISK
  6495                              <1> ;	;CALL	E_MSG			; DISPLAY ERROR AND SET (BP) ERROR FLAG
  6496                              <1> ;	;JMP	short POD_DONE
  6497                              <1> 
  6498                              <1> ;;HD_RESET_1:
  6499                              <1> ;;	;PUSH	BX			; SAVE TIMER LIMITS
  6500                              <1> ;;	;PUSH	CX
  6501                              <1> ;;RES_1: MOV	AH,09H			; SET DRIVE PARAMETERS
  6502                              <1> ;;	INT	13H
  6503                              <1> ;;	JC	short RES_2
  6504                              <1> ;;	MOV	AH,11H			; RECALIBRATE DRIVE
  6505                              <1> ;;	INT	13H
  6506                              <1> ;;	JNC	short RES_CK		; DRIVE OK
  6507                              <1> ;;RES_2: ;CALL	POD_TCHK		; CHECK TIME OUT
  6508                              <1> ;;	cmp	word [wait_count], 6*182 ; waiting time (in timer ticks)
  6509                              <1> ;;					; (30 seconds)		
  6510                              <1> ;;	;cmc
  6511                              <1> ;;	;JNC	short RES_1
  6512                              <1> ;;	jb	short RES_1
  6513                              <1> ;;;RES_FL: ;MOV	SI,OFFSET F1781 	; INDICATE DISK 1 FAILURE;
  6514                              <1> ;;	;TEST	DL,1
  6515                              <1> ;;	;JNZ	RES_E1
  6516                              <1> ;;	;MOV	SI,OFFSET F1780 	; INDICATE DISK 0 FAILURE
  6517                              <1> ;;	;CALL	SET_FAIL		; DO NOT TRY TO IPL DISK 0
  6518                              <1> ;;	;JMP	SHORT RES_E1
  6519                              <1> ;;RES_ER: ; 22/12/2014
  6520                              <1> ;;RES_OK:
  6521                              <1> ;;	;POP	CX			; RESTORE TIMER LIMITS
  6522                              <1> ;;	;POP	BX
  6523                              <1> ;;	RETn
  6524                              <1> ;;
  6525                              <1> ;;RES_RS: MOV	AH,00H			; RESET THE DRIVE
  6526                              <1> ;;	INT	13H
  6527                              <1> ;;RES_CK: MOV	AH,08H			; GET MAX CYLINDER,HEAD,SECTOR
  6528                              <1> ;;	MOV	BL,DL			; SAVE DRIVE CODE
  6529                              <1> ;;	INT	13H
  6530                              <1> ;;	JC	short RES_ER
  6531                              <1> ;;	MOV	[NEC_STATUS],CX 	; SAVE MAX CYLINDER, SECTOR
  6532                              <1> ;;	MOV	DL,BL			; RESTORE DRIVE CODE
  6533                              <1> ;;RES_3: MOV	AX,0401H		; VERIFY THE LAST SECTOR
  6534                              <1> ;;	INT	13H
  6535                              <1> ;;	JNC	short RES_OK		; VERIFY OK
  6536                              <1> ;;	CMP	AH,BAD_SECTOR		; OK ALSO IF JUST ID READ
  6537                              <1> ;;	JE	short RES_OK
  6538                              <1> ;;	CMP	AH,DATA_CORRECTED
  6539                              <1> ;;	JE	short RES_OK
  6540                              <1> ;;	CMP	AH,BAD_ECC
  6541                              <1> ;;	JE	short RES_OK
  6542                              <1> ;;	;CALL	POD_TCHK		; CHECK FOR TIME OUT
  6543                              <1> ;;	cmp	word [wait_count], 6*182 ; waiting time (in timer ticks)
  6544                              <1> ;;					; (60 seconds)		
  6545                              <1> ;;	cmc
  6546                              <1> ;;	JC	short RES_ER		; FAILED
  6547                              <1> ;;	MOV	CX,[NEC_STATUS] 	; GET SECTOR ADDRESS, AND CYLINDER
  6548                              <1> ;;	MOV	AL,CL			; SEPARATE OUT SECTOR NUMBER
  6549                              <1> ;;	AND	AL,3FH
  6550                              <1> ;;	DEC	AL			; TRY PREVIOUS ONE
  6551                              <1> ;;	JZ	short RES_RS		; WE'VE TRIED ALL SECTORS ON TRACK
  6552                              <1> ;;	AND	CL,0C0H 		; KEEP CYLINDER BITS
  6553                              <1> ;;	OR	CL,AL			; MERGE SECTOR WITH CYLINDER BITS
  6554                              <1> ;;	MOV	[NEC_STATUS],CX 	; SAVE CYLINDER, NEW SECTOR NUMBER
  6555                              <1> ;;	JMP	short RES_3		; TRY AGAIN
  6556                              <1> ;;;RES_ER: MOV	SI,OFFSET F1791 	; INDICATE DISK 1 ERROR
  6557                              <1> ;;	;TEST	DL,1
  6558                              <1> ;;	;JNZ	short RES_E1
  6559                              <1> ;;	;MOV	SI,OFFSET F1790 	; INDICATE DISK 0 ERROR
  6560                              <1> ;;;RES_E1:
  6561                              <1> ;;	;CALL	E_MSG			; DISPLAY ERROR AND SET (BP) ERROR FLAG
  6562                              <1> ;;;RES_OK:
  6563                              <1> ;;	;POP	CX			; RESTORE TIMER LIMITS
  6564                              <1> ;;	;POP	BX
  6565                              <1> ;;	;RETn
  6566                              <1> ;
  6567                              <1> ;;SET_FAIL:
  6568                              <1> ;	;MOV	AX,X*(CMOS_DIAG+NMI)	; GET CMOS ERROR BYTE
  6569                              <1> ;	;CALL	CMOS_READ
  6570                              <1> ;	;OR	AL,HF_FAIL		; SET DO NOT IPL FROM DISK FLAG
  6571                              <1> ;	;XCHG	AH,AL			; SAVE IT
  6572                              <1> ;	;CALL	CMOS_WRITE		; PUT IT OUT
  6573                              <1> ;	;RETn
  6574                              <1> ;
  6575                              <1> ;;POD_TCHK:				; CHECK FOR 30 SECOND TIME OUT
  6576                              <1> ;	;POP	AX			; SAVE RETURN
  6577                              <1> ;	;POP	CX			; GET TIME OUT LIMITS
  6578                              <1> ;	;POP	BX
  6579                              <1> ;	;PUSH	BX			; AND SAVE THEM AGAIN
  6580                              <1> ;	;PUSH	CX
  6581                              <1> ;	;PUSH	AX
  6582                              <1> ;	;push	ds
  6583                              <1> ;	;xor	ax, ax
  6584                              <1> ;	;mov	ds, ax			; RESTORE RETURN
  6585                              <1> ;	;MOV	AX, [TIMER_LOW]		; AX = CURRENT TIME
  6586                              <1> ;	;				; BX = START TIME
  6587                              <1> ;	;				; CX = END TIME
  6588                              <1> ;	;pop	ds
  6589                              <1> ;	;CMP	BX,CX
  6590                              <1> ;	;JB	short TCHK1		; START < END
  6591                              <1> ;	;CMP	BX,AX
  6592                              <1> ;	;JB	short TCHKG		; END < START < CURRENT
  6593                              <1> ;	;JMP	SHORT TCHK2		; END, CURRENT < START
  6594                              <1> ;;TCHK1: CMP	AX,BX
  6595                              <1> ;;	JB	short TCHKNG		; CURRENT < START < END
  6596                              <1> ;;TCHK2: CMP	AX,CX
  6597                              <1> ;;	JB	short TCHKG		; START < CURRENT < END
  6598                              <1> ;;					; OR CURRENT < END < START
  6599                              <1> ;;TCHKNG: STC				; CARRY SET INDICATES TIME OUT
  6600                              <1> ;;	RETn
  6601                              <1> ;;TCHKG: CLC				; INDICATE STILL TIME
  6602                              <1> ;;	RETn
  6603                              <1> ;;
  6604                              <1> ;;int_13h:
  6605                              <1> 
  6606                              <1> ;----------------------------------------
  6607                              <1> ;	FIXED DISK BIOS ENTRY POINT	:
  6608                              <1> ;----------------------------------------
  6609                              <1> 
  6610                              <1> ; 30/08/2020
  6611                              <1> ; 29/08/2020
  6612                              <1> ; 15/01/2017
  6613                              <1> ; 14/01/2017
  6614                              <1> ; 07/01/2017
  6615                              <1> ; 02/01/2017
  6616                              <1> ; 01/06/2016
  6617                              <1> ; 16/05/2016, 27/05/2016, 28/05/2016, 29/05/2016
  6618                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  6619                              <1> int33h:  ; DISK I/O
  6620                              <1> 	; 29/05/2016
  6621 00005292 80642408FE          <1> 	and	byte [esp+8], 11111110b  ; clear carry bit of eflags register
  6622                              <1> 	; 16/05/2016
  6623 00005297 1E                  <1> 	push	ds
  6624 00005298 53                  <1> 	push	ebx ; user's buffer address (virtual)
  6625 00005299 66BB1000            <1> 	mov	bx, KDATA ; System (Kernel's) data segment
  6626 0000529D 8EDB                <1> 	mov	ds, bx
  6627                              <1> 
  6628                              <1> 	;;15/01/2017
  6629                              <1> 	; 14/01/2017
  6630                              <1> 	; 02/01/2017
  6631                              <1> 	;;mov	byte [intflg], 33h	; disk io interrupt 
  6632                              <1> 	;pop	ebx
  6633                              <1> 	;mov	[user_buffer], ebx		
  6634                              <1> 
  6635 0000529F 8F05[BC960100]      <1> 	pop	dword [user_buffer] ; 01/06/2016
  6636                              <1> 
  6637 000052A5 C605[F68F0100]00    <1> 	mov	byte [scount], 0 ; sector count for transfer
  6638 000052AC 80FC03              <1> 	cmp	ah, 03h ; chs write
  6639 000052AF 7744                <1> 	ja	short int33h_2
  6640 000052B1 7407                <1> 	je	short int33h_0
  6641 000052B3 80FC02              <1> 	cmp	ah, 02h ; chs read
  6642 000052B6 726F                <1> 	jb	short int33h_5
  6643 000052B8 EB68                <1> 	jmp	short int33h_4
  6644                              <1> int33h_0:
  6645                              <1> 	; transfer user's buffer content to sector buffer
  6646 000052BA 51                  <1> 	push	ecx
  6647 000052BB 0FB6C8              <1> 	movzx	ecx, al
  6648                              <1> int33h_1:
  6649 000052BE 56                  <1> 	push	esi
  6650 000052BF 8B35[BC960100]      <1> 	mov	esi, [user_buffer]
  6651                              <1> 	; esi = user's buffer address (virtual, ebx)
  6652 000052C5 57                  <1> 	push	edi
  6653 000052C6 06                  <1> 	push	es
  6654 000052C7 50                  <1> 	push	eax
  6655 000052C8 66B81000            <1> 	mov	ax, KDATA
  6656 000052CC 8EC0                <1> 	mov	es, ax
  6657 000052CE BF00000700          <1> 	mov	edi, Cluster_Buffer
  6658 000052D3 C1E109              <1> 	shl	ecx, 9 ; * 512
  6659 000052D6 E8D3C80000          <1> 	call	transfer_from_user_buffer
  6660 000052DB 58                  <1> 	pop	eax
  6661 000052DC 07                  <1> 	pop	es
  6662 000052DD 5F                  <1> 	pop	edi
  6663 000052DE 5E                  <1> 	pop	esi
  6664 000052DF 59                  <1> 	pop	ecx
  6665 000052E0 7345                <1> 	jnc	short int33h_5
  6666 000052E2 8B1D[BC960100]      <1> 	mov	ebx, [user_buffer] ; 01/06/2016
  6667 000052E8 1F                  <1> 	pop	ds
  6668                              <1> 
  6669                              <1> 	;;15/01/2017
  6670                              <1> 	; 02/01/2017
  6671                              <1> 	;cli
  6672                              <1> 	;;mov	byte [ss:intflg], 0 ; 07/01/2017
  6673                              <1> 	;
  6674                              <1> 	; (*) 29/05/2016
  6675                              <1> 	; (*) retf 4 ; skip eflags on stack
  6676                              <1> 
  6677                              <1> 	; 29/05/2016 -set carry flag on stack-
  6678                              <1> 	; [esp] = EIP
  6679                              <1> 	; [esp+4] = CS
  6680                              <1> 	; [esp+8] = E-FLAGS
  6681 000052E9 804C240801          <1> 	or	byte [esp+8], 1  ; set carry bit of eflags register
  6682                              <1> 	; [esp+12] = ESP (user)
  6683                              <1> 	; [esp+16] = SS (User)
  6684 000052EE B8FF000000          <1> 	mov	eax, 0FFh ; Unknown error !?
  6685                              <1> 	;iretd
  6686 000052F3 EB7E                <1> 	jmp	short int33h_7  ; 07/01/2017	
  6687                              <1> 
  6688                              <1> 	; (*) 29/05/2016 - 'ref 4' intruction causes to stack fault
  6689                              <1> 	; (OUTER-PRIVILEGE-LEVEL)
  6690                              <1> 	; INTEL 80386 PROGRAMMER'S REFERENCE MANUAL 1986
  6691                              <1> 	; // RETF instruction:
  6692                              <1> 	;
  6693                              <1> 	; IF OperandMode=32 THEN
  6694                              <1>  	;    Load CS:EIP from stack;
  6695                              <1>  	;    Set CS RPL to CPL;
  6696                              <1>  	;    Increment eSP by 8 plus the immediate offset if it exists;
  6697                              <1>  	;    Load SS:eSP from stack;
  6698                              <1>  	; ELSE (* OperandMode=16 *)
  6699                              <1>  	;    Load CS:IP from stack;
  6700                              <1>  	;    Set CS RPL to CPL;
  6701                              <1>  	;    Increment eSP by 4 plus the immediate offset if it exists;
  6702                              <1> 	;    Load SS:eSP from stack;
  6703                              <1>  	; FI;
  6704                              <1> 	;
  6705                              <1> 	; //
  6706                              <1> 
  6707                              <1> int33h_2:
  6708 000052F5 80FC05              <1> 	cmp	ah, 05h ; format track
  6709 000052F8 770A                <1> 	ja	short int33h_3
  6710 000052FA 722B                <1> 	jb	short int33h_5
  6711 000052FC 51                  <1> 	push	ecx
  6712 000052FD B901000000          <1> 	mov	ecx, 1
  6713 00005302 EBBA                <1> 	jmp	short int33h_1
  6714                              <1> int33h_3:
  6715 00005304 80FC1C              <1> 	cmp	ah, 1Ch ; LBA write
  6716 00005307 771E                <1> 	ja	short int33h_5
  6717 00005309 74AF                <1> 	je	short int33h_0
  6718 0000530B 80FC1B              <1> 	cmp	ah, 1Bh ; LBA read
  6719 0000530E 7412                <1> 	je	short int33h_4
  6720                              <1> 	; 29/08/2020
  6721 00005310 80FC08              <1> 	cmp	ah, 08h ; get disk parameters
  6722                              <1> 	;jne	short int33h_5
  6723 00005313 7405                <1> 	je	short int33h_10
  6724 00005315 80FC15              <1> 	cmp	ah, 15h	; read DASD type (get disk size)
  6725 00005318 750D                <1> 	jne	short int33h_5
  6726                              <1> int33h_10:
  6727                              <1> 	; 01/06/2016
  6728 0000531A 8B1D[BC960100]      <1> 	mov	ebx, [user_buffer] ; user's buffer address
  6729 00005320 EB0A                <1> 	jmp	short int33h_6
  6730                              <1> int33h_4:
  6731 00005322 A2[F68F0100]        <1> 	mov	byte [scount], al ; <= 128 sectors
  6732                              <1> int33h_5:
  6733 00005327 BB00000700          <1> 	mov	ebx, Cluster_Buffer ; max. 65536 bytes
  6734                              <1> 				    ; buf. addr: 70000h	
  6735                              <1> 	;mov	byte [ClusterBuffer_Valid], 0
  6736                              <1> int33h_6:
  6737 0000532C 1F                  <1> 	pop	ds
  6738 0000532D 9C                  <1> 	pushfd
  6739 0000532E 0E                  <1> 	push 	cs
  6740 0000532F E84D000000          <1> 	call 	DISK_IO
  6741 00005334 2E8B1D[BC960100]    <1> 	mov	ebx, [CS:user_buffer] ; 01/06/2016
  6742 0000533B 723D                <1> 	jc	short int33h_9
  6743                              <1> 	;
  6744 0000533D 2E803D[F68F0100]00  <1> 	cmp	byte [CS:scount], 0
  6745 00005345 762C                <1> 	jna	short int33h_7
  6746                              <1> 	;
  6747                              <1> 	; transfer sector buffer content to user's buffer
  6748 00005347 06                  <1> 	push	es
  6749 00005348 1E                  <1> 	push	ds
  6750 00005349 50                  <1> 	push	eax
  6751 0000534A 66B81000            <1> 	mov	ax, KDATA
  6752 0000534E 8ED8                <1> 	mov	ds, ax
  6753 00005350 8EC0                <1> 	mov	es, ax
  6754 00005352 51                  <1> 	push	ecx
  6755 00005353 56                  <1> 	push	esi
  6756 00005354 57                  <1> 	push	edi
  6757 00005355 0FB60D[F68F0100]    <1> 	movzx	ecx, byte [scount]
  6758 0000535C C1E109              <1> 	shl	ecx, 9 ; * 512 bytes
  6759 0000535F 89DF                <1> 	mov	edi, ebx ; user's buffer address
  6760 00005361 BE00000700          <1> 	mov	esi, Cluster_Buffer
  6761 00005366 E8F9C70000          <1> 	call	transfer_to_user_buffer
  6762 0000536B 5F                  <1> 	pop	edi
  6763 0000536C 5E                  <1> 	pop	esi
  6764 0000536D 59                  <1> 	pop	ecx
  6765 0000536E 58                  <1> 	pop	eax
  6766 0000536F 1F                  <1> 	pop	ds
  6767 00005370 07                  <1> 	pop	es
  6768 00005371 7202                <1> 	jc	short int33h_8
  6769                              <1> int33h_7:
  6770 00005373 FA                  <1> 	cli
  6771                              <1> 	;;15/01/2017
  6772                              <1> 	;;mov	byte [ss:intflg], 0 ; 07/01/2017
  6773                              <1> 	; cf = 0  ; use eflags which is in stack
  6774 00005374 CF                  <1> 	iretd	
  6775                              <1> int33h_8:
  6776 00005375 B8FF000000          <1> 	mov	eax, 0FFh ; Unknown error !?
  6777                              <1> int33h_9:
  6778                              <1> 	; cf = 1
  6779                              <1> 
  6780                              <1> 	; (*) 29/05/2016	
  6781                              <1> 	; (*) retf 4 ; skip eflags on stack
  6782                              <1> 	; Note: This 'retf 4' was wrong, -it was causing
  6783                              <1> 	;       to stack errors in ring 3-
  6784                              <1> 	;	POP sequence of 'retf 4' is as
  6785                              <1> 	;       "eip, cs, eflags, esp, ss, +4 bytes" 
  6786                              <1>         ;       it is not as "eip, cs, +4 bytes, esp, ss" ! 
  6787                              <1> 
  6788                              <1> 	; 29/05/2016 -set carry flag on stack-
  6789 0000537A 804C240801          <1> 	or	byte [esp+8], 1  ; set carry bit of eflags register
  6790                              <1> 	;iretd
  6791 0000537F EBF2                <1> 	jmp	short int33h_7 ; 07/01/2017
  6792                              <1> 
  6793                              <1> ; 30/08/2020
  6794                              <1> ; 09/12/2017
  6795                              <1> ; 29/05/2016
  6796                              <1> ; 27/05/2016 - TRDOS 386 (TRDOS v2.0)
  6797                              <1> 
  6798                              <1> DISK_IO:
  6799 00005381 80FA80              <1> 	CMP	DL,80H			; TEST FOR FIXED DISK DRIVE
  6800                              <1> 	;JAE	short A1		; YES, HANDLE HERE
  6801                              <1> 	;;;INT	40H			; DISKETTE HANDLER
  6802                              <1> 	;;call	int40h
  6803 00005384 0F82FFEFFFFF        <1> 	jb	DISKETTE_IO_1
  6804                              <1> ;RET_2:
  6805                              <1> 	;RETf	2			; BACK TO CALLER
  6806                              <1> ;	retf	4
  6807                              <1> A1:
  6808 0000538A FB                  <1> 	STI				; ENABLE INTERRUPTS
  6809                              <1> 	;; 04/01/2015
  6810                              <1> 	;;OR	AH,AH
  6811                              <1> 	;;JNZ	short A2
  6812                              <1> 	;;INT	40H			; RESET NEC WHEN AH=0
  6813                              <1> 	;;SUB	AH,AH
  6814 0000538B 80FA83              <1> 	CMP	DL,(80H + S_MAX_FILE - 1) ; 83h ; 30/08/2020 
  6815                              <1> 	;JA	short RET_2
  6816 0000538E 7614                <1> 	jna	short _A0
  6817                              <1> 	; 29/05/2016
  6818 00005390 1E                  <1> 	push	ds
  6819 00005391 50                  <1> 	push	eax ; 30/08/2020 (ax --> eax)
  6820 00005392 66B81000            <1> 	mov	ax, KDATA
  6821 00005396 8ED8                <1> 	mov	ds, ax
  6822 00005398 58                  <1> 	pop	eax ; 
  6823 00005399 B4AA                <1>         mov     ah, 0AAh        ; Hard disk drive not ready !
  6824                              <1> 				; (Programmer's guide to AMIBIOS, 1992)
  6825 0000539B 8825[CB8A0100]      <1> 	mov     byte [DISK_STATUS1], ah
  6826 000053A1 1F                  <1> 	pop	ds
  6827 000053A2 EB38                <1> 	jmp	short RET_2
  6828                              <1> _A0:
  6829                              <1> 	; 18/01/2015
  6830 000053A4 08E4                <1> 	or	ah,ah
  6831 000053A6 743A                <1> 	jz	short A4
  6832 000053A8 80FC0D              <1> 	cmp	ah,0Dh	; Alternate reset
  6833 000053AB 7504                <1> 	jne	short A2
  6834 000053AD 28E4                <1> 	sub	ah,ah	; Reset
  6835 000053AF EB31                <1> 	jmp	short A4
  6836                              <1> A2:
  6837 000053B1 80FC08              <1> 	CMP	AH,08H			; GET PARAMETERS IS A SPECIAL CASE
  6838                              <1> 	;JNZ	short A3
  6839                              <1>         ;JMP    GET_PARM_N
  6840 000053B4 0F8452030000        <1> 	je	GET_PARM_N
  6841 000053BA 80FC15              <1> A3:	CMP	AH,15H			; READ DASD TYPE IS ALSO
  6842                              <1> 	;JNZ	short A4
  6843                              <1>         ;JMP    READ_DASD_TYPE
  6844 000053BD 0F84DB020000        <1>         je      READ_DASD_TYPE
  6845                              <1> 	; 02/02/2015
  6846 000053C3 80FC1D              <1> 	cmp	ah, 1Dh			;(Temporary for Retro UNIX 386 v1)
  6847                              <1> 	; 12/01/2015
  6848 000053C6 F5                  <1> 	cmc
  6849 000053C7 7319                <1> 	jnc	short A4
  6850                              <1> int33h_bad_cmd:
  6851                              <1> 	; 16/05/2016
  6852                              <1> 	; 30/01/2015
  6853                              <1> 	; 29/05/2016
  6854 000053C9 1E                  <1> 	push	ds
  6855 000053CA 6650                <1> 	push	ax
  6856 000053CC 66B81000            <1> 	mov	ax, KDATA
  6857 000053D0 8ED8                <1> 	mov	ds, ax
  6858 000053D2 6658                <1> 	pop	ax
  6859 000053D4 B401                <1> 	mov	ah, BAD_CMD
  6860 000053D6 8825[CB8A0100]      <1> 	mov     [DISK_STATUS1], ah ; BAD_CMD  ; COMMAND ERROR
  6861                              <1>         ;jmp	short RET_2
  6862                              <1> RET_2:
  6863                              <1> 	; (*) 29/05/2016
  6864                              <1> 	; (*) retf 4
  6865 000053DC 804C240801          <1> 	or	byte [esp+8], 1 ; set carry bit of eflags register
  6866 000053E1 CF                  <1> 	iretd
  6867                              <1> A4:					; SAVE REGISTERS DURING OPERATION
  6868 000053E2 C8080000            <1> 	ENTER	8,0			; SAVE (BP) AND MAKE ROOM FOR @CMD_BLOCK
  6869 000053E6 53                  <1> 	PUSH	eBX			;  IN THE STACK, THE COMMAND BLOCK IS:
  6870 000053E7 51                  <1> 	PUSH	eCX			;   @CMD_BLOCK == BYTE PTR [BP]-8
  6871 000053E8 52                  <1> 	PUSH	eDX
  6872 000053E9 1E                  <1> 	PUSH	DS
  6873 000053EA 06                  <1> 	PUSH	ES
  6874 000053EB 56                  <1> 	PUSH	eSI
  6875 000053EC 57                  <1> 	PUSH	eDI
  6876                              <1> 	;;04/01/2015
  6877                              <1> 	;;OR	AH,AH			; CHECK FOR RESET
  6878                              <1> 	;;JNZ	short A5
  6879                              <1> 	;;MOV	DL,80H			; FORCE DRIVE 80 FOR RESET
  6880                              <1> ;;A5:	
  6881                              <1> 	;push	cs
  6882                              <1> 	;pop	ds
  6883                              <1> 	; 21/02/2015
  6884 000053ED 6650                <1> 	push	ax
  6885 000053EF 66B81000            <1> 	mov	ax, KDATA
  6886 000053F3 8ED8                <1> 	mov	ds, ax
  6887 000053F5 8EC0                <1> 	mov	es, ax	
  6888 000053F7 6658                <1> 	pop	ax
  6889 000053F9 E88D000000          <1> 	CALL	DISK_IO_CONT		; PERFORM THE OPERATION
  6890                              <1> 	;;CALL	DDS			; ESTABLISH SEGMENT
  6891 000053FE 8A25[CB8A0100]      <1> 	MOV	AH,[DISK_STATUS1]	; GET STATUS FROM OPERATION
  6892                              <1> 	;(*) CMP AH,1			; SET THE CARRY FLAG TO INDICATE
  6893                              <1> 	;(*) CMC			; SUCCESS OR FAILURE
  6894 00005404 5F                  <1> 	POP	eDI			; RESTORE REGISTERS
  6895 00005405 5E                  <1> 	POP	eSI
  6896 00005406 07                  <1>         POP     ES
  6897 00005407 1F                  <1>         POP     DS
  6898 00005408 5A                  <1> 	POP	eDX
  6899 00005409 59                  <1> 	POP	eCX
  6900 0000540A 5B                  <1> 	POP	eBX
  6901 0000540B C9                  <1> 	LEAVE				; ADJUST (SP) AND RESTORE (BP)
  6902                              <1> 	;RETf	2			; THROW AWAY SAVED FLAGS
  6903                              <1> 	; (*) 29/05/2016
  6904                              <1> 	; (*) retf 4
  6905 0000540C 80FC01              <1> 	cmp	ah, 1
  6906 0000540F 7205                <1> 	jc	short _A5 
  6907 00005411 804C240801          <1> 	or	byte [esp+8], 1 ; set carry bit of eflags register
  6908                              <1> _A5:
  6909 00005416 CF                  <1> 	iretd
  6910                              <1> 
  6911                              <1> ; 21/02/2015
  6912                              <1> ;       dw --> dd
  6913                              <1> D1:					; FUNCTION TRANSFER TABLE
  6914 00005417 [DA550000]          <1> 	dd	DISK_RESET		; 000H
  6915 0000541B [51560000]          <1> 	dd	RETURN_STATUS		; 001H
  6916 0000541F [5E560000]          <1> 	dd	DISK_READ		; 002H
  6917 00005423 [67560000]          <1> 	dd	DISK_WRITE		; 003H
  6918 00005427 [70560000]          <1> 	dd	DISK_VERF		; 004H
  6919 0000542B [88560000]          <1> 	dd	FMT_TRK 		; 005H
  6920 0000542F [D0550000]          <1> 	dd	BAD_COMMAND		; 006H	FORMAT BAD SECTORS
  6921 00005433 [D0550000]          <1> 	dd	BAD_COMMAND		; 007H	FORMAT DRIVE
  6922 00005437 [D0550000]          <1> 	dd	BAD_COMMAND		; 008H	RETURN PARAMETERS
  6923 0000543B [A5570000]          <1> 	dd	INIT_DRV		; 009H
  6924 0000543F [04580000]          <1> 	dd	RD_LONG 		; 00AH
  6925 00005443 [0D580000]          <1> 	dd	WR_LONG 		; 00BH
  6926 00005447 [16580000]          <1> 	dd	DISK_SEEK		; 00CH
  6927 0000544B [DA550000]          <1> 	dd	DISK_RESET		; 00DH
  6928 0000544F [D0550000]          <1> 	dd	BAD_COMMAND		; 00EH	READ BUFFER
  6929 00005453 [D0550000]          <1> 	dd	BAD_COMMAND		; 00FH	WRITE BUFFER
  6930 00005457 [3E580000]          <1> 	dd	TST_RDY 		; 010H
  6931 0000545B [62580000]          <1> 	dd	HDISK_RECAL		; 011H
  6932 0000545F [D0550000]          <1> 	dd	BAD_COMMAND		; 012H	MEMORY DIAGNOSTIC
  6933 00005463 [D0550000]          <1> 	dd	BAD_COMMAND		; 013H	DRIVE DIAGNOSTIC
  6934 00005467 [98580000]          <1> 	dd	CTLR_DIAGNOSTIC 	; 014H	CONTROLLER DIAGNOSTIC
  6935                              <1> 	; 02/02/2015 (Temporary - Retro UNIX 386 v1 - DISK I/O test)
  6936 0000546B [D0550000]          <1> 	dd	BAD_COMMAND		; 015h
  6937 0000546F [D0550000]          <1> 	dd	BAD_COMMAND		; 016h
  6938 00005473 [D0550000]          <1> 	dd	BAD_COMMAND		; 017h
  6939 00005477 [D0550000]          <1> 	dd	BAD_COMMAND		; 018h
  6940 0000547B [D0550000]          <1> 	dd	BAD_COMMAND		; 019h
  6941 0000547F [D0550000]          <1> 	dd	BAD_COMMAND		; 01Ah
  6942 00005483 [5E560000]          <1> 	dd	DISK_READ		; 01Bh ; LBA read
  6943 00005487 [67560000]          <1> 	dd	DISK_WRITE		; 01Ch ; LBA write
  6944                              <1> D1L     EQU    $ - D1
  6945                              <1> 
  6946                              <1> DISK_IO_CONT:
  6947                              <1> 	;;CALL	DDS			; ESTABLISH SEGMENT
  6948 0000548B 80FC01              <1> 	CMP	AH,01H			; RETURN STATUS
  6949                              <1> 	;;JNZ	short SU0
  6950                              <1>         ;;JMP	RETURN_STATUS
  6951 0000548E 0F84BD010000        <1> 	je	RETURN_STATUS
  6952                              <1> SU0:
  6953 00005494 C605[CB8A0100]00    <1> 	MOV	byte [DISK_STATUS1],0 	; RESET THE STATUS INDICATOR
  6954                              <1> 	;;PUSH	BX			; SAVE DATA ADDRESS
  6955                              <1> 	;mov	si, bx ;; 14/02/2015
  6956 0000549B 89DE                <1> 	mov	esi, ebx ; 21/02/2015
  6957 0000549D 8A1D[CC8A0100]      <1> 	MOV	BL,[HF_NUM]		; GET NUMBER OF DRIVES
  6958                              <1> 	;; 04/01/2015
  6959                              <1> 	;;PUSH	AX
  6960 000054A3 80E27F              <1> 	AND	DL,7FH			; GET DRIVE AS 0 OR 1
  6961                              <1> 					; (get drive number as 0 to 3)
  6962 000054A6 38D3                <1> 	CMP	BL,DL
  6963                              <1>         ;;JBE   BAD_COMMAND_POP         ; INVALID DRIVE
  6964 000054A8 0F8622010000        <1>         jbe     BAD_COMMAND ;; 14/02/2015
  6965                              <1>         ;
  6966                              <1> 	;;03/01/2015
  6967 000054AE 29DB                <1> 	sub	ebx, ebx
  6968 000054B0 88D3                <1> 	mov	bl, dl
  6969                              <1> 	;sub	bh, bh
  6970 000054B2 883D[E08A0100]      <1> 	mov	[LBAMode], bh 	; 0
  6971                              <1> 	;;test	byte [bx+hd0_type], 1	; LBA ready ?
  6972                              <1> 	;test	byte [ebx+hd0_type], 1
  6973                              <1> 	;jz	short su1		; no
  6974                              <1> 	;inc	byte [LBAMode]
  6975                              <1> ;su1:
  6976                              <1> 	; 21/02/2015 (32 bit modification)
  6977                              <1> 	;04/01/2015
  6978 000054B8 6650                <1> 	push	ax ; ***
  6979                              <1> 	;PUSH	ES ; **
  6980 000054BA 6652                <1> 	PUSH	DX ; *
  6981 000054BC 6650                <1> 	push	ax
  6982 000054BE E8BB060000          <1> 	CALL	GET_VEC 		; GET DISK PARAMETERS
  6983                              <1> 	; 02/02/2015
  6984                              <1> 	;mov	ax, [ES:BX+16] ; I/O port base address (1F0h, 170h)
  6985 000054C3 668B4310            <1> 	mov	ax, [ebx+16]
  6986 000054C7 66A3[006E0000]      <1> 	mov	[HF_PORT], ax
  6987                              <1> 	;mov	dx, [ES:BX+18] ; control port address (3F6h, 376h)
  6988 000054CD 668B5312            <1> 	mov	dx, [ebx+18]
  6989 000054D1 668915[026E0000]    <1> 	mov	[HF_REG_PORT], dx
  6990                              <1> 	;mov	al, [ES:BX+20] ; head register upper nibble (A0h,B0h,E0h,F0h)
  6991 000054D8 8A4314              <1> 	mov	al, [ebx+20]
  6992                              <1> 	; 23/02/2015
  6993 000054DB A840                <1> 	test	al, 40h	 ; LBA bit (bit 6)
  6994 000054DD 7406                <1> 	jz 	short su1
  6995 000054DF FE05[E08A0100]      <1> 	inc	byte [LBAMode] ; 1 
  6996                              <1> su1: 	 
  6997 000054E5 C0E804              <1> 	shr 	al, 4
  6998 000054E8 2401                <1> 	and	al, 1			
  6999 000054EA A2[046E0000]        <1> 	mov	[hf_m_s], al 
  7000                              <1> 	;
  7001                              <1> 	; 03/01/2015
  7002                              <1> 	;MOV	AL,byte [ES:BX+8]	; GET CONTROL BYTE MODIFIER
  7003 000054EF 8A4308              <1> 	mov	al, [ebx+8]
  7004                              <1> 	;MOV	DX,[HF_REG_PORT]	; Device Control register	
  7005 000054F2 EE                  <1> 	OUT	DX,AL			; SET EXTRA HEAD OPTION
  7006                              <1> 					; Control Byte:  (= 08h, here)
  7007                              <1> 					; bit 0 - 0
  7008                              <1> 					; bit 1 - nIEN (1 = disable irq)
  7009                              <1> 					; bit 2 - SRST (software RESET)
  7010                              <1> 					; bit 3 - use extra heads (8 to 15)
  7011                              <1> 					;         -always set to 1-	
  7012                              <1> 					; (bits 3 to 7 are reserved
  7013                              <1> 					;          for ATA devices)
  7014 000054F3 8A25[CD8A0100]      <1> 	MOV	AH,[CONTROL_BYTE]	; SET EXTRA HEAD OPTION IN
  7015 000054F9 80E4C0              <1> 	AND	AH,0C0H 		; CONTROL BYTE
  7016 000054FC 08C4                <1> 	OR	AH,AL
  7017 000054FE 8825[CD8A0100]      <1> 	MOV	[CONTROL_BYTE],AH	
  7018                              <1> 	; 04/01/2015
  7019 00005504 6658                <1> 	pop	ax
  7020 00005506 665A                <1> 	pop	dx ; * ;; 14/02/2015
  7021 00005508 20E4                <1> 	and	ah, ah	; Reset function ?
  7022 0000550A 7507                <1> 	jnz	short su2
  7023                              <1> 	;;pop	dx ; * ;; 14/02/2015
  7024                              <1> 	;pop	es ; **
  7025 0000550C 6658                <1> 	pop	ax ; ***
  7026                              <1> 	;;pop	bx
  7027 0000550E E9C7000000          <1>         jmp     DISK_RESET
  7028                              <1> su2:
  7029 00005513 803D[E08A0100]00    <1> 	cmp	byte [LBAMode], 0
  7030 0000551A 7662                <1> 	jna	short su3
  7031                              <1> 	;
  7032                              <1> 	; 02/02/2015 (LBA read/write function calls)
  7033 0000551C 80FC1B              <1> 	cmp	ah, 1Bh
  7034 0000551F 720B                <1> 	jb	short lbarw1
  7035 00005521 80FC1C              <1> 	cmp	ah, 1Ch
  7036 00005524 775D                <1> 	ja 	short invldfnc
  7037                              <1> 	;;pop	dx ; * ; 14/02/2015
  7038                              <1> 	;mov	ax, cx ; Lower word of LBA address (bits 0-15)
  7039 00005526 89C8                <1> 	mov	eax, ecx ; LBA address (21/02/2015)
  7040                              <1> 	;; 14/02/2015
  7041 00005528 88D1                <1> 	mov	cl, dl ; 14/02/2015
  7042                              <1> 	;;mov	dx, bx
  7043                              <1> 	;mov	dx, si ; higher word of LBA address (bits 16-23)
  7044                              <1> 	;;mov	bx, di
  7045                              <1> 	;mov	si, di ; Buffer offset
  7046 0000552A EB32                <1> 	jmp	short lbarw2
  7047                              <1> lbarw1:
  7048                              <1> 	; convert CHS to LBA
  7049                              <1> 	;
  7050                              <1> 	; LBA calculation - AWARD BIOS - 1999 - AHDSK.ASM
  7051                              <1> 	; LBA = "# of Heads" * Sectors/Track * Cylinder + Head * Sectors/Track
  7052                              <1> 	;	+ Sector - 1
  7053 0000552C 6652                <1> 	push	dx ; * ;; 14/02/2015
  7054                              <1> 	;xor	dh, dh
  7055 0000552E 31D2                <1> 	xor	edx, edx
  7056                              <1> 	;mov	dl, [ES:BX+14]	; sectors per track (logical)
  7057 00005530 8A530E              <1> 	mov	dl, [ebx+14]
  7058                              <1> 	;xor	ah, ah
  7059 00005533 31C0                <1> 	xor	eax, eax
  7060                              <1> 	;mov	al, [ES:BX+2]	; heads (logical) 	
  7061 00005535 8A4302              <1> 	mov	al, [ebx+2]
  7062 00005538 FEC8                <1> 	dec	al
  7063 0000553A 6640                <1> 	inc	ax		; 0 =  256
  7064 0000553C 66F7E2              <1> 	mul 	dx
  7065                              <1> 		; AX = # of Heads" * Sectors/Track
  7066 0000553F 6689CA              <1> 	mov	dx, cx
  7067                              <1> 	;and	cx, 3Fh	 ; sector  (1 to 63)
  7068 00005542 83E13F              <1> 	and	ecx, 3fh
  7069 00005545 86D6                <1> 	xchg	dl, dh
  7070 00005547 C0EE06              <1> 	shr	dh, 6
  7071                              <1> 		; DX = cylinder (0 to 1023)
  7072                              <1> 	;mul 	dx
  7073                              <1> 		; DX:AX = # of Heads" * Sectors/Track * Cylinder
  7074 0000554A F7E2                <1> 	mul	edx
  7075 0000554C FEC9                <1> 	dec	cl  ; sector - 1
  7076                              <1> 	;add	ax, cx
  7077                              <1> 	;adc	dx, 0
  7078                              <1> 		; DX:AX = # of Heads" * Sectors/Track * Cylinder + Sector -1
  7079 0000554E 01C8                <1> 	add	eax, ecx
  7080 00005550 6659                <1> 	pop	cx ; * ; ch = head, cl = drive number (zero based)
  7081                              <1> 	;push	dx
  7082                              <1> 	;push	ax
  7083 00005552 50                  <1> 	push	eax
  7084                              <1> 	;mov	al, [ES:BX+14]	; sectors per track (logical)	
  7085 00005553 8A430E              <1> 	mov	al, [ebx+14]
  7086 00005556 F6E5                <1> 	mul	ch
  7087                              <1> 		;  AX = Head * Sectors/Track
  7088 00005558 0FB7C0              <1>         movzx	eax, ax ; 09/12/2017
  7089                              <1> 	;pop	dx
  7090 0000555B 5A                  <1> 	pop	edx
  7091                              <1> 	;add	ax, dx
  7092                              <1> 	;pop	dx
  7093                              <1> 	;adc	dx, 0 ; add carry bit
  7094 0000555C 01D0                <1> 	add	eax, edx
  7095                              <1> lbarw2:
  7096 0000555E 29D2                <1> 	sub	edx, edx ; 21/02/2015
  7097 00005560 88CA                <1> 	mov	dl, cl ; 21/02/2015
  7098 00005562 C645F800            <1>         mov     byte [CMD_BLOCK], 0 ; Features Register
  7099                              <1> 				; NOTE: Features register (1F1h, 171h)
  7100                              <1> 				; is not used for ATA device R/W functions. 
  7101                              <1> 				; It is old/obsolete 'write precompensation'
  7102                              <1> 				; register and error register
  7103                              <1> 				; for old ATA/IDE devices.
  7104                              <1> 	; 18/01/2014
  7105                              <1> 	;mov	ch, [hf_m_s]	; Drive 0 (master) or 1 (slave)
  7106 00005566 8A0D[046E0000]      <1> 	mov	cl, [hf_m_s]
  7107                              <1> 	;shl	ch, 4		; bit 4 (drive bit)
  7108                              <1> 	;or	ch, 0E0h	; bit 5 = 1
  7109                              <1> 				; bit 6 = 1 = LBA mode
  7110                              <1> 				; bit 7 = 1
  7111 0000556C 80C90E              <1> 	or	cl, 0Eh ; 1110b
  7112                              <1> 	;and	dh, 0Fh		; LBA byte 4 (bits 24 to 27)
  7113 0000556F 25FFFFFF0F          <1> 	and	eax, 0FFFFFFFh
  7114 00005574 C1E11C              <1> 	shl	ecx, 28 ; 21/02/2015
  7115                              <1> 	;or	dh, ch
  7116 00005577 09C8                <1> 	or	eax, ecx	
  7117                              <1> 	;;mov	[CMD_BLOCK+2], al ; LBA byte 1 (bits 0 to 7)
  7118                              <1> 				  ; (Sector Number Register)
  7119                              <1> 	;;mov	[CMD_BLOCK+3], ah ; LBA byte 2 (bits 8 to 15)
  7120                              <1> 				  ; (Cylinder Low Register)
  7121                              <1> 	;mov	[CMD_BLOCK+2], ax ; LBA byte 1, 2
  7122                              <1> 	;mov	[CMD_BLOCK+4], dl ; LBA byte 3 (bits 16 to 23)
  7123                              <1> 				  ; (Cylinder High Register)
  7124                              <1> 	;;mov	[CMD_BLOCK+5], dh ; LBA byte 4 (bits 24 to 27)
  7125                              <1> 				  ; (Drive/Head Register)
  7126                              <1> 	
  7127                              <1> 	;mov	[CMD_BLOCK+4], dx ; LBA byte 4, LBA & DEV select bits
  7128 00005579 8945FA              <1> 	mov	[CMD_BLOCK+2], eax ; 21/02/2015
  7129                              <1> 	;14/02/2015
  7130                              <1> 	;mov	dl, cl ; Drive number (INIT_DRV)		
  7131 0000557C EB38                <1> 	jmp	short su4
  7132                              <1> su3:
  7133                              <1> 	; 02/02/2015 
  7134                              <1> 	; (Temporary functions 1Bh & 1Ch are not valid for CHS mode) 
  7135 0000557E 80FC14              <1> 	cmp 	ah, 14h
  7136 00005581 7604                <1> 	jna 	short chsfnc
  7137                              <1> invldfnc:
  7138                              <1>         ; 14/02/2015  
  7139                              <1> 	;pop	es ; **
  7140 00005583 6658                <1>         pop     ax ; ***
  7141                              <1>         ;jmp     short BAD_COMMAND_POP
  7142 00005585 EB49                <1>         jmp     short BAD_COMMAND
  7143                              <1> chsfnc:	
  7144                              <1> 	;MOV	AX,[ES:BX+5]		; GET WRITE PRE-COMPENSATION CYLINDER
  7145 00005587 668B4305            <1> 	mov	ax, [ebx+5]
  7146 0000558B 66C1E802            <1> 	SHR	AX,2
  7147 0000558F 8845F8              <1> 	MOV	[CMD_BLOCK],AL
  7148                              <1> 	;;MOV	AL,[ES:BX+8]		; GET CONTROL BYTE MODIFIER
  7149                              <1> 	;;PUSH	DX
  7150                              <1> 	;;MOV	DX,[HF_REG_PORT]
  7151                              <1> 	;;OUT	DX,AL			; SET EXTRA HEAD OPTION
  7152                              <1> 	;;POP	DX ; * 
  7153                              <1> 	;;POP	ES ; **
  7154                              <1> 	;;MOV	AH,[CONTROL_BYTE]	; SET EXTRA HEAD OPTION IN
  7155                              <1> 	;;AND	AH,0C0H 		; CONTROL BYTE	
  7156                              <1> 	;;OR	AH,AL
  7157                              <1> 	;;MOV	[CONTROL_BYTE],AH
  7158                              <1> 	;
  7159 00005592 88C8                <1> 	MOV	AL,CL			; GET SECTOR NUMBER
  7160 00005594 243F                <1> 	AND	AL,3FH
  7161 00005596 8845FA              <1> 	MOV	[CMD_BLOCK+2],AL
  7162 00005599 886DFB              <1> 	MOV	[CMD_BLOCK+3],CH 	; GET CYLINDER NUMBER
  7163 0000559C 88C8                <1> 	MOV	AL,CL
  7164 0000559E C0E806              <1> 	SHR	AL,6
  7165 000055A1 8845FC              <1> 	MOV	[CMD_BLOCK+4],AL 	; CYLINDER HIGH ORDER 2 BITS
  7166                              <1> 	;;05/01/2015
  7167                              <1> 	;;MOV	AL,DL			; DRIVE NUMBER
  7168 000055A4 A0[046E0000]        <1> 	mov	al, [hf_m_s]
  7169 000055A9 C0E004              <1> 	SHL	AL,4
  7170 000055AC 80E60F              <1> 	AND	DH,0FH			; HEAD NUMBER
  7171 000055AF 08F0                <1> 	OR	AL,DH
  7172                              <1> 	;OR	AL,80H or 20H
  7173 000055B1 0CA0                <1> 	OR	AL,80h+20h		; ECC AND 512 BYTE SECTORS
  7174 000055B3 8845FD              <1> 	MOV	[CMD_BLOCK+5],AL 	; ECC/SIZE/DRIVE/HEAD
  7175                              <1> su4:
  7176                              <1> 	;POP	ES ; **
  7177                              <1>         ;; 14/02/2015
  7178                              <1>         ;;POP   AX
  7179                              <1>         ;;MOV   [CMD_BLOCK+1],AL        ; SECTOR COUNT
  7180                              <1>         ;;PUSH  AX
  7181                              <1>         ;;MOV   AL,AH                   ; GET INTO LOW BYTE
  7182                              <1>         ;;XOR   AH,AH                   ; ZERO HIGH BYTE
  7183                              <1>         ;;SAL   AX,1                    ; *2 FOR TABLE LOOKUP
  7184 000055B6 6658                <1>         pop     ax ; ***
  7185 000055B8 8845F9              <1>         mov     [CMD_BLOCK+1], al
  7186 000055BB 29DB                <1>         sub	ebx, ebx
  7187 000055BD 88E3                <1> 	mov     bl, ah
  7188                              <1>         ;xor     bh, bh
  7189                              <1>         ;sal     bx, 1
  7190 000055BF 66C1E302            <1>         sal	bx, 2	; 32 bit offset (21/02/2015)
  7191                              <1> 	;;MOV   SI,AX                   ; PUT INTO SI FOR BRANCH
  7192                              <1>         ;;CMP   AX,D1L                  ; TEST WITHIN RANGE
  7193                              <1>         ;;JNB   short BAD_COMMAND_POP
  7194                              <1>         ;cmp     bx, D1L
  7195 000055C3 83FB74              <1> 	cmp	ebx, D1L
  7196 000055C6 7308                <1> 	jnb	short BAD_COMMAND
  7197                              <1>         ;xchg    bx, si
  7198 000055C8 87DE                <1>         xchg	ebx, esi
  7199                              <1> 	;;;POP	AX			; RESTORE AX
  7200                              <1> 	;;;POP	BX			; AND DATA ADDRESS
  7201                              <1> 	
  7202                              <1> 	;;PUSH	CX
  7203                              <1> 	;;PUSH	AX			; ADJUST ES:BX
  7204                              <1> 	;MOV	CX,BX			; GET 3 HIGH ORDER NIBBLES OF BX
  7205                              <1> 	;SHR	CX,4
  7206                              <1> 	;MOV	AX,ES
  7207                              <1> 	;ADD	AX,CX
  7208                              <1> 	;MOV	ES,AX
  7209                              <1> 	;AND	BX,000FH		; ES:BX CHANGED TO ES:000X
  7210                              <1> 	;;POP	AX
  7211                              <1> 	;;POP	CX
  7212                              <1> 	;;JMP	word [CS:SI+D1]
  7213                              <1> 	;jmp	word [SI+D1]
  7214 000055CA FFA6[17540000]      <1> 	jmp	dword [esi+D1]
  7215                              <1> ;;BAD_COMMAND_POP:
  7216                              <1> ;;	POP	AX
  7217                              <1> ;;	POP	BX
  7218                              <1> BAD_COMMAND:
  7219 000055D0 C605[CB8A0100]01    <1>         MOV     byte [DISK_STATUS1],BAD_CMD  ; COMMAND ERROR
  7220 000055D7 B000                <1> 	MOV	AL,0
  7221 000055D9 C3                  <1> 	RETn
  7222                              <1> 
  7223                              <1> ;----------------------------------------
  7224                              <1> ;	RESET THE DISK SYSTEM  (AH=00H) :
  7225                              <1> ;----------------------------------------
  7226                              <1> 
  7227                              <1> ; 18-1-2015 : one controller reset (not other one)
  7228                              <1> 
  7229                              <1> DISK_RESET:
  7230 000055DA FA                  <1> 	CLI
  7231 000055DB E4A1                <1> 	IN	AL,INTB01		; GET THE MASK REGISTER
  7232                              <1> 	;JMP	$+2
  7233                              <1> 	IODELAY
  2970 000055DD EB00                <2>  jmp short $+2
  2971 000055DF EB00                <2>  jmp short $+2
  7234                              <1> 	;AND	AL,0BFH 		; ENABLE FIXED DISK INTERRUPT
  7235 000055E1 243F                <1> 	and	al,3Fh			; 22/12/2014 (IRQ 14 & IRQ 15)
  7236 000055E3 E6A1                <1> 	OUT	INTB01,AL
  7237 000055E5 FB                  <1> 	STI				; START INTERRUPTS
  7238                              <1> 	; 14/02/2015
  7239 000055E6 6689D7              <1> 	mov	di, dx	
  7240                              <1> 	; 04/01/2015
  7241                              <1> 	;xor	di,di
  7242                              <1> drst0:
  7243 000055E9 B004                <1> 	MOV	AL,04H  ; bit 2 - SRST 
  7244                              <1> 	;MOV	DX,HF_REG_PORT
  7245 000055EB 668B15[026E0000]    <1> 	MOV	DX,[HF_REG_PORT]
  7246 000055F2 EE                  <1> 	OUT	DX,AL			; RESET
  7247                              <1> ;	MOV	CX,10			; DELAY COUNT
  7248                              <1> ;DRD:	DEC	CX
  7249                              <1> ;	JNZ	short DRD		; WAIT 4.8 MICRO-SEC
  7250                              <1> 	;mov	cx,2			; wait for 30 micro seconds	
  7251 000055F3 B902000000          <1>         mov	ecx, 2 ; 21/02/2015
  7252 000055F8 E851CEFFFF          <1> 	call    WAITF                   ; (Award Bios 1999 - WAIT_REFRESH,
  7253                              <1>                                         ; 40 micro seconds)
  7254 000055FD A0[CD8A0100]        <1> 	mov	al,[CONTROL_BYTE]
  7255 00005602 240F                <1> 	AND	AL,0FH			; SET HEAD OPTION
  7256 00005604 EE                  <1> 	OUT	DX,AL			; TURN RESET OFF
  7257 00005605 E86A040000          <1> 	CALL	NOT_BUSY
  7258 0000560A 7515                <1> 	JNZ	short DRERR		; TIME OUT ON RESET
  7259 0000560C 668B15[006E0000]    <1> 	MOV	DX,[HF_PORT]
  7260 00005613 FEC2                <1> 	inc	dl  ; HF_PORT+1
  7261                              <1> 	; 02/01/2015 - Award BIOS 1999 - AHDSK.ASM
  7262                              <1>         ;mov     cl, 10
  7263 00005615 B90A000000          <1>         mov     ecx, 10 ; 21/02/2015 
  7264                              <1> drst1:
  7265 0000561A EC                  <1> 	IN	AL,DX			; GET RESET STATUS
  7266 0000561B 3C01                <1> 	CMP	AL,1
  7267                              <1> 	; 04/01/2015
  7268 0000561D 740A                <1> 	jz	short drst2
  7269                              <1> 	;JNZ	short DRERR		; BAD RESET STATUS
  7270                              <1>         	; Drive/Head Register - bit 4
  7271 0000561F E2F9                <1> 	loop	drst1
  7272                              <1> DRERR:	
  7273 00005621 C605[CB8A0100]05    <1> 	MOV	byte [DISK_STATUS1],BAD_RESET ; CARD FAILED
  7274 00005628 C3                  <1> 	RETn
  7275                              <1> drst2:
  7276                              <1> 	; 14/02/2015
  7277 00005629 6689FA              <1> 	mov	dx,di
  7278                              <1> ;drst3:
  7279                              <1> ;	; 05/01/2015
  7280                              <1> ;	shl 	di,1
  7281                              <1> ;	; 04/01/2015
  7282                              <1> ;	mov	ax,[di+hd_cports]
  7283                              <1> ;	cmp	ax,[HF_REG_PORT]
  7284                              <1> ;	je	short drst4
  7285                              <1> ;	mov	[HF_REG_PORT], ax
  7286                              <1> ;	; 03/01/2015
  7287                              <1> ;	mov	ax,[di+hd_ports]
  7288                              <1> ;       mov     [HF_PORT], ax
  7289                              <1> ;	; 05/01/2014
  7290                              <1> ;	shr	di,1
  7291                              <1> ;	; 04/01/2015
  7292                              <1> ;	jmp	short drst0	; reset other controller
  7293                              <1> ;drst4:
  7294                              <1> ;	; 05/01/2015
  7295                              <1> ;	shr	di,1
  7296                              <1> ;	mov	al,[di+hd_dregs]
  7297                              <1> ;	and	al,10h ; bit 4 only
  7298                              <1> ;	shr	al,4 ; bit 4  -> bit 0
  7299                              <1> ;	mov	[hf_m_s], al ; (0 = master, 1 = slave)
  7300                              <1> 	;
  7301 0000562C A0[046E0000]        <1> 	mov	al, [hf_m_s] ; 18/01/2015
  7302 00005631 A801                <1> 	test	al,1
  7303                              <1> ;	jnz	short drst6
  7304 00005633 7516                <1>         jnz     short drst4
  7305 00005635 8065FDEF            <1> 	AND     byte [CMD_BLOCK+5],0EFH ; SET TO DRIVE 0
  7306                              <1> ;drst5:
  7307                              <1> drst3:
  7308 00005639 E867010000          <1> 	CALL	INIT_DRV		; SET MAX HEADS
  7309                              <1> 	;mov	dx,di
  7310 0000563E E81F020000          <1> 	CALL	HDISK_RECAL		; RECAL TO RESET SEEK SPEED
  7311                              <1> 	; 04/01/2014
  7312                              <1> ;	inc	di
  7313                              <1> ;	mov	dx,di
  7314                              <1> ;	cmp	dl,[HF_NUM]
  7315                              <1> ;	jb	short drst3
  7316                              <1> ;DRE:
  7317 00005643 C605[CB8A0100]00    <1> 	MOV	byte [DISK_STATUS1],0 	; IGNORE ANY SET UP ERRORS
  7318 0000564A C3                  <1> 	RETn
  7319                              <1> ;drst6:
  7320                              <1> drst4:		; Drive/Head Register - bit 4
  7321 0000564B 804DFD10            <1> 	OR      byte [CMD_BLOCK+5],010H ; SET TO DRIVE 1     
  7322                              <1>         ;jmp    short drst5
  7323 0000564F EBE8                <1>         jmp     short drst3
  7324                              <1> 
  7325                              <1> ;----------------------------------------
  7326                              <1> ;	DISK STATUS ROUTINE  (AH = 01H) :
  7327                              <1> ;----------------------------------------
  7328                              <1> 
  7329                              <1> RETURN_STATUS:
  7330 00005651 A0[CB8A0100]        <1> 	MOV	AL,[DISK_STATUS1]	; OBTAIN PREVIOUS STATUS
  7331 00005656 C605[CB8A0100]00    <1>         MOV     byte [DISK_STATUS1],0   ; RESET STATUS
  7332 0000565D C3                  <1> 	RETn
  7333                              <1> 
  7334                              <1> ;----------------------------------------
  7335                              <1> ;	DISK READ ROUTINE    (AH = 02H) :
  7336                              <1> ;----------------------------------------
  7337                              <1> 
  7338                              <1> DISK_READ:
  7339 0000565E C645FE20            <1> 	MOV	byte [CMD_BLOCK+6],READ_CMD
  7340 00005662 E986020000          <1>         JMP     COMMANDI
  7341                              <1> 
  7342                              <1> ;----------------------------------------
  7343                              <1> ;	DISK WRITE ROUTINE   (AH = 03H) :
  7344                              <1> ;----------------------------------------
  7345                              <1> 
  7346                              <1> DISK_WRITE:
  7347 00005667 C645FE30            <1> 	MOV	byte [CMD_BLOCK+6],WRITE_CMD
  7348 0000566B E9D8020000          <1>         JMP     COMMANDO
  7349                              <1> 
  7350                              <1> ;----------------------------------------
  7351                              <1> ;	DISK VERIFY	     (AH = 04H) :
  7352                              <1> ;----------------------------------------
  7353                              <1> 
  7354                              <1> DISK_VERF:
  7355 00005670 C645FE40            <1> 	MOV	byte [CMD_BLOCK+6],VERIFY_CMD
  7356 00005674 E846030000          <1> 	CALL	COMMAND
  7357 00005679 750C                <1> 	JNZ	short VERF_EXIT		; CONTROLLER STILL BUSY
  7358 0000567B E8B8030000          <1> 	CALL	_WAIT			; (Original: CALL WAIT)	
  7359 00005680 7505                <1> 	JNZ	short VERF_EXIT		; TIME OUT
  7360 00005682 E845040000          <1> 	CALL	CHECK_STATUS
  7361                              <1> VERF_EXIT:
  7362 00005687 C3                  <1> 	RETn
  7363                              <1> 
  7364                              <1> ;----------------------------------------
  7365                              <1> ;	FORMATTING	     (AH = 05H) :
  7366                              <1> ;----------------------------------------
  7367                              <1> 
  7368                              <1> FMT_TRK:				; FORMAT TRACK	(AH = 005H)
  7369 00005688 C645FE50            <1> 	MOV	byte [CMD_BLOCK+6],FMTTRK_CMD
  7370                              <1> 	;PUSH	ES
  7371                              <1> 	;PUSH	BX
  7372 0000568C 53                  <1> 	push	ebx
  7373 0000568D E8EC040000          <1> 	CALL	GET_VEC 		; GET DISK PARAMETERS ADDRESS
  7374                              <1> 	;MOV	AL,[ES:BX+14]		; GET SECTORS/TRACK
  7375 00005692 8A430E              <1> 	mov	al, [ebx+14]
  7376 00005695 8845F9              <1> 	MOV	[CMD_BLOCK+1],AL 	; SET SECTOR COUNT IN COMMAND
  7377 00005698 5B                  <1> 	pop	ebx
  7378                              <1> 	;POP	BX
  7379                              <1> 	;POP	ES
  7380 00005699 E9B1020000          <1>         JMP     CMD_OF                  ; GO EXECUTE THE COMMAND
  7381                              <1> 
  7382                              <1> ; 30/08/2020
  7383                              <1> 
  7384                              <1> ;----------------------------------------
  7385                              <1> ;	READ DASD TYPE	     (AH = 15H) :
  7386                              <1> ;----------------------------------------
  7387                              <1> 
  7388                              <1> READ_DASD_TYPE:
  7389                              <1> READ_D_T:				; GET DRIVE PARAMETERS
  7390 0000569E 1E                  <1> 	PUSH	DS			; SAVE REGISTERS
  7391                              <1> 	;PUSH	ES
  7392 0000569F 53                  <1> 	PUSH	eBX
  7393                              <1> 	;CALL	DDS			; ESTABLISH ADDRESSING
  7394                              <1> 	;push	cs
  7395                              <1> 	;pop	ds
  7396 000056A0 66BB1000            <1>         mov	bx, KDATA
  7397 000056A4 8EDB                <1> 	mov	ds, bx
  7398                              <1> 	;mov	es, bx
  7399 000056A6 C605[CB8A0100]00    <1> 	MOV     byte [DISK_STATUS1],0
  7400 000056AD 8A1D[CC8A0100]      <1> 	MOV	BL,[HF_NUM]		; GET NUMBER OF DRIVES
  7401 000056B3 80E27F              <1> 	AND	DL,7FH			; GET DRIVE NUMBER
  7402 000056B6 38D3                <1> 	CMP	BL,DL
  7403 000056B8 763C                <1> 	JBE	short RDT_NOT_PRESENT 	; RETURN DRIVE NOT PRESENT
  7404 000056BA 0FB6C2              <1> 	movzx	eax, dl ; 28/08/2020
  7405 000056BD E8BC040000          <1> 	CALL	GET_VEC 		; GET DISK PARAMETERS ADDRESS
  7406                              <1> 	
  7407                              <1> 	; 28/08/2020 - TRDOS 386 v2
  7408 000056C2 F6431440            <1> 	test	byte [ebx+20], 40h	; LBA bit (bit 6)
  7409 000056C6 751D                <1> 	jnz	short RDT3 ; LBA disk (may be > 8GB)
  7410                              <1> 
  7411                              <1> 	;MOV	AL,[ES:BX+2]		; HEADS
  7412 000056C8 8A4302              <1> 	mov	al, [ebx+2]
  7413                              <1> 	;MOV	CL,[ES:BX+14]
  7414 000056CB 8A4B0E              <1> 	mov	cl, [ebx+14]
  7415 000056CE F6E9                <1> 	IMUL	CL			; * NUMBER OF SECTORS
  7416                              <1> 	;MOV	CX,[ES:BX]		; MAX NUMBER OF CYLINDERS
  7417 000056D0 668B0B              <1> 	mov	cx, [ebx]
  7418                              <1> 	;
  7419                              <1> 	; 02/01/2015 
  7420                              <1> 	; ** leave the last cylinder as reserved for diagnostics **
  7421                              <1> 	; (Also in Award BIOS - 1999, AHDSK.ASM, FUN15 -> sub ax, 1)
  7422 000056D3 6649                <1> 	DEC	CX			; LEAVE ONE FOR DIAGNOSTICS
  7423                              <1> 	;
  7424 000056D5 66F7E9              <1> 	IMUL	CX			; NUMBER OF SECTORS
  7425 000056D8 6689D1              <1> 	MOV	CX,DX			; HIGH ORDER HALF
  7426 000056DB 6689C2              <1> 	MOV	DX,AX			; LOW ORDER HALF
  7427                              <1> 	;SUB	AX,AX
  7428                              <1> 	; 28/08/2020
  7429                              <1> 	;sub	al, al
  7430                              <1> RDT4:
  7431 000056DE 29C0                <1> 	sub	eax, eax ; 28/08/2020
  7432                              <1> 	;
  7433 000056E0 B403                <1> 	MOV	AH,03H			; INDICATE FIXED DISK
  7434                              <1> 	; 30/08/2020 (clc is not needed here)
  7435                              <1> 	;and	byte [esp+8], 0FEh ; clear carry bit of eflags register
  7436                              <1> RDT2:	
  7437 000056E2 5B                  <1> 	POP	eBX			; RESTORE REGISTERS
  7438                              <1> 	;POP	ES
  7439 000056E3 1F                  <1> 	POP	DS
  7440                              <1> 	; (*) CLC			; CLEAR CARRY
  7441                              <1> 	;RETf	2
  7442                              <1> 	; (*) 29/05/2016
  7443                              <1> 	; (*) retf 4
  7444                              <1> 	; 30/08/2020 (clc is not needed here)
  7445                              <1> 	;and	byte [esp+8], 0FEh ; clear carry bit of eflags register
  7446 000056E4 CF                  <1> 	iretd
  7447                              <1> 
  7448                              <1> RDT3:	; 28/08/2020
  7449                              <1> 	; (use the result of INT 13h, function 48h as disk size)
  7450                              <1> 	; eax = al = zero based hard disk number
  7451                              <1> 	; 29/08/2020
  7452                              <1> 	;add	al, 2 ; hd0 = physical disk drive 2
  7453 000056E5 C0E002              <1> 	shl	al, 2 ; * 4
  7454                              <1> RDT5:
  7455                              <1> 	;add	eax, drv.size
  7456 000056E8 05[466E0000]        <1> 	add	eax, drv.size+8 ; 29/08/2020
  7457 000056ED 668B10              <1> 	mov	dx, [eax]   ; low word of disk size
  7458 000056F0 668B4802            <1> 	mov	cx, [eax+2] ; high word of disk size
  7459                              <1> 	;sub	eax, eax
  7460 000056F4 EBE8                <1> 	jmp	short RDT4		
  7461                              <1> 
  7462                              <1> RDT_NOT_PRESENT:
  7463                              <1> 	; 30/08/2020
  7464 000056F6 C605[CB8A0100]AA    <1> 	mov	byte [DISK_STATUS1], NOT_RDY ; DRIVE NOT READY
  7465                              <1> 
  7466                              <1> 	;SUB	AX,AX			; DRIVE NOT PRESENT RETURN
  7467 000056FD 29C0                <1> 	sub	eax, eax ; 30/08/2020
  7468 000056FF 6689C1              <1> 	MOV	CX,AX			; ZERO BLOCK COUNT
  7469 00005702 6689C2              <1> 	MOV	DX,AX
  7470                              <1> 	; 30/08/2020
  7471 00005705 804C241001          <1> 	or	byte [esp+16], 1 ; set carry bit of eflags register
  7472                              <1> 		; cf = 1 -> ah = 0, drive not ready, disk type = 0
  7473 0000570A EBD6                <1> 	JMP	short RDT2
  7474                              <1> 
  7475                              <1> ; 28/05/2016
  7476                              <1> ; 27/05/2016 - TRDOS 386 (TRDOS v2.0)
  7477                              <1> 
  7478                              <1> ;----------------------------------------
  7479                              <1> ;	GET PARAMETERS	     (AH = 08H) :
  7480                              <1> ;----------------------------------------
  7481                              <1> 
  7482                              <1> GET_PARM_N:
  7483                              <1> 	; ebx = user's buffer address for parameters table
  7484                              <1> ;GET_PARM:				; GET DRIVE PARAMETERS
  7485 0000570C 1E                  <1> 	PUSH	DS			; SAVE REGISTERS
  7486 0000570D 06                  <1> 	PUSH	ES
  7487 0000570E 53                  <1> 	PUSH	eBX
  7488                              <1> 	;MOV	AX,ABS0 		; ESTABLISH ADDRESSING
  7489                              <1> 	;MOV	DS,AX
  7490                              <1> 	;TEST	DL,1			; CHECK FOR DRIVE 1
  7491                              <1> 	;JZ	short G0
  7492                              <1> 	;LES	BX,@HF1_TBL_VEC
  7493                              <1> 	;JMP	SHORT G1
  7494                              <1> ;G0:	LES	BX,@HF_TBL_VEC
  7495                              <1> ;G1:
  7496                              <1> 	;CALL	DDS			; ESTABLISH SEGMENT
  7497                              <1> 	; 22/12/2014
  7498                              <1> 	;push	cs
  7499                              <1> 	;pop	ds
  7500 0000570F 66BB1000            <1> 	mov	bx, KDATA
  7501 00005713 8EDB                <1> 	mov	ds, bx
  7502 00005715 8EC3                <1> 	mov	es, bx	; 27/05/2016
  7503                              <1> 	;
  7504 00005717 80EA80              <1> 	SUB	DL,80H
  7505                              <1> 	;CMP	DL,MAX_FILE		; TEST WITHIN RANGE
  7506                              <1> 	;JAE	short G4 ; 29/08/2020 - BugFix
  7507                              <1> 	; 30/08/2020
  7508 0000571A 3A15[CC8A0100]      <1> 	cmp	dl, [HF_NUM] ; is hard disk index < hard disk count ?	
  7509 00005720 736A                <1> 	jae	short G4     ; no, error ! drive not ready !	
  7510                              <1> 	;
  7511 00005722 31DB                <1> 	xor	ebx, ebx ; 21/02/2015
  7512                              <1> 	; 22/12/2014
  7513 00005724 88D3                <1> 	mov	bl, dl
  7514                              <1> 	;xor	bh, bh  
  7515 00005726 C0E302              <1> 	shl	bl, 2			; convert index to offset
  7516                              <1> 	;add	bx, HF_TBL_VEC
  7517 00005729 81C3[D08A0100]      <1> 	add	ebx, HF_TBL_VEC
  7518                              <1> 	;mov	ax, [bx+2]
  7519                              <1> 	;mov	es, ax			; dpt segment
  7520                              <1> 	;mov	bx, [bx]		; dpt offset
  7521 0000572F 8B1B                <1> 	mov	ebx, [ebx] ; 32 bit offset	
  7522                              <1> 
  7523 00005731 C605[CB8A0100]00    <1> 	MOV	byte [DISK_STATUS1],0
  7524                              <1>         ;MOV	AX,[ES:BX]		; MAX NUMBER OF CYLINDERS
  7525 00005738 668B03              <1> 	mov	ax, [ebx]
  7526                              <1> 	;;SUB	AX,2			; ADJUST FOR 0-N
  7527 0000573B 6648                <1> 	dec	ax			; max. cylinder number
  7528 0000573D 88C5                <1> 	MOV	CH,AL
  7529 0000573F 66250003            <1> 	AND	AX,0300H		; HIGH TWO BITS OF CYLINDER
  7530 00005743 66D1E8              <1> 	SHR	AX,1
  7531 00005746 66D1E8              <1> 	SHR	AX,1
  7532                              <1> 	;OR	AL,[ES:BX+14]		; SECTORS
  7533 00005749 0A430E              <1> 	or	al, [ebx+14]
  7534 0000574C 88C1                <1> 	MOV	CL,AL
  7535                              <1> 	;MOV	DH,[ES:BX+2]		; HEADS
  7536 0000574E 8A7302              <1> 	mov	dh, [ebx+2]
  7537 00005751 FECE                <1> 	DEC	DH			; 0-N RANGE
  7538 00005753 8A15[CC8A0100]      <1> 	MOV	DL,[HF_NUM]		; DRIVE COUNT
  7539 00005759 6629C0              <1> 	SUB	AX,AX
  7540                              <1>         ;27/12/2014 
  7541                              <1> 	;mov	di, bx			; HDPT offset
  7542                              <1> 
  7543                              <1> 	; 29/08/2020
  7544 0000575C 833C2400            <1> 	cmp	dword [esp], 0
  7545 00005760 7703                <1> 	ja	short G7 ; ebx > 0
  7546                              <1> 
  7547                              <1> 	; if EBX (user's buffer address) = 0, do not copy DPT
  7548 00005762 5B                  <1> 	pop	ebx
  7549 00005763 EB24                <1> 	jmp	short G5
  7550                              <1> G7:
  7551                              <1> 	; 27/05/2016
  7552                              <1> 	; return fixed disk parameters table to user
  7553                              <1> 	; in user's buffer, which is pointed by EBX
  7554                              <1> 	;
  7555 00005765 873C24              <1> 	xchg	edi, [esp]		; ebx (input)-> edi, edi -> [esp]
  7556 00005768 56                  <1> 	push	esi
  7557 00005769 89DE                <1> 	mov	esi, ebx		; hard disk parameter table (32 bytes)	
  7558 0000576B 89FB                <1> 	mov	ebx, edi		; ebx = user's buffer address
  7559 0000576D 51                  <1> 	push	ecx
  7560 0000576E 50                  <1> 	push	eax
  7561 0000576F B920000000          <1> 	mov	ecx, 32 ; 32 bytes
  7562 00005774 E8EBC30000          <1> 	call	transfer_to_user_buffer ; trdosk6.s (16/05/2016)
  7563 00005779 58                  <1> 	pop	eax
  7564 0000577A 59                  <1> 	pop	ecx
  7565 0000577B 5E                  <1> 	pop	esi
  7566 0000577C 5F                  <1> 	pop	edi
  7567 0000577D 730A                <1> 	jnc	short G5
  7568                              <1> 	; 29/05/2016 (*)
  7569 0000577F B8FF000000          <1> 	mov	eax, 0FFh ; unknown error !
  7570                              <1> G6:
  7571 00005784 804C241001          <1> 	or	byte [esp+16], 1 ; set carry bit of eflags register
  7572                              <1> G5:
  7573                              <1> 	; 27/05/2016
  7574                              <1> 	;POP	eBX			; RESTORE REGISTERS
  7575 00005789 07                  <1> 	POP	ES
  7576 0000578A 1F                  <1> 	POP	DS
  7577                              <1> 	;RETf	2
  7578                              <1> 	; (*) 29/05/2016
  7579                              <1> 	; (*) retf 4
  7580                              <1> 	; (*) or byte [esp+8], 1 ; set carry bit of eflags register
  7581 0000578B CF                  <1> 	iretd
  7582                              <1> G4:
  7583 0000578C C605[CB8A0100]07    <1> 	MOV     byte [DISK_STATUS1],INIT_FAIL ; OPERATION FAILED
  7584                              <1> 	;mov	ah, NOT_DRY ; 30/08/2020 - 'drive not ready' error code
  7585 00005793 B407                <1> 	MOV	AH,INIT_FAIL
  7586 00005795 28C0                <1> 	SUB	AL,AL
  7587                              <1> 	;SUB	DX,DX
  7588                              <1> 	; 30/08/2020
  7589 00005797 8A15[CC8A0100]      <1> 	mov	dl, [HF_NUM] ; disk count
  7590 0000579D 28F6                <1> 	sub	dh, dh
  7591 0000579F 6629C9              <1> 	SUB	CX,CX
  7592                              <1> 	; 29/05/2016 (*)
  7593                              <1> 	;STC				; SET ERROR FLAG
  7594                              <1> 	;JMP	short G5
  7595                              <1> 	; 29/08/2020 - BugFix
  7596 000057A2 5B                  <1> 	pop	ebx
  7597 000057A3 EBDF                <1> 	jmp	short G6
  7598                              <1> 
  7599                              <1> ;----------------------------------------
  7600                              <1> ;	INITIALIZE DRIVE     (AH = 09H) :
  7601                              <1> ;----------------------------------------
  7602                              <1> 	; 03/01/2015
  7603                              <1> 	; According to ATA-ATAPI specification v2.0 to v5.0
  7604                              <1> 	; logical sector per logical track
  7605                              <1> 	; and logical heads - 1 would be set but
  7606                              <1> 	; it is seen as it will be good
  7607                              <1> 	; if physical parameters will be set here
  7608                              <1> 	; because, number of heads <= 16.
  7609                              <1> 	; (logical heads usually more than 16)
  7610                              <1> 	; NOTE: ATA logical parameters (software C, H, S)
  7611                              <1> 	;	== INT 13h physical parameters
  7612                              <1> 
  7613                              <1> ;INIT_DRV:
  7614                              <1> ;	MOV	byte [CMD_BLOCK+6],SET_PARM_CMD
  7615                              <1> ;	CALL	GET_VEC 		; ES:BX -> PARAMETER BLOCK
  7616                              <1> ;	MOV	AL,[ES:BX+2]		; GET NUMBER OF HEADS
  7617                              <1> ;	DEC	AL			; CONVERT TO 0-INDEX
  7618                              <1> ;	MOV	AH,[CMD_BLOCK+5] 	; GET SDH REGISTER
  7619                              <1> ;	AND	AH,0F0H 		; CHANGE HEAD NUMBER
  7620                              <1> ;	OR	AH,AL			; TO MAX HEAD
  7621                              <1> ;	MOV	[CMD_BLOCK+5],AH
  7622                              <1> ;	MOV	AL,[ES:BX+14]		; MAX SECTOR NUMBER
  7623                              <1> ;	MOV	[CMD_BLOCK+1],AL
  7624                              <1> ;	SUB	AX,AX
  7625                              <1> ;	MOV	[CMD_BLOCK+3],AL 	; ZERO FLAGS
  7626                              <1> ;	CALL	COMMAND 		; TELL CONTROLLER
  7627                              <1> ;	JNZ	short INIT_EXIT		; CONTROLLER BUSY ERROR
  7628                              <1> ;	CALL	NOT_BUSY		; WAIT FOR IT TO BE DONE
  7629                              <1> ;	JNZ	short INIT_EXIT		; TIME OUT
  7630                              <1> ;	CALL	CHECK_STATUS
  7631                              <1> ;INIT_EXIT:
  7632                              <1> ;	RETn
  7633                              <1> 
  7634                              <1> ; 04/01/2015
  7635                              <1> ; 02/01/2015 - Derived from from AWARD BIOS 1999
  7636                              <1> ;				 AHDSK.ASM - INIT_DRIVE
  7637                              <1> INIT_DRV:
  7638                              <1> 	;xor	ah,ah
  7639 000057A5 31C0                <1> 	xor	eax, eax ; 21/02/2015
  7640 000057A7 B00B                <1> 	mov	al,11 ; Physical heads from translated HDPT
  7641 000057A9 3825[E08A0100]      <1>         cmp     [LBAMode], ah   ; 0
  7642 000057AF 7702                <1> 	ja	short idrv0
  7643 000057B1 B002                <1> 	mov	al,2  ; Physical heads from standard HDPT
  7644                              <1> idrv0:
  7645                              <1> 	; DL = drive number (0 based)
  7646 000057B3 E8C6030000          <1> 	call	GET_VEC
  7647                              <1> 	;push	bx
  7648 000057B8 53                  <1> 	push	ebx ; 21/02/2015
  7649                              <1> 	;add	bx,ax
  7650 000057B9 01C3                <1> 	add	ebx, eax
  7651                              <1> 	;; 05/01/2015
  7652 000057BB 8A25[046E0000]      <1> 	mov	ah, [hf_m_s] ; drive number (0= master, 1= slave)
  7653                              <1> 	;;and 	ah,1 
  7654 000057C1 C0E404              <1> 	shl	ah,4
  7655 000057C4 80CCA0              <1> 	or	ah,0A0h  ; Drive/Head register - 10100000b (A0h)	
  7656                              <1> 	;mov	al,[es:bx]
  7657 000057C7 8A03                <1> 	mov	al, [ebx] ; 21/02/2015
  7658 000057C9 FEC8                <1> 	dec	al	 ; last head number 
  7659                              <1> 	;and	al,0Fh
  7660 000057CB 08E0                <1> 	or	al,ah	 ; lower 4 bits for head number
  7661                              <1> 	;
  7662 000057CD C645FE91            <1> 	mov	byte [CMD_BLOCK+6],SET_PARM_CMD
  7663 000057D1 8845FD              <1> 	mov	[CMD_BLOCK+5],al
  7664                              <1> 	;pop	bx
  7665 000057D4 5B                  <1> 	pop	ebx
  7666 000057D5 29C0                <1> 	sub	eax, eax ; 21/02/2015
  7667 000057D7 B004                <1> 	mov	al,4 ; Physical sec per track from translated HDPT
  7668 000057D9 803D[E08A0100]00    <1> 	cmp	byte [LBAMode], 0
  7669 000057E0 7702                <1> 	ja	short idrv1
  7670 000057E2 B00E                <1> 	mov	al,14 ; Physical sec per track from standard HDPT
  7671                              <1> idrv1:
  7672                              <1> 	;xor	ah,ah
  7673                              <1> 	;add	bx,ax
  7674 000057E4 01C3                <1> 	add	ebx, eax ; 21/02/2015
  7675                              <1> 	;mov	al,[es:bx]
  7676                              <1> 			; sector number
  7677 000057E6 8A03                <1> 	mov	al, [ebx]
  7678 000057E8 8845F9              <1> 	mov	[CMD_BLOCK+1],al
  7679 000057EB 28C0                <1> 	sub	al,al
  7680 000057ED 8845FB              <1> 	mov	[CMD_BLOCK+3],al  ; ZERO FLAGS
  7681 000057F0 E8CA010000          <1> 	call	COMMAND 	  ; TELL CONTROLLER
  7682 000057F5 750C                <1> 	jnz	short INIT_EXIT	  ; CONTROLLER BUSY ERROR
  7683 000057F7 E878020000          <1> 	call	NOT_BUSY	  ; WAIT FOR IT TO BE DONE
  7684 000057FC 7505                <1> 	jnz	short INIT_EXIT	  ; TIME OUT
  7685 000057FE E8C9020000          <1> 	call	CHECK_STATUS
  7686                              <1> INIT_EXIT:
  7687 00005803 C3                  <1> 	RETn
  7688                              <1> 
  7689                              <1> ;----------------------------------------
  7690                              <1> ;	READ LONG	     (AH = 0AH) :
  7691                              <1> ;----------------------------------------
  7692                              <1> 
  7693                              <1> RD_LONG:
  7694                              <1> 	;MOV	@CMD_BLOCK+6,READ_CMD OR ECC_MODE
  7695 00005804 C645FE22            <1>         mov     byte [CMD_BLOCK+6],READ_CMD + ECC_MODE 
  7696 00005808 E9E0000000          <1>         JMP     COMMANDI
  7697                              <1> 
  7698                              <1> ;----------------------------------------
  7699                              <1> ;	WRITE LONG	     (AH = 0BH) :
  7700                              <1> ;----------------------------------------
  7701                              <1> 
  7702                              <1> WR_LONG:
  7703                              <1> 	;MOV	@CMD_BLOCK+6,WRITE_CMD OR ECC_MODE
  7704 0000580D C645FE32            <1>         MOV     byte [CMD_BLOCK+6],WRITE_CMD + ECC_MODE
  7705 00005811 E932010000          <1>         JMP     COMMANDO
  7706                              <1> 
  7707                              <1> ;----------------------------------------
  7708                              <1> ;	SEEK		     (AH = 0CH) :
  7709                              <1> ;----------------------------------------
  7710                              <1> 
  7711                              <1> DISK_SEEK:
  7712 00005816 C645FE70            <1>         MOV     byte [CMD_BLOCK+6],SEEK_CMD
  7713 0000581A E8A0010000          <1> 	CALL	COMMAND
  7714 0000581F 751C                <1> 	JNZ	short DS_EXIT 		; CONTROLLER BUSY ERROR
  7715 00005821 E812020000          <1> 	CALL	_WAIT
  7716 00005826 7515                <1>         JNZ     DS_EXIT                 ; TIME OUT ON SEEK
  7717 00005828 E89F020000          <1> 	CALL	CHECK_STATUS
  7718 0000582D 803D[CB8A0100]40    <1>         CMP     byte [DISK_STATUS1],BAD_SEEK
  7719 00005834 7507                <1> 	JNE	short DS_EXIT
  7720 00005836 C605[CB8A0100]00    <1>         MOV     byte [DISK_STATUS1],0
  7721                              <1> DS_EXIT:
  7722 0000583D C3                  <1> 	RETn
  7723                              <1> 
  7724                              <1> ;----------------------------------------
  7725                              <1> ;	TEST DISK READY      (AH = 10H) :
  7726                              <1> ;----------------------------------------
  7727                              <1> 
  7728                              <1> TST_RDY:				; WAIT FOR CONTROLLER
  7729 0000583E E831020000          <1> 	CALL	NOT_BUSY
  7730 00005843 751C                <1> 	JNZ	short TR_EX
  7731 00005845 8A45FD              <1> 	MOV	AL,[CMD_BLOCK+5] 	; SELECT DRIVE
  7732 00005848 668B15[006E0000]    <1> 	MOV	DX,[HF_PORT]
  7733 0000584F 80C206              <1> 	add	dl,6
  7734 00005852 EE                  <1> 	OUT	DX,AL
  7735 00005853 E88C020000          <1> 	CALL	CHECK_ST		; CHECK STATUS ONLY
  7736 00005858 7507                <1> 	JNZ	short TR_EX
  7737 0000585A C605[CB8A0100]00    <1> 	MOV	byte [DISK_STATUS1],0 	; WIPE OUT DATA CORRECTED ERROR
  7738                              <1> TR_EX:	
  7739 00005861 C3                  <1> 	RETn
  7740                              <1> 
  7741                              <1> ;----------------------------------------
  7742                              <1> ;	RECALIBRATE	     (AH = 11H) :
  7743                              <1> ;----------------------------------------
  7744                              <1> 
  7745                              <1> HDISK_RECAL:
  7746 00005862 C645FE10            <1>         MOV     byte [CMD_BLOCK+6],RECAL_CMD ; 10h, 16
  7747 00005866 E854010000          <1> 	CALL	COMMAND 		; START THE OPERATION
  7748 0000586B 7523                <1> 	JNZ	short RECAL_EXIT	; ERROR
  7749 0000586D E8C6010000          <1> 	CALL	_WAIT			; WAIT FOR COMPLETION
  7750 00005872 7407                <1> 	JZ	short RECAL_X 		; TIME OUT ONE OK ?
  7751 00005874 E8BF010000          <1> 	CALL	_WAIT			; WAIT FOR COMPLETION LONGER
  7752 00005879 7515                <1> 	JNZ	short RECAL_EXIT	; TIME OUT TWO TIMES IS ERROR
  7753                              <1> RECAL_X:
  7754 0000587B E84C020000          <1> 	CALL	CHECK_STATUS
  7755 00005880 803D[CB8A0100]40    <1> 	CMP	byte [DISK_STATUS1],BAD_SEEK ; SEEK NOT COMPLETE
  7756 00005887 7507                <1> 	JNE	short RECAL_EXIT	; IS OK
  7757 00005889 C605[CB8A0100]00    <1> 	MOV	byte [DISK_STATUS1],0
  7758                              <1> RECAL_EXIT:
  7759 00005890 803D[CB8A0100]00    <1>         CMP     byte [DISK_STATUS1],0
  7760 00005897 C3                  <1> 	RETn
  7761                              <1> 
  7762                              <1> ;----------------------------------------
  7763                              <1> ;      CONTROLLER DIAGNOSTIC (AH = 14H) :
  7764                              <1> ;----------------------------------------
  7765                              <1> 
  7766                              <1> CTLR_DIAGNOSTIC:
  7767 00005898 FA                  <1>         CLI                             ; DISABLE INTERRUPTS WHILE CHANGING MASK
  7768 00005899 E4A1                <1> 	IN	AL,INTB01		; TURN ON SECOND INTERRUPT CHIP
  7769                              <1> 	;AND	AL,0BFH
  7770 0000589B 243F                <1> 	and	al, 3Fh			; enable IRQ 14 & IRQ 15
  7771                              <1> 	;JMP	$+2
  7772                              <1> 	IODELAY
  2970 0000589D EB00                <2>  jmp short $+2
  2971 0000589F EB00                <2>  jmp short $+2
  7773 000058A1 E6A1                <1> 	OUT	INTB01,AL
  7774                              <1> 	IODELAY
  2970 000058A3 EB00                <2>  jmp short $+2
  2971 000058A5 EB00                <2>  jmp short $+2
  7775 000058A7 E421                <1> 	IN	AL,INTA01		; LET INTERRUPTS PASS THRU TO
  7776 000058A9 24FB                <1> 	AND	AL,0FBH 		;  SECOND CHIP
  7777                              <1> 	;JMP	$+2
  7778                              <1> 	IODELAY
  2970 000058AB EB00                <2>  jmp short $+2
  2971 000058AD EB00                <2>  jmp short $+2
  7779 000058AF E621                <1> 	OUT	INTA01,AL
  7780 000058B1 FB                  <1> 	STI
  7781 000058B2 E8BD010000          <1> 	CALL	NOT_BUSY		; WAIT FOR CARD
  7782 000058B7 752B                <1> 	JNZ	short CD_ERR		; BAD CARD
  7783                              <1> 	;MOV	DX, HF_PORT+7
  7784 000058B9 668B15[006E0000]    <1> 	mov	dx, [HF_PORT]
  7785 000058C0 80C207              <1> 	add	dl, 7
  7786 000058C3 B090                <1> 	MOV	AL,DIAG_CMD		; START DIAGNOSE
  7787 000058C5 EE                  <1> 	OUT	DX,AL
  7788 000058C6 E8A9010000          <1> 	CALL	NOT_BUSY		; WAIT FOR IT TO COMPLETE
  7789 000058CB B480                <1> 	MOV	AH,TIME_OUT
  7790 000058CD 7517                <1> 	JNZ	short CD_EXIT 		; TIME OUT ON DIAGNOSTIC
  7791                              <1> 	;MOV	DX,HF_PORT+1		; GET ERROR REGISTER
  7792 000058CF 668B15[006E0000]    <1> 	mov	dx, [HF_PORT]
  7793 000058D6 FEC2                <1> 	inc	dl
  7794 000058D8 EC                  <1> 	IN	AL,DX
  7795 000058D9 A2[C28A0100]        <1> 	MOV	[HF_ERROR],AL		; SAVE IT
  7796 000058DE B400                <1> 	MOV	AH,0
  7797 000058E0 3C01                <1> 	CMP	AL,1			; CHECK FOR ALL OK
  7798 000058E2 7402                <1> 	JE	SHORT CD_EXIT
  7799 000058E4 B420                <1> CD_ERR: MOV	AH,BAD_CNTLR
  7800                              <1> CD_EXIT:
  7801 000058E6 8825[CB8A0100]      <1> 	MOV	[DISK_STATUS1],AH
  7802 000058EC C3                  <1> 	RETn
  7803                              <1> 
  7804                              <1> ;----------------------------------------
  7805                              <1> ; COMMANDI				:
  7806                              <1> ;	REPEATEDLY INPUTS DATA TILL	:
  7807                              <1> ;	NSECTOR RETURNS ZERO		:
  7808                              <1> ;----------------------------------------
  7809                              <1> COMMANDI:
  7810 000058ED E862020000          <1> 	CALL	CHECK_DMA		; CHECK 64K BOUNDARY ERROR
  7811 000058F2 7253                <1> 	JC	short CMD_ABORT
  7812                              <1> 	;MOV	DI,BX
  7813 000058F4 89DF                <1> 	mov	edi, ebx ; 21/02/2015
  7814 000058F6 E8C4000000          <1> 	CALL	COMMAND 		; OUTPUT COMMAND
  7815 000058FB 754A                <1> 	JNZ	short CMD_ABORT
  7816                              <1> CMD_I1:
  7817 000058FD E836010000          <1> 	CALL	_WAIT			; WAIT FOR DATA REQUEST INTERRUPT
  7818 00005902 7543                <1> 	JNZ	short TM_OUT		; TIME OUT
  7819                              <1> cmd_i1x: ; 18/02/2016
  7820                              <1> 	;MOV	CX,256			; SECTOR SIZE IN WORDS
  7821 00005904 B900010000          <1> 	mov	ecx, 256 ; 21/02/2015	
  7822                              <1> 	;MOV	DX,HF_PORT
  7823 00005909 668B15[006E0000]    <1> 	mov	dx,[HF_PORT]
  7824 00005910 FA                  <1> 	CLI
  7825 00005911 FC                  <1> 	CLD
  7826 00005912 F3666D              <1> 	REP	INSW			; GET THE SECTOR
  7827 00005915 FB                  <1> 	STI
  7828 00005916 F645FE02            <1> 	TEST	byte [CMD_BLOCK+6],ECC_MODE ; CHECK FOR NORMAL INPUT
  7829 0000591A 7419                <1> 	JZ	short CMD_I3
  7830 0000591C E880010000          <1> 	CALL	WAIT_DRQ		; WAIT FOR DATA REQUEST
  7831 00005921 7224                <1> 	JC	short TM_OUT
  7832                              <1> 	;MOV	DX,HF_PORT
  7833 00005923 668B15[006E0000]    <1> 	mov	dx,[HF_PORT]
  7834                              <1> 	;MOV	CX,4			; GET ECC BYTES
  7835 0000592A B904000000          <1> 	mov 	ecx, 4 ; mov cx, 4 
  7836 0000592F EC                  <1> CMD_I2: IN	AL,DX
  7837                              <1> 	;MOV	[ES:DI],AL		; GO SLOW FOR BOARD
  7838 00005930 8807                <1> 	mov 	[edi], al ; 21/02/2015
  7839 00005932 47                  <1> 	INC	eDI
  7840 00005933 E2FA                <1> 	LOOP	CMD_I2
  7841                              <1> CMD_I3: 
  7842                              <1> 	; wait for 400 ns
  7843 00005935 80C207              <1> 	add 	dl, 7
  7844 00005938 EC                  <1> 	in	al, dx
  7845 00005939 EC                  <1> 	in	al, dx
  7846 0000593A EC                  <1> 	in	al, dx
  7847                              <1> 	;
  7848 0000593B E88C010000          <1> 	CALL	CHECK_STATUS
  7849 00005940 7505                <1> 	JNZ	short CMD_ABORT		; ERROR RETURNED
  7850 00005942 FE4DF9              <1> 	DEC	byte [CMD_BLOCK+1]	; CHECK FOR MORE
  7851                              <1> 	;JNZ	SHORT CMD_I1
  7852 00005945 75BD                <1> 	jnz	short cmd_i1x ; 18/02/2016
  7853                              <1> CMD_ABORT:
  7854 00005947 C3                  <1> TM_OUT: RETn
  7855                              <1> 
  7856                              <1> ;----------------------------------------
  7857                              <1> ; COMMANDO				:
  7858                              <1> ;	REPEATEDLY OUTPUTS DATA TILL	:
  7859                              <1> ;	NSECTOR RETURNS ZERO		:
  7860                              <1> ;----------------------------------------
  7861                              <1> COMMANDO:
  7862 00005948 E807020000          <1> 	CALL	CHECK_DMA		; CHECK 64K BOUNDARY ERROR
  7863 0000594D 72F8                <1> 	JC	short CMD_ABORT
  7864 0000594F 89DE                <1> CMD_OF: MOV	eSI,eBX ; 21/02/2015
  7865 00005951 E869000000          <1> 	CALL	COMMAND 		; OUTPUT COMMAND
  7866 00005956 75EF                <1> 	JNZ	short CMD_ABORT
  7867 00005958 E844010000          <1> 	CALL	WAIT_DRQ		; WAIT FOR DATA REQUEST
  7868 0000595D 72E8                <1> 	JC	short TM_OUT			; TOO LONG
  7869                              <1> CMD_O1: ;PUSH	DS
  7870                              <1> 	;PUSH	ES			; MOVE ES TO DS
  7871                              <1> 	;POP	DS
  7872                              <1> 	;MOV	CX,256			; PUT THE DATA OUT TO THE CARD
  7873                              <1> 	;MOV	DX,HF_PORT
  7874                              <1> 	; 01/02/2015
  7875 0000595F 668B15[006E0000]    <1> 	mov	dx, [HF_PORT]
  7876                              <1> 	;push	es
  7877                              <1> 	;pop	ds
  7878                              <1> 	;mov	cx, 256
  7879 00005966 B900010000          <1> 	mov	ecx, 256 ; 21/02/2015
  7880 0000596B FA                  <1> 	CLI
  7881 0000596C FC                  <1> 	CLD
  7882 0000596D F3666F              <1> 	REP	OUTSW
  7883 00005970 FB                  <1> 	STI
  7884                              <1> 	;POP	DS			; RESTORE DS
  7885 00005971 F645FE02            <1> 	TEST	byte [CMD_BLOCK+6],ECC_MODE ; CHECK FOR NORMAL OUTPUT
  7886 00005975 7419                <1> 	JZ	short CMD_O3
  7887 00005977 E825010000          <1> 	CALL	WAIT_DRQ		; WAIT FOR DATA REQUEST
  7888 0000597C 72C9                <1> 	JC	short TM_OUT
  7889                              <1> 	;MOV	DX,HF_PORT
  7890 0000597E 668B15[006E0000]    <1> 	mov	dx, [HF_PORT]
  7891                              <1> 	;MOV	CX,4			; OUTPUT THE ECC BYTES
  7892 00005985 B904000000          <1> 	mov	ecx, 4  ; mov cx, 4
  7893                              <1> CMD_O2: ;MOV	AL,[ES:SI]
  7894 0000598A 8A06                <1> 	mov	al, [esi]
  7895 0000598C EE                  <1> 	OUT	DX,AL
  7896 0000598D 46                  <1> 	INC	eSI
  7897 0000598E E2FA                <1> 	LOOP	CMD_O2
  7898                              <1> CMD_O3:
  7899 00005990 E8A3000000          <1> 	CALL	_WAIT			; WAIT FOR SECTOR COMPLETE INTERRUPT
  7900 00005995 75B0                <1> 	JNZ	short TM_OUT		; ERROR RETURNED
  7901 00005997 E830010000          <1> 	CALL	CHECK_STATUS
  7902 0000599C 75A9                <1> 	JNZ	short CMD_ABORT
  7903 0000599E F605[C18A0100]08    <1> 	TEST	byte [HF_STATUS],ST_DRQ	; CHECK FOR MORE
  7904 000059A5 75B8                <1> 	JNZ	SHORT CMD_O1
  7905                              <1> 	;MOV	DX,HF_PORT+2		; CHECK RESIDUAL SECTOR COUNT
  7906 000059A7 668B15[006E0000]    <1> 	mov	dx, [HF_PORT]
  7907                              <1> 	;add	dl, 2
  7908 000059AE FEC2                <1> 	inc	dl
  7909 000059B0 FEC2                <1> 	inc	dl
  7910 000059B2 EC                  <1> 	IN	AL,DX			;
  7911 000059B3 A8FF                <1> 	TEST	AL,0FFH 		;
  7912 000059B5 7407                <1> 	JZ	short CMD_O4			; COUNT = 0  OK
  7913 000059B7 C605[CB8A0100]BB    <1> 	MOV	byte [DISK_STATUS1],UNDEF_ERR 
  7914                              <1> 					; OPERATION ABORTED - PARTIAL TRANSFER
  7915                              <1> CMD_O4:
  7916 000059BE C3                  <1> 	RETn
  7917                              <1> 
  7918                              <1> ;--------------------------------------------------------
  7919                              <1> ; COMMAND						:
  7920                              <1> ;	THIS ROUTINE OUTPUTS THE COMMAND BLOCK		:
  7921                              <1> ; OUTPUT						:
  7922                              <1> ;	BL = STATUS					:
  7923                              <1> ;	BH = ERROR REGISTER				:
  7924                              <1> ;--------------------------------------------------------
  7925                              <1> 
  7926                              <1> COMMAND:
  7927 000059BF 53                  <1> 	PUSH	eBX			; WAIT FOR SEEK COMPLETE AND READY
  7928                              <1> 	;;MOV	CX,DELAY_2		; SET INITIAL DELAY BEFORE TEST
  7929                              <1> COMMAND1:
  7930                              <1> 	;;PUSH	CX			; SAVE LOOP COUNT
  7931 000059C0 E879FEFFFF          <1> 	CALL	TST_RDY 		; CHECK DRIVE READY
  7932                              <1> 	;;POP	CX
  7933 000059C5 7419                <1> 	JZ	short COMMAND2		; DRIVE IS READY
  7934 000059C7 803D[CB8A0100]80    <1>         CMP     byte [DISK_STATUS1],TIME_OUT ; TST_RDY TIMED OUT--GIVE UP
  7935                              <1> 	;JZ	short CMD_TIMEOUT
  7936                              <1> 	;;LOOP	COMMAND1		; KEEP TRYING FOR A WHILE
  7937                              <1> 	;JMP	SHORT COMMAND4		; ITS NOT GOING TO GET READY
  7938 000059CE 7507                <1> 	jne	short COMMAND4
  7939                              <1> CMD_TIMEOUT:
  7940 000059D0 C605[CB8A0100]20    <1> 	MOV	byte [DISK_STATUS1],BAD_CNTLR
  7941                              <1> COMMAND4:
  7942 000059D7 5B                  <1> 	POP	eBX
  7943 000059D8 803D[CB8A0100]00    <1>         CMP     byte [DISK_STATUS1],0   ; SET CONDITION CODE FOR CALLER
  7944 000059DF C3                  <1> 	RETn
  7945                              <1> COMMAND2:
  7946 000059E0 5B                  <1> 	POP	eBX
  7947 000059E1 57                  <1> 	PUSH	eDI
  7948 000059E2 C605[C38A0100]00    <1> 	MOV	byte [HF_INT_FLAG],0	; RESET INTERRUPT FLAG
  7949 000059E9 FA                  <1> 	CLI				; INHIBIT INTERRUPTS WHILE CHANGING MASK
  7950 000059EA E4A1                <1> 	IN	AL,INTB01		; TURN ON SECOND INTERRUPT CHIP
  7951                              <1> 	;AND	AL,0BFH
  7952 000059EC 243F                <1> 	and	al, 3Fh			; Enable IRQ 14 & 15
  7953                              <1> 	;JMP	$+2
  7954                              <1> 	IODELAY
  2970 000059EE EB00                <2>  jmp short $+2
  2971 000059F0 EB00                <2>  jmp short $+2
  7955 000059F2 E6A1                <1> 	OUT	INTB01,AL
  7956 000059F4 E421                <1> 	IN	AL,INTA01		; LET INTERRUPTS PASS THRU TO
  7957 000059F6 24FB                <1> 	AND	AL,0FBH 		;  SECOND CHIP
  7958                              <1> 	;JMP	$+2
  7959                              <1> 	IODELAY
  2970 000059F8 EB00                <2>  jmp short $+2
  2971 000059FA EB00                <2>  jmp short $+2
  7960 000059FC E621                <1> 	OUT	INTA01,AL
  7961 000059FE FB                  <1> 	STI
  7962 000059FF 31FF                <1> 	XOR	eDI,eDI			; INDEX THE COMMAND TABLE
  7963                              <1> 	;MOV	DX,HF_PORT+1		; DISK ADDRESS
  7964 00005A01 668B15[006E0000]    <1> 	mov	dx, [HF_PORT]
  7965 00005A08 FEC2                <1> 	inc	dl
  7966 00005A0A F605[CD8A0100]C0    <1> 	TEST	byte [CONTROL_BYTE],0C0H ; CHECK FOR RETRY SUPPRESSION
  7967 00005A11 7411                <1> 	JZ	short COMMAND3
  7968 00005A13 8A45FE              <1> 	MOV	AL, [CMD_BLOCK+6] 	; YES-GET OPERATION CODE
  7969 00005A16 24F0                <1> 	AND	AL,0F0H 		; GET RID OF MODIFIERS
  7970 00005A18 3C20                <1> 	CMP	AL,20H			; 20H-40H IS READ, WRITE, VERIFY
  7971 00005A1A 7208                <1> 	JB	short COMMAND3
  7972 00005A1C 3C40                <1> 	CMP	AL,40H
  7973 00005A1E 7704                <1> 	JA	short COMMAND3
  7974 00005A20 804DFE01            <1> 	OR	byte [CMD_BLOCK+6],NO_RETRIES 
  7975                              <1> 					; VALID OPERATION FOR RETRY SUPPRESS
  7976                              <1> COMMAND3:
  7977 00005A24 8A443DF8            <1> 	MOV	AL,[CMD_BLOCK+eDI]	; GET THE COMMAND STRING BYTE
  7978 00005A28 EE                  <1> 	OUT	DX,AL			; GIVE IT TO CONTROLLER
  7979                              <1> 	IODELAY
  2970 00005A29 EB00                <2>  jmp short $+2
  2971 00005A2B EB00                <2>  jmp short $+2
  7980 00005A2D 47                  <1> 	INC	eDI			; NEXT BYTE IN COMMAND BLOCK
  7981 00005A2E 6642                <1> 	INC	DX			; NEXT DISK ADAPTER REGISTER
  7982 00005A30 6683FF07            <1> 	cmp	di, 7	; 1/1/2015	; ALL DONE?
  7983 00005A34 75EE                <1> 	JNZ	short COMMAND3		; NO--GO DO NEXT ONE
  7984 00005A36 5F                  <1> 	POP	eDI
  7985 00005A37 C3                  <1> 	RETn				; ZERO FLAG IS SET
  7986                              <1> 
  7987                              <1> ;CMD_TIMEOUT:
  7988                              <1> ;	MOV	byte [DISK_STATUS1],BAD_CNTLR
  7989                              <1> ;COMMAND4:
  7990                              <1> ;	POP	BX
  7991                              <1> ;	CMP	[DISK_STATUS1],0 	; SET CONDITION CODE FOR CALLER
  7992                              <1> ;	RETn
  7993                              <1> 
  7994                              <1> ;----------------------------------------
  7995                              <1> ;	WAIT FOR INTERRUPT		:
  7996                              <1> ;----------------------------------------
  7997                              <1> ;WAIT:
  7998                              <1> _WAIT:
  7999 00005A38 FB                  <1> 	STI				; MAKE SURE INTERRUPTS ARE ON
  8000                              <1> 	;SUB	CX,CX			; SET INITIAL DELAY BEFORE TEST
  8001                              <1> 	;CLC
  8002                              <1> 	;MOV	AX,9000H		; DEVICE WAIT INTERRUPT
  8003                              <1> 	;INT	15H
  8004                              <1> 	;JC	WT2			; DEVICE TIMED OUT
  8005                              <1> 	;MOV	BL,DELAY_1		; SET DELAY COUNT
  8006                              <1> 
  8007                              <1> 	;mov	bl, WAIT_HDU_INT_HI
  8008                              <1> 	;; 21/02/2015
  8009                              <1> 	;;mov	bl, WAIT_HDU_INT_HI + 1
  8010                              <1> 	;;mov	cx, WAIT_HDU_INT_LO
  8011 00005A39 B915160500          <1> 	mov	ecx, WAIT_HDU_INT_LH
  8012                              <1> 					; (AWARD BIOS -> WAIT_FOR_MEM)
  8013                              <1> ;-----	WAIT LOOP
  8014                              <1> 
  8015                              <1> WT1:	
  8016                              <1> 	;TEST	byte [HF_INT_FLAG],80H	; TEST FOR INTERRUPT
  8017 00005A3E F605[C38A0100]C0    <1> 	test 	byte [HF_INT_FLAG],0C0h
  8018                              <1> 	;LOOPZ	WT1
  8019 00005A45 7517                <1> 	JNZ	short WT3		; INTERRUPT--LETS GO
  8020                              <1> 	;DEC	BL
  8021                              <1> 	;JNZ	short WT1		; KEEP TRYING FOR A WHILE
  8022                              <1> 
  8023                              <1> WT1_hi:
  8024 00005A47 E461                <1> 	in	al, SYS1 ; 61h (PORT_B)	; wait for lo to hi
  8025 00005A49 A810                <1> 	test	al, 10h			; transition on memory
  8026 00005A4B 75FA                <1> 	jnz	short WT1_hi		; refresh.
  8027                              <1> WT1_lo:
  8028 00005A4D E461                <1> 	in	al, SYS1 		; 061h (PORT_B)	
  8029 00005A4F A810                <1> 	test	al, 10h			
  8030 00005A51 74FA                <1> 	jz	short WT1_lo
  8031 00005A53 E2E9                <1> 	loop	WT1
  8032                              <1> 	;;or	bl, bl
  8033                              <1> 	;;jz	short WT2	
  8034                              <1> 	;;dec	bl
  8035                              <1> 	;;jmp	short WT1
  8036                              <1> 	;dec	bl
  8037                              <1> 	;jnz	short WT1	
  8038                              <1> 
  8039 00005A55 C605[CB8A0100]80    <1> WT2:	MOV	byte [DISK_STATUS1],TIME_OUT ; REPORT TIME OUT ERROR
  8040 00005A5C EB0E                <1> 	JMP	SHORT WT4
  8041 00005A5E C605[CB8A0100]00    <1> WT3:	MOV	byte [DISK_STATUS1],0
  8042 00005A65 C605[C38A0100]00    <1> 	MOV	byte [HF_INT_FLAG],0
  8043 00005A6C 803D[CB8A0100]00    <1> WT4:	CMP	byte [DISK_STATUS1],0 	; SET CONDITION CODE FOR CALLER
  8044 00005A73 C3                  <1> 	RETn
  8045                              <1> 
  8046                              <1> ;----------------------------------------
  8047                              <1> ;	WAIT FOR CONTROLLER NOT BUSY	:
  8048                              <1> ;----------------------------------------
  8049                              <1> NOT_BUSY:
  8050 00005A74 FB                  <1> 	STI				; MAKE SURE INTERRUPTS ARE ON
  8051                              <1> 	;PUSH	eBX
  8052                              <1> 	;SUB	CX,CX			; SET INITIAL DELAY BEFORE TEST
  8053 00005A75 668B15[006E0000]    <1> 	mov	DX, [HF_PORT]
  8054 00005A7C 80C207              <1> 	add	dl, 7			; Status port (HF_PORT+7)
  8055                              <1> 	;MOV	BL,DELAY_1
  8056                              <1> 					; wait for 10 seconds
  8057                              <1> 	;mov 	cx, WAIT_HDU_INT_LO	; 1615h
  8058                              <1> 	;;mov 	bl, WAIT_HDU_INT_HI	;   05h
  8059                              <1> 	;mov	bl, WAIT_HDU_INT_HI + 1
  8060 00005A7F B915160500          <1> 	mov	ecx, WAIT_HDU_INT_LH  ; 21/02/2015
  8061                              <1> 	;
  8062                              <1> ;;      mov     byte [wait_count], 0    ; Reset wait counter
  8063                              <1> NB1:	
  8064 00005A84 EC                  <1> 	IN	AL,DX			; CHECK STATUS
  8065                              <1> 	;TEST	AL,ST_BUSY
  8066 00005A85 2480                <1> 	and	al, ST_BUSY
  8067                              <1> 	;LOOPNZ	NB1
  8068 00005A87 7410                <1> 	JZ	short NB2		; NOT BUSY--LETS GO
  8069                              <1> 	;DEC	BL			
  8070                              <1> 	;JNZ	short NB1		; KEEP TRYING FOR A WHILE
  8071                              <1> 
  8072 00005A89 E461                <1> NB1_hi: IN	AL,SYS1			; wait for hi to lo
  8073 00005A8B A810                <1> 	TEST	AL,010H			; transition on memory
  8074 00005A8D 75FA                <1> 	JNZ	SHORT NB1_hi		; refresh.
  8075 00005A8F E461                <1> NB1_lo: IN	AL,SYS1
  8076 00005A91 A810                <1> 	TEST	AL,010H
  8077 00005A93 74FA                <1> 	JZ	short NB1_lo
  8078 00005A95 E2ED                <1> 	LOOP	NB1
  8079                              <1> 	;dec	bl
  8080                              <1> 	;jnz	short NB1
  8081                              <1> 	;
  8082                              <1> ;;      cmp     byte [wait_count], 182  ; 10 seconds (182 timer ticks)
  8083                              <1> ;;	jb	short NB1
  8084                              <1> 	;
  8085                              <1> 	;MOV	[DISK_STATUS1],TIME_OUT	; REPORT TIME OUT ERROR
  8086                              <1> 	;JMP	SHORT NB3
  8087 00005A97 B080                <1> 	mov	al, TIME_OUT
  8088                              <1> NB2:	
  8089                              <1> 	;MOV	byte [DISK_STATUS1],0
  8090                              <1> ;NB3:	
  8091                              <1> 	;POP	eBX
  8092 00005A99 A2[CB8A0100]        <1> 	mov	[DISK_STATUS1], al	;;; will be set after return
  8093                              <1> 	;CMP	byte [DISK_STATUS1],0 	; SET CONDITION CODE FOR CALLER
  8094 00005A9E 08C0                <1> 	or	al, al			; (zf = 0 --> timeout)
  8095 00005AA0 C3                  <1> 	RETn
  8096                              <1> 
  8097                              <1> ;----------------------------------------
  8098                              <1> ;	WAIT FOR DATA REQUEST		:
  8099                              <1> ;----------------------------------------
  8100                              <1> WAIT_DRQ:
  8101                              <1> 	;MOV	CX,DELAY_3
  8102                              <1> 	;MOV	DX,HF_PORT+7
  8103 00005AA1 668B15[006E0000]    <1> 	mov	dx, [HF_PORT]
  8104 00005AA8 80C207              <1> 	add	dl, 7
  8105                              <1> 	;;MOV	bl, WAIT_HDU_DRQ_HI	; 0
  8106                              <1> 	;MOV	cx, WAIT_HDU_DRQ_LO	; 1000 (30 milli seconds)
  8107                              <1> 					; (but it is written as 2000
  8108                              <1> 					; micro seconds in ATORGS.ASM file
  8109                              <1> 					; of Award Bios - 1999, D1A0622)
  8110 00005AAB B9E8030000          <1> 	mov 	ecx, WAIT_HDU_DRQ_LH ; 21/02/2015 
  8111 00005AB0 EC                  <1> WQ_1:	IN	AL,DX			; GET STATUS
  8112 00005AB1 A808                <1> 	TEST	AL,ST_DRQ		; WAIT FOR DRQ
  8113 00005AB3 7516                <1> 	JNZ	short WQ_OK
  8114                              <1> 	;LOOP	WQ_1			; KEEP TRYING FOR A SHORT WHILE
  8115                              <1> WQ_hi:	
  8116 00005AB5 E461                <1> 	IN	AL,SYS1			; wait for hi to lo
  8117 00005AB7 A810                <1> 	TEST	AL,010H			; transition on memory
  8118 00005AB9 75FA                <1> 	JNZ	SHORT WQ_hi		; refresh.
  8119 00005ABB E461                <1> WQ_lo:  IN      AL,SYS1
  8120 00005ABD A810                <1> 	TEST	AL,010H
  8121 00005ABF 74FA                <1> 	JZ	SHORT WQ_lo
  8122 00005AC1 E2ED                <1> 	LOOP	WQ_1
  8123                              <1> 
  8124 00005AC3 C605[CB8A0100]80    <1>         MOV     byte [DISK_STATUS1],TIME_OUT ; ERROR
  8125 00005ACA F9                  <1> 	STC
  8126                              <1> WQ_OK:
  8127 00005ACB C3                  <1> 	RETn
  8128                              <1> ;WQ_OK:	;CLC
  8129                              <1> ;	RETn
  8130                              <1> 
  8131                              <1> ;----------------------------------------
  8132                              <1> ;	CHECK FIXED DISK STATUS 	:
  8133                              <1> ;----------------------------------------
  8134                              <1> CHECK_STATUS:
  8135 00005ACC E813000000          <1> 	CALL	CHECK_ST		; CHECK THE STATUS BYTE
  8136 00005AD1 7509                <1> 	JNZ	short CHECK_S1		; AN ERROR WAS FOUND
  8137 00005AD3 A801                <1> 	TEST	AL,ST_ERROR		; WERE THERE ANY OTHER ERRORS
  8138 00005AD5 7405                <1> 	JZ	short CHECK_S1		; NO ERROR REPORTED
  8139 00005AD7 E849000000          <1> 	CALL	CHECK_ER		; ERROR REPORTED
  8140                              <1> CHECK_S1:
  8141 00005ADC 803D[CB8A0100]00    <1> 	CMP	byte [DISK_STATUS1],0 	; SET STATUS FOR CALLER
  8142 00005AE3 C3                  <1> 	RETn
  8143                              <1> 
  8144                              <1> ;----------------------------------------
  8145                              <1> ;	CHECK FIXED DISK STATUS BYTE	:
  8146                              <1> ;----------------------------------------
  8147                              <1> CHECK_ST:
  8148                              <1> 	;MOV	DX,HF_PORT+7		; GET THE STATUS
  8149 00005AE4 668B15[006E0000]    <1> 	mov	dx, [HF_PORT]
  8150 00005AEB 80C207              <1> 	add	dl, 7
  8151                              <1> 	
  8152                              <1> 	; 17/02/2016
  8153                              <1> 	;(http://wiki.osdev.org/ATA_PIO_Mode)
  8154                              <1> 	;"delay 400ns to allow drive to set new values of BSY and DRQ"
  8155 00005AEE EC                  <1> 	IN	AL,DX
  8156                              <1> 	;in	al, dx ; 100ns
  8157                              <1> 	;in	al, dx ; 100ns
  8158                              <1>  	;in	al, dx ; 100ns
  8159                              <1> 	NEWIODELAY ; 18/02/2016 (AWARD BIOS - 1999, 'CKST' in AHSDK.ASM)
  2975 00005AEF E6EB                <2>  out 0ebh,al
  8160                              <1> 	;
  8161 00005AF1 A2[C18A0100]        <1> 	MOV	[HF_STATUS],AL
  8162 00005AF6 B400                <1> 	MOV	AH,0
  8163 00005AF8 A880                <1> 	TEST	AL,ST_BUSY		; IF STILL BUSY
  8164 00005AFA 751A                <1> 	JNZ	short CKST_EXIT		;  REPORT OK
  8165 00005AFC B4CC                <1> 	MOV	AH,WRITE_FAULT
  8166 00005AFE A820                <1> 	TEST	AL,ST_WRT_FLT		; CHECK FOR WRITE FAULT
  8167 00005B00 7514                <1> 	JNZ	short CKST_EXIT
  8168 00005B02 B4AA                <1> 	MOV	AH,NOT_RDY
  8169 00005B04 A840                <1> 	TEST	AL,ST_READY		; CHECK FOR NOT READY
  8170 00005B06 740E                <1> 	JZ	short CKST_EXIT
  8171 00005B08 B440                <1> 	MOV	AH,BAD_SEEK
  8172 00005B0A A810                <1> 	TEST	AL,ST_SEEK_COMPL	; CHECK FOR SEEK NOT COMPLETE
  8173 00005B0C 7408                <1> 	JZ	short CKST_EXIT
  8174 00005B0E B411                <1> 	MOV	AH,DATA_CORRECTED
  8175 00005B10 A804                <1> 	TEST	AL,ST_CORRCTD		; CHECK FOR CORRECTED ECC
  8176 00005B12 7502                <1> 	JNZ	short CKST_EXIT
  8177 00005B14 B400                <1> 	MOV	AH,0
  8178                              <1> CKST_EXIT:
  8179 00005B16 8825[CB8A0100]      <1> 	MOV	[DISK_STATUS1],AH	; SET ERROR FLAG
  8180 00005B1C 80FC11              <1> 	CMP	AH,DATA_CORRECTED	; KEEP GOING WITH DATA CORRECTED
  8181 00005B1F 7403                <1> 	JZ	short CKST_EX1
  8182 00005B21 80FC00              <1> 	CMP	AH,0
  8183                              <1> CKST_EX1:
  8184 00005B24 C3                  <1> 	RETn
  8185                              <1> 
  8186                              <1> ;----------------------------------------
  8187                              <1> ;	CHECK FIXED DISK ERROR REGISTER :
  8188                              <1> ;----------------------------------------
  8189                              <1> CHECK_ER:
  8190                              <1> 	;MOV	DX, HF_PORT+1		; GET THE ERROR REGISTER
  8191 00005B25 668B15[006E0000]    <1> 	mov	dx, [HF_PORT]		;
  8192 00005B2C FEC2                <1> 	inc	dl
  8193 00005B2E EC                  <1> 	IN	AL,DX
  8194 00005B2F A2[C28A0100]        <1> 	MOV	[HF_ERROR],AL
  8195 00005B34 53                  <1> 	PUSH	eBX ; 21/02/2015
  8196 00005B35 B908000000          <1> 	MOV	eCX,8			; TEST ALL 8 BITS
  8197 00005B3A D0E0                <1> CK1:	SHL	AL,1			; MOVE NEXT ERROR BIT TO CARRY
  8198 00005B3C 7202                <1> 	JC	short CK2		; FOUND THE ERROR
  8199 00005B3E E2FA                <1> 	LOOP	CK1			; KEEP TRYING
  8200 00005B40 BB[F46D0000]        <1> CK2:	MOV	eBX, ERR_TBL		; COMPUTE ADDRESS OF
  8201 00005B45 01CB                <1> 	ADD	eBX,eCX			; ERROR CODE
  8202                              <1> 	;;MOV	AH,BYTE [CS:BX]		; GET ERROR CODE
  8203                              <1> 	;mov	ah, [bx]
  8204 00005B47 8A23                <1> 	mov	ah, [ebx] ; 21/02/2015	
  8205 00005B49 8825[CB8A0100]      <1> CKEX:	MOV	[DISK_STATUS1],AH	; SAVE ERROR CODE
  8206 00005B4F 5B                  <1> 	POP	eBX
  8207 00005B50 80FC00              <1> 	CMP	AH,0
  8208 00005B53 C3                  <1> 	RETn
  8209                              <1> 
  8210                              <1> ;--------------------------------------------------------
  8211                              <1> ; CHECK_DMA						:
  8212                              <1> ;  -CHECK ES:BX AND # SECTORS TO MAKE SURE THAT IT WILL :
  8213                              <1> ;   FIT WITHOUT SEGMENT OVERFLOW.			:
  8214                              <1> ;  -ES:BX HAS BEEN REVISED TO THE FORMAT SSSS:000X	:
  8215                              <1> ;  -OK IF # SECTORS < 80H (7FH IF LONG READ OR WRITE)	:
  8216                              <1> ;  -OK IF # SECTORS = 80H (7FH) AND BX <= 00H (04H)	:
  8217                              <1> ;  -ERROR OTHERWISE					:
  8218                              <1> ;--------------------------------------------------------
  8219                              <1> CHECK_DMA:
  8220 00005B54 6650                <1> 	PUSH	AX			; SAVE REGISTERS
  8221 00005B56 66B80080            <1> 	MOV	AX,8000H		; AH = MAX # SECTORS AL = MAX OFFSET
  8222 00005B5A F645FE02            <1>         TEST    byte [CMD_BLOCK+6],ECC_MODE
  8223 00005B5E 7404                <1> 	JZ	short CKD1
  8224 00005B60 66B8047F            <1> 	MOV	AX,7F04H		; ECC IS 4 MORE BYTES
  8225 00005B64 3A65F9              <1> CKD1:	CMP	AH, [CMD_BLOCK+1] 	; NUMBER OF SECTORS
  8226 00005B67 7706                <1> 	JA	short CKDOK		; IT WILL FIT
  8227 00005B69 7208                <1> 	JB	short CKDERR		; TOO MANY
  8228 00005B6B 38D8                <1> 	CMP	AL,BL			; CHECK OFFSET ON MAX SECTORS
  8229 00005B6D 7204                <1> 	JB	short CKDERR		; ERROR
  8230 00005B6F F8                  <1> CKDOK:	CLC				; CLEAR CARRY
  8231 00005B70 6658                <1> 	POP	AX
  8232 00005B72 C3                  <1> 	RETn				; NORMAL RETURN
  8233 00005B73 F9                  <1> CKDERR: STC				; INDICATE ERROR
  8234 00005B74 C605[CB8A0100]09    <1>         MOV     byte [DISK_STATUS1],DMA_BOUNDARY
  8235 00005B7B 6658                <1> 	POP	AX
  8236 00005B7D C3                  <1> 	RETn
  8237                              <1> 
  8238                              <1> ;----------------------------------------
  8239                              <1> ;	SET UP ES:BX-> DISK PARMS	:
  8240                              <1> ;----------------------------------------
  8241                              <1> 					
  8242                              <1> ; INPUT -> DL = 0 based drive number
  8243                              <1> ; OUTPUT -> ES:BX = disk parameter table address
  8244                              <1> 
  8245                              <1> GET_VEC:
  8246                              <1> 	;SUB	AX,AX			; GET DISK PARAMETER ADDRESS
  8247                              <1> 	;MOV	ES,AX
  8248                              <1> 	;TEST	DL,1
  8249                              <1> 	;JZ	short GV_0
  8250                              <1> ;	LES	BX,[HF1_TBL_VEC] 	; ES:BX -> DRIVE PARAMETERS
  8251                              <1> ;	JMP	SHORT GV_EXIT
  8252                              <1> ;GV_0:
  8253                              <1> ;	LES	BX,[HF_TBL_VEC]		; ES:BX -> DRIVE PARAMETERS
  8254                              <1> ;
  8255                              <1> 	;xor	bh, bh
  8256 00005B7E 31DB                <1> 	xor	ebx, ebx
  8257 00005B80 88D3                <1> 	mov	bl, dl
  8258                              <1> 	;;02/01/2015
  8259                              <1> 	;;shl	bl, 1			; port address offset
  8260                              <1> 	;;mov	ax, [bx+hd_ports]	; Base port address (1F0h, 170h)
  8261                              <1> 	;;shl	bl, 1			; dpt pointer offset
  8262 00005B82 C0E302              <1> 	shl	bl, 2	;;
  8263                              <1> 	;add	bx, HF_TBL_VEC		; Disk parameter table pointer
  8264 00005B85 81C3[D08A0100]      <1> 	add	ebx, HF_TBL_VEC ; 21/02/2015
  8265                              <1> 	;push	word [bx+2]		; dpt segment
  8266                              <1> 	;pop	es
  8267                              <1> 	;mov	bx, [bx]		; dpt offset
  8268 00005B8B 8B1B                <1> 	mov	ebx, [ebx]		
  8269                              <1> ;GV_EXIT:
  8270 00005B8D C3                  <1> 	RETn
  8271                              <1> 
  8272                              <1> hdc1_int: ; 21/02/2015
  8273                              <1> ;--- HARDWARE INT 76H -- ( IRQ LEVEL  14 ) ----------------------
  8274                              <1> ;								:
  8275                              <1> ;	FIXED DISK INTERRUPT ROUTINE				:
  8276                              <1> ;								:
  8277                              <1> ;----------------------------------------------------------------
  8278                              <1> 
  8279                              <1> ; 22/12/2014
  8280                              <1> ; IBM PC-XT Model 286 System BIOS Source Code - DISK.ASM (HD_INT)
  8281                              <1> ;	 '11/15/85'
  8282                              <1> ; AWARD BIOS 1999 (D1A0622) 
  8283                              <1> ;	Source Code - ATORGS.ASM (INT_HDISK, INT_HDISK1)
  8284                              <1> 
  8285                              <1> ;int_76h:
  8286                              <1> HD_INT:
  8287 00005B8E 6650                <1> 	PUSH	AX
  8288 00005B90 1E                  <1> 	PUSH	DS
  8289                              <1> 	;CALL	DDS
  8290                              <1> 	; 21/02/2015 (32 bit, 386 pm modification)
  8291 00005B91 66B81000            <1> 	mov	ax, KDATA
  8292 00005B95 8ED8                <1> 	mov 	ds, ax
  8293                              <1> 	;
  8294                              <1> 	;;MOV	@HF_INT_FLAG,0FFH	; ALL DONE
  8295                              <1>         ;mov     byte [CS:HF_INT_FLAG], 0FFh
  8296 00005B97 C605[C38A0100]FF    <1> 	mov	byte [HF_INT_FLAG], 0FFh
  8297                              <1> 	;
  8298 00005B9E 6652                <1> 	push	dx
  8299 00005BA0 66BAF701            <1> 	mov	dx, HDC1_BASEPORT+7	; Status Register (1F7h)
  8300                              <1> 					; Clear Controller
  8301                              <1> Clear_IRQ1415:				; (Award BIOS - 1999)
  8302 00005BA4 EC                  <1> 	in	al, dx			;
  8303 00005BA5 665A                <1> 	pop	dx
  8304                              <1> 	NEWIODELAY
  2975 00005BA7 E6EB                <2>  out 0ebh,al
  8305                              <1> 	;
  8306 00005BA9 B020                <1> 	MOV	AL,EOI			; NON-SPECIFIC END OF INTERRUPT
  8307 00005BAB E6A0                <1> 	OUT	INTB00,AL		; FOR CONTROLLER #2
  8308                              <1> 	;JMP	$+2			; WAIT
  8309                              <1> 	NEWIODELAY
  2975 00005BAD E6EB                <2>  out 0ebh,al
  8310 00005BAF E620                <1> 	OUT	INTA00,AL		; FOR CONTROLLER #1
  8311 00005BB1 1F                  <1> 	POP	DS
  8312                              <1> 	;STI				; RE-ENABLE INTERRUPTS
  8313                              <1> 	;MOV	AX,9100H		; DEVICE POST
  8314                              <1> 	;INT	15H			;  INTERRUPT
  8315                              <1> irq15_iret: ; 25/02/2015
  8316 00005BB2 6658                <1> 	POP	AX
  8317 00005BB4 CF                  <1> 	IRETd				; RETURN FROM INTERRUPT
  8318                              <1> 
  8319                              <1> hdc2_int: ; 21/02/2015
  8320                              <1> ;++++ HARDWARE INT 77H ++ ( IRQ LEVEL  15 ) +++++++++++++++++++++
  8321                              <1> ;								:
  8322                              <1> ;	FIXED DISK INTERRUPT ROUTINE				:
  8323                              <1> ;								:
  8324                              <1> ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  8325                              <1> 
  8326                              <1> ;int_77h:
  8327                              <1> HD1_INT:
  8328 00005BB5 6650                <1> 	PUSH	AX
  8329                              <1> 	; Check if that is a spurious IRQ (from slave PIC)
  8330                              <1> 	; 25/02/2015 (source: http://wiki.osdev.org/8259_PIC)
  8331 00005BB7 B00B                <1> 	mov	al, 0Bh  ; In-Service Register
  8332 00005BB9 E6A0                <1> 	out	0A0h, al
  8333 00005BBB EB00                <1>         jmp short $+2
  8334 00005BBD EB00                <1> 	jmp short $+2
  8335 00005BBF E4A0                <1> 	in	al, 0A0h
  8336 00005BC1 2480                <1> 	and 	al, 80h ; bit 7 (is it real IRQ 15 or fake?)
  8337 00005BC3 74ED                <1> 	jz	short irq15_iret ; Fake (spurious)IRQ, do not send EOI)
  8338                              <1> 	;
  8339 00005BC5 1E                  <1> 	PUSH	DS
  8340                              <1> 	;CALL	DDS
  8341                              <1> 	; 21/02/2015 (32 bit, 386 pm modification)
  8342 00005BC6 66B81000            <1> 	mov	ax, KDATA
  8343 00005BCA 8ED8                <1> 	mov 	ds, ax
  8344                              <1> 	;
  8345                              <1> 	;;MOV	@HF_INT_FLAG,0FFH	; ALL DONE
  8346                              <1>         ;or      byte [CS:HF_INT_FLAG],0C0h 
  8347 00005BCC 800D[C38A0100]C0    <1> 	or	byte [HF_INT_FLAG], 0C0h
  8348                              <1> 	;
  8349 00005BD3 6652                <1> 	push	dx
  8350 00005BD5 66BA7701            <1> 	mov	dx, HDC2_BASEPORT+7	; Status Register (177h)
  8351                              <1> 					; Clear Controller (Award BIOS 1999)
  8352 00005BD9 EBC9                <1> 	jmp	short Clear_IRQ1415
  8353                              <1> 
  8354                              <1> 
  8355                              <1> ;%include 'diskdata.inc' ; 11/03/2015
  8356                              <1> ;%include 'diskbss.inc' ; 11/03/2015
  8357                              <1> 
  8358                              <1> 
  8359                              <1> ;////////////////////////////////////////////////////////////////////
  8360                              <1> ;; END OF DISK I/O SYTEM ///
  2895                                  %include 'memory.s'  ; 09/03/2015
  2896                              <1> ; ****************************************************************************
  2897                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.3 - memory.s
  2898                              <1> ; ----------------------------------------------------------------------------
  2899                              <1> ; Last Update: 15/12/2020
  2900                              <1> ; ----------------------------------------------------------------------------
  2901                              <1> ; Beginning: 24/01/2016
  2902                              <1> ; ----------------------------------------------------------------------------
  2903                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
  2904                              <1> ; ----------------------------------------------------------------------------
  2905                              <1> ; Turkish Rational DOS
  2906                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
  2907                              <1> ;
  2908                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
  2909                              <1> ; memory.inc (18/10/2015)
  2910                              <1> ; ****************************************************************************
  2911                              <1> 
  2912                              <1> ; MEMORY.ASM - Retro UNIX 386 v1 MEMORY MANAGEMENT FUNCTIONS (PROCEDURES)
  2913                              <1> ; Retro UNIX 386 v1 Kernel (unix386.s, v0.2.0.14) - MEMORY.INC
  2914                              <1> ; Last Modification: 18/10/2015
  2915                              <1> 
  2916                              <1> ; ///////// MEMORY MANAGEMENT FUNCTIONS (PROCEDURES) ///////////////
  2917                              <1> 
  2918                              <1> ;;04/11/2014 (unix386.s)	
  2919                              <1> ;PDE_A_PRESENT	equ	1		; Present flag for PDE
  2920                              <1> ;PDE_A_WRITE	equ 	2		; Writable (write permission) flag
  2921                              <1> ;PDE_A_USER	equ	4		; User (non-system/kernel) page flag
  2922                              <1> ;;
  2923                              <1> ;PTE_A_PRESENT	equ	1		; Present flag for PTE (bit 0)
  2924                              <1> ;PTE_A_WRITE	equ 	2		; Writable (write permission) flag (bit 1)
  2925                              <1> ;PTE_A_USER	equ	4		; User (non-system/kernel) page flag (bit 2)
  2926                              <1> ;PTE_A_ACCESS   equ	32		; Accessed flag (bit 5) ; 09/03/2015
  2927                              <1> 
  2928                              <1> ; 27/04/2015
  2929                              <1> ; 09/03/2015
  2930                              <1> PAGE_SIZE 	equ 4096		; page size in bytes
  2931                              <1> PAGE_SHIFT 	equ 12			; page table shift count
  2932                              <1> PAGE_D_SHIFT 	equ 22	; 12 + 10	; page directory shift count
  2933                              <1> PAGE_OFF	equ 0FFFh		; 12 bit byte offset in page frame
  2934                              <1> PTE_MASK 	equ 03FFh		; page table entry mask
  2935                              <1> PTE_DUPLICATED  equ 200h		; duplicated page sign (AVL bit 0)
  2936                              <1> PDE_A_CLEAR	equ 0F000h		; to clear PDE attribute bits
  2937                              <1> PTE_A_CLEAR	equ 0F000h		; to clear PTE attribute bits
  2938                              <1> LOGIC_SECT_SIZE equ 512			; logical sector size
  2939                              <1> ERR_MAJOR_PF	equ 0E0h		; major error: page fault
  2940                              <1> ERR_MINOR_IM	equ 4 ;15/10/2016 (1->4); insufficient (out of) memory
  2941                              <1> ERR_MINOR_PV	equ 6 ;15/10/2016 (1->4); protection violation
  2942                              <1> SWP_DISK_READ_ERR 	   equ 40
  2943                              <1> SWP_DISK_NOT_PRESENT_ERR   equ 41
  2944                              <1> SWP_SECTOR_NOT_PRESENT_ERR equ 42
  2945                              <1> SWP_NO_FREE_SPACE_ERR      equ 43
  2946                              <1> SWP_DISK_WRITE_ERR         equ 44
  2947                              <1> SWP_NO_PAGE_TO_SWAP_ERR    equ 45
  2948                              <1> PTE_A_ACCESS_BIT equ 5  ; Bit 5 (accessed flag)        
  2949                              <1> SECTOR_SHIFT     equ 3  ; sector shift (to convert page block number)
  2950                              <1> ; 12/07/2016
  2951                              <1> PTE_SHARED	 equ 400h		; AVL bit 1, direct memory access bit	
  2952                              <1> 					; (Indicates that the page is not allocated
  2953                              <1> 					; for the process, it is a shared or system
  2954                              <1>                                         ; page, it must not be deallocated!)
  2955                              <1> ; 14/12/2020
  2956                              <1> ; (Linear Frame Buffer - video memory mark : AVL bit 1, outside M.A.T.)
  2957                              <1> PDE_EXTERNAL	equ 400h	; Page directory entry for external memory blocks
  2958                              <1> PTE_EXTERNAL	equ 400h	; Allocated kernel pages for Linear Frame Buffer
  2959                              <1> 				; (Out of memory allocation table)	
  2960                              <1> 
  2961                              <1> ;
  2962                              <1> ;; Retro Unix 386 v1 - paging method/principles
  2963                              <1> ;;
  2964                              <1> ;; 10/10/2014
  2965                              <1> ;; RETRO UNIX 386 v1 - PAGING METHOD/PRINCIPLES
  2966                              <1> ;;
  2967                              <1> ;; KERNEL PAGE MAP: 1 to 1 physical memory page map
  2968                              <1> ;;	(virtual address = physical address)
  2969                              <1> ;; KERNEL PAGE TABLES:
  2970                              <1> ;;	Kernel page directory and all page tables are
  2971                              <1> ;;	on memory as initialized, as equal to physical memory
  2972                              <1> ;;	layout. Kernel pages can/must not be swapped out/in.
  2973                              <1> ;;
  2974                              <1> ;;	what for: User pages may be swapped out, when accessing
  2975                              <1> ;;	a page in kernel/system mode, if it would be swapped out,
  2976                              <1> ;;	kernel would have to swap it in! But it is also may be
  2977                              <1> ;;	in use by a user process. (In system/kernel mode
  2978                              <1> ;;	kernel can access all memory pages even if they are
  2979                              <1> ;;	reserved/allocated for user processes. Swap out/in would
  2980                              <1> ;;	cause conflicts.) 
  2981                              <1> ;;	
  2982                              <1> ;;	As result of these conditions,
  2983                              <1> ;;	all kernel pages must be initialized as equal to 
  2984                              <1> ;;	physical layout for preventing page faults. 
  2985                              <1> ;;	Also, calling "allocate page" procedure after
  2986                              <1> ;;	a page fault can cause another page fault (double fault)
  2987                              <1> ;;	if all kernel page tables would not be initialized.
  2988                              <1> ;;
  2989                              <1> ;;	[first_page] = Beginning of users space, as offset to 
  2990                              <1> ;;	memory allocation table. (double word aligned)
  2991                              <1> ;;
  2992                              <1> ;;	[next_page] = first/next free space to be searched
  2993                              <1> ;;	as offset to memory allocation table. (dw aligned)
  2994                              <1> ;;
  2995                              <1> ;;	[last_page] = End of memory (users space), as offset
  2996                              <1> ;;	to memory allocation table. (double word aligned)
  2997                              <1> ;;
  2998                              <1> ;; USER PAGE TABLES:
  2999                              <1> ;;	Demand paging (& 'copy on write' allocation method) ...
  3000                              <1> ;;		'ready only' marked copies of the 
  3001                              <1> ;;		parent process's page table entries (for
  3002                              <1> ;;		same physical memory).
  3003                              <1> ;;		(A page will be copied to a new page after
  3004                              <1> ;;		 if it causes R/W page fault.)
  3005                              <1> ;;
  3006                              <1> ;;	Every user process has own (different)
  3007                              <1> ;;	page directory and page tables.	
  3008                              <1> ;;
  3009                              <1> ;;	Code starts at virtual address 0, always.
  3010                              <1> ;;	(Initial value of EIP is 0 in user mode.)
  3011                              <1> ;;	(Programs can be written/developed as simple
  3012                              <1> ;;	 flat memory programs.)
  3013                              <1> ;;
  3014                              <1> ;; MEMORY ALLOCATION STRATEGY:
  3015                              <1> ;;	Memory page will be allocated by kernel only 
  3016                              <1> ;;		(in kernel/system mode only).
  3017                              <1> ;;	* After a
  3018                              <1> ;;	  - 'not present' page fault
  3019                              <1> ;;	  - 'writing attempt on read only page' page fault 	 	
  3020                              <1> ;;	* For loading (opening, reading) a file or disk/drive
  3021                              <1> ;;	* As responce to 'allocate additional memory blocks' 
  3022                              <1> ;;	  request by running process.
  3023                              <1> ;;	* While creating a process, allocating a new buffer,
  3024                              <1> ;;	  new page tables etc.
  3025                              <1> ;;
  3026                              <1> ;;	At first,
  3027                              <1> ;;	- 'allocate page' procedure will be called;
  3028                              <1> ;,	   if it will return with a valid (>0) physical address
  3029                              <1> ;;	   (that means the relevant M.A.T. bit has been RESET)	
  3030                              <1> ;;	   relevant memory page/block will be cleared (zeroed).
  3031                              <1> ;;	- 'allocate page' will be called for allocating page
  3032                              <1> ;;	   directory, page table and running space (data/code).
  3033                              <1> ;;	- every successful 'allocate page' call will decrease
  3034                              <1> ;;	  'free_pages' count (pointer).
  3035                              <1> ;;	- 'out of (insufficient) memory error' will be returned
  3036                              <1> ;;	  if 'free_pages' points to a ZERO.
  3037                              <1> ;;	- swapping out and swapping in (if it is not a new page)
  3038                              <1> ;;	  procedures will be called as responce to 'out of memory'
  3039                              <1> ;;	  error except errors caused by attribute conflicts.
  3040                              <1> ;;	 (swapper functions)	 
  3041                              <1> ;;					
  3042                              <1> ;;	At second,
  3043                              <1> ;;	- page directory entry will be updated then page table
  3044                              <1> ;;	  entry will be updated.		
  3045                              <1> ;;
  3046                              <1> ;; MEMORY ALLOCATION TABLE FORMAT:
  3047                              <1> ;;	- M.A.T. has a size according to available memory as
  3048                              <1> ;;	  follows:
  3049                              <1> ;;		  - 1 (allocation) bit per 1 page (4096 bytes)
  3050                              <1> ;;		  - a bit with value of 0 means allocated page
  3051                              <1> ;;		  - a bit with value of 1 means a free page
  3052                              <1> ;,	- 'free_pages' pointer holds count of free pages
  3053                              <1> ;;	  depending on M.A.T.
  3054                              <1> ;;		(NOTE: Free page count will not be checked
  3055                              <1> ;;		again -on M.A.T.- after initialization. 
  3056                              <1> ;;		Kernel will trust on initial count.)
  3057                              <1> ;,	- 'free_pages' count will be decreased by allocation
  3058                              <1> ;;	  and it will be increased by deallocation procedures.
  3059                              <1> ;;	
  3060                              <1> ;;	- Available memory will be calculated during
  3061                              <1> ;;	  the kernel's initialization stage (in real mode).
  3062                              <1> ;;	  Memory allocation table and kernel page tables 
  3063                              <1> ;;	  will be formatted/sized as result of available
  3064                              <1> ;;	  memory calculation before paging is enabled.
  3065                              <1> ;;
  3066                              <1> ;; For 4GB Available/Present Memory: (max. possible memory size)
  3067                              <1> ;;	- Memory Allocation Table size will be 128 KB.
  3068                              <1> ;;	- Memory allocation for kernel page directory size 
  3069                              <1> ;;	  is always 4 KB. (in addition to total allocation size
  3070                              <1> ;;	  for page tables)
  3071                              <1> ;;	- Memory allocation for kernel page tables (1024 tables)
  3072                              <1> ;;	  is 4 MB (1024*4*1024 bytes).
  3073                              <1> ;;	- User (available) space will be started 
  3074                              <1> ;;	  at 6th MB of the memory (after 1MB+4MB).
  3075                              <1> ;;	- The first 640 KB is for kernel's itself plus
  3076                              <1> ;;	  memory allocation table and kernel's page directory
  3077                              <1> ;;	  (D0000h-EFFFFh may be used as kernel space...)	
  3078                              <1> ;;	- B0000h to B7FFFh address space (32 KB) will be used
  3079                              <1> ;; 	  for buffers.
  3080                              <1> ;;	- ROMBIOS, VIDEO BUFFER and VIDEO ROM space are reserved.
  3081                              <1> ;,	  (A0000h-AFFFFh, C0000h-CFFFFh, F0000h-FFFFFh)
  3082                              <1> ;;	- Kernel page tables start at 100000h (2nd MB)
  3083                              <1> ;;
  3084                              <1> ;; For 1GB Available Memory:
  3085                              <1> ;;	- Memory Allocation Table size will be 32 KB.
  3086                              <1> ;;	- Memory allocation for kernel page directory size 
  3087                              <1> ;;	  is always 4 KB. (in addition to total allocation size
  3088                              <1> ;;	  for page tables)
  3089                              <1> ;;	- Memory allocation for kernel page tables (256 tables)
  3090                              <1> ;;	  is 1 MB (256*4*1024 bytes).
  3091                              <1> ;;	- User (available) space will be started 
  3092                              <1> ;;	  at 3th MB of the memory (after 1MB+1MB).
  3093                              <1> ;;	- The first 640 KB is for kernel's itself plus
  3094                              <1> ;;	  memory allocation table and kernel's page directory
  3095                              <1> ;;	  (D0000h-EFFFFh may be used as kernel space...)	
  3096                              <1> ;;	- B0000h to B7FFFh address space (32 KB) will be used
  3097                              <1> ;; 	  for buffers.
  3098                              <1> ;;	- ROMBIOS, VIDEO BUFFER and VIDEO ROM space are reserved.
  3099                              <1> ;,	  (A0000h-AFFFFh, C0000h-CFFFFh, F0000h-FFFFFh)
  3100                              <1> ;;	- Kernel page tables start at 100000h (2nd MB).	
  3101                              <1> ;;
  3102                              <1> ;;
  3103                              <1> 
  3104                              <1> 
  3105                              <1> ;;************************************************************************************
  3106                              <1> ;; 
  3107                              <1> ;; RETRO UNIX 386 v1 - Paging (Method for Copy On Write paging principle)
  3108                              <1> ;; DEMAND PAGING - PARENT&CHILD PAGE TABLE DUPLICATION PRINCIPLES (23/04/2015)
  3109                              <1> 
  3110                              <1> ;; Main factor: "sys fork" system call 
  3111                              <1> ;;	
  3112                              <1> ;; 		FORK
  3113                              <1> ;;                      |----> parent - duplicated PTEs, read only pages
  3114                              <1> ;;  writable pages ---->|
  3115                              <1> ;;                      |----> child - duplicated PTEs, read only pages
  3116                              <1> ;; 
  3117                              <1> ;; AVL bit (0) of Page Table Entry is used as duplication sign 
  3118                              <1> ;; 
  3119                              <1> ;; AVL Bit 0 [PTE Bit 9] = 'Duplicated PTE belongs to child' sign/flag (if it is set)
  3120                              <1> ;; Note: Dirty bit (PTE bit 6) may be used instead of AVL bit 0 (PTE bit 9)
  3121                              <1> ;;       -while R/W bit is 0-. 
  3122                              <1> ;; 
  3123                              <1> ;; Duplicate page tables with writable pages (the 1st sys fork in the process):
  3124                              <1> ;; # Parent's Page Table Entries are updated to point same pages as read only, 
  3125                              <1> ;;   as duplicated PTE bit  -AVL bit 0, PTE bit 9- are reset/clear.
  3126                              <1> ;; # Then Parent's Page Table is copied to Child's Page Table.
  3127                              <1> ;; # Child's Page Table Entries are updated as duplicated child bit
  3128                              <1> ;;   -AVL bit 0, PTE bit 9- is set.	  
  3129                              <1> ;; 
  3130                              <1> ;; Duplicate page tables with read only pages (several sys fork system calls):
  3131                              <1> ;; # Parent's read only pages are copied to new child pages. 
  3132                              <1> ;;   Parent's PTE attributes are not changed.
  3133                              <1> ;;   (Because, there is another parent-child fork before this fork! We must not
  3134                              <1> ;;    destroy/mix previous fork result).
  3135                              <1> ;; # Child's Page Table Entries (which are corresponding to Parent's 
  3136                              <1> ;;   read only pages) are set as writable (while duplicated PTE bit is clear). 
  3137                              <1> ;; # Parent's PTEs with writable page attribute are updated to point same pages 
  3138                              <1> ;;   as read only, (while) duplicated PTE bit is reset (clear).
  3139                              <1> ;; # Parent's Page Table Entries (with writable page attribute) are duplicated 
  3140                              <1> ;;   as Child's Page Table Entries without copying actual page.
  3141                              <1> ;; # Child 's Page Table Entries (which are corresponding to Parent's writable 
  3142                              <1> ;;   pages) are updated as duplicated PTE bit (AVL bit 0, PTE bit 9- is set.
  3143                              <1> ;; 
  3144                              <1> ;; !? WHAT FOR (duplication after duplication):
  3145                              <1> ;; In UNIX method for sys fork (a typical 'fork' application in /etc/init)
  3146                              <1> ;; program/executable code continues from specified location as child process, 
  3147                              <1> ;; returns back previous code location as parent process, every child after 
  3148                              <1> ;; every sys fork uses last image of code and data just prior the fork.
  3149                              <1> ;; Even if the parent code changes data, the child will not see the changed data 
  3150                              <1> ;; after the fork. In Retro UNIX 8086 v1, parent's process segment (32KB)
  3151                              <1> ;; was copied to child's process segment (all of code and data) according to
  3152                              <1> ;; original UNIX v1 which copies all of parent process code and data -core- 
  3153                              <1> ;; to child space -core- but swaps that core image -of child- on to disk.
  3154                              <1> ;; If I (Erdogan Tan) would use a method of to copy parent's core
  3155                              <1> ;; (complete running image of parent process) to the child process; 
  3156                              <1> ;; for big sizes, i would force Retro UNIX 386 v1 to spend many memory pages 
  3157                              <1> ;; and times only for a sys fork. (It would excessive reservation for sys fork,
  3158                              <1> ;; because sys fork usually is prior to sys exec; sys exec always establishes
  3159                              <1> ;; a new/fresh core -running space-, by clearing all code/data content). 
  3160                              <1> ;; 'Read Only' page flag ensures page fault handler is needed only for a few write
  3161                              <1> ;; attempts between sys fork and sys exec, not more... (I say so by thinking 
  3162                              <1> ;; of "/etc/init" content, specially.) sys exec will clear page tables and
  3163                              <1> ;; new/fresh pages will be used to load and run new executable/program.
  3164                              <1> ;; That is what for i have preferred "copy on write", "duplication" method
  3165                              <1> ;; for sharing same read only pages between parent and child processes.
  3166                              <1> ;; That is a pitty i have to use new private flag (AVL bit 0, "duplicated PTE 
  3167                              <1> ;; belongs to child" sign) for cooperation on duplicated pages between a parent 
  3168                              <1> ;; and it's child processes; otherwise parent process would destroy data belongs
  3169                              <1> ;; to its child or vice versa; or some pages would remain unclaimed 
  3170                              <1> ;; -deallocation problem-.
  3171                              <1> ;; Note: to prevent conflicts, read only pages must not be swapped out... 
  3172                              <1> ;; 
  3173                              <1> ;; WHEN PARENT TRIES TO WRITE IT'S READ ONLY (DUPLICATED) PAGE:
  3174                              <1> ;; # Page fault handler will do those:
  3175                              <1> ;;   - 'Duplicated PTE' flag (PTE bit 9) is checked (on the failed PTE).
  3176                              <1> ;;   - If it is reset/clear, there is a child uses same page.
  3177                              <1> ;;   - Parent's read only page -previous page- is copied to a new writable page. 
  3178                              <1> ;;   - Parent's PTE is updated as writable page, as unique page (AVL=0)
  3179                              <1> ;;   - (Page fault handler whill check this PTE later, if child process causes to
  3180                              <1> ;;     page fault due to write attempt on read only page. Of course, the previous 
  3181                              <1> ;;     read only page will be converted to writable and unique page which belongs
  3182                              <1> ;;     to child process.)	
  3183                              <1> ;; WHEN CHILD TRIES TO WRITE IT'S READ ONLY (DUPLICATED) PAGE:
  3184                              <1> ;; # Page fault handler will do those:
  3185                              <1> ;;   - 'Duplicated PTE' flag (PTE bit 9) is checked (on the failed PTE).
  3186                              <1> ;;   - If it is set, there is a parent uses -or was using- same page.
  3187                              <1> ;;   - Same PTE address within parent's page table is checked if it has same page
  3188                              <1> ;;     address or not. 
  3189                              <1> ;;   - If parent's PTE has same address, child will continue with a new writable page.
  3190                              <1> ;;     Parent's PTE will point to same (previous) page as writable, unique (AVL=0).	
  3191                              <1> ;;   - If parent's PTE has different address, child will continue with it's 
  3192                              <1> ;;     own/same page but read only flag (0) will be changed to writable flag (1) and
  3193                              <1> ;;     'duplicated PTE (belongs to child)' flag/sign will be cleared/reset. 	  	
  3194                              <1> ;; 
  3195                              <1> ;; NOTE: When a child process is terminated, read only flags of parent's page tables
  3196                              <1> ;;       will be set as writable (and unique) in case of child process was using 
  3197                              <1> ;;       same pages with duplicated child PTE sign... Depending on sys fork and 
  3198                              <1> ;;       duplication method details, it is not possible multiple child processes
  3199                              <1> ;;       were using same page with duplicated PTEs.
  3200                              <1> ;; 
  3201                              <1> ;;************************************************************************************   
  3202                              <1> 
  3203                              <1> ;; 08/10/2014
  3204                              <1> ;; 11/09/2014 - Retro UNIX 386 v1 PAGING (further) draft
  3205                              <1> ;;		by Erdogan Tan (Based on KolibriOS 'memory.inc')
  3206                              <1> 
  3207                              <1> ;; 'allocate_page' code is derived and modified from KolibriOS
  3208                              <1> ;; 'alloc_page' procedure in 'memory.inc' 
  3209                              <1> ;; (25/08/2014, Revision: 5057) file 
  3210                              <1> ;; by KolibriOS Team (2004-2012)
  3211                              <1> 
  3212                              <1> allocate_page:
  3213                              <1> 	; 01/07/2015
  3214                              <1> 	; 05/05/2015
  3215                              <1> 	; 30/04/2015
  3216                              <1> 	; 16/10/2014
  3217                              <1> 	; 08/10/2014
  3218                              <1> 	; 09/09/2014 (Retro UNIX 386 v1 - beginning)
  3219                              <1> 	;
  3220                              <1> 	; INPUT -> none
  3221                              <1> 	;
  3222                              <1> 	; OUTPUT ->
  3223                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF THE ALLOCATED PAGE
  3224                              <1> 	;	(corresponding MEMORY ALLOCATION TABLE bit is RESET)
  3225                              <1> 	;
  3226                              <1> 	;	CF = 1 and EAX = 0 
  3227                              <1> 	; 		   if there is not a free page to be allocated	
  3228                              <1> 	;
  3229                              <1> 	; Modified Registers -> none (except EAX)
  3230                              <1> 	;
  3231 00005BDB A1[388A0100]        <1> 	mov	eax, [free_pages]
  3232 00005BE0 21C0                <1> 	and	eax, eax
  3233 00005BE2 7438                <1> 	jz	short out_of_memory
  3234                              <1> 	;
  3235 00005BE4 53                  <1> 	push	ebx
  3236 00005BE5 51                  <1> 	push	ecx
  3237                              <1> 	;
  3238 00005BE6 BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL   ; Memory Allocation Table offset
  3239 00005BEB 89D9                <1> 	mov	ecx, ebx
  3240                              <1>  				     ; NOTE: 32 (first_page) is initial
  3241                              <1> 				     ; value of [next_page].
  3242                              <1> 				     ; It points to the first available
  3243                              <1> 				     ; page block for users (ring 3) ...	
  3244                              <1> 				     ; (MAT offset 32 = 1024/32)	
  3245                              <1> 				     ; (at the of the first 4 MB)		
  3246 00005BED 031D[3C8A0100]      <1> 	add	ebx, [next_page] ; Free page searching starts from here
  3247                              <1> 				 ; next_free_page >> 5
  3248 00005BF3 030D[408A0100]      <1> 	add	ecx, [last_page] ; Free page searching ends here
  3249                              <1> 				 ; (total_pages - 1) >> 5
  3250                              <1> al_p_scan:
  3251 00005BF9 39CB                <1> 	cmp	ebx, ecx
  3252 00005BFB 770A                <1> 	ja	short al_p_notfound
  3253                              <1> 	;
  3254                              <1> 	; 01/07/2015
  3255                              <1> 	; AMD64 Architecture Programmers Manual
  3256                              <1> 	; Volume 3:
  3257                              <1> 	; General-Purpose and System Instructions
  3258                              <1> 	;
  3259                              <1> 	; BSF - Bit Scan Forward
  3260                              <1> 	;
  3261                              <1> 	;   Searches the value in a register or a memory location
  3262                              <1> 	;   (second operand) for the least-significant set bit. 
  3263                              <1> 	;   If a set bit is found, the instruction clears the zero flag (ZF)
  3264                              <1> 	;   and stores the index of the least-significant set bit in a destination
  3265                              <1> 	;   register (first operand). If the second operand contains 0, 
  3266                              <1> 	;   the instruction sets ZF to 1 and does not change the contents of the 
  3267                              <1> 	;   destination register. The bit index is an unsigned offset from bit 0 
  3268                              <1> 	;   of the searched value
  3269                              <1> 	;
  3270 00005BFD 0FBC03              <1> 	bsf	eax, [ebx] ; Scans source operand for first bit set (1).
  3271                              <1> 			   ; Clear ZF if a bit is found set (1) and 
  3272                              <1> 			   ; loads the destination with an index to
  3273                              <1> 			   ; first set bit. (0 -> 31) 
  3274                              <1> 			   ; Sets ZF to 1 if no bits are found set.
  3275 00005C00 7525                <1> 	jnz	short al_p_found ; ZF = 0 -> a free page has been found
  3276                              <1> 			 ;
  3277                              <1> 			 ; NOTE:  a Memory Allocation Table bit 
  3278                              <1> 			 ;	  with value of 1 means 
  3279                              <1> 			 ;	  the corresponding page is free 
  3280                              <1> 			 ;	  (Retro UNIX 386 v1 feature only!)
  3281 00005C02 83C304              <1> 	add	ebx, 4
  3282                              <1> 			 ; We return back for searching next page block
  3283                              <1> 			 ; NOTE: [free_pages] is not ZERO; so, 
  3284                              <1> 			 ;	 we always will find at least 1 free page here.
  3285 00005C05 EBF2                <1>         jmp     short al_p_scan
  3286                              <1> 	;
  3287                              <1> al_p_notfound:
  3288 00005C07 81E900001000        <1> 	sub	ecx, MEM_ALLOC_TBL
  3289 00005C0D 890D[3C8A0100]      <1> 	mov	[next_page], ecx ; next/first free page = last page 
  3290                              <1> 				 ; (deallocate_page procedure will change it)
  3291 00005C13 31C0                <1> 	xor	eax, eax
  3292 00005C15 A3[388A0100]        <1> 	mov	[free_pages], eax ; 0
  3293 00005C1A 59                  <1> 	pop	ecx
  3294 00005C1B 5B                  <1> 	pop	ebx
  3295                              <1> 	;
  3296                              <1> out_of_memory:
  3297 00005C1C E85B040000          <1> 	call	swap_out
  3298 00005C21 7325                <1> 	jnc	short al_p_ok  ; [free_pages] = 0, re-allocation by swap_out
  3299                              <1> 	;
  3300 00005C23 29C0                <1> 	sub 	eax, eax ; 0
  3301 00005C25 F9                  <1> 	stc
  3302 00005C26 C3                  <1> 	retn
  3303                              <1> 
  3304                              <1> al_p_found:
  3305 00005C27 89D9                <1> 	mov	ecx, ebx
  3306 00005C29 81E900001000        <1> 	sub	ecx, MEM_ALLOC_TBL
  3307 00005C2F 890D[3C8A0100]      <1> 	mov	[next_page], ecx ; Set first free page searching start
  3308                              <1> 				 ; address/offset (to the next)
  3309 00005C35 FF0D[388A0100]      <1>         dec     dword [free_pages] ; 1 page has been allocated (X = X-1) 
  3310                              <1> 	;
  3311 00005C3B 0FB303              <1> 	btr	[ebx], eax	 ; The destination bit indexed by the source value
  3312                              <1> 				 ; is copied into the Carry Flag and then cleared
  3313                              <1> 				 ; in the destination.
  3314                              <1> 				 ;
  3315                              <1> 				 ; Reset the bit which is corresponding to the 
  3316                              <1> 				 ; (just) allocated page.
  3317                              <1> 	; 01/07/2015 (4*8 = 32, 1 allocation byte = 8 pages)	
  3318 00005C3E C1E103              <1> 	shl	ecx, 3		 ; (page block offset * 32) + page index
  3319 00005C41 01C8                <1> 	add	eax, ecx	 ; = page number
  3320 00005C43 C1E00C              <1> 	shl	eax, 12		 ; physical address of the page (flat/real value)
  3321                              <1> 	; EAX = physical address of memory page
  3322                              <1> 	;
  3323                              <1> 	; NOTE: The relevant page directory and page table entry will be updated
  3324                              <1> 	;       according to this EAX value...
  3325 00005C46 59                  <1> 	pop	ecx
  3326 00005C47 5B                  <1> 	pop	ebx
  3327                              <1> al_p_ok:
  3328 00005C48 C3                  <1> 	retn
  3329                              <1> 
  3330                              <1> 
  3331                              <1> make_page_dir:
  3332                              <1> 	; 18/04/2015
  3333                              <1> 	; 12/04/2015
  3334                              <1> 	; 23/10/2014
  3335                              <1> 	; 16/10/2014
  3336                              <1> 	; 09/10/2014 ; (Retro UNIX 386 v1 - beginning)
  3337                              <1> 	;
  3338                              <1> 	; INPUT ->
  3339                              <1> 	;	none
  3340                              <1> 	; OUTPUT ->
  3341                              <1> 	;	(EAX = 0)
  3342                              <1> 	;	cf = 1 -> insufficient (out of) memory error
  3343                              <1> 	;	cf = 0 ->
  3344                              <1> 	;	u.pgdir = page directory (physical) address of the current
  3345                              <1> 	;		  process/user.
  3346                              <1> 	;
  3347                              <1> 	; Modified Registers -> EAX
  3348                              <1> 	;
  3349 00005C49 E88DFFFFFF          <1> 	call	allocate_page
  3350 00005C4E 7216                <1> 	jc	short mkpd_error
  3351                              <1> 	;
  3352 00005C50 A3[B8030300]        <1> 	mov	[u.pgdir], eax    ; Page dir address for current user/process
  3353                              <1> 				  ; (Physical address)
  3354                              <1> clear_page:
  3355                              <1> 	; 18/04/2015
  3356                              <1> 	; 09/10/2014 ; (Retro UNIX 386 v1 - beginning)
  3357                              <1> 	;
  3358                              <1> 	; INPUT ->
  3359                              <1> 	;	EAX = physical address of the page
  3360                              <1> 	; OUTPUT ->
  3361                              <1> 	;	all bytes of the page will be cleared
  3362                              <1> 	;
  3363                              <1> 	; Modified Registers -> none
  3364                              <1> 	;
  3365 00005C55 57                  <1> 	push	edi
  3366 00005C56 51                  <1> 	push	ecx
  3367 00005C57 50                  <1> 	push	eax
  3368 00005C58 B900040000          <1> 	mov	ecx, PAGE_SIZE / 4
  3369 00005C5D 89C7                <1> 	mov	edi, eax
  3370 00005C5F 31C0                <1> 	xor	eax, eax
  3371 00005C61 F3AB                <1> 	rep	stosd
  3372 00005C63 58                  <1> 	pop	eax
  3373 00005C64 59                  <1> 	pop	ecx
  3374 00005C65 5F                  <1> 	pop	edi
  3375                              <1> mkpd_error:
  3376                              <1> mkpt_error:
  3377 00005C66 C3                  <1> 	retn
  3378                              <1> 
  3379                              <1> make_page_table:
  3380                              <1> 	; 23/06/2015
  3381                              <1> 	; 18/04/2015
  3382                              <1> 	; 12/04/2015
  3383                              <1> 	; 16/10/2014
  3384                              <1> 	; 09/10/2014 ; (Retro UNIX 386 v1 - beginning)
  3385                              <1> 	;
  3386                              <1> 	; INPUT ->
  3387                              <1> 	;	EBX = virtual (linear) address
  3388                              <1> 	;	ECX = page table attributes (lower 12 bits)
  3389                              <1> 	;	      (higher 20 bits must be ZERO)
  3390                              <1> 	;	      (bit 0 must be 1)	 
  3391                              <1> 	;	u.pgdir = page directory (physical) address
  3392                              <1> 	; OUTPUT ->
  3393                              <1> 	;	EDX = Page directory entry address
  3394                              <1> 	;	EAX = Page table address
  3395                              <1> 	;	cf = 1 -> insufficient (out of) memory error
  3396                              <1> 	;	cf = 0 -> page table address in the PDE (EDX)
  3397                              <1> 	;
  3398                              <1> 	; Modified Registers -> EAX, EDX
  3399                              <1> 	;
  3400 00005C67 E86FFFFFFF          <1> 	call	allocate_page
  3401 00005C6C 72F8                <1> 	jc	short mkpt_error
  3402 00005C6E E811000000          <1> 	call	set_pde	
  3403 00005C73 EBE0                <1> 	jmp	short clear_page
  3404                              <1> 
  3405                              <1> make_page:
  3406                              <1> 	; 24/07/2015
  3407                              <1> 	; 23/06/2015 ; (Retro UNIX 386 v1 - beginning)
  3408                              <1> 	;
  3409                              <1> 	; INPUT ->
  3410                              <1> 	;	EBX = virtual (linear) address
  3411                              <1> 	;	ECX = page attributes (lower 12 bits)
  3412                              <1> 	;	      (higher 20 bits must be ZERO)
  3413                              <1> 	;	      (bit 0 must be 1)	 
  3414                              <1> 	;	u.pgdir = page directory (physical) address
  3415                              <1> 	; OUTPUT ->
  3416                              <1> 	;	EBX = Virtual address
  3417                              <1> 	;	(EDX = PTE value)
  3418                              <1> 	;	EAX = Physical address
  3419                              <1> 	;	cf = 1 -> insufficient (out of) memory error
  3420                              <1> 	;
  3421                              <1> 	; Modified Registers -> EAX, EDX
  3422                              <1> 	;
  3423 00005C75 E861FFFFFF          <1> 	call	allocate_page
  3424 00005C7A 7207                <1> 	jc	short mkp_err
  3425 00005C7C E821000000          <1> 	call	set_pte	
  3426 00005C81 73D2                <1> 	jnc	short clear_page ; 18/04/2015
  3427                              <1> mkp_err:
  3428 00005C83 C3                  <1> 	retn
  3429                              <1> 
  3430                              <1> 
  3431                              <1> set_pde:	; Set page directory entry (PDE)
  3432                              <1> 	; 20/07/2015
  3433                              <1> 	; 18/04/2015
  3434                              <1> 	; 12/04/2015
  3435                              <1> 	; 23/10/2014
  3436                              <1> 	; 10/10/2014 ; (Retro UNIX 386 v1 - beginning)
  3437                              <1> 	;
  3438                              <1> 	; INPUT ->
  3439                              <1> 	;	EAX = physical address
  3440                              <1> 	;	      (use present value if EAX = 0)
  3441                              <1> 	;	EBX = virtual (linear) address
  3442                              <1> 	;	ECX = page table attributes (lower 12 bits)
  3443                              <1> 	;	      (higher 20 bits must be ZERO)
  3444                              <1> 	;	      (bit 0 must be 1)	 
  3445                              <1> 	;	u.pgdir = page directory (physical) address
  3446                              <1> 	; OUTPUT ->
  3447                              <1> 	;	EDX = PDE address
  3448                              <1> 	;	EAX = page table address (physical)
  3449                              <1> 	;	;(CF=1 -> Invalid page address)
  3450                              <1> 	;
  3451                              <1> 	; Modified Registers -> EDX
  3452                              <1> 	;
  3453 00005C84 89DA                <1> 	mov	edx, ebx
  3454 00005C86 C1EA16              <1> 	shr	edx, PAGE_D_SHIFT ; 22
  3455 00005C89 C1E202              <1> 	shl	edx, 2 ; offset to page directory (1024*4)
  3456 00005C8C 0315[B8030300]      <1> 	add	edx, [u.pgdir]
  3457                              <1> 	;
  3458 00005C92 21C0                <1> 	and	eax, eax
  3459 00005C94 7506                <1> 	jnz	short spde_1
  3460                              <1> 	;
  3461 00005C96 8B02                <1> 	mov	eax, [edx]  ; old PDE value
  3462                              <1> 	;test	al, 1
  3463                              <1> 	;jz	short spde_2
  3464 00005C98 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h  ; clear lower 12 bits
  3465                              <1> spde_1:
  3466                              <1> 	;and	cx, 0FFFh
  3467 00005C9C 8902                <1> 	mov	[edx], eax
  3468 00005C9E 66090A              <1> 	or	[edx], cx
  3469 00005CA1 C3                  <1> 	retn
  3470                              <1> ;spde_2: ; error
  3471                              <1> ;	stc
  3472                              <1> ;	retn
  3473                              <1> 
  3474                              <1> set_pte:	; Set page table entry (PTE)
  3475                              <1> 	; 24/07/2015
  3476                              <1> 	; 20/07/2015
  3477                              <1> 	; 23/06/2015
  3478                              <1> 	; 18/04/2015
  3479                              <1> 	; 12/04/2015
  3480                              <1> 	; 10/10/2014 ; (Retro UNIX 386 v1 - beginning)
  3481                              <1> 	;
  3482                              <1> 	; INPUT ->
  3483                              <1> 	;	EAX = physical page address
  3484                              <1> 	;	      (use present value if EAX = 0)
  3485                              <1> 	;	EBX = virtual (linear) address
  3486                              <1> 	;	ECX = page attributes (lower 12 bits)
  3487                              <1> 	;	      (higher 20 bits must be ZERO)
  3488                              <1> 	;	      (bit 0 must be 1)	 
  3489                              <1> 	;	u.pgdir = page directory (physical) address
  3490                              <1> 	; OUTPUT ->
  3491                              <1> 	;	EAX = physical page address
  3492                              <1> 	;	(EDX = PTE value)
  3493                              <1> 	;	EBX = virtual address
  3494                              <1> 	;
  3495                              <1> 	;	CF = 1 -> error
  3496                              <1> 	;
  3497                              <1> 	; Modified Registers -> EAX, EDX
  3498                              <1> 	;
  3499 00005CA2 50                  <1> 	push	eax
  3500 00005CA3 A1[B8030300]        <1> 	mov	eax, [u.pgdir] ; 20/07/2015
  3501 00005CA8 E837000000          <1> 	call 	get_pde
  3502                              <1> 		; EDX = PDE address
  3503                              <1> 		; EAX = PDE value
  3504 00005CAD 5A                  <1> 	pop	edx ; physical page address
  3505 00005CAE 722A                <1> 	jc	short spte_err ; PDE not present
  3506                              <1> 	;
  3507 00005CB0 53                  <1> 	push	ebx ; 24/07/2015
  3508 00005CB1 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 bits
  3509                              <1> 			    ; EDX = PT address (physical)	
  3510 00005CB5 C1EB0C              <1> 	shr	ebx, PAGE_SHIFT ; 12
  3511 00005CB8 81E3FF030000        <1> 	and	ebx, PTE_MASK	; 03FFh
  3512                              <1> 			 ; clear higher 10 bits (PD bits)
  3513 00005CBE C1E302              <1> 	shl	ebx, 2   ; offset to page table (1024*4)
  3514 00005CC1 01C3                <1> 	add	ebx, eax
  3515                              <1> 	;
  3516 00005CC3 8B03                <1> 	mov	eax, [ebx] ; Old PTE value
  3517 00005CC5 A801                <1> 	test	al, 1
  3518 00005CC7 740C                <1> 	jz	short spte_0
  3519 00005CC9 09D2                <1> 	or	edx, edx
  3520 00005CCB 750F                <1> 	jnz	short spte_1
  3521 00005CCD 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 bits
  3522 00005CD1 89C2                <1> 	mov	edx, eax
  3523 00005CD3 EB09                <1> 	jmp	short spte_2	
  3524                              <1> spte_0:
  3525                              <1> 	; If this PTE contains a swap (disk) address,
  3526                              <1> 	; it can be updated by using 'swap_in' procedure
  3527                              <1> 	; only!
  3528 00005CD5 21C0                <1> 	and	eax, eax
  3529 00005CD7 7403                <1> 	jz	short spte_1
  3530                              <1> 	; 24/07/2015
  3531                              <1> 	; swapped page ! (on disk)
  3532 00005CD9 5B                  <1> 	pop	ebx
  3533                              <1> spte_err:
  3534 00005CDA F9                  <1> 	stc
  3535 00005CDB C3                  <1> 	retn
  3536                              <1> spte_1: 
  3537 00005CDC 89D0                <1> 	mov	eax, edx
  3538                              <1> spte_2:
  3539 00005CDE 09CA                <1> 	or	edx, ecx
  3540                              <1> 	; 23/06/2015
  3541 00005CE0 8913                <1> 	mov	[ebx], edx ; PTE value in EDX
  3542                              <1> 	; 24/07/2015
  3543 00005CE2 5B                  <1> 	pop	ebx
  3544 00005CE3 C3                  <1> 	retn
  3545                              <1> 
  3546                              <1> get_pde:	; Get present value of the relevant PDE
  3547                              <1> 	; 20/07/2015
  3548                              <1> 	; 18/04/2015
  3549                              <1> 	; 12/04/2015
  3550                              <1> 	; 10/10/2014 ; (Retro UNIX 386 v1 - beginning)
  3551                              <1> 	;
  3552                              <1> 	; INPUT ->
  3553                              <1> 	;	EBX = virtual (linear) address
  3554                              <1> 	;	EAX = page directory (physical) address
  3555                              <1> 	; OUTPUT ->
  3556                              <1> 	;	EDX = Page directory entry address
  3557                              <1> 	;	EAX = Page directory entry value
  3558                              <1> 	;	CF = 1 -> PDE not present or invalid ? 
  3559                              <1> 	; Modified Registers -> EDX, EAX
  3560                              <1> 	;
  3561 00005CE4 89DA                <1> 	mov	edx, ebx
  3562 00005CE6 C1EA16              <1> 	shr	edx, PAGE_D_SHIFT ; 22  (12+10)
  3563 00005CE9 C1E202              <1> 	shl 	edx, 2 ; offset to page directory (1024*4)
  3564 00005CEC 01C2                <1> 	add	edx, eax ; page directory address (physical)
  3565 00005CEE 8B02                <1> 	mov	eax, [edx]
  3566 00005CF0 A801                <1> 	test	al, PDE_A_PRESENT ; page table is present or not !
  3567 00005CF2 751F                <1> 	jnz	short gpte_retn
  3568 00005CF4 F9                  <1> 	stc
  3569                              <1> gpde_retn:	
  3570 00005CF5 C3                  <1> 	retn
  3571                              <1> 
  3572                              <1> get_pte:
  3573                              <1> 		; Get present value of the relevant PTE
  3574                              <1> 	; 29/07/2015
  3575                              <1> 	; 20/07/2015
  3576                              <1> 	; 18/04/2015
  3577                              <1> 	; 12/04/2015
  3578                              <1> 	; 10/10/2014 ; (Retro UNIX 386 v1 - beginning)
  3579                              <1> 	;
  3580                              <1> 	; INPUT ->
  3581                              <1> 	;	EBX = virtual (linear) address
  3582                              <1> 	;	EAX = page directory (physical) address
  3583                              <1> 	; OUTPUT ->
  3584                              <1> 	;	EDX = Page table entry address (if CF=0)
  3585                              <1> 	;	      Page directory entry address (if CF=1)
  3586                              <1> 	;            (Bit 0 value is 0 if PT is not present)
  3587                              <1> 	;	EAX = Page table entry value (page address)
  3588                              <1> 	;	CF = 1 -> PDE not present or invalid ? 
  3589                              <1> 	; Modified Registers -> EAX, EDX
  3590                              <1> 	;
  3591 00005CF6 E8E9FFFFFF          <1> 	call 	get_pde
  3592 00005CFB 72F8                <1> 	jc	short gpde_retn	; page table is not present
  3593                              <1> 	;jnc	short gpte_1
  3594                              <1> 	;retn
  3595                              <1> ;gpte_1:
  3596 00005CFD 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 bits
  3597 00005D01 89DA                <1> 	mov	edx, ebx
  3598 00005D03 C1EA0C              <1> 	shr	edx, PAGE_SHIFT ; 12
  3599 00005D06 81E2FF030000        <1> 	and	edx, PTE_MASK	; 03FFh
  3600                              <1> 			 ; clear higher 10 bits (PD bits)
  3601 00005D0C C1E202              <1> 	shl	edx, 2 ; offset from start of page table (1024*4)
  3602 00005D0F 01C2                <1> 	add	edx, eax
  3603 00005D11 8B02                <1> 	mov	eax, [edx]
  3604                              <1> gpte_retn:
  3605 00005D13 C3                  <1> 	retn
  3606                              <1> 
  3607                              <1> deallocate_page_dir:
  3608                              <1> 	; 15/09/2015
  3609                              <1> 	; 05/08/2015
  3610                              <1> 	; 30/04/2015
  3611                              <1> 	; 28/04/2015
  3612                              <1> 	; 17/10/2014
  3613                              <1> 	; 12/10/2014 (Retro UNIX 386 v1 - beginning)
  3614                              <1> 	;
  3615                              <1> 	; INPUT ->
  3616                              <1> 	;	EAX = PHYSICAL ADDRESS OF THE PAGE DIRECTORY (CHILD)
  3617                              <1> 	;	EBX = PHYSICAL ADDRESS OF THE PARENT'S PAGE DIRECTORY
  3618                              <1> 	; OUTPUT ->
  3619                              <1> 	;	All of page tables in the page directory
  3620                              <1> 	;	and page dir's itself will be deallocated
  3621                              <1> 	;	except 'read only' duplicated pages (will be converted
  3622                              <1> 	;	to writable pages).
  3623                              <1> 	;
  3624                              <1> 	; Modified Registers -> EAX
  3625                              <1> 	;
  3626                              <1> 	;
  3627 00005D14 56                  <1> 	push	esi
  3628 00005D15 51                  <1> 	push	ecx
  3629 00005D16 50                  <1> 	push	eax
  3630 00005D17 89C6                <1> 	mov	esi, eax 
  3631 00005D19 31C9                <1> 	xor	ecx, ecx
  3632                              <1> 	; The 1st PDE points to Kernel Page Table 0 (the 1st 4MB),
  3633                              <1> 	; it must not be deallocated
  3634 00005D1B 890E                <1> 	mov	[esi], ecx ; 0 ; clear PDE 0
  3635                              <1> dapd_0:
  3636 00005D1D AD                  <1> 	lodsd
  3637 00005D1E A801                <1> 	test	al, PDE_A_PRESENT ; bit 0, present flag (must be 1)
  3638 00005D20 7409                <1> 	jz	short dapd_1	
  3639 00005D22 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
  3640 00005D26 E812000000          <1> 	call	deallocate_page_table			
  3641                              <1> dapd_1:
  3642 00005D2B 41                  <1> 	inc	ecx ; page directory entry index
  3643 00005D2C 81F900040000        <1> 	cmp	ecx, PAGE_SIZE / 4 ; 1024
  3644 00005D32 72E9                <1> 	jb	short dapd_0
  3645                              <1> dapd_2:
  3646 00005D34 58                  <1> 	pop	eax
  3647 00005D35 E87F000000          <1> 	call	deallocate_page	; deallocate the page dir's itself
  3648 00005D3A 59                  <1> 	pop	ecx
  3649 00005D3B 5E                  <1> 	pop	esi
  3650 00005D3C C3                  <1> 	retn
  3651                              <1> 
  3652                              <1> deallocate_page_table:
  3653                              <1> 	; 12/07/2016
  3654                              <1> 	; 19/09/2015
  3655                              <1> 	; 15/09/2015
  3656                              <1> 	; 05/08/2015
  3657                              <1> 	; 30/04/2015
  3658                              <1> 	; 28/04/2015
  3659                              <1> 	; 24/10/2014
  3660                              <1> 	; 23/10/2014
  3661                              <1> 	; 12/10/2014 (Retro UNIX 386 v1 - beginning)
  3662                              <1> 	;
  3663                              <1> 	; INPUT ->
  3664                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF THE PAGE TABLE
  3665                              <1> 	;	EBX = PHYSICAL ADDRESS OF THE PARENT'S PAGE DIRECTORY
  3666                              <1> 	;	(ECX = page directory entry index)
  3667                              <1> 	; OUTPUT ->
  3668                              <1> 	;	All of pages in the page table and page table's itself
  3669                              <1> 	;	will be deallocated except 'read only' duplicated pages
  3670                              <1> 	;	(will be converted to writable pages).
  3671                              <1> 	;
  3672                              <1> 	; Modified Registers -> EAX
  3673                              <1> 	;
  3674 00005D3D 56                  <1> 	push	esi
  3675 00005D3E 57                  <1> 	push	edi
  3676 00005D3F 52                  <1> 	push	edx
  3677 00005D40 50                  <1> 	push	eax ; *
  3678 00005D41 89C6                <1> 	mov	esi, eax 
  3679 00005D43 31FF                <1> 	xor	edi, edi ; 0
  3680                              <1> dapt_0:
  3681 00005D45 AD                  <1> 	lodsd
  3682 00005D46 A801                <1> 	test	al, PTE_A_PRESENT ; bit 0, present flag (must be 1)
  3683 00005D48 7441                <1> 	jz	short dapt_1
  3684                              <1> 	;
  3685 00005D4A A802                <1> 	test	al, PTE_A_WRITE   ; bit 1, writable (r/w) flag
  3686                              <1> 				  ; (must be 1)
  3687 00005D4C 754C                <1> 	jnz	short dapt_3
  3688                              <1> 	; Read only -duplicated- page (belongs to a parent or a child)
  3689 00005D4E 66A90002            <1>         test    ax, PTE_DUPLICATED ; Was this page duplicated 
  3690                              <1> 				   ; as child's page ?
  3691 00005D52 7451                <1> 	jz	short dapt_4 ; Clear PTE but don't deallocate the page!
  3692                              <1> 	; check the parent's PTE value is read only & same page or not.. 
  3693                              <1> 	; ECX = page directory entry index (0-1023)
  3694 00005D54 53                  <1> 	push	ebx
  3695 00005D55 51                  <1> 	push	ecx
  3696 00005D56 66C1E102            <1> 	shl	cx, 2 ; *4 
  3697 00005D5A 01CB                <1> 	add	ebx, ecx ; PDE offset (for the parent)
  3698 00005D5C 8B0B                <1> 	mov	ecx, [ebx]
  3699 00005D5E F6C101              <1> 	test	cl, PDE_A_PRESENT ; present (valid) or not ?
  3700 00005D61 7435                <1> 	jz	short dapt_2	; parent process does not use this page
  3701 00005D63 6681E100F0          <1> 	and	cx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
  3702                              <1> 	; EDI = page table entry index (0-1023)
  3703 00005D68 89FA                <1> 	mov	edx, edi 
  3704 00005D6A 66C1E202            <1> 	shl	dx, 2 ; *4 
  3705 00005D6E 01CA                <1> 	add	edx, ecx ; PTE offset (for the parent)
  3706 00005D70 8B1A                <1> 	mov	ebx, [edx]
  3707 00005D72 F6C301              <1> 	test	bl, PTE_A_PRESENT ; present or not ?
  3708 00005D75 7421                <1> 	jz	short dapt_2	; parent process does not use this page
  3709 00005D77 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; Clear attribute bits 
  3710 00005D7B 6681E300F0          <1> 	and	bx, PTE_A_CLEAR ; 0F000h ; Clear attribute bits
  3711 00005D80 39D8                <1> 	cmp	eax, ebx	; parent's and child's pages are same ?
  3712 00005D82 7514                <1> 	jne	short dapt_2	; not same page
  3713                              <1> 				; deallocate the child's page
  3714 00005D84 800A02              <1>         or      byte [edx], PTE_A_WRITE ; convert to writable page (parent)
  3715 00005D87 59                  <1> 	pop	ecx
  3716 00005D88 5B                  <1> 	pop	ebx
  3717 00005D89 EB1A                <1> 	jmp	short dapt_4
  3718                              <1> dapt_1:
  3719 00005D8B 09C0                <1> 	or	eax, eax	; swapped page ?
  3720 00005D8D 741D                <1> 	jz	short dapt_5	; no
  3721                              <1> 				; yes
  3722 00005D8F D1E8                <1> 	shr	eax, 1
  3723 00005D91 E8CA040000          <1> 	call	unlink_swap_block ; Deallocate swapped page block
  3724                              <1> 				  ; on the swap disk (or in file)
  3725 00005D96 EB14                <1> 	jmp	short dapt_5
  3726                              <1> dapt_2:
  3727 00005D98 59                  <1> 	pop	ecx
  3728 00005D99 5B                  <1> 	pop	ebx
  3729                              <1> dapt_3:	
  3730                              <1> 	; 12/07/2016
  3731 00005D9A 66A90004            <1> 	test	ax, PTE_SHARED ; shared or direct memory access indicator
  3732 00005D9E 7505                <1> 	jnz	short dapt_4   ; AVL bit 1 = 1, do not deallocate this page!
  3733                              <1> 	;
  3734                              <1> 	;and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
  3735 00005DA0 E814000000          <1> 	call	deallocate_page ; set the mem allocation bit of this page
  3736                              <1> dapt_4:
  3737 00005DA5 C746FC00000000      <1> 	mov	dword [esi-4], 0 ; clear/reset PTE (child, dupl. as parent)
  3738                              <1> dapt_5:
  3739 00005DAC 47                  <1> 	inc	edi ; page table entry index
  3740 00005DAD 81FF00040000        <1> 	cmp	edi, PAGE_SIZE / 4 ; 1024
  3741 00005DB3 7290                <1> 	jb	short dapt_0
  3742                              <1> 	;
  3743 00005DB5 58                  <1> 	pop	eax ; *
  3744 00005DB6 5A                  <1> 	pop	edx
  3745 00005DB7 5F                  <1> 	pop	edi	
  3746 00005DB8 5E                  <1> 	pop	esi
  3747                              <1> 	;
  3748                              <1> 	;call	deallocate_page	; deallocate the page table's itself
  3749                              <1> 	;retn
  3750                              <1> 
  3751                              <1> deallocate_page:
  3752                              <1> 	; 15/09/2015
  3753                              <1> 	; 28/04/2015
  3754                              <1> 	; 10/03/2015
  3755                              <1> 	; 17/10/2014
  3756                              <1> 	; 12/10/2014 (Retro UNIX 386 v1 - beginning)
  3757                              <1> 	;
  3758                              <1> 	; INPUT -> 
  3759                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF THE ALLOCATED PAGE
  3760                              <1> 	; OUTPUT ->
  3761                              <1> 	;	[free_pages] is increased
  3762                              <1> 	;	(corresponding MEMORY ALLOCATION TABLE bit is SET)
  3763                              <1> 	;	CF = 1 if the page is already deallocated
  3764                              <1> 	; 	       (or not allocated) before.  
  3765                              <1> 	;
  3766                              <1> 	; Modified Registers -> EAX
  3767                              <1> 	;
  3768 00005DB9 53                  <1> 	push	ebx
  3769 00005DBA 52                  <1> 	push	edx
  3770                              <1> 	;
  3771 00005DBB C1E80C              <1> 	shr	eax, PAGE_SHIFT      ; shift physical address to 
  3772                              <1> 				     ; 12 bits right
  3773                              <1> 				     ; to get page number
  3774 00005DBE 89C2                <1> 	mov	edx, eax
  3775                              <1> 	; 15/09/2015
  3776 00005DC0 C1EA03              <1> 	shr	edx, 3		     ; to get offset to M.A.T.
  3777                              <1> 				     ; (1 allocation bit = 1 page)
  3778                              <1> 				     ; (1 allocation bytes = 8 pages)
  3779 00005DC3 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
  3780                              <1> 				     ; (to get 32 bit position)			
  3781                              <1> 	;
  3782 00005DC6 BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL   ; Memory Allocation Table address
  3783 00005DCB 01D3                <1> 	add	ebx, edx
  3784 00005DCD 83E01F              <1> 	and	eax, 1Fh	     ; lower 5 bits only
  3785                              <1> 				     ; (allocation bit position)	 
  3786 00005DD0 3B15[3C8A0100]      <1> 	cmp 	edx, [next_page]     ; is the new free page address lower
  3787                              <1> 				     ; than the address in 'next_page' ?
  3788                              <1> 				     ; (next/first free page value)		
  3789 00005DD6 7306                <1> 	jnb	short dap_1	     ; no	
  3790 00005DD8 8915[3C8A0100]      <1> 	mov	[next_page], edx     ; yes
  3791                              <1> dap_1:
  3792 00005DDE 0FAB03              <1> 	bts	[ebx], eax	     ; unlink/release/deallocate page
  3793                              <1> 				     ; set relevant bit to 1.
  3794                              <1> 				     ; set CF to the previous bit value	
  3795                              <1> 	;cmc			     ; complement carry flag	
  3796                              <1> 	;jc	short dap_2	     ; do not increase free_pages count
  3797                              <1> 				     ; if the page is already deallocated
  3798                              <1> 				     ; before.	
  3799 00005DE1 FF05[388A0100]      <1>         inc     dword [free_pages]
  3800                              <1> dap_2:
  3801 00005DE7 5A                  <1> 	pop	edx
  3802 00005DE8 5B                  <1> 	pop	ebx
  3803 00005DE9 C3                  <1> 	retn
  3804                              <1> 
  3805                              <1> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3806                              <1> ;;                                                              ;;
  3807                              <1> ;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
  3808                              <1> ;; Distributed under terms of the GNU General Public License    ;;
  3809                              <1> ;;                                                              ;;
  3810                              <1> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3811                              <1> 
  3812                              <1> ;;$Revision: 5057 $
  3813                              <1> 
  3814                              <1> 
  3815                              <1> ;;align 4
  3816                              <1> ;;proc alloc_page
  3817                              <1> 
  3818                              <1> ;;        pushfd
  3819                              <1> ;;        cli
  3820                              <1> ;;        push    ebx
  3821                              <1> ;;;//-
  3822                              <1> ;;        cmp     [pg_data.pages_free], 1
  3823                              <1> ;;        jle     .out_of_memory
  3824                              <1> ;;;//-
  3825                              <1> ;;
  3826                              <1> ;;        mov     ebx, [page_start]
  3827                              <1> ;;        mov     ecx, [page_end]
  3828                              <1> ;;.l1:
  3829                              <1> ;;        bsf     eax, [ebx];
  3830                              <1> ;;        jnz     .found
  3831                              <1> ;;        add     ebx, 4
  3832                              <1> ;;        cmp     ebx, ecx
  3833                              <1> ;;        jb      .l1
  3834                              <1> ;;        pop     ebx
  3835                              <1> ;;        popfd
  3836                              <1> ;;        xor     eax, eax
  3837                              <1> ;;        ret
  3838                              <1> ;;.found:
  3839                              <1> ;;;//-
  3840                              <1> ;;        dec     [pg_data.pages_free]
  3841                              <1> ;;        jz      .out_of_memory
  3842                              <1> ;;;//-
  3843                              <1> ;;        btr     [ebx], eax
  3844                              <1> ;;        mov     [page_start], ebx
  3845                              <1> ;;        sub     ebx, sys_pgmap
  3846                              <1> ;;        lea     eax, [eax+ebx*8]
  3847                              <1> ;;        shl     eax, 12
  3848                              <1> ;;;//-       dec [pg_data.pages_free]
  3849                              <1> ;;        pop     ebx
  3850                              <1> ;;        popfd
  3851                              <1> ;;        ret
  3852                              <1> ;;;//-
  3853                              <1> ;;.out_of_memory:
  3854                              <1> ;;        mov     [pg_data.pages_free], 1
  3855                              <1> ;;        xor     eax, eax
  3856                              <1> ;;        pop     ebx
  3857                              <1> ;;        popfd
  3858                              <1> ;;        ret
  3859                              <1> ;;;//-
  3860                              <1> ;;endp
  3861                              <1> 
  3862                              <1> duplicate_page_dir:
  3863                              <1> 	; 21/09/2015
  3864                              <1> 	; 31/08/2015
  3865                              <1> 	; 20/07/2015
  3866                              <1> 	; 28/04/2015
  3867                              <1> 	; 27/04/2015
  3868                              <1> 	; 18/04/2015
  3869                              <1> 	; 12/04/2015
  3870                              <1> 	; 18/10/2014
  3871                              <1> 	; 16/10/2014 (Retro UNIX 386 v1 - beginning)
  3872                              <1> 	;
  3873                              <1> 	; INPUT -> 
  3874                              <1> 	;	[u.pgdir] = PHYSICAL (real/flat) ADDRESS of the parent's
  3875                              <1> 	;		    page directory.
  3876                              <1> 	; OUTPUT ->
  3877                              <1> 	;	EAX =  PHYSICAL (real/flat) ADDRESS of the child's
  3878                              <1> 	;	       page directory.
  3879                              <1> 	;	(New page directory with new page table entries.)
  3880                              <1> 	;	(New page tables with read only copies of the parent's
  3881                              <1> 	;	pages.)
  3882                              <1> 	;	EAX = 0 -> Error (CF = 1)
  3883                              <1> 	;
  3884                              <1> 	; Modified Registers -> none (except EAX)
  3885                              <1> 	;
  3886 00005DEA E8ECFDFFFF          <1> 	call	allocate_page
  3887 00005DEF 723E                <1> 	jc	short dpd_err
  3888                              <1> 	;
  3889 00005DF1 55                  <1> 	push	ebp ; 20/07/2015
  3890 00005DF2 56                  <1> 	push	esi
  3891 00005DF3 57                  <1> 	push	edi
  3892 00005DF4 53                  <1> 	push	ebx
  3893 00005DF5 51                  <1> 	push	ecx
  3894 00005DF6 8B35[B8030300]      <1> 	mov	esi, [u.pgdir]
  3895 00005DFC 89C7                <1> 	mov	edi, eax
  3896 00005DFE 50                  <1> 	push	eax ; save child's page directory address
  3897                              <1> 	; 31/08/2015
  3898                              <1> 	; copy PDE 0 from the parent's page dir to the child's page dir
  3899                              <1> 	; (use same system space for all user page tables) 
  3900 00005DFF A5                  <1> 	movsd
  3901 00005E00 BD00004000          <1> 	mov	ebp, 1024*4096 ; pass the 1st 4MB (system space)
  3902 00005E05 B9FF030000          <1> 	mov	ecx, (PAGE_SIZE / 4) - 1 ; 1023
  3903                              <1> dpd_0:	
  3904 00005E0A AD                  <1> 	lodsd
  3905                              <1> 	;or	eax, eax
  3906                              <1>         ;jnz     short dpd_1
  3907 00005E0B A801                <1> 	test	al, PDE_A_PRESENT ;  bit 0 =  1
  3908 00005E0D 7508                <1> 	jnz	short dpd_1
  3909                              <1>  	; 20/07/2015 (virtual address at the end of the page table)	
  3910 00005E0F 81C500004000        <1> 	add	ebp, 1024*4096 ; page size * PTE count
  3911 00005E15 EB0F                <1> 	jmp	short dpd_2
  3912                              <1> dpd_1:	
  3913 00005E17 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear attribute bits
  3914 00005E1B 89C3                <1> 	mov	ebx, eax
  3915                              <1> 	; EBX = Parent's page table address
  3916 00005E1D E81F000000          <1> 	call	duplicate_page_table
  3917 00005E22 720C                <1> 	jc	short dpd_p_err
  3918                              <1> 	; EAX = Child's page table address
  3919 00005E24 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER
  3920                              <1> 			 ; set bit 0, bit 1 and bit 2 to 1
  3921                              <1> 			 ; (present, writable, user)
  3922                              <1> dpd_2:
  3923 00005E26 AB                  <1> 	stosd
  3924 00005E27 E2E1                <1> 	loop	dpd_0
  3925                              <1> 	;
  3926 00005E29 58                  <1> 	pop	eax  ; restore child's page directory address
  3927                              <1> dpd_3:
  3928 00005E2A 59                  <1> 	pop	ecx
  3929 00005E2B 5B                  <1> 	pop	ebx
  3930 00005E2C 5F                  <1> 	pop	edi
  3931 00005E2D 5E                  <1> 	pop	esi
  3932 00005E2E 5D                  <1> 	pop	ebp ; 20/07/2015
  3933                              <1> dpd_err:
  3934 00005E2F C3                  <1> 	retn
  3935                              <1> dpd_p_err:
  3936                              <1> 	; release the allocated pages missing (recover free space)
  3937 00005E30 58                  <1> 	pop	eax  ; the new page directory address (physical)
  3938 00005E31 8B1D[B8030300]      <1> 	mov	ebx, [u.pgdir] ; parent's page directory address 
  3939 00005E37 E8D8FEFFFF          <1> 	call 	deallocate_page_dir
  3940 00005E3C 29C0                <1> 	sub	eax, eax ; 0
  3941 00005E3E F9                  <1> 	stc
  3942 00005E3F EBE9                <1> 	jmp	short dpd_3	
  3943                              <1> 
  3944                              <1> duplicate_page_table:
  3945                              <1> 	; 20/02/2017
  3946                              <1> 	; 21/09/2015
  3947                              <1> 	; 20/07/2015
  3948                              <1> 	; 05/05/2015
  3949                              <1> 	; 28/04/2015
  3950                              <1> 	; 27/04/2015
  3951                              <1> 	; 18/04/2015
  3952                              <1> 	; 18/10/2014
  3953                              <1> 	; 16/10/2014 (Retro UNIX 386 v1 - beginning)
  3954                              <1> 	;
  3955                              <1> 	; INPUT -> 
  3956                              <1> 	;	EBX = PHYSICAL (real/flat) ADDRESS of the parent's page table.
  3957                              <1> 	;       20/02/2017		 
  3958                              <1> 	;	EBP = Linear address of the page (from 'duplicate_page_dir')
  3959                              <1> 	;	      (Linear address = CORE + user's virtual address) 	
  3960                              <1> 	; OUTPUT ->
  3961                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS of the child's page table.
  3962                              <1> 	;	      (with 'read only' attribute of page table entries)
  3963                              <1> 	;	20/02/2017
  3964                              <1> 	;	EBP = Next linear page address (for 'duplicate_page_dir')
  3965                              <1> 	;	
  3966                              <1> 	;	CF = 1 -> error 
  3967                              <1> 	;
  3968                              <1> 	; Modified Registers -> EBP (except EAX)
  3969                              <1> 	;
  3970 00005E41 E895FDFFFF          <1> 	call	allocate_page
  3971 00005E46 726A                <1> 	jc	short dpt_err
  3972                              <1> 	;
  3973 00005E48 50                  <1> 	push	eax ; *
  3974 00005E49 56                  <1> 	push	esi
  3975 00005E4A 57                  <1> 	push	edi
  3976 00005E4B 52                  <1> 	push	edx
  3977 00005E4C 51                  <1> 	push	ecx
  3978                              <1> 	;
  3979 00005E4D 89DE                <1> 	mov	esi, ebx
  3980 00005E4F 89C7                <1> 	mov	edi, eax
  3981 00005E51 89C2                <1> 	mov	edx, eax
  3982 00005E53 81C200100000        <1> 	add	edx, PAGE_SIZE 	
  3983                              <1> dpt_0:
  3984 00005E59 AD                  <1> 	lodsd
  3985 00005E5A 21C0                <1> 	and	eax, eax
  3986 00005E5C 7444                <1> 	jz	short dpt_3
  3987 00005E5E A801                <1> 	test	al, PTE_A_PRESENT ;  bit 0 =  1
  3988 00005E60 7507                <1> 	jnz	short dpt_1
  3989                              <1> 	; 20/07/2015
  3990                              <1> 	; ebp = virtual (linear) address of the memory page
  3991 00005E62 E83F050000          <1> 	call	reload_page ; 28/04/2015
  3992 00005E67 7244                <1> 	jc	short dpt_p_err
  3993                              <1> dpt_1:
  3994                              <1> 	; 21/09/2015
  3995 00005E69 89C1                <1> 	mov	ecx, eax
  3996 00005E6B 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits
  3997 00005E6F F6C102              <1> 	test	cl, PTE_A_WRITE ; writable page ?
  3998 00005E72 7525                <1> 	jnz	short dpt_2
  3999                              <1> 	; Read only (parent) page
  4000                              <1> 	; 	- there is a third process which uses this page -
  4001                              <1> 	; Allocate a new page for the child process
  4002 00005E74 E862FDFFFF          <1> 	call	allocate_page
  4003 00005E79 7232                <1> 	jc	short dpt_p_err
  4004 00005E7B 57                  <1> 	push	edi
  4005 00005E7C 56                  <1> 	push	esi
  4006 00005E7D 89CE                <1> 	mov	esi, ecx
  4007 00005E7F 89C7                <1> 	mov	edi, eax
  4008 00005E81 B900040000          <1> 	mov	ecx, PAGE_SIZE/4
  4009 00005E86 F3A5                <1> 	rep	movsd	; copy page (4096 bytes)
  4010 00005E88 5E                  <1> 	pop	esi
  4011 00005E89 5F                  <1> 	pop	edi
  4012                              <1> 	; 
  4013 00005E8A 53                  <1> 	push	ebx
  4014 00005E8B 50                  <1> 	push	eax
  4015                              <1> 	; 20/07/2015
  4016 00005E8C 89EB                <1> 	mov	ebx, ebp
  4017                              <1> 	; ebx = virtual (linear) address of the memory page
  4018 00005E8E E887030000          <1> 	call	add_to_swap_queue
  4019 00005E93 58                  <1> 	pop	eax
  4020 00005E94 5B                  <1> 	pop	ebx
  4021                              <1> 	; 21/09/2015
  4022 00005E95 0C07                <1> 	or	al, PTE_A_USER+PTE_A_WRITE+PTE_A_PRESENT 
  4023                              <1> 		; user + writable + present page
  4024 00005E97 EB09                <1> 	jmp	short dpt_3
  4025                              <1> dpt_2:
  4026                              <1> 	;or	ax, PTE_A_USER+PTE_A_PRESENT 
  4027 00005E99 0C05                <1> 	or	al, PTE_A_USER+PTE_A_PRESENT 
  4028                              <1> 		    ; (read only page!)
  4029 00005E9B 8946FC              <1> 	mov	[esi-4], eax ; update parent's PTE
  4030 00005E9E 660D0002            <1> 	or      ax, PTE_DUPLICATED  ; (read only page & duplicated PTE!)
  4031                              <1> dpt_3:
  4032 00005EA2 AB                  <1> 	stosd  ; EDI points to child's PTE  	 
  4033                              <1> 	;
  4034 00005EA3 81C500100000        <1> 	add	ebp, 4096 ; 20/07/2015 (next page)
  4035                              <1> 	;
  4036 00005EA9 39D7                <1> 	cmp	edi, edx
  4037 00005EAB 72AC                <1> 	jb	short dpt_0
  4038                              <1> dpt_p_err:
  4039 00005EAD 59                  <1> 	pop	ecx
  4040 00005EAE 5A                  <1> 	pop	edx
  4041 00005EAF 5F                  <1> 	pop	edi
  4042 00005EB0 5E                  <1> 	pop	esi
  4043 00005EB1 58                  <1> 	pop	eax ; *
  4044                              <1> dpt_err:
  4045 00005EB2 C3                  <1> 	retn
  4046                              <1> 
  4047                              <1> page_fault_handler:	; CPU EXCEPTION 0Eh (14) : Page Fault !
  4048                              <1> 	; 21/09/2015
  4049                              <1> 	; 19/09/2015
  4050                              <1> 	; 17/09/2015
  4051                              <1> 	; 28/08/2015
  4052                              <1> 	; 20/07/2015
  4053                              <1> 	; 28/06/2015
  4054                              <1> 	; 03/05/2015
  4055                              <1> 	; 30/04/2015
  4056                              <1> 	; 18/04/2015
  4057                              <1> 	; 12/04/2015
  4058                              <1> 	; 30/10/2014
  4059                              <1> 	; 11/09/2014
  4060                              <1> 	; 10/09/2014 (Retro UNIX 386 v1 - beginning)
  4061                              <1> 	;
  4062                              <1> 	; Note: This is not an interrupt/exception handler.
  4063                              <1> 	;	This is a 'page fault remedy' subroutine 
  4064                              <1> 	;	which will be called by standard/uniform
  4065                              <1> 	;	exception handler.
  4066                              <1> 	;
  4067                              <1> 	; INPUT -> 
  4068                              <1> 	;	[error_code] = 32 bit ERROR CODE (lower 5 bits are valid)
  4069                              <1> 	;
  4070                              <1> 	;	cr2 = the virtual (linear) address 
  4071                              <1> 	;	      which has caused to page fault (19/09/2015)
  4072                              <1> 	;
  4073                              <1> 	; OUTPUT ->
  4074                              <1> 	;	(corresponding PAGE TABLE ENTRY is mapped/set)
  4075                              <1> 	;	EAX = 0 -> no error
  4076                              <1> 	;	EAX > 0 -> error code in EAX (also CF = 1)
  4077                              <1> 	;
  4078                              <1> 	; Modified Registers -> none (except EAX)
  4079                              <1> 	;	
  4080                              <1>         ;
  4081                              <1>         ; ERROR CODE:
  4082                              <1> 	;	 31  .....	4   3	2   1	0
  4083                              <1> 	;	+---+-- --+---+---+---+---+---+---+
  4084                              <1> 	;	|   Reserved  | I | R | U | W | P |
  4085                              <1> 	;	+---+-- --+---+---+---+---+---+---+
  4086                              <1> 	;
  4087                              <1> 	; P : PRESENT -	When set, the page fault was caused by 
  4088                              <1>     	;		a page-protection violation. When not set,
  4089                              <1> 	;		it was caused by a non-present page.
  4090                              <1> 	; W : WRITE   -	When set, the page fault was caused by
  4091                              <1> 	;		a page write. When not set, it was caused
  4092                              <1> 	;		by a page read.
  4093                              <1> 	; U : USER    -	When set, the page fault was caused 
  4094                              <1> 	;		while CPL = 3. 
  4095                              <1> 	;		This does not necessarily mean that
  4096                              <1> 	;		the page fault was a privilege violation.
  4097                              <1> 	; R : RESERVD -	When set, the page fault was caused by
  4098                              <1> 	;     WRITE	reading a 1 in a reserved field.
  4099                              <1> 	; I : INSTRUC -	When set, the page fault was caused by
  4100                              <1> 	;     FETCH	an instruction fetch
  4101                              <1> 	;
  4102                              <1> 	;; x86 (32 bit) VIRTUAL ADDRESS TRANSLATION
  4103                              <1> 	;  31               22                  12 11                    0
  4104                              <1> 	; +-------------------+-------------------+-----------------------+
  4105                              <1>        	; | PAGE DIR. ENTRY # | PAGE TAB. ENTRY # |        OFFSET         |
  4106                              <1>        	; +-------------------+-------------------+-----------------------+
  4107                              <1> 	;
  4108                              <1> 
  4109                              <1> 	;; CR3 REGISTER (Control Register 3)
  4110                              <1> 	;  31                                   12             5 4 3 2   0
  4111                              <1> 	; +---------------------------------------+-------------+---+-----+
  4112                              <1>       	; |                                       |  		|P|P|     |
  4113                              <1>       	; |   PAGE DIRECTORY TABLE BASE ADDRESS   |  reserved	|C|W|rsvrd|
  4114                              <1>       	; |                                       | 		|D|T|     |
  4115                              <1>    	; +---------------------------------------+-------------+---+-----+
  4116                              <1> 	;
  4117                              <1> 	;	PWT    - WRITE THROUGH
  4118                              <1> 	;	PCD    - CACHE DISABLE		
  4119                              <1> 	;
  4120                              <1> 	;
  4121                              <1> 	;; x86 PAGE DIRECTORY ENTRY (4 KByte Page)
  4122                              <1> 	;  31                                   12 11  9 8 7 6 5 4 3 2 1 0
  4123                              <1> 	; +---------------------------------------+-----+---+-+-+---+-+-+-+
  4124                              <1>       	; |                                       |     | | | | |P|P|U|R| |
  4125                              <1>       	; |     PAGE TABLE BASE ADDRESS 31..12    | AVL |G|0|D|A|C|W|/|/|P|
  4126                              <1>       	; |                                       |     | | | | |D|T|S|W| |
  4127                              <1>    	; +---------------------------------------+-----+---+-+-+---+-+-+-+
  4128                              <1> 	;
  4129                              <1>         ;       P      - PRESENT
  4130                              <1>         ;       R/W    - READ/WRITE
  4131                              <1>         ;       U/S    - USER/SUPERVISOR
  4132                              <1> 	;	PWT    - WRITE THROUGH
  4133                              <1> 	;	PCD    - CACHE DISABLE	
  4134                              <1> 	;	A      - ACCESSED	
  4135                              <1>         ;       D      - DIRTY (IGNORED)
  4136                              <1> 	;	PAT    - PAGE ATTRIBUTE TABLE INDEX (CACHE BEHAVIOR)
  4137                              <1> 	;	G      - GLOBAL	(IGNORED) 
  4138                              <1>         ;       AVL    - AVAILABLE FOR SYSTEMS PROGRAMMER USE
  4139                              <1> 	;
  4140                              <1> 	;
  4141                              <1> 	;; x86 PAGE TABLE ENTRY (4 KByte Page)
  4142                              <1> 	;  31                                   12 11  9 8 7 6 5 4 3 2 1 0
  4143                              <1> 	; +---------------------------------------+-----+---+-+-+---+-+-+-+
  4144                              <1>       	; |                                       |     | |P| | |P|P|U|R| |
  4145                              <1>       	; |     PAGE FRAME BASE ADDRESS 31..12    | AVL |G|A|D|A|C|W|/|/|P|
  4146                              <1>       	; |                                       |     | |T| | |D|T|S|W| |
  4147                              <1>    	; +---------------------------------------+-----+---+-+-+---+-+-+-+
  4148                              <1> 	;
  4149                              <1>         ;       P      - PRESENT
  4150                              <1>         ;       R/W    - READ/WRITE
  4151                              <1>         ;       U/S    - USER/SUPERVISOR
  4152                              <1> 	;	PWT    - WRITE THROUGH
  4153                              <1> 	;	PCD    - CACHE DISABLE	
  4154                              <1> 	;	A      - ACCESSED	
  4155                              <1>         ;       D      - DIRTY
  4156                              <1> 	;	PAT    - PAGE ATTRIBUTE TABLE INDEX (CACHE BEHAVIOR)
  4157                              <1> 	;	G      - GLOBAL	 
  4158                              <1>         ;       AVL    - AVAILABLE FOR SYSTEMS PROGRAMMER USE
  4159                              <1> 	;
  4160                              <1> 	;
  4161                              <1> 	;; 80386 PAGE TABLE ENTRY (4 KByte Page)
  4162                              <1> 	;  31                                   12 11  9 8 7 6 5 4 3 2 1 0
  4163                              <1> 	; +---------------------------------------+-----+-+-+-+-+---+-+-+-+
  4164                              <1>       	; |                                       |     | | | | | | |U|R| |
  4165                              <1>       	; |     PAGE FRAME BASE ADDRESS 31..12    | AVL |0|0|D|A|0|0|/|/|P|
  4166                              <1>       	; |                                       |     | | | | | | |S|W| |
  4167                              <1>       	; +---------------------------------------+-----+-+-+-+-+---+-+-+-+
  4168                              <1> 	;
  4169                              <1>         ;       P      - PRESENT
  4170                              <1>         ;       R/W    - READ/WRITE
  4171                              <1>         ;       U/S    - USER/SUPERVISOR
  4172                              <1>         ;       D      - DIRTY
  4173                              <1>         ;       AVL    - AVAILABLE FOR SYSTEMS PROGRAMMER USE
  4174                              <1> 	;
  4175                              <1>         ;       NOTE: 0 INDICATES INTEL RESERVED. DO NOT DEFINE.
  4176                              <1> 	;
  4177                              <1> 	;
  4178                              <1> 	;; Invalid Page Table Entry
  4179                              <1> 	; 31                                                           1 0
  4180                              <1>       	; +-------------------------------------------------------------+-+
  4181                              <1>       	; |                                                             | |
  4182                              <1>       	; |                          AVAILABLE                          |0|
  4183                              <1>       	; |                                                             | |
  4184                              <1>       	; +-------------------------------------------------------------+-+
  4185                              <1> 	;
  4186                              <1> 
  4187 00005EB3 53                  <1> 	push	ebx
  4188 00005EB4 52                  <1> 	push	edx
  4189 00005EB5 51                  <1> 	push	ecx
  4190                              <1> 	;
  4191                              <1> 	; 21/09/2015 (debugging)
  4192 00005EB6 FF05[CC030300]      <1> 	inc	dword [u.pfcount] ; page fault count for running process
  4193 00005EBC FF05[80050300]      <1> 	inc	dword [PF_Count] ; total page fault count	
  4194                              <1> 	; 28/06/2015
  4195                              <1> 	;mov	edx, [error_code] ; Lower 5 bits are valid
  4196 00005EC2 8A15[78050300]      <1> 	mov	dl, [error_code]
  4197                              <1> 	;
  4198 00005EC8 F6C201              <1> 	test	dl, 1	; page fault was caused by a non-present page
  4199                              <1> 			; sign
  4200 00005ECB 7422                <1> 	jz	short pfh_alloc_np
  4201                              <1> 	; 
  4202                              <1> 	; If it is not a 'write on read only page' type page fault
  4203                              <1> 	; major page fault error with minor reason must be returned without 
  4204                              <1> 	; fixing the problem. 'sys_exit with error' will be needed
  4205                              <1> 	; after return here!
  4206                              <1> 	; Page fault will be remedied, by copying page contents
  4207                              <1> 	; to newly allocated page with write permission;
  4208                              <1> 	; sys_fork -> sys_exec -> copy on write, demand paging method is 
  4209                              <1> 	; used for working with minimum possible memory usage. 
  4210                              <1> 	; sys_fork will duplicate page directory and tables of parent  
  4211                              <1> 	; process with 'read only' flag. If the child process attempts to
  4212                              <1> 	; write on these read only pages, page fault will be directed here
  4213                              <1> 	; for allocating a new page with same data/content. 
  4214                              <1> 	;
  4215                              <1> 	; IMPORTANT : Retro UNIX 386 v1 (and SINGLIX and TR-DOS)
  4216                              <1> 	; will not force to separate CODE and DATA space 
  4217                              <1> 	; in a process/program... 
  4218                              <1> 	; CODE segment/section may contain DATA!
  4219                              <1> 	; It is flat, smoth and simplest programming method already as in 
  4220                              <1> 	; Retro UNIX 8086 v1 and MS-DOS programs.
  4221                              <1> 	;	
  4222 00005ECD F6C202              <1> 	test	dl, 2	; page fault was caused by a page write
  4223                              <1> 			; sign
  4224 00005ED0 0F84AB000000        <1>         jz      pfh_p_err
  4225                              <1> 	; 31/08/2015
  4226 00005ED6 F6C204              <1> 	test	dl, 4	; page fault was caused while CPL = 3 (user mode)
  4227                              <1> 			; sign.  (U+W+P = 4+2+1 = 7)
  4228 00005ED9 0F84A2000000        <1>         jz	pfh_pv_err
  4229                              <1> 	;
  4230                              <1> 	; make a new page and copy the parent's page content
  4231                              <1> 	; as the child's new page content
  4232                              <1> 	;
  4233 00005EDF 0F20D3              <1> 	mov	ebx, cr2 ; CR2 contains the linear address 
  4234                              <1> 			 ; which has caused to page fault
  4235 00005EE2 E8A2000000          <1> 	call 	copy_page
  4236 00005EE7 0F828D000000        <1>         jc      pfh_im_err ; insufficient memory
  4237                              <1> 	;
  4238 00005EED EB7D                <1>         jmp     pfh_cpp_ok
  4239                              <1> 	;
  4240                              <1> pfh_alloc_np:
  4241 00005EEF E8E7FCFFFF          <1> 	call	allocate_page	; (allocate a new page)
  4242 00005EF4 0F8280000000        <1>         jc      pfh_im_err	; 'insufficient memory' error
  4243                              <1> pfh_chk_cpl:
  4244                              <1> 	; EAX = Physical (base) address of the allocated (new) page
  4245                              <1> 		; (Lower 12 bits are ZERO, because 
  4246                              <1> 		;	the address is on a page boundary)
  4247 00005EFA 80E204              <1> 	and	dl, 4	; CPL = 3 ?
  4248 00005EFD 7505                <1> 	jnz	short pfh_um
  4249                              <1> 			; Page fault handler for kernel/system mode (CPL=0)		
  4250 00005EFF 0F20DB              <1> 	mov	ebx, cr3 ; CR3 (Control Register 3) contains physical address
  4251                              <1> 			 ; of the current/active page directory
  4252                              <1> 			 ; (Always kernel/system mode page directory, here!)
  4253                              <1> 			 ; Note: Lower 12 bits are 0. (page boundary)
  4254 00005F02 EB06                <1> 	jmp	short pfh_get_pde
  4255                              <1> 	;
  4256                              <1> pfh_um:			; Page fault handler for user/appl. mode (CPL=3)
  4257 00005F04 8B1D[B8030300]      <1>  	mov	ebx, [u.pgdir] ; Page directory of current/active process
  4258                              <1> 			; Physical address of the USER's page directory
  4259                              <1> 			; Note: Lower 12 bits are 0. (page boundary)
  4260                              <1> pfh_get_pde:
  4261 00005F0A 80CA03              <1> 	or	dl, 3	; USER + WRITE + PRESENT or SYSTEM + WRITE + PRESENT
  4262 00005F0D 0F20D1              <1> 	mov	ecx, cr2 ; CR2 contains the virtual address 
  4263                              <1> 			 ; which has been caused to page fault
  4264                              <1> 			 ;
  4265 00005F10 C1E914              <1> 	shr	ecx, 20	 ; shift 20 bits right
  4266 00005F13 80E1FC              <1> 	and	cl, 0FCh ; mask lower 2 bits to get PDE offset		
  4267                              <1> 	;
  4268 00005F16 01CB                <1> 	add	ebx, ecx ; now, EBX points to the relevant page dir entry 
  4269 00005F18 8B0B                <1> 	mov	ecx, [ebx] ; physical (base) address of the page table 	
  4270 00005F1A F6C101              <1> 	test	cl, 1	 ; check bit 0 is set (1) or not (0).
  4271 00005F1D 740B                <1> 	jz	short pfh_set_pde ; Page directory entry is not valid,
  4272                              <1> 			  	  ; set/validate page directory entry
  4273 00005F1F 6681E100F0          <1> 	and	cx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
  4274 00005F24 89CB                <1> 	mov	ebx, ecx ; Physical address of the page table
  4275 00005F26 89C1                <1> 	mov	ecx, eax ; new page address (physical) 	
  4276 00005F28 EB16                <1> 	jmp	short pfh_get_pte
  4277                              <1> pfh_set_pde:
  4278                              <1> 	;; NOTE: Page directories and page tables never be swapped out!
  4279                              <1> 	;;	 (So, we know this PDE is empty or invalid)
  4280                              <1> 	;
  4281 00005F2A 08D0                <1> 	or	al, dl	 ; lower 3 bits are used as U/S, R/W, P flags
  4282 00005F2C 8903                <1> 	mov	[ebx], eax ; Let's put the new page directory entry here !
  4283 00005F2E 30C0                <1> 	xor	al, al	 ; clear lower (3..8) bits
  4284 00005F30 89C3                <1> 	mov	ebx, eax
  4285 00005F32 E8A4FCFFFF          <1> 	call	allocate_page	 ; (allocate a new page)
  4286 00005F37 7241                <1> 	jc	short pfh_im_err   ; 'insufficient memory' error
  4287                              <1> pfh_spde_1:
  4288                              <1> 	; EAX = Physical (base) address of the allocated (new) page
  4289 00005F39 89C1                <1> 	mov	ecx, eax
  4290 00005F3B E815FDFFFF          <1> 	call	clear_page ; Clear page content
  4291                              <1> pfh_get_pte:
  4292 00005F40 0F20D0              <1> 	mov	eax, cr2 ; virtual address
  4293                              <1> 			 ; which has been caused to page fault
  4294 00005F43 89C7                <1> 	mov	edi, eax ; 20/07/2015
  4295 00005F45 C1E80C              <1> 	shr	eax, 12	 ; shift 12 bit right to get 
  4296                              <1> 			 ; higher 20 bits of the page fault address 
  4297 00005F48 25FF030000          <1> 	and	eax, 3FFh ; mask PDE# bits, the result is PTE# (0 to 1023)
  4298 00005F4D C1E002              <1> 	shl	eax, 2	; shift 2 bits left to get PTE offset
  4299 00005F50 01C3                <1> 	add	ebx, eax ; now, EBX points to the relevant page table entry 
  4300 00005F52 8B03                <1> 	mov	eax, [ebx] ; get previous value of pte
  4301                              <1> 		; bit 0 of EAX is always 0 (otherwise we would not be here)
  4302 00005F54 21C0                <1> 	and	eax, eax
  4303 00005F56 7410                <1> 	jz	short pfh_gpte_1
  4304                              <1> 	; 20/07/2015
  4305 00005F58 87D9                <1> 	xchg	ebx, ecx ; new page address (physical)
  4306 00005F5A 55                  <1> 	push	ebp ; 20/07/2015
  4307 00005F5B 0F20D5              <1> 	mov	ebp, cr2
  4308                              <1> 		; ECX = physical address of the page table entry
  4309                              <1> 		; EBX = Memory page address (physical!)
  4310                              <1> 		; EAX = Swap disk (offset) address
  4311                              <1> 		; EBP = virtual address (page fault address)
  4312 00005F5E E8B7000000          <1> 	call	swap_in
  4313 00005F63 5D                  <1> 	pop	ebp
  4314 00005F64 7210                <1> 	jc      short pfh_err_retn
  4315 00005F66 87CB                <1> 	xchg	ecx, ebx
  4316                              <1> 		; EBX = physical address of the page table entry
  4317                              <1> 		; ECX = new page
  4318                              <1> pfh_gpte_1:
  4319 00005F68 08D1                <1> 	or	cl, dl	; lower 3 bits are used as U/S, R/W, P flags
  4320 00005F6A 890B                <1> 	mov	[ebx], ecx ; Let's put the new page table entry here !
  4321                              <1> pfh_cpp_ok:
  4322                              <1> 	; 20/07/2015
  4323 00005F6C 0F20D3              <1> 	mov	ebx, cr2
  4324 00005F6F E8A6020000          <1> 	call 	add_to_swap_queue
  4325                              <1> 	;
  4326                              <1> 	; The new PTE (which contains the new page) will be added to 
  4327                              <1> 	; the swap queue, here. 
  4328                              <1> 	; (Later, if memory will become insufficient, 
  4329                              <1> 	; one page will be swapped out which is at the head of 
  4330                              <1> 	; the swap queue by using FIFO and access check methods.)
  4331                              <1> 	;
  4332 00005F74 31C0                <1> 	xor	eax, eax  ; 0
  4333                              <1> 	;
  4334                              <1> pfh_err_retn:
  4335 00005F76 59                  <1> 	pop	ecx
  4336 00005F77 5A                  <1> 	pop	edx
  4337 00005F78 5B                  <1> 	pop	ebx
  4338 00005F79 C3                  <1> 	retn 
  4339                              <1> 	
  4340                              <1> pfh_im_err:
  4341 00005F7A B8E4000000          <1> 	mov	eax, ERR_MAJOR_PF + ERR_MINOR_IM ; Error code in AX
  4342                              <1> 			; Major (Primary) Error: Page Fault
  4343                              <1> 			; Minor (Secondary) Error: Insufficient Memory !
  4344 00005F7F EBF5                <1> 	jmp	short pfh_err_retn
  4345                              <1> 
  4346                              <1> 
  4347                              <1> pfh_p_err: ; 09/03/2015
  4348                              <1> pfh_pv_err:
  4349                              <1> 	; Page fault was caused by a protection-violation
  4350 00005F81 B8E6000000          <1> 	mov	eax, ERR_MAJOR_PF + ERR_MINOR_PV ; Error code in AX
  4351                              <1> 			; Major (Primary) Error: Page Fault
  4352                              <1> 			; Minor (Secondary) Error: Protection violation !
  4353 00005F86 F9                  <1> 	stc
  4354 00005F87 EBED                <1> 	jmp	short pfh_err_retn
  4355                              <1> 
  4356                              <1> copy_page:
  4357                              <1> 	; 22/09/2015
  4358                              <1> 	; 21/09/2015
  4359                              <1> 	; 19/09/2015
  4360                              <1> 	; 07/09/2015
  4361                              <1> 	; 31/08/2015
  4362                              <1> 	; 20/07/2015
  4363                              <1> 	; 05/05/2015
  4364                              <1> 	; 03/05/2015
  4365                              <1> 	; 18/04/2015
  4366                              <1> 	; 12/04/2015
  4367                              <1> 	; 30/10/2014
  4368                              <1> 	; 18/10/2014 (Retro UNIX 386 v1 - beginning)
  4369                              <1> 	;
  4370                              <1> 	; INPUT -> 
  4371                              <1> 	;	EBX = Virtual (linear) address of source page
  4372                              <1> 	;	     (Page fault address)
  4373                              <1> 	; OUTPUT ->
  4374                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF THE ALLOCATED PAGE
  4375                              <1> 	;	(corresponding PAGE TABLE ENTRY is mapped/set)
  4376                              <1> 	;	EAX = 0 (CF = 1) 
  4377                              <1> 	;		if there is not a free page to be allocated
  4378                              <1> 	;	(page content of the source page will be copied
  4379                              <1> 	;	onto the target/new page) 	
  4380                              <1> 	;
  4381                              <1> 	; Modified Registers -> ecx, ebx (except EAX)
  4382                              <1> 	;	
  4383 00005F89 56                  <1> 	push	esi
  4384 00005F8A 57                  <1> 	push	edi
  4385                              <1> 	;push	ebx
  4386                              <1> 	;push	ecx
  4387 00005F8B 31F6                <1> 	xor 	esi, esi
  4388 00005F8D C1EB0C              <1> 	shr	ebx, 12 ; shift 12 bits right to get PDE & PTE numbers
  4389 00005F90 89D9                <1> 	mov	ecx, ebx ; save page fault address (as 12 bit shifted)
  4390 00005F92 C1EB08              <1> 	shr	ebx, 8	 ; shift 8 bits right and then
  4391 00005F95 80E3FC              <1> 	and	bl, 0FCh ; mask lower 2 bits to get PDE offset	
  4392 00005F98 89DF                <1> 	mov 	edi, ebx ; save it for the parent of current process
  4393 00005F9A 031D[B8030300]      <1> 	add	ebx, [u.pgdir] ; EBX points to the relevant page dir entry 
  4394 00005FA0 8B03                <1> 	mov	eax, [ebx] ; physical (base) address of the page table
  4395 00005FA2 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits 	
  4396 00005FA6 89CB                <1> 	mov	ebx, ecx   ; (restore higher 20 bits of page fault address)
  4397 00005FA8 81E3FF030000        <1> 	and	ebx, 3FFh  ; mask PDE# bits, the result is PTE# (0 to 1023)
  4398 00005FAE 66C1E302            <1> 	shl	bx, 2	   ; shift 2 bits left to get PTE offset
  4399 00005FB2 01C3                <1> 	add	ebx, eax   ; EBX points to the relevant page table entry 
  4400                              <1> 	; 07/09/2015
  4401 00005FB4 66F7030002          <1>         test    word [ebx], PTE_DUPLICATED ; (Does current process share this
  4402                              <1> 				     ; read only page as a child process?)	
  4403 00005FB9 7509                <1> 	jnz	short cpp_0 ; yes
  4404 00005FBB 8B0B                <1> 	mov	ecx, [ebx] ; PTE value
  4405 00005FBD 6681E100F0          <1> 	and	cx, PTE_A_CLEAR ; 0F000h  ; clear page attributes
  4406 00005FC2 EB32                <1> 	jmp	short cpp_1
  4407                              <1> cpp_0:
  4408 00005FC4 89FE                <1> 	mov	esi, edi
  4409 00005FC6 0335[BC030300]      <1> 	add	esi, [u.ppgdir] ; the parent's page directory entry
  4410 00005FCC 8B06                <1> 	mov	eax, [esi] ; physical (base) address of the page table
  4411 00005FCE 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits
  4412 00005FD2 89CE                <1> 	mov	esi, ecx   ; (restore higher 20 bits of page fault address)	
  4413 00005FD4 81E6FF030000        <1> 	and	esi, 3FFh  ; mask PDE# bits, the result is PTE# (0 to 1023)
  4414 00005FDA 66C1E602            <1> 	shl	si, 2	   ; shift 2 bits left to get PTE offset
  4415 00005FDE 01C6                <1> 	add	esi, eax   ; EDX points to the relevant page table entry  	
  4416 00005FE0 8B0E                <1> 	mov	ecx, [esi] ; PTE value of the parent process
  4417                              <1> 	; 21/09/2015
  4418 00005FE2 8B03                <1> 	mov	eax, [ebx] ; PTE value of the child process
  4419 00005FE4 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear page attributes	
  4420                              <1> 	;
  4421 00005FE8 F6C101              <1> 	test	cl, PTE_A_PRESENT ; is it a present/valid page ?
  4422 00005FEB 7424                <1> 	jz	short cpp_3 ; the parent's page is not same page  	
  4423                              <1> 	;
  4424 00005FED 6681E100F0          <1> 	and	cx, PTE_A_CLEAR ; 0F000h ; clear page attributes
  4425 00005FF2 39C8                <1> 	cmp	eax, ecx   ; Same page?	
  4426 00005FF4 751B                <1> 	jne	short cpp_3 ; Parent page and child page are not same 
  4427                              <1> 			    ; Convert child's page to writable page
  4428                              <1> cpp_1:
  4429 00005FF6 E8E0FBFFFF          <1> 	call	allocate_page
  4430 00005FFB 721A                <1> 	jc	short cpp_4 ; 'insufficient memory' error
  4431 00005FFD 21F6                <1> 	and	esi, esi    ; check ESI is valid or not
  4432 00005FFF 7405                <1> 	jz	short cpp_2
  4433                              <1> 		; Convert read only page to writable page 
  4434                              <1> 		;(for the parent of the current process)
  4435                              <1> 	;and	word [esi], PTE_A_CLEAR ; 0F000h
  4436                              <1> 	; 22/09/2015
  4437 00006001 890E                <1> 	mov	[esi], ecx
  4438 00006003 800E07              <1> 	or	byte [esi], PTE_A_PRESENT + PTE_A_WRITE + PTE_A_USER
  4439                              <1> 				 ; 1+2+4 = 7
  4440                              <1> cpp_2:
  4441 00006006 89C7                <1> 	mov	edi, eax ; new page address of the child process
  4442                              <1> 	; 07/09/2015
  4443 00006008 89CE                <1> 	mov	esi, ecx ; the page address of the parent process
  4444 0000600A B900040000          <1> 	mov	ecx, PAGE_SIZE / 4
  4445 0000600F F3A5                <1> 	rep	movsd ; 31/08/2015
  4446                              <1> cpp_3:		
  4447 00006011 0C07                <1> 	or	al, PTE_A_PRESENT + PTE_A_WRITE + PTE_A_USER ; 1+2+4 = 7
  4448 00006013 8903                <1> 	mov	[ebx], eax ; Update PTE
  4449 00006015 28C0                <1> 	sub	al, al ; clear attributes
  4450                              <1> cpp_4:
  4451                              <1> 	;pop	ecx
  4452                              <1> 	;pop	ebx
  4453 00006017 5F                  <1> 	pop	edi
  4454 00006018 5E                  <1> 	pop	esi
  4455 00006019 C3                  <1> 	retn
  4456                              <1> 
  4457                              <1> ;; 28/04/2015
  4458                              <1> ;; 24/10/2014
  4459                              <1> ;; 21/10/2014 (Retro UNIX 386 v1 - beginning)
  4460                              <1> ;; SWAP_PAGE_QUEUE (4096 bytes)
  4461                              <1> ;;
  4462                              <1> ;;   0000   0001   0002   0003   ....   1020   1021   1022   1023	
  4463                              <1> ;; +------+------+------+------+-    -+------+------+------+------+
  4464                              <1> ;; |  pg1 |  pg2 |  pg3 |  pg4 | .... |pg1021|pg1022|pg1023|pg1024|
  4465                              <1> ;; +------+------+------+------+-    -+------+------+------+------+    
  4466                              <1> ;;
  4467                              <1> ;; [swpq_last] = 0 to 4096 (step 4) -> the last position on the queue
  4468                              <1> ;;
  4469                              <1> ;; Method:
  4470                              <1> ;;	Swap page queue is a list of allocated pages with physical
  4471                              <1> ;;	addresses (system mode virtual adresses = physical addresses).
  4472                              <1> ;;	It is used for 'swap_in' and 'swap_out' procedures.
  4473                              <1> ;;	When a new page is being allocated, swap queue is updated
  4474                              <1> ;;	by 'swap_queue_shift' procedure, header of the queue (offset 0)
  4475                              <1> ;;	is checked for 'accessed' flag. If the 1st page on the queue
  4476                              <1> ;;	is 'accessed' or 'read only', it is dropped from the list;
  4477                              <1> ;;	other pages from the 2nd to the last (in [swpq_last]) shifted
  4478                              <1> ;; 	to head then the 2nd page becomes the 1st and '[swpq_last]' 
  4479                              <1> ;;	offset value becomes it's previous offset value - 4.
  4480                              <1> ;;	If the 1st page of the swap page queue is not 'accessed'	
  4481                              <1> ;;	the queue/list is not shifted.
  4482                              <1> ;;	After the queue/list shift, newly allocated page is added
  4483                              <1> ;;	to the tail of the queue at the [swpq_count*4] position.
  4484                              <1> ;;	But, if [swpq_count] > 1023, the newly allocated page
  4485                              <1> ;;	will not be added to the tail of swap page queue.  		 
  4486                              <1> ;;	
  4487                              <1> ;;	During 'swap_out' procedure, swap page queue is checked for
  4488                              <1> ;;	the first non-accessed, writable page in the list, 
  4489                              <1> ;;	from the head to the tail. The list is shifted to left 
  4490                              <1> ;;	(to the head) till a non-accessed page will be found in the list.
  4491                              <1> ;;	Then, this page	is swapped out (to disk) and then it is dropped
  4492                              <1> ;;	from the list by a final swap queue shift. [swpq_count] value
  4493                              <1> ;;	is changed. If all pages on the queue' are 'accessed', 
  4494                              <1> ;;	'insufficient memory' error will be returned ('swap_out' 
  4495                              <1> ;;	procedure will be failed)...
  4496                              <1> ;;
  4497                              <1> ;;	Note: If the 1st page of the queue is an 'accessed' page,
  4498                              <1> ;;	'accessed' flag of the page will be reset (0) and that page
  4499                              <1> ;;	(PTE) will be added to the tail of the queue after
  4500                              <1> ;;	the check, if [swpq_count] < 1023. If [swpq_count] = 1024
  4501                              <1> ;;	the queue will be rotated and the PTE in the head will be
  4502                              <1> ;;	added to the tail after resetting 'accessed' bit. 
  4503                              <1> ;;
  4504                              <1> ;;
  4505                              <1> ;;	
  4506                              <1> ;; SWAP DISK/FILE (with 4096 bytes swapped page blocks)
  4507                              <1> ;;
  4508                              <1> ;;  00000000  00000004  00000008  0000000C   ...   size-8    size-4
  4509                              <1> ;; +---------+---------+---------+---------+-- --+---------+---------+
  4510                              <1> ;; |descriptr| page(1) | page(2) | page(3) | ... |page(n-1)| page(n) |
  4511                              <1> ;; +---------+---------+---------+---------+-- --+---------+---------+    
  4512                              <1> ;;
  4513                              <1> ;; [swpd_next] = the first free block address in swapped page records
  4514                              <1> ;;    		 for next free block search by 'swap_out' procedure.
  4515                              <1> ;; [swpd_size] = swap disk/file size in sectors (512 bytes)
  4516                              <1> ;;		 NOTE: max. possible swap disk size is 1024 GB
  4517                              <1> ;; 		 (entire swap space must be accessed by using
  4518                              <1> ;;		 31 bit offset address) 
  4519                              <1> ;; [swpd_free] = free block (4096 bytes) count in swap disk/file space
  4520                              <1> ;; [swpd_start] = absolute/start address of the swap disk/file
  4521                              <1> ;;		  0 for file, or beginning sector of the swap partition
  4522                              <1> ;; [swp_drv] = logical drive description table addr. of swap disk/file
  4523                              <1> ;;
  4524                              <1> ;; 					
  4525                              <1> ;; Method:
  4526                              <1> ;;	When the memory (ram) becomes insufficient, page allocation
  4527                              <1> ;;	procedure swaps out a page from memory to the swap disk 
  4528                              <1> ;;	(partition) or swap file to get a new free page at the memory.
  4529                              <1> ;;	Swapping out is performed by using swap page queue.
  4530                              <1> ;;
  4531                              <1> ;; 	Allocation block size of swap disk/file is equal to page size
  4532                              <1> ;;	(4096 bytes). Swapping address (in sectors) is recorded
  4533                              <1> ;;	into relevant page file entry as 31 bit physical (logical)
  4534                              <1> ;;	offset address as 1 bit shifted to left for present flag (0).
  4535                              <1> ;;	Swapped page address is between 1 and swap disk/file size - 4.	  
  4536                              <1> ;;	Absolute physical (logical) address of the swapped page is 
  4537                              <1> ;;	calculated by adding offset value to the swap partition's 
  4538                              <1> ;;	start address. If the swap device (disk) is a virtual disk 
  4539                              <1> ;;	or it is a file, start address of the swap disk/volume is 0, 
  4540                              <1> ;;	and offset value is equal to absolute (physical or logical)
  4541                              <1> ;;	address/position. (It has not to be ZERO if the swap partition 
  4542                              <1> ;;	is in a partitioned virtual hard disk.) 
  4543                              <1> ;;
  4544                              <1> ;;	Note: Swap addresses are always specified/declared in sectors, 
  4545                              <1> ;;	not in bytes or	in blocks/zones/clusters (4096 bytes) as unit.
  4546                              <1> ;;
  4547                              <1> ;;	Swap disk/file allocation is mapped via 'Swap Allocation Table'
  4548                              <1> ;;	at memory as similar to 'Memory Allocation Table'.
  4549                              <1> ;;
  4550                              <1> ;;	Every bit of Swap Allocation Table repsesents one swap block
  4551                              <1> ;;	(equal to page size) respectively. Bit 0 of the S.A.T. byte 0
  4552                              <1> ;;	is reserved for swap disk/file block 0 as descriptor block
  4553                              <1> ;;	(also for compatibility with PTE). If bit value is ZERO,
  4554                              <1> ;;	it means relevant (respective) block is in use, and, 
  4555                              <1> ;;	of course, if bit value is 1, it means relevant (respective)
  4556                              <1> ;;      swap disk/file block is free.
  4557                              <1> ;;	For example: bit 1 of the byte 128 repsesents block 1025 
  4558                              <1> ;;	(128*8+1) or sector (offset) 8200 on the swap disk or
  4559                              <1> ;;	byte (offset/position) 4198400 in the swap file. 
  4560                              <1> ;;	4GB swap space is represented via 128KB Swap Allocation Table.
  4561                              <1> ;;	Initial layout of Swap Allocation Table is as follows:
  4562                              <1> ;;	------------------------------------------------------------
  4563                              <1> ;;	0111111111111111111111111 .... 11111111111111111111111111111
  4564                              <1> ;;	------------------------------------------------------------
  4565                              <1> ;;	(0 is reserved block, 1s represent free blocks respectively.)
  4566                              <1> ;;	(Note: Allocation cell/unit of the table is bit, not byte)
  4567                              <1> ;;
  4568                              <1> ;;	..............................................................
  4569                              <1> ;;
  4570                              <1> ;;	'swap_out' procedure checks 'free_swap_blocks' count at first,
  4571                              <1> ;;	then it searches Swap Allocation Table if free count is not
  4572                              <1> ;;	zero. From begining the [swpd_next] dword value, the first bit 
  4573                              <1> ;;	position with value of 1 on the table is converted to swap
  4574                              <1> ;;	disk/file offset address, in sectors (not 4096 bytes block).
  4575                              <1> ;;	'ldrv_write' procedure is called with ldrv (logical drive
  4576                              <1> ;;	number of physical swap disk or virtual swap disk)
  4577                              <1> ;;	number, sector offset (not absolute sector -LBA- number),
  4578                              <1> ;;	and sector count (8, 512*8 = 4096) and buffer adress
  4579                              <1> ;;	(memory page). That will be a direct disk write procedure.
  4580                              <1> ;;	(for preventing late memory allocation, significant waiting). 
  4581                              <1> ;;	If disk write procedure returns with error or free count of 
  4582                              <1> ;;	swap blocks is ZERO, 'swap_out' procedure will return with
  4583                              <1> ;;	'insufficient memory error' (cf=1). 
  4584                              <1> ;;
  4585                              <1> ;;	(Note: Even if free swap disk/file blocks was not zero,
  4586                              <1> ;;	any disk write error will not be fixed by 'swap_out' procedure,
  4587                              <1> ;;	in other words, 'swap_out' will not check the table for other
  4588                              <1> ;;	free blocks after a disk write error. It will return to 
  4589                              <1> ;;	the caller with error (CF=1) which means swapping is failed. 
  4590                              <1> ;;
  4591                              <1> ;;	After writing the page on to swap disk/file address/sector,
  4592                              <1> ;;	'swap_out' procesure returns with that swap (offset) sector
  4593                              <1> ;;	address (cf=0). 
  4594                              <1> ;;
  4595                              <1> ;;	..............................................................
  4596                              <1> ;;
  4597                              <1> ;;	'swap_in' procedure loads addressed (relevant) swap disk or
  4598                              <1> ;;	file sectors at specified memory page. Then page allocation
  4599                              <1> ;;	procedure updates relevant page table entry with 'present' 
  4600                              <1> ;;	attribute. If swap disk or file reading fails there is nothing
  4601                              <1> ;;	to do, except to terminate the process which is the owner of
  4602                              <1> ;;	the swapped page.
  4603                              <1> ;;
  4604                              <1> ;;	'swap_in' procedure sets the relevant/respective bit value
  4605                              <1> ;;	in the Swap Allocation Table (as free block). 'swap_in' also
  4606                              <1> ;;	updates [swpd_first] pointer if it is required.
  4607                              <1> ;;
  4608                              <1> ;;	..............................................................	 
  4609                              <1> ;;
  4610                              <1> ;;	Note: If [swap_enabled] value is ZERO, that means there is not
  4611                              <1> ;;	a swap disk or swap file in use... 'swap_in' and 'swap_out'
  4612                              <1> ;;	procedures ans 'swap page que' procedures will not be active...
  4613                              <1> ;;	'Insufficient memory' error will be returned by 'swap_out'
  4614                              <1> ;;	and 'general protection fault' will be returned by 'swap_in'
  4615                              <1> ;;	procedure, if it is called mistakenly (a wrong value in a PTE).		
  4616                              <1> ;;
  4617                              <1> 
  4618                              <1> swap_in:
  4619                              <1> 	; 31/08/2015
  4620                              <1> 	; 20/07/2015
  4621                              <1> 	; 28/04/2015
  4622                              <1> 	; 18/04/2015
  4623                              <1> 	; 24/10/2014 (Retro UNIX 386 v1 - beginning)
  4624                              <1> 	;
  4625                              <1> 	; INPUT -> 
  4626                              <1> 	;	EBX = PHYSICAL (real/flat) ADDRESS OF THE MEMORY PAGE
  4627                              <1> 	;	EBP = VIRTUAL (LINEAR) ADDRESS (page fault address)
  4628                              <1> 	;	EAX = Offset Address for the swapped page on the
  4629                              <1> 	;	      swap disk or in the swap file.
  4630                              <1> 	;
  4631                              <1> 	; OUTPUT ->
  4632                              <1> 	;	EAX = 0 if loading at memory has been successful
  4633                              <1> 	;
  4634                              <1> 	;	CF = 1 -> swap disk reading error (disk/file not present
  4635                              <1> 	;		  or sector not present or drive not ready
  4636                              <1> 	;	     EAX = Error code
  4637                              <1> 	;	     [u.error] = EAX 
  4638                              <1> 	;		       = The last error code for the process
  4639                              <1> 	;		         (will be reset after returning to user)	  
  4640                              <1> 	;
  4641                              <1> 	; Modified Registers -> EAX
  4642                              <1> 	;
  4643                              <1> 
  4644 0000601A 833D[62050300]00    <1>         cmp     dword [swp_drv], 0
  4645 00006021 7646                <1> 	jna	short swpin_dnp_err
  4646                              <1> 
  4647 00006023 3B05[66050300]      <1> 	cmp	eax, [swpd_size]
  4648 00006029 734A                <1> 	jnb	short swpin_snp_err
  4649                              <1> 
  4650 0000602B 56                  <1> 	push	esi
  4651 0000602C 53                  <1> 	push	ebx
  4652 0000602D 51                  <1> 	push	ecx
  4653 0000602E 8B35[62050300]      <1> 	mov	esi, [swp_drv]	
  4654 00006034 B908000000          <1> 	mov	ecx, PAGE_SIZE / LOGIC_SECT_SIZE  ; 8 !
  4655                              <1> 		; Note: Even if corresponding physical disk's sector 
  4656                              <1> 		; size different than 512 bytes, logical disk sector
  4657                              <1> 		; size is 512 bytes and disk reading procedure
  4658                              <1> 		; will be performed for reading 4096 bytes
  4659                              <1> 		; (2*2048, 8*512). 
  4660                              <1> 	; ESI = Logical disk description table address
  4661                              <1> 	; EBX = Memory page (buffer) address (physical!)
  4662                              <1> 	; EAX = Sector adress (offset address, logical sector number)
  4663                              <1> 	; ECX = Sector count ; 8 sectors
  4664 00006039 50                  <1> 	push	eax
  4665 0000603A E8AF020000          <1> 	call	logical_disk_read
  4666 0000603F 58                  <1> 	pop	eax
  4667 00006040 730C                <1> 	jnc	short swpin_read_ok
  4668                              <1> 	;
  4669 00006042 B828000000          <1> 	mov	eax, SWP_DISK_READ_ERR ; drive not ready or read error
  4670 00006047 A3[C8030300]        <1> 	mov	[u.error], eax
  4671 0000604C EB17                <1> 	jmp	short swpin_retn
  4672                              <1> 	;
  4673                              <1> swpin_read_ok:
  4674                              <1> 	; EAX = Offset address (logical sector number)
  4675 0000604E E80D020000          <1> 	call	unlink_swap_block  ; Deallocate swap block	
  4676                              <1> 	;
  4677                              <1> 	; EBX = Memory page (buffer) address (physical!)
  4678                              <1> 	; 20/07/2015
  4679 00006053 89EB                <1> 	mov	ebx, ebp ; virtual address (page fault address)
  4680 00006055 6681E300F0          <1>         and     bx, ~PAGE_OFF ; ~0FFFh ; reset bits, 0 to 11
  4681 0000605A 8A1D[B3030300]      <1> 	mov	bl, [u.uno] ; current process number
  4682                              <1> 	; EBX = Virtual (Linear) address & process number combination
  4683 00006060 E8DB000000          <1> 	call	swap_queue_shift
  4684                              <1> 	; eax = 0 ; 10/06/2016 (if ebx input > 0, eax output = 0)
  4685                              <1> 	;sub	eax, eax  ; 0 ; Error Code = 0  (no error)
  4686                              <1> 	; zf = 1
  4687                              <1> swpin_retn:
  4688 00006065 59                  <1> 	pop	ecx
  4689 00006066 5B                  <1> 	pop	ebx
  4690 00006067 5E                  <1> 	pop	esi
  4691 00006068 C3                  <1> 	retn
  4692                              <1> 
  4693                              <1> swpin_dnp_err:
  4694 00006069 B829000000          <1> 	mov	eax, SWP_DISK_NOT_PRESENT_ERR
  4695                              <1> swpin_err_retn:
  4696 0000606E A3[C8030300]        <1> 	mov	[u.error], eax
  4697 00006073 F9                  <1> 	stc
  4698 00006074 C3                  <1> 	retn
  4699                              <1> 
  4700                              <1> swpin_snp_err:
  4701 00006075 B82A000000          <1> 	mov	eax, SWP_SECTOR_NOT_PRESENT_ERR
  4702 0000607A EBF2                <1> 	jmp	short swpin_err_retn
  4703                              <1> 
  4704                              <1> swap_out:
  4705                              <1> 	; 10/06/2016
  4706                              <1> 	; 07/06/2016
  4707                              <1>         ; 23/05/2016
  4708                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
  4709                              <1> 	; 24/10/2014 - 31/08/2015 (Retro UNIX 386 v1)
  4710                              <1> 	;
  4711                              <1> 	; INPUT -> 
  4712                              <1> 	;	none
  4713                              <1> 	;
  4714                              <1> 	; OUTPUT ->
  4715                              <1> 	;	EAX = Physical page address (which is swapped out
  4716                              <1> 	;	      for allocating a new page)
  4717                              <1> 	;	CF = 1 -> swap disk writing error (disk/file not present
  4718                              <1> 	;		  or sector not present or drive not ready
  4719                              <1> 	;	     EAX = Error code
  4720                              <1> 	;	     [u.error] = EAX 
  4721                              <1> 	;		       = The last error code for the process
  4722                              <1> 	;		         (will be reset after returning to user)	  
  4723                              <1> 	;
  4724                              <1> 	; Modified Registers -> none (except EAX)
  4725                              <1> 	;
  4726 0000607C 66833D[60050300]01  <1> 	cmp 	word [swpq_count], 1
  4727 00006084 0F82AF000000        <1>         jc      swpout_im_err ; 'insufficient memory'
  4728                              <1> 
  4729                              <1>         ;cmp    dword [swp_drv], 1
  4730                              <1> 	;jc	short swpout_dnp_err ; 'swap disk/file not present'
  4731                              <1> 
  4732 0000608A 833D[6A050300]01    <1>         cmp     dword [swpd_free], 1
  4733 00006091 0F828F000000        <1>         jc      swpout_nfspc_err ; 'no free space on swap disk'
  4734                              <1> 
  4735 00006097 53                  <1> 	push	ebx ; *
  4736                              <1> swpout_1:
  4737                              <1> 	; 10/06/2016
  4738 00006098 31DB                <1> 	xor	ebx, ebx ; shift the queue and return a PTE value
  4739 0000609A E8A1000000          <1> 	call	swap_queue_shift
  4740 0000609F 21C0                <1> 	and	eax, eax	; 0 = empty queue (improper entries)
  4741 000060A1 0F848A000000        <1>         jz      swpout_npts_err        ; There is not any proper PTE
  4742                              <1> 				       ; pointer in the swap queue
  4743                              <1> 	; EAX = PTE value of the page
  4744                              <1> 	; EBX = PTE address of the page
  4745 000060A7 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits
  4746                              <1> 	;
  4747                              <1> 	; 07/06/2016
  4748                              <1> 	; 19/05/2016
  4749                              <1> 	; check this page is in timer events or not
  4750                              <1> 	
  4751                              <1> swpout_timer_page_0:
  4752 000060AB 52                  <1> 	push	edx ; **
  4753                              <1> 
  4754                              <1> 	; 07/06/2016
  4755 000060AC 803D[C3960100]00    <1> 	cmp	byte [timer_events], 0 
  4756 000060B3 762F                <1> 	jna	short swpout_2
  4757                              <1> 	;
  4758 000060B5 8A15[C3960100]      <1> 	mov	dl, [timer_events]
  4759                              <1> 
  4760 000060BB 51                  <1> 	push	ecx ; ***
  4761 000060BC 53                  <1> 	push	ebx ; ****
  4762 000060BD BB[60040300]        <1> 	mov	ebx, timer_set ; beginning address of timer event
  4763                              <1> 			       ; structures 
  4764                              <1> swpout_timer_page_1:
  4765 000060C2 8A0B                <1> 	mov	cl, [ebx]
  4766 000060C4 08C9                <1> 	or	cl, cl ; 0 = free, >0 = process number
  4767 000060C6 7415                <1> 	jz	short swpout_timer_page_3
  4768 000060C8 8B4B0C              <1> 	mov	ecx, [ebx+12] ; response (signal return) address
  4769 000060CB 6681E100F0          <1> 	and	cx, PTE_A_CLEAR ; clear offset part (right 12 bits)
  4770                              <1> 				; of the response byte address, to
  4771                              <1> 				; get beginning of the page address)
  4772 000060D0 39C8                <1> 	cmp	eax, ecx
  4773 000060D2 7505                <1> 	jne	short swpout_timer_page_2 ; not same page
  4774                              <1> 	
  4775                              <1> 	; !same page!
  4776                              <1> 	;
  4777                              <1> 	; NOTE: // 19/05/2016 // - TRDOS 386 feature only ! -
  4778                              <1> 	; This page will be used by the kernel to put timer event
  4779                              <1> 	; response (signal return) byte at the requested address;
  4780                              <1> 	; in order to prevent a possible wrong write (while
  4781                              <1> 	; this page is swapped out) on physical memory,
  4782                              <1> 	; we must protect this page against to be swapped out!
  4783                              <1> 	;
  4784 000060D4 5B                  <1> 	pop	ebx ; ****
  4785 000060D5 59                  <1> 	pop	ecx ; ***
  4786 000060D6 5A                  <1> 	pop	edx ; **
  4787 000060D7 EBBF                <1> 	jmp	short swpout_1	; do not swap out this page !
  4788                              <1>  
  4789                              <1> swpout_timer_page_2:
  4790                              <1> 	; 07/06/2016
  4791 000060D9 FECA                <1> 	dec	dl
  4792 000060DB 7405                <1> 	jz	short swpout_timer_page_4
  4793                              <1> swpout_timer_page_3:
  4794                              <1> 	;cmp	ebx, timer_set + 240 ; last timer event (15*16) 
  4795                              <1> 	;jnb	short swpout_timer_page_4
  4796 000060DD 83C310              <1> 	add	ebx, 16
  4797 000060E0 EBE0                <1> 	jmp	short swpout_timer_page_1	
  4798                              <1> 
  4799                              <1> swpout_timer_page_4:
  4800 000060E2 5B                  <1> 	pop	ebx ; ****
  4801 000060E3 59                  <1> 	pop	ecx ; ***
  4802                              <1> swpout_2:
  4803 000060E4 89DA                <1> 	mov	edx, ebx	       ; Page table entry address	
  4804 000060E6 89C3                <1> 	mov	ebx, eax	       ; Buffer (Page) Address				
  4805                              <1> 	;
  4806 000060E8 E8A6010000          <1> 	call	link_swap_block
  4807 000060ED 7304                <1> 	jnc	short swpout_3	       ; It may not be needed here	
  4808                              <1> 				       ; because [swpd_free] value
  4809                              <1> 				       ; was checked at the beginging. 	
  4810 000060EF 5A                  <1> 	pop	edx ; **
  4811 000060F0 5B                  <1> 	pop	ebx ; *
  4812 000060F1 EB33                <1> 	jmp	short swpout_nfspc_err 
  4813                              <1> swpout_3:
  4814 000060F3 A900000080          <1> 	test	eax, 80000000h ; test bit 31 (this may not be needed!)
  4815 000060F8 752C                <1> 	jnz	short swpout_nfspc_err  ; 10/06/2016 (bit 31 = 1 !)
  4816                              <1> 	;	
  4817 000060FA 56                  <1> 	push	esi ; **
  4818 000060FB 51                  <1> 	push	ecx ; ***
  4819 000060FC 50                  <1> 	push	eax ; sector address ; (31 bit !, bit 31 = 0)
  4820 000060FD 8B35[62050300]      <1> 	mov	esi, [swp_drv]	
  4821 00006103 B908000000          <1> 	mov	ecx, PAGE_SIZE / LOGIC_SECT_SIZE  ; 8 !
  4822                              <1> 		; Note: Even if corresponding physical disk's sector 
  4823                              <1> 		; size different than 512 bytes, logical disk sector
  4824                              <1> 		; size is 512 bytes and disk writing procedure
  4825                              <1> 		; will be performed for writing 4096 bytes
  4826                              <1> 		; (2*2048, 8*512). 
  4827                              <1> 	; ESI = Logical disk description table address
  4828                              <1> 	; EBX = Buffer (Page) address
  4829                              <1> 	; EAX = Sector adress (offset address, logical sector number)
  4830                              <1> 	; ECX = Sector count ; 8 sectors
  4831                              <1> 	; edx = PTE address
  4832 00006108 E8E2010000          <1> 	call	logical_disk_write
  4833                              <1> 	; edx = PTE address
  4834 0000610D 59                  <1> 	pop	ecx ; sector address	
  4835 0000610E 730C                <1> 	jnc	short swpout_write_ok
  4836                              <1> 	;
  4837                              <1> 	;; call	unlink_swap_block ; this block must be left as 'in use'
  4838                              <1> swpout_dw_err:
  4839 00006110 B82C000000          <1> 	mov	eax, SWP_DISK_WRITE_ERR ; drive not ready or write error
  4840 00006115 A3[C8030300]        <1> 	mov	[u.error], eax
  4841 0000611A EB06                <1> 	jmp	short swpout_retn
  4842                              <1> 	;
  4843                              <1> swpout_write_ok:
  4844                              <1> 	; EBX = Buffer (page) address
  4845                              <1> 	; EDX = Page Table Entry address
  4846                              <1> 	; ECX = Swap disk sector (file block) address (31 bit)
  4847 0000611C D1E1                <1> 	shl 	ecx, 1  ; 31 bit sector address from bit 1 to bit 31 
  4848 0000611E 890A                <1> 	mov 	[edx], ecx 
  4849                              <1> 		; bit 0 = 0 (swapped page)
  4850 00006120 89D8                <1> 	mov	eax, ebx
  4851                              <1> swpout_retn:
  4852 00006122 59                  <1> 	pop	ecx ; ***
  4853 00006123 5E                  <1> 	pop	esi ; **
  4854 00006124 5B                  <1> 	pop	ebx ; *
  4855 00006125 C3                  <1> 	retn
  4856                              <1> 
  4857                              <1> ;swpout_dnp_err:
  4858                              <1> ;	mov	eax, SWP_DISK_NOT_PRESENT_ERR ; disk not present
  4859                              <1> ;	jmp	short swpout_err_retn
  4860                              <1> swpout_nfspc_err:
  4861 00006126 B82B000000          <1> 	mov	eax, SWP_NO_FREE_SPACE_ERR ; no free space
  4862                              <1> swpout_err_retn:
  4863 0000612B A3[C8030300]        <1> 	mov	[u.error], eax
  4864                              <1> 	;stc
  4865 00006130 C3                  <1> 	retn
  4866                              <1> swpout_npts_err:
  4867 00006131 B82D000000          <1> 	mov	eax, SWP_NO_PAGE_TO_SWAP_ERR
  4868 00006136 5B                  <1> 	pop	ebx
  4869 00006137 EBF2                <1> 	jmp	short swpout_err_retn
  4870                              <1> swpout_im_err:
  4871 00006139 B804000000          <1> 	mov	eax, ERR_MINOR_IM ; insufficient (out of) memory
  4872 0000613E EBEB                <1> 	jmp	short swpout_err_retn
  4873                              <1> 
  4874                              <1> swap_queue_shift:
  4875                              <1> 	; 26/03/2017
  4876                              <1> 	; 10/06/2016
  4877                              <1> 	; 09/06/2016 - TRDOS 386 (TRDOS v2.0)
  4878                              <1> 	; 23/10/2014 - 20/07/2015 (Retro UNIX 386 v1)
  4879                              <1> 	;
  4880                              <1> 	; INPUT ->
  4881                              <1> 	;	EBX = Virtual (linear) address (bit 12 to 31) 
  4882                              <1> 	;	      and process number combination (bit 0 to 11)
  4883                              <1> 	;	EBX = 0 -> shift/drop from the head (offset 0)
  4884                              <1> 	;	
  4885                              <1> 	; OUTPUT ->
  4886                              <1> 	;	If EBX input > 0 
  4887                              <1> 	;	   the queue will be shifted 4 bytes (dword),
  4888                              <1> 	; 	   from the tail to the head, up to entry offset
  4889                              <1> 	; 	   which points to EBX input value or nothing
  4890                              <1> 	;	   to do if EBX value is not found on the queue.
  4891                              <1> 	;	   (The entry -with EBX value- will be removed
  4892                              <1> 	;	   from the queue if it is found.)
  4893                              <1> 	;
  4894                              <1> 	;	   EAX = 0		
  4895                              <1> 	;
  4896                              <1> 	;	If EBX input = 0
  4897                              <1> 	;	   the queue will be shifted 4 bytes (dword),
  4898                              <1> 	; 	   from the tail to the head, if the PTE address
  4899                              <1> 	;	   which is pointed in head of the queue is marked
  4900                              <1> 	;	   as "accessed" or it is marked as "non present".
  4901                              <1> 	;	   (If "accessed" flag of the PTE -which is pointed
  4902                              <1> 	;	   in the head- is set -to 1-, it will be reset
  4903                              <1> 	;	   -to 0- and then, the queue will be rotated 
  4904                              <1> 	;	   -without dropping pointer of the PTE from 
  4905                              <1> 	;	   the queue- for 4 bytes on head to tail direction.
  4906                              <1> 	;	   Pointer in the head will be moved into the tail,
  4907                              <1> 	;	   other PTEs will be shifted on head direction.)
  4908                              <1> 	;
  4909                              <1> 	;	   Swap queue will be shifted up to the first
  4910                              <1> 	;	   'present' or 'non accessed' page will be found
  4911                              <1> 	;	   (as pointed) on the queue head (then it will be
  4912                              <1>         ;          removed/dropped from the queue).
  4913                              <1> 	;
  4914                              <1> 	;	   EAX (> 0) = PTE value of the page which is
  4915                              <1> 	;		 (it's pointer -virtual address-) dropped
  4916                              <1> 	;		 (removed) from swap queue.
  4917                              <1> 	;	   EBX = PTE address of the page (if EAX > 0)
  4918                              <1> 	;	         which is (it's pointer -virtual address-)
  4919                              <1> 	;		 dropped (removed) from swap queue.
  4920                              <1> 	;
  4921                              <1> 	;	   EAX = 0 -> empty swap queue ! 
  4922                              <1> 	;
  4923                              <1> 	; Modified Registers -> EAX, EBX
  4924                              <1> 	;
  4925 00006140 0FB705[60050300]    <1> 	movzx   eax, word [swpq_count]  ; Max. 1024
  4926 00006147 6621C0              <1> 	and	ax, ax
  4927 0000614A 7431                <1> 	jz	short swpqs_retn
  4928 0000614C 57                  <1> 	push	edi
  4929 0000614D 56                  <1> 	push	esi
  4930 0000614E 51                  <1> 	push	ecx
  4931 0000614F BE00E00800          <1> 	mov	esi, swap_queue
  4932 00006154 89C1                <1> 	mov	ecx, eax
  4933 00006156 09DB                <1> 	or	ebx, ebx
  4934 00006158 7424                <1> 	jz	short swpqs_7
  4935                              <1> swpqs_1:
  4936 0000615A AD                  <1> 	lodsd
  4937 0000615B 39D8                <1> 	cmp	eax, ebx
  4938 0000615D 7406                <1> 	je	short swpqs_2
  4939 0000615F E2F9                <1> 	loop	swpqs_1
  4940                              <1> 	; 10/06/2016
  4941 00006161 29C0                <1> 	sub	eax, eax 
  4942 00006163 EB15                <1> 	jmp	short swpqs_6
  4943                              <1> swpqs_2:
  4944 00006165 89F7                <1> 	mov	edi, esi
  4945 00006167 83EF04              <1> 	sub 	edi, 4
  4946                              <1> swpqs_3:
  4947 0000616A 66FF0D[60050300]    <1> 	dec	word [swpq_count]
  4948 00006171 7403                <1> 	jz	short swpqs_5
  4949                              <1> swpqs_4:
  4950 00006173 49                  <1> 	dec 	ecx
  4951 00006174 F3A5                <1> 	rep	movsd	; shift up (to the head)
  4952                              <1> swpqs_5:
  4953 00006176 31C0                <1> 	xor	eax, eax
  4954 00006178 8907                <1> 	mov	[edi], eax
  4955                              <1> swpqs_6:
  4956 0000617A 59                  <1> 	pop	ecx
  4957 0000617B 5E                  <1> 	pop	esi
  4958 0000617C 5F                  <1> 	pop	edi
  4959                              <1> swpqs_retn:
  4960 0000617D C3                  <1> 	retn		
  4961                              <1> swpqs_7:
  4962 0000617E 89F7                <1> 	mov	edi, esi ; head
  4963 00006180 AD                  <1> 	lodsd
  4964                              <1> 	; 20/07/2015
  4965 00006181 89C3                <1> 	mov	ebx, eax
  4966 00006183 81E300F0FFFF        <1> 	and	ebx, ~PAGE_OFF ; ~0FFFh 
  4967                              <1> 		      ; ebx = virtual address (at page boundary)	
  4968 00006189 25FF0F0000          <1> 	and	eax, PAGE_OFF ; 0FFFh
  4969                              <1> 		      ; ax = process number (1 to 4095)
  4970 0000618E 3A05[B3030300]      <1> 	cmp	al, [u.uno]
  4971                              <1> 		; Max. 16 (nproc) processes for Retro UNIX 386 v1
  4972 00006194 7507                <1> 	jne	short swpqs_8
  4973 00006196 A1[B8030300]        <1> 	mov	eax, [u.pgdir]
  4974 0000619B EB28                <1> 	jmp	short swpqs_9
  4975                              <1> swpqs_8:
  4976                              <1> 	; 09/06/2016
  4977 0000619D 80B8[AF000300]00    <1> 	cmp	byte [eax+p.stat-1], 0
  4978 000061A4 76C4                <1> 	jna	short swpqs_3     ; free (or terminated) process
  4979 000061A6 80B8[AF000300]02    <1> 	cmp	byte [eax+p.stat-1], 2 ; waiting
  4980 000061AD 77BB                <1> 	ja	short swpqs_3 	  ; zombie (3) or undefined ?	
  4981                              <1> 
  4982                              <1> 	;shl	ax, 2
  4983 000061AF C0E002              <1> 	shl	al, 2
  4984 000061B2 8B80[BC000300]      <1> 	mov 	eax, [eax+p.upage-4]
  4985 000061B8 09C0                <1> 	or	eax, eax
  4986 000061BA 74AE                <1> 	jz	short swpqs_3 ; invalid upage
  4987 000061BC 83C05C              <1> 	add	eax, u.pgdir - user
  4988                              <1> 			 ; u.pgdir value for the process
  4989                              <1> 			 ; is in [eax]
  4990 000061BF 8B00                <1> 	mov	eax, [eax]
  4991 000061C1 21C0                <1> 	and	eax, eax
  4992 000061C3 74A5                <1> 	jz	short swpqs_3 ; invalid page directory
  4993                              <1> swpqs_9:
  4994 000061C5 52                  <1> 	push	edx
  4995                              <1> 	; eax = page directory
  4996                              <1> 	; ebx = virtual address
  4997 000061C6 E82BFBFFFF          <1> 	call	get_pte
  4998 000061CB 89D3                <1> 	mov	ebx, edx	; PTE address
  4999 000061CD 5A                  <1> 	pop	edx
  5000                              <1> 	; 10/06/2016
  5001 000061CE 723A                <1> 	jc	short swpqs_13 ; empty PDE
  5002                              <1> 	; EAX = PTE value
  5003 000061D0 A801                <1> 	test	al, PTE_A_PRESENT ; bit 0 = 1
  5004 000061D2 7436                <1> 	jz	short swpqs_13  ; Drop non-present page
  5005                              <1> 			        ; from the queue (head)
  5006 000061D4 A802                <1> 	test	al, PTE_A_WRITE	; bit 1 = 0 (read only)
  5007 000061D6 7432                <1> 	jz	short swpqs_13  ; Drop read only page
  5008                              <1> 			        ; from the queue (head) 	
  5009                              <1> 	;test	al, PTE_A_ACCESS ; bit 5 = 1 (Accessed)
  5010                              <1> 	;jnz	short swpqs_11  ; present
  5011                              <1> 			        ; accessed page
  5012 000061D8 0FBAF005            <1>         btr     eax, PTE_A_ACCESS_BIT ; reset 'accessed' bit
  5013 000061DC 7210                <1> 	jc	short swpqs_11  ; accessed page
  5014                              <1> 
  5015 000061DE 49                  <1> 	dec	ecx
  5016 000061DF 66890D[60050300]    <1> 	mov	[swpq_count], cx
  5017 000061E6 7402                <1>         jz      short swpqs_10
  5018                              <1> 		; esi = head + 4
  5019                              <1> 		; edi = head
  5020 000061E8 F3A5                <1> 	rep	movsd	 ; n = 1 to k-1, [n - 1] = [n]
  5021                              <1> swpqs_10:
  5022 000061EA 890F                <1> 	mov	[edi], ecx ; 0
  5023 000061EC EB8C                <1> 	jmp	short swpqs_6 ; 26/03/2017
  5024                              <1> 
  5025                              <1> swpqs_11:
  5026 000061EE 8903                <1> 	mov	[ebx], eax     ; save changed attribute
  5027                              <1> 	; Rotation (head -> tail)
  5028 000061F0 49                  <1> 	dec	ecx     ; entry count -> last entry number		
  5029 000061F1 74F7                <1> 	jz	short swpqs_10
  5030                              <1> 		; esi = head + 4
  5031                              <1> 		; edi = head
  5032 000061F3 8B07                <1> 	mov	eax, [edi] ; 20/07/2015
  5033 000061F5 F3A5                <1> 	rep	movsd	 ; n = 1 to k-1, [n - 1] = [n]
  5034 000061F7 8907                <1> 	mov	[edi], eax ; head -> tail ; [k] = [1]
  5035                              <1> 
  5036 000061F9 668B0D[60050300]    <1> 	mov	cx, [swpq_count]
  5037                              <1> 
  5038                              <1> swpqs_12:
  5039 00006200 BE00E00800          <1> 	mov	esi, swap_queue ; head
  5040 00006205 E974FFFFFF          <1>         jmp     swpqs_7
  5041                              <1> 
  5042                              <1> swpqs_13:
  5043 0000620A 49                  <1> 	dec	ecx
  5044 0000620B 66890D[60050300]    <1> 	mov	[swpq_count], cx
  5045 00006212 0F845EFFFFFF        <1>         jz      swpqs_5
  5046 00006218 EBE6                <1> 	jmp	short swpqs_12
  5047                              <1> 
  5048                              <1> add_to_swap_queue:
  5049                              <1> ; temporary - 16/09/2015
  5050 0000621A C3                  <1> retn
  5051                              <1> 	; 20/02/2017
  5052                              <1> 	; 20/07/2015
  5053                              <1> 	; 24/10/2014 (Retro UNIX 386 v1 - beginning)
  5054                              <1> 	;
  5055                              <1> 	; Adds new page to swap queue
  5056                              <1> 	; (page directories and page tables must not be added
  5057                              <1> 	; to swap queue)	
  5058                              <1> 	;
  5059                              <1> 	; INPUT ->
  5060                              <1> 	;	EBX = Linear (Virtual) addr for current process
  5061                              <1> 	;	[u.uno]
  5062                              <1> 	;	20/02/2017
  5063                              <1> 	;	(Linear address = CORE + user's virtual address)
  5064                              <1> 	;
  5065                              <1> 	; OUTPUT ->
  5066                              <1> 	;	EAX = [swpq_count]
  5067                              <1> 	;	      (after the PTE has been added)
  5068                              <1> 	;	EAX = 0 -> Swap queue is full, (1024 entries)
  5069                              <1> 	;	      the PTE could not be added.
  5070                              <1> 	;
  5071                              <1> 	; Modified Registers -> EAX
  5072                              <1> 	;
  5073 0000621B 53                  <1> 	push	ebx
  5074 0000621C 6681E300F0          <1>         and     bx, ~PAGE_OFF ; ~0FFFh ; reset bits, 0 to 11
  5075 00006221 8A1D[B3030300]      <1> 	mov	bl, [u.uno] ; current process number
  5076 00006227 E814FFFFFF          <1> 	call	swap_queue_shift ; drop from the queue if
  5077                              <1> 				 ; it is already on the queue
  5078                              <1> 		; then add it to the tail of the queue
  5079 0000622C 0FB705[60050300]    <1> 	movzx	eax, word [swpq_count]
  5080 00006233 663D0004            <1> 	cmp	ax, 1024
  5081 00006237 7205                <1> 	jb	short atsq_1
  5082 00006239 6629C0              <1> 	sub	ax, ax
  5083 0000623C 5B                  <1> 	pop	ebx
  5084 0000623D C3                  <1> 	retn
  5085                              <1> atsq_1:
  5086 0000623E 56                  <1> 	push	esi
  5087 0000623F BE00E00800          <1> 	mov	esi, swap_queue
  5088 00006244 6621C0              <1> 	and	ax, ax
  5089 00006247 740A                <1> 	jz	short atsq_2
  5090 00006249 66C1E002            <1> 	shl	ax, 2	; convert to offset
  5091 0000624D 01C6                <1> 	add	esi, eax
  5092 0000624F 66C1E802            <1> 	shr	ax, 2
  5093                              <1> atsq_2:
  5094 00006253 6640                <1> 	inc	ax
  5095 00006255 891E                <1> 	mov	[esi], ebx ; Virtual address + [u.uno] combination
  5096 00006257 66A3[60050300]      <1> 	mov	[swpq_count], ax
  5097 0000625D 5E                  <1> 	pop	esi
  5098 0000625E 5B                  <1> 	pop	ebx
  5099 0000625F C3                  <1> 	retn
  5100                              <1> 
  5101                              <1> unlink_swap_block:
  5102                              <1> 	; 15/09/2015
  5103                              <1> 	; 30/04/2015
  5104                              <1> 	; 18/04/2015
  5105                              <1> 	; 24/10/2014 (Retro UNIX 386 v1 - beginning)
  5106                              <1> 	;
  5107                              <1> 	; INPUT -> 
  5108                              <1> 	;	EAX = swap disk/file offset address
  5109                              <1> 	;	      (bit 1 to bit 31)
  5110                              <1> 	; OUTPUT ->
  5111                              <1> 	;	[swpd_free] is increased
  5112                              <1> 	;	(corresponding SWAP DISK ALLOC. TABLE bit is SET)
  5113                              <1> 	;
  5114                              <1> 	; Modified Registers -> EAX
  5115                              <1> 	;
  5116 00006260 53                  <1> 	push	ebx
  5117 00006261 52                  <1> 	push	edx
  5118                              <1> 	;
  5119 00006262 C1E804              <1> 	shr	eax, SECTOR_SHIFT+1  ;3+1 ; shift sector address to 
  5120                              <1> 				     ; 3 bits right
  5121                              <1> 				     ; to get swap block/page number
  5122 00006265 89C2                <1> 	mov	edx, eax
  5123                              <1> 	; 15/09/2015
  5124 00006267 C1EA03              <1> 	shr	edx, 3		     ; to get offset to S.A.T.
  5125                              <1> 				     ; (1 allocation bit = 1 page)
  5126                              <1> 				     ; (1 allocation bytes = 8 pages)
  5127 0000626A 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
  5128                              <1> 				     ; (to get 32 bit position)			
  5129                              <1> 	;
  5130 0000626D BB00000D00          <1> 	mov	ebx, swap_alloc_table ; Swap Allocation Table address
  5131 00006272 01D3                <1> 	add	ebx, edx
  5132 00006274 83E01F              <1> 	and	eax, 1Fh	     ; lower 5 bits only
  5133                              <1> 				     ; (allocation bit position)	 
  5134 00006277 3B05[6E050300]      <1> 	cmp 	eax, [swpd_next]     ; is the new free block addr. lower
  5135                              <1> 				     ; than the address in 'swpd_next' ?
  5136                              <1> 				     ; (next/first free block value)		
  5137 0000627D 7305                <1> 	jnb	short uswpbl_1	     ; no	
  5138 0000627F A3[6E050300]        <1> 	mov	[swpd_next], eax     ; yes	
  5139                              <1> uswpbl_1:
  5140 00006284 0FAB03              <1> 	bts	[ebx], eax	     ; unlink/release/deallocate block
  5141                              <1> 				     ; set relevant bit to 1.
  5142                              <1> 				     ; set CF to the previous bit value	
  5143 00006287 F5                  <1> 	cmc			     ; complement carry flag	
  5144 00006288 7206                <1> 	jc	short uswpbl_2	     ; do not increase swfd_free count
  5145                              <1> 				     ; if the block is already deallocated
  5146                              <1> 				     ; before.	
  5147 0000628A FF05[6A050300]      <1>         inc     dword [swpd_free]
  5148                              <1> uswpbl_2:
  5149 00006290 5A                  <1> 	pop	edx
  5150 00006291 5B                  <1> 	pop	ebx
  5151 00006292 C3                  <1> 	retn
  5152                              <1> 
  5153                              <1> link_swap_block:
  5154                              <1> 	; 01/07/2015
  5155                              <1> 	; 18/04/2015
  5156                              <1> 	; 24/10/2014 (Retro UNIX 386 v1 - beginning)
  5157                              <1> 	;
  5158                              <1> 	; INPUT -> none
  5159                              <1> 	;
  5160                              <1> 	; OUTPUT ->
  5161                              <1> 	;	EAX = OFFSET ADDRESS OF THE ALLOCATED BLOCK (4096 bytes)
  5162                              <1> 	;	      in sectors (corresponding 
  5163                              <1> 	;	      SWAP DISK ALLOCATION TABLE bit is RESET)
  5164                              <1> 	;
  5165                              <1> 	;	CF = 1 and EAX = 0 
  5166                              <1> 	; 		   if there is not a free block to be allocated	
  5167                              <1> 	;
  5168                              <1> 	; Modified Registers -> none (except EAX)
  5169                              <1> 	;
  5170                              <1> 
  5171                              <1> 	;mov	eax, [swpd_free]
  5172                              <1> 	;and	eax, eax
  5173                              <1> 	;jz	short out_of_swpspc
  5174                              <1> 	;
  5175 00006293 53                  <1> 	push	ebx
  5176 00006294 51                  <1> 	push	ecx
  5177                              <1> 	;
  5178 00006295 BB00000D00          <1> 	mov	ebx, swap_alloc_table ; Swap Allocation Table offset
  5179 0000629A 89D9                <1> 	mov	ecx, ebx
  5180 0000629C 031D[6E050300]      <1> 	add	ebx, [swpd_next] ; Free block searching starts from here
  5181                              <1> 				 ; next_free_swap_block >> 5
  5182 000062A2 030D[72050300]      <1> 	add	ecx, [swpd_last] ; Free block searching ends here
  5183                              <1> 				 ; (total_swap_blocks - 1) >> 5
  5184                              <1> lswbl_scan:
  5185 000062A8 39CB                <1> 	cmp	ebx, ecx
  5186 000062AA 770A                <1> 	ja	short lswbl_notfound
  5187                              <1> 	;
  5188 000062AC 0FBC03              <1> 	bsf	eax, [ebx] ; Scans source operand for first bit set (1).
  5189                              <1> 			   ; Clears ZF if a bit is found set (1) and 
  5190                              <1> 			   ; loads the destination with an index to
  5191                              <1> 			   ; first set bit. (0 -> 31) 
  5192                              <1> 			   ; Sets ZF to 1 if no bits are found set.
  5193                              <1> 	; 01/07/2015
  5194 000062AF 751C                <1> 	jnz	short lswbl_found ; ZF = 0 -> a free block has been found
  5195                              <1> 			 ;
  5196                              <1> 			 ; NOTE:  a Swap Disk Allocation Table bit 
  5197                              <1> 			 ;	  with value of 1 means 
  5198                              <1> 			 ;	  the corresponding page is free 
  5199                              <1> 			 ;	  (Retro UNIX 386 v1 feaure only!)
  5200 000062B1 83C304              <1> 	add	ebx, 4
  5201                              <1> 			 ; We return back for searching next page block
  5202                              <1> 			 ; NOTE: [swpd_free] is not ZERO; so, 
  5203                              <1> 			 ;	 we always will find at least 1 free block here.
  5204 000062B4 EBF2                <1> 	jmp    	short lswbl_scan
  5205                              <1> 	;
  5206                              <1> lswbl_notfound:	
  5207 000062B6 81E900000D00        <1> 	sub	ecx, swap_alloc_table
  5208 000062BC 890D[6E050300]      <1> 	mov	[swpd_next], ecx ; next/first free page = last page 
  5209                              <1> 				 ; (unlink_swap_block procedure will change it)
  5210 000062C2 31C0                <1> 	xor	eax, eax
  5211 000062C4 A3[6A050300]        <1> 	mov	[swpd_free], eax
  5212 000062C9 F9                  <1> 	stc
  5213                              <1> lswbl_ok:
  5214 000062CA 59                  <1> 	pop	ecx
  5215 000062CB 5B                  <1> 	pop	ebx
  5216 000062CC C3                  <1> 	retn
  5217                              <1> 	;
  5218                              <1> ;out_of_swpspc:
  5219                              <1> ;	stc
  5220                              <1> ;	retn
  5221                              <1> 
  5222                              <1> lswbl_found:
  5223 000062CD 89D9                <1> 	mov	ecx, ebx
  5224 000062CF 81E900000D00        <1> 	sub	ecx, swap_alloc_table
  5225 000062D5 890D[6E050300]      <1> 	mov	[swpd_next], ecx ; Set first free block searching start
  5226                              <1> 				 ; address/offset (to the next)
  5227 000062DB FF0D[6A050300]      <1>         dec     dword [swpd_free] ; 1 block has been allocated (X = X-1) 
  5228                              <1> 	;
  5229 000062E1 0FB303              <1> 	btr	[ebx], eax	 ; The destination bit indexed by the source value
  5230                              <1> 				 ; is copied into the Carry Flag and then cleared
  5231                              <1> 				 ; in the destination.
  5232                              <1> 				 ;
  5233                              <1> 				 ; Reset the bit which is corresponding to the 
  5234                              <1> 				 ; (just) allocated block.
  5235 000062E4 C1E105              <1> 	shl	ecx, 5		 ; (block offset * 32) + block index
  5236 000062E7 01C8                <1> 	add	eax, ecx	 ; = block number
  5237 000062E9 C1E003              <1> 	shl	eax, SECTOR_SHIFT ; 3, sector (offset) address of the block
  5238                              <1> 				 ; 1 block =  8 sectors
  5239                              <1> 	;
  5240                              <1> 	; EAX = offset address of swap disk/file sector (beginning of the block)
  5241                              <1> 	;
  5242                              <1> 	; NOTE: The relevant page table entry will be updated
  5243                              <1> 	;       according to this EAX value...
  5244                              <1> 	;
  5245 000062EC EBDC                <1> 	jmp	short lswbl_ok
  5246                              <1> 
  5247                              <1> logical_disk_read:
  5248                              <1> 	; 20/07/2015
  5249                              <1> 	; 09/03/2015 (temporary code here)
  5250                              <1> 	;
  5251                              <1> 	; INPUT ->
  5252                              <1> 	; 	ESI = Logical disk description table address
  5253                              <1> 	; 	EBX = Memory page (buffer) address (physical!)
  5254                              <1> 	; 	EAX = Sector adress (offset address, logical sector number)
  5255                              <1> 	; 	ECX = Sector count
  5256                              <1> 	;
  5257                              <1> 	;
  5258 000062EE C3                  <1> 	retn
  5259                              <1> 
  5260                              <1> logical_disk_write:
  5261                              <1> 	; 20/07/2015
  5262                              <1> 	; 09/03/2015 (temporary code here)
  5263                              <1> 	;
  5264                              <1> 	; INPUT ->
  5265                              <1> 	; 	ESI = Logical disk description table address
  5266                              <1> 	; 	EBX = Memory page (buffer) address (physical!)
  5267                              <1> 	; 	EAX = Sector adress (offset address, logical sector number)
  5268                              <1> 	; 	ECX = Sector count
  5269                              <1> 	;
  5270 000062EF C3                  <1> 	retn
  5271                              <1> 
  5272                              <1> get_physical_addr:
  5273                              <1> 	; 26/03/2017
  5274                              <1> 	; 20/02/2017
  5275                              <1> 	; 27/05/2016 - TRDOS 386 (TRDOS v2.0)
  5276                              <1> 	; 18/10/2015
  5277                              <1> 	; 29/07/2015
  5278                              <1> 	; 20/07/2015
  5279                              <1> 	; 04/06/2015
  5280                              <1> 	; 20/05/2015
  5281                              <1> 	; 28/04/2015
  5282                              <1> 	; 18/04/2015
  5283                              <1> 	; Get physical address
  5284                              <1> 	;     (allocates a new page for user if it is not present)
  5285                              <1> 	;	
  5286                              <1> 	; (This subroutine is needed for mapping user's virtual 
  5287                              <1> 	; (buffer) address to physical address (of the buffer).)
  5288                              <1> 	; ('sys write', 'sys read' system calls...)
  5289                              <1> 	;
  5290                              <1> 	; INPUT ->
  5291                              <1> 	;	EBX = virtual address
  5292                              <1> 	;	u.pgdir = page directory (physical) address
  5293                              <1> 	;
  5294                              <1> 	; OUTPUT ->
  5295                              <1> 	;	EAX = physical address 
  5296                              <1> 	;	EBX = linear address	
  5297                              <1> 	;	EDX = physical address of the page frame
  5298                              <1> 	;	      (with attribute bits)
  5299                              <1> 	;	ECX = byte count within the page frame
  5300                              <1> 	;
  5301                              <1> 	; Modified Registers -> EAX, EBX, ECX, EDX
  5302                              <1> 	;
  5303 000062F0 81C300004000        <1> 	add	ebx, CORE ; 18/10/2015
  5304                              <1> get_physical_addr_x: ; 27/05/2016
  5305 000062F6 A1[B8030300]        <1> 	mov	eax, [u.pgdir]
  5306 000062FB E8F6F9FFFF          <1> 	call	get_pte
  5307                              <1> 		; EDX = Page table entry address (if CF=0)
  5308                              <1> 	        ;       Page directory entry address (if CF=1)
  5309                              <1> 		;       (Bit 0 value is 0 if PT is not present)
  5310                              <1> 		; EAX = Page table entry value (page address)
  5311                              <1> 		;	CF = 1 -> PDE not present or invalid ? 
  5312 00006300 731C                <1> 	jnc	short gpa_1
  5313                              <1> 	;
  5314 00006302 E8D4F8FFFF          <1> 	call	allocate_page
  5315 00006307 7248                <1> 	jc	short gpa_im_err  ; 'insufficient memory' error
  5316                              <1> gpa_0:
  5317 00006309 E847F9FFFF          <1> 	call 	clear_page
  5318                              <1> 	; EAX = Physical (base) address of the allocated (new) page
  5319 0000630E 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER ; 4+2+1 = 7
  5320                              <1> 			   ; lower 3 bits are used as U/S, R/W, P flags
  5321                              <1> 			   ; (user, writable, present page)	
  5322 00006310 8902                <1> 	mov	[edx], eax ; Let's put the new page directory entry here !
  5323 00006312 A1[B8030300]        <1> 	mov	eax, [u.pgdir]	
  5324 00006317 E8DAF9FFFF          <1> 	call	get_pte
  5325 0000631C 7233                <1> 	jc	short gpa_im_err ; 'insufficient memory' error
  5326                              <1> gpa_1:
  5327                              <1> 	; EAX = PTE value, EDX = PTE address
  5328 0000631E A801                <1> 	test 	al, PTE_A_PRESENT
  5329 00006320 751F                <1> 	jnz	short gpa_3 ; 26/03/2017
  5330 00006322 09C0                <1> 	or	eax, eax
  5331 00006324 7456                <1> 	jz	short gpa_7  ; Allocate a new page
  5332                              <1> 	; 20/07/2015
  5333 00006326 55                  <1> 	push	ebp
  5334 00006327 89DD                <1> 	mov	ebp, ebx ; virtual (linear) address
  5335                              <1> 	; reload swapped page
  5336 00006329 E878000000          <1> 	call	reload_page ; 28/04/2015
  5337 0000632E 5D                  <1> 	pop	ebp
  5338 0000632F 724A                <1> 	jc	short gpa_retn
  5339                              <1> gpa_2:
  5340                              <1> 	; 26/03/2017
  5341                              <1> 	; 20/02/2017
  5342                              <1> 	; If a page will contain a Signal Response Byte
  5343                              <1> 	; it must not be swapped out, because
  5344                              <1> 	; timer service or irq callback service
  5345                              <1> 	; will write a signal return/response byte 
  5346                              <1> 	; directly by using physical address of Signal
  5347                              <1> 	; Response Byte.(Even if process is not running,
  5348                              <1> 	; or it is running with swapped out pages.)
  5349                              <1> 	;
  5350                              <1> 	; 'no_page_swap' will be set by 'systimer' or
  5351                              <1> 	; 'syscalbac' sistem functions/calls. (*)
  5352                              <1> 	;
  5353 00006331 803D[029C0100]00    <1> 	cmp	byte [no_page_swap], 0
  5354 00006338 761D                <1> 	jna	short gpa_4 ; this page can be swapped out
  5355                              <1> 	; this page must not be swapped out
  5356                              <1> 	; but 'no_page_swap' must be reset here
  5357                              <1> 	; imediately for other callers (*)
  5358                              <1> 	; (otherwise, swap queue would not be long enough) 
  5359 0000633A E84B000000          <1> 	call	gpa_8 ; 26/03/2017
  5360 0000633F EB1D                <1> 	jmp	short gpa_5
  5361                              <1> gpa_3: 
  5362                              <1> 	; 26/03/2017
  5363 00006341 803D[029C0100]00    <1> 	cmp	byte [no_page_swap], 0
  5364 00006348 7618                <1> 	jna	short gpa_6 ; this page can be swapped out
  5365 0000634A E83B000000          <1> 	call	gpa_8
  5366 0000634F EB11                <1> 	jmp	short gpa_6
  5367                              <1> 
  5368                              <1> gpa_im_err:	
  5369 00006351 B804000000          <1> 	mov	eax, ERR_MINOR_IM ; Insufficient memory (minor) error!
  5370                              <1> 				  ; Major error = 0 (No protection fault)	
  5371 00006356 C3                  <1> 	retn
  5372                              <1> gpa_4:
  5373                              <1> 	; 20/07/2015
  5374                              <1> 	; 20/05/2015
  5375                              <1> 	; add this page to swap queue
  5376 00006357 50                  <1> 	push	eax 
  5377                              <1> 	; EBX = Linear (CORE+virtual) address ; 20/02/2017 
  5378 00006358 E8BDFEFFFF          <1> 	call 	add_to_swap_queue
  5379 0000635D 58                  <1> 	pop	eax
  5380                              <1> gpa_5:
  5381                              <1> 		; PTE address in EDX
  5382                              <1> 		; virtual address in EBX
  5383                              <1> 	; EAX = memory page address
  5384 0000635E 0C07                <1> 	or	al, PTE_A_PRESENT + PTE_A_USER + PTE_A_WRITE
  5385                              <1> 				  ; present flag, bit 0 = 1
  5386                              <1> 				  ; user flag, bit 2 = 1	
  5387                              <1> 				  ; writable flag, bit 1 = 1
  5388 00006360 8902                <1> 	mov	[edx], eax  ; Update PTE value
  5389                              <1> gpa_6:
  5390                              <1> 	; 18/10/2015
  5391 00006362 89D9                <1> 	mov	ecx, ebx
  5392 00006364 81E1FF0F0000        <1> 	and	ecx, PAGE_OFF
  5393 0000636A 89C2                <1> 	mov 	edx, eax
  5394 0000636C 662500F0            <1> 	and	ax, PTE_A_CLEAR
  5395 00006370 01C8                <1> 	add	eax, ecx
  5396 00006372 F7D9                <1> 	neg	ecx ; 1 -> -1 (0FFFFFFFFh), 4095 (0FFFh) -> -4095
  5397 00006374 81C100100000        <1> 	add	ecx, PAGE_SIZE
  5398 0000637A F8                  <1> 	clc
  5399                              <1> gpa_retn:
  5400 0000637B C3                  <1> 	retn
  5401                              <1> gpa_7:	
  5402 0000637C E85AF8FFFF          <1> 	call	allocate_page
  5403 00006381 72CE                <1> 	jc	short gpa_im_err ; 'insufficient memory' error
  5404 00006383 E8CDF8FFFF          <1> 	call	clear_page
  5405 00006388 EBA7                <1> 	jmp	short gpa_2
  5406                              <1> 
  5407                              <1> gpa_8: ; 26/03/2017
  5408 0000638A C605[029C0100]00    <1> 	mov	byte [no_page_swap], 0
  5409 00006391 53                  <1> 	push	ebx
  5410 00006392 50                  <1> 	push	eax ; 26/03/2017
  5411 00006393 6681E300F0          <1>         and     bx, ~PAGE_OFF ; ~0FFFh ; reset bits, 0 to 11
  5412 00006398 8A1D[B3030300]      <1> 	mov	bl, [u.uno] ; current process number
  5413 0000639E E89DFDFFFF          <1> 	call	swap_queue_shift ; drop from the queue if
  5414                              <1> 				 ; it is already on the queue
  5415 000063A3 58                  <1> 	pop	eax ; 26/03/2017
  5416 000063A4 5B                  <1> 	pop	ebx
  5417 000063A5 C3                  <1> 	retn
  5418                              <1> 
  5419                              <1> reload_page:
  5420                              <1> 	; 20/07/2015
  5421                              <1> 	; 28/04/2015 (Retro UNIX 386 v1 - beginning)
  5422                              <1> 	;
  5423                              <1> 	; Reload (Restore) swapped page at memory
  5424                              <1> 	;
  5425                              <1> 	; INPUT -> 
  5426                              <1> 	;	EBP = Virtual (linear) memory address
  5427                              <1> 	;	EAX = PTE value (swap disk sector address)
  5428                              <1> 	;	(Swap disk sector address = bit 1 to bit 31 of EAX)	
  5429                              <1> 	; OUTPUT ->
  5430                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF RELOADED PAGE
  5431                              <1> 	;
  5432                              <1> 	;	CF = 1 and EAX = error code
  5433                              <1> 	;
  5434                              <1> 	; Modified Registers -> none (except EAX)
  5435                              <1> 	;
  5436 000063A6 D1E8                <1> 	shr	eax, 1   ; Convert PTE value to swap disk address 
  5437 000063A8 53                  <1> 	push	ebx      ;
  5438 000063A9 89C3                <1> 	mov	ebx, eax ; Swap disk (offset) address	
  5439 000063AB E82BF8FFFF          <1> 	call	allocate_page
  5440 000063B0 720C                <1> 	jc	short rlp_im_err
  5441 000063B2 93                  <1> 	xchg 	eax, ebx	
  5442                              <1> 	; EBX = Physical memory (page) address
  5443                              <1> 	; EAX = Swap disk (offset) address
  5444                              <1> 	; EBP = Virtual (linear) memory address
  5445 000063B3 E862FCFFFF          <1> 	call	swap_in
  5446 000063B8 720B                <1> 	jc	short rlp_swp_err  ; (swap disk/file read error)
  5447 000063BA 89D8                <1> 	mov	eax, ebx	
  5448                              <1> rlp_retn:
  5449 000063BC 5B                  <1> 	pop	ebx
  5450 000063BD C3                  <1> 	retn
  5451                              <1> 	
  5452                              <1> rlp_im_err:	
  5453 000063BE B804000000          <1> 	mov	eax, ERR_MINOR_IM ; Insufficient memory (minor) error!
  5454                              <1> 				  ; Major error = 0 (No protection fault)	
  5455 000063C3 EBF7                <1> 	jmp	short rlp_retn
  5456                              <1> 
  5457                              <1> rlp_swp_err:
  5458 000063C5 B828000000          <1> 	mov 	eax, SWP_DISK_READ_ERR ; Swap disk read error !
  5459 000063CA EBF0                <1> 	jmp	short rlp_retn
  5460                              <1> 
  5461                              <1> 
  5462                              <1> copy_page_dir:
  5463                              <1> 	; 19/09/2015
  5464                              <1> 	; temporary - 07/09/2015
  5465                              <1> 	; 07/09/2015 (Retro UNIX 386 v1 - beginning)
  5466                              <1> 	;
  5467                              <1> 	; INPUT -> 
  5468                              <1> 	;	[u.pgdir] = PHYSICAL (real/flat) ADDRESS of the parent's
  5469                              <1> 	;		    page directory.
  5470                              <1> 	; OUTPUT ->
  5471                              <1> 	;	EAX =  PHYSICAL (real/flat) ADDRESS of the child's
  5472                              <1> 	;	       page directory.
  5473                              <1> 	;	(New page directory with new page table entries.)
  5474                              <1> 	;	(New page tables with read only copies of the parent's
  5475                              <1> 	;	pages.)
  5476                              <1> 	;	EAX = 0 -> Error (CF = 1)
  5477                              <1> 	;
  5478                              <1> 	; Modified Registers -> none (except EAX)
  5479                              <1> 	;
  5480 000063CC E80AF8FFFF          <1> 	call	allocate_page
  5481 000063D1 723E                <1> 	jc	short cpd_err
  5482                              <1> 	;
  5483 000063D3 55                  <1> 	push	ebp ; 20/07/2015
  5484 000063D4 56                  <1> 	push	esi
  5485 000063D5 57                  <1> 	push	edi
  5486 000063D6 53                  <1> 	push	ebx
  5487 000063D7 51                  <1> 	push	ecx
  5488 000063D8 8B35[B8030300]      <1> 	mov	esi, [u.pgdir]
  5489 000063DE 89C7                <1> 	mov	edi, eax
  5490 000063E0 50                  <1> 	push	eax ; save child's page directory address
  5491                              <1> 	; copy PDE 0 from the parent's page dir to the child's page dir
  5492                              <1> 	; (use same system space for all user page tables) 
  5493 000063E1 A5                  <1> 	movsd
  5494 000063E2 BD00004000          <1> 	mov	ebp, 1024*4096 ; pass the 1st 4MB (system space)
  5495 000063E7 B9FF030000          <1> 	mov	ecx, (PAGE_SIZE / 4) - 1 ; 1023
  5496                              <1> cpd_0:	
  5497 000063EC AD                  <1> 	lodsd
  5498                              <1> 	;or	eax, eax
  5499                              <1>         ;jnz     short cpd_1
  5500 000063ED A801                <1> 	test	al, PDE_A_PRESENT ;  bit 0 =  1
  5501 000063EF 7508                <1> 	jnz	short cpd_1
  5502                              <1>  	; (virtual address at the end of the page table)	
  5503 000063F1 81C500004000        <1> 	add	ebp, 1024*4096 ; page size * PTE count
  5504 000063F7 EB0F                <1> 	jmp	short cpd_2
  5505                              <1> cpd_1:	
  5506 000063F9 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear attribute bits
  5507 000063FD 89C3                <1> 	mov	ebx, eax
  5508                              <1> 	; EBX = Parent's page table address
  5509 000063FF E81F000000          <1> 	call	copy_page_table
  5510 00006404 720C                <1> 	jc	short cpd_p_err
  5511                              <1> 	; EAX = Child's page table address
  5512 00006406 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER
  5513                              <1> 			 ; set bit 0, bit 1 and bit 2 to 1
  5514                              <1> 			 ; (present, writable, user)
  5515                              <1> cpd_2:
  5516 00006408 AB                  <1> 	stosd
  5517 00006409 E2E1                <1> 	loop	cpd_0
  5518                              <1> 	;
  5519 0000640B 58                  <1> 	pop	eax  ; restore child's page directory address
  5520                              <1> cpd_3:
  5521 0000640C 59                  <1> 	pop	ecx
  5522 0000640D 5B                  <1> 	pop	ebx
  5523 0000640E 5F                  <1> 	pop	edi
  5524 0000640F 5E                  <1> 	pop	esi
  5525 00006410 5D                  <1> 	pop	ebp
  5526                              <1> cpd_err:
  5527 00006411 C3                  <1> 	retn
  5528                              <1> cpd_p_err:
  5529                              <1> 	; release the allocated pages missing (recover free space)
  5530 00006412 58                  <1> 	pop	eax  ; the new page directory address (physical)
  5531 00006413 8B1D[B8030300]      <1> 	mov	ebx, [u.pgdir] ; parent's page directory address 
  5532 00006419 E8F6F8FFFF          <1> 	call 	deallocate_page_dir
  5533 0000641E 29C0                <1> 	sub	eax, eax ; 0
  5534 00006420 F9                  <1> 	stc
  5535 00006421 EBE9                <1> 	jmp	short cpd_3	
  5536                              <1> 
  5537                              <1> copy_page_table:
  5538                              <1> 	; 19/09/2015
  5539                              <1> 	; temporary - 07/09/2015
  5540                              <1> 	; 07/09/2015 (Retro UNIX 386 v1 - beginning)
  5541                              <1> 	;
  5542                              <1> 	; INPUT -> 
  5543                              <1> 	;	EBX = PHYSICAL (real/flat) ADDRESS of the parent's page table.
  5544                              <1> 	;	EBP = page table entry index (from 'copy_page_dir')
  5545                              <1> 	; OUTPUT ->
  5546                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS of the child's page table.
  5547                              <1> 	;	EBP = (recent) page table index (for 'add_to_swap_queue')	
  5548                              <1> 	;	CF = 1 -> error 
  5549                              <1> 	;
  5550                              <1> 	; Modified Registers -> EBP (except EAX)
  5551                              <1> 	;
  5552 00006423 E8B3F7FFFF          <1> 	call	allocate_page
  5553 00006428 725A                <1> 	jc	short cpt_err
  5554                              <1> 	;
  5555 0000642A 50                  <1> 	push	eax ; *
  5556                              <1> 	;push 	ebx
  5557 0000642B 56                  <1> 	push	esi
  5558 0000642C 57                  <1> 	push	edi
  5559 0000642D 52                  <1> 	push	edx
  5560 0000642E 51                  <1> 	push	ecx
  5561                              <1> 	;
  5562 0000642F 89DE                <1> 	mov	esi, ebx
  5563 00006431 89C7                <1> 	mov	edi, eax
  5564 00006433 89C2                <1> 	mov	edx, eax
  5565 00006435 81C200100000        <1> 	add	edx, PAGE_SIZE 	
  5566                              <1> cpt_0:
  5567 0000643B AD                  <1> 	lodsd
  5568 0000643C A801                <1> 	test	al, PTE_A_PRESENT ;  bit 0 =  1
  5569 0000643E 750B                <1> 	jnz	short cpt_1
  5570 00006440 21C0                <1> 	and	eax, eax
  5571 00006442 7430                <1> 	jz	short cpt_2
  5572                              <1> 	; ebp = virtual (linear) address of the memory page
  5573 00006444 E85DFFFFFF          <1> 	call	reload_page ; 28/04/2015
  5574 00006449 7234                <1> 	jc	short cpt_p_err
  5575                              <1> cpt_1:
  5576 0000644B 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits
  5577 0000644F 89C1                <1> 	mov	ecx, eax
  5578                              <1> 	; Allocate a new page for the child process
  5579 00006451 E885F7FFFF          <1> 	call	allocate_page
  5580 00006456 7227                <1> 	jc	short cpt_p_err
  5581 00006458 57                  <1> 	push	edi
  5582 00006459 56                  <1> 	push	esi
  5583 0000645A 89CE                <1> 	mov	esi, ecx
  5584 0000645C 89C7                <1> 	mov	edi, eax
  5585 0000645E B900040000          <1> 	mov	ecx, PAGE_SIZE/4
  5586 00006463 F3A5                <1> 	rep	movsd	; copy page (4096 bytes)
  5587 00006465 5E                  <1> 	pop	esi
  5588 00006466 5F                  <1> 	pop	edi
  5589                              <1> 	; 
  5590 00006467 53                  <1> 	push	ebx
  5591 00006468 50                  <1> 	push	eax
  5592 00006469 89EB                <1> 	mov	ebx, ebp
  5593                              <1> 	; ebx = virtual address of the memory page
  5594 0000646B E8AAFDFFFF          <1> 	call	add_to_swap_queue
  5595 00006470 58                  <1> 	pop	eax
  5596 00006471 5B                  <1> 	pop	ebx
  5597                              <1> 	;
  5598                              <1> 	;or	ax, PTE_A_USER+PTE_A_PRESENT 
  5599 00006472 0C07                <1> 	or	al, PTE_A_USER+PTE_A_WRITE+PTE_A_PRESENT 
  5600                              <1> cpt_2:
  5601 00006474 AB                  <1> 	stosd  ; EDI points to child's PTE  	 
  5602                              <1> 	;
  5603 00006475 81C500100000        <1> 	add	ebp, 4096 ; 20/07/2015 (next page)
  5604                              <1> 	;
  5605 0000647B 39D7                <1> 	cmp	edi, edx
  5606 0000647D 72BC                <1> 	jb	short cpt_0
  5607                              <1> cpt_p_err:
  5608 0000647F 59                  <1> 	pop	ecx
  5609 00006480 5A                  <1> 	pop	edx
  5610 00006481 5F                  <1> 	pop	edi
  5611 00006482 5E                  <1> 	pop	esi
  5612                              <1> 	;pop	ebx
  5613 00006483 58                  <1> 	pop	eax ; *
  5614                              <1> cpt_err:
  5615 00006484 C3                  <1> 	retn
  5616                              <1> 
  5617                              <1> allocate_memory_block:
  5618                              <1> 	; 01/05/2017
  5619                              <1> 	; 28/04/2017
  5620                              <1> 	; 25/04/2017
  5621                              <1> 	; 01/04/2016, 02/04/2016, 03/04/2016
  5622                              <1> 	; 13/03/2016, 14/03/2016
  5623                              <1> 	; 12/03/2016 (TRDOS 386 = TRDOS v2.0)
  5624                              <1> 	; Allocating contiguous memory pages (in the kernel's memory space)
  5625                              <1> 	;
  5626                              <1> 	; INPUT -> 
  5627                              <1> 	;	EAX = Beginning address (physical)
  5628                              <1> 	;	EAX = 0 -> Allocate memory block from the first proper aperture	
  5629                              <1> 	;	ECX = Number of bytes to be allocated
  5630                              <1> 	;
  5631                              <1> 	; OUTPUT ->
  5632                              <1> 	; 	1) cf = 0 -> successful
  5633                              <1> 	;	EAX = Beginning (physical) address of the allocated memory block
  5634                              <1> 	;	ECX = Number of allocated bytes (rounded up to page borders) 
  5635                              <1> 	;	2) cf = 1 -> unsuccessful
  5636                              <1> 	;	 2.1) If EAX > 0 -> 
  5637                              <1> 	;	      (Number of requested pages is more than # of free pages
  5638                              <1> 	;	       but contiguous free pages -the aperture- is not enough!)	   	
  5639                              <1> 	;	      EAX = Beginning address of available aperture
  5640                              <1> 	;		    (one of all aperture with max. aperture size/length)		
  5641                              <1> 	;	      ECX = Size of available aperture (memory block) in bytes
  5642                              <1> 	;	 2.2) If EAX = 0 -> Out of memory error 
  5643                              <1> 	;	            (number of free pages is less than requested number)
  5644                              <1> 	;	      ECX = Total number of free bytes (free pages * 4096) 
  5645                              <1> 	;		    (It is not number of contiguous free bytes)	
  5646                              <1> 	;
  5647                              <1> 	; (Modified Registers -> EAX, ECX)
  5648                              <1> 	;
  5649                              <1> 	; PURPOSE: Loading a file at memory for copying or running etc.
  5650                              <1> 	; If this procedure returns with cf is set, ECX contains maximum
  5651                              <1> 	; available space and EAX contains the beginning address of it.
  5652                              <1> 	; If EAX has zero, ECX contains total number of free bytes.
  5653                              <1> 	; If requested block has been successfully allocated (by rounding up to
  5654                              <1> 	; the last page border), it must be deallocated later by using
  5655                              <1> 	; 'deallocate_memory_block' procedure.    
  5656                              <1> 
  5657 00006485 52                  <1> 	push	edx ; *
  5658 00006486 BAFF0F0000          <1> 	mov	edx, PAGE_SIZE - 1   ; 4095
  5659 0000648B 01D0                <1> 	add	eax, edx
  5660 0000648D 01D1                <1> 	add	ecx, edx
  5661 0000648F C1E90C              <1> 	shr	ecx, PAGE_SHIFT	     ; 12
  5662                              <1> 
  5663                              <1> 	; ECX = number of contiguous pages to be allocated
  5664 00006492 8B15[388A0100]      <1> 	mov	edx, [free_pages]
  5665                              <1> 	; 01/05/2017
  5666                              <1> 	;or	ecx, ecx
  5667                              <1> 	;jz	short amb3
  5668                              <1> 	; If ECX=0, set cf to 1 and return with max. available mem block size
  5669                              <1> 
  5670 00006498 39D1                <1> 	cmp	ecx, edx
  5671 0000649A 7760                <1> 	ja	short amb_3
  5672                              <1> 
  5673 0000649C C1E80C              <1> 	shr	eax, PAGE_SHIFT      ; 12
  5674                              <1> 
  5675 0000649F 89C2                <1> 	mov	edx, eax 	     ; page number
  5676 000064A1 C1EA03              <1> 	shr	edx, 3		     ; to get offset to M.A.T.
  5677                              <1> 				     ; (1 allocation bit = 1 page)
  5678                              <1> 				     ; (1 allocation bytes = 8 pages)
  5679 000064A4 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
  5680                              <1> 				     ; (to get 32 bit position)	
  5681 000064A7 53                  <1> 	push	ebx ; **
  5682                              <1> amb_0:
  5683 000064A8 890D[EC950100]      <1> 	mov	[mem_ipg_count], ecx ; initial (reset) value of page count
  5684 000064AE 890D[F0950100]      <1> 	mov	[mem_pg_count], ecx
  5685 000064B4 31C9                <1> 	xor	ecx, ecx ; 0
  5686 000064B6 890D[F4950100]      <1> 	mov	[mem_aperture], ecx ; 0
  5687 000064BC 890D[F8950100]      <1> 	mov	[mem_max_aperture], ecx ; 0
  5688                              <1> 	
  5689 000064C2 BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL   ; Memory Allocation Table address.
  5690 000064C7 3B15[3C8A0100]      <1> 	cmp	edx, [next_page]     ; Is the beginning page address lower
  5691                              <1> 				     ; than the address in 'next_page' ?
  5692                              <1> 				     ; (the first/next free page of user space)		
  5693 000064CD 7208                <1> 	jb	short amb_1
  5694 000064CF 3B15[408A0100]      <1> 	cmp 	edx, [last_page]     ; is the beginning page address higher
  5695                              <1> 				     ; than the address in 'last_page' ?
  5696                              <1> 				     ; (end of the memory)		
  5697 000064D5 7606                <1> 	jna	short amb_2	     ; no	
  5698                              <1> amb_1:
  5699 000064D7 8B15[3C8A0100]      <1> 	mov	edx, [next_page]     ; M.A.T. offset (1 M.A.T. byte = 8 pages)
  5700                              <1> amb_2:
  5701 000064DD 01D3                <1> 	add	ebx, edx
  5702                              <1> 
  5703                              <1> 	; 28/04/2017
  5704                              <1> 	;xor	ecx, ecx
  5705 000064DF 0FBC0B              <1> 	bsf	ecx, [ebx]	     ; 0 to 31
  5706 000064E2 89D0                <1> 	mov	eax, edx
  5707 000064E4 C1E003              <1> 	shl	eax, 3		     ; *8	
  5708 000064E7 01C8                <1> 	add	eax, ecx	     ; beginning page number
  5709                              <1> 
  5710 000064E9 A3[FC950100]        <1> 	mov	[mem_pg_pos], eax    ; beginning page no (for curr. mem. aperture)
  5711 000064EE A3[00960100]        <1>  	mov	[mem_max_pg_pos], eax ; beginning page no for max. mem. aperture
  5712                              <1> 
  5713 000064F3 83E01F              <1> 	and	eax, 1Fh	     ; lower 5 bits only (0 to 31)
  5714                              <1> 				     ; (allocation bit position)	 
  5715 000064F6 750E                <1> 	jnz	short amb_4	     ; 0
  5716 000064F8 B120                <1> 	mov	cl, 32
  5717 000064FA EB4B                <1> 	jmp	short amb_10
  5718                              <1> 
  5719                              <1> amb_3:	; out_of_memory
  5720 000064FC 31C0                <1> 	xor	eax, eax ; 0
  5721 000064FE 89D1                <1> 	mov	ecx, edx ; free pages
  5722 00006500 C1E10C              <1> 	shl	ecx, PAGE_SHIFT
  5723 00006503 5A                  <1> 	pop	edx ; *
  5724 00006504 F9                  <1> 	stc
  5725 00006505 C3                  <1> 	retn	
  5726                              <1> amb_4:
  5727 00006506 8B13                <1> 	mov	edx, [ebx]
  5728 00006508 88C1                <1> 	mov	cl, al ; 1 to 31
  5729 0000650A D3EA                <1> 	shr	edx, cl
  5730 0000650C 89D0                <1> 	mov	eax, edx
  5731                              <1> amb_5:
  5732 0000650E D1E8                <1> 	shr	eax, 1 ; (***)
  5733 00006510 7317                <1> 	jnc	short amb_7
  5734 00006512 FF05[F4950100]      <1> 	inc	dword [mem_aperture]
  5735 00006518 FF0D[F0950100]      <1> 	dec	dword [mem_pg_count]
  5736 0000651E 7470                <1> 	jz	short amb_15
  5737                              <1> amb_6:
  5738                              <1> 	; 28/04/2017
  5739 00006520 FEC1                <1> 	inc	cl
  5740 00006522 80F920              <1> 	cmp	cl, 32
  5741 00006525 730D                <1> 	jnb	short amb_9
  5742 00006527 EBE5                <1> 	jmp	short amb_5
  5743                              <1> amb_7:
  5744 00006529 50                  <1> 	push	eax ; (***) allocation bits (in shifted status)
  5745 0000652A E81B010000          <1> 	call	amb_26 ; set maximum memory aperture (free memory block size)
  5746 0000652F 58                  <1> 	pop	eax ; (***)
  5747 00006530 EBEE                <1> 	jmp	short amb_6
  5748                              <1> amb_8:
  5749                              <1> 	; 28/04/2017
  5750 00006532 B120                <1> 	mov	cl, 32
  5751                              <1> amb_9:
  5752 00006534 89DA                <1> 	mov	edx, ebx
  5753 00006536 81EA00001000        <1> 	sub	edx, MEM_ALLOC_TBL
  5754 0000653C 3B15[408A0100]      <1> 	cmp	edx, [last_page]
  5755 00006542 7336                <1> 	jnb	short amb_14 ; contiguous pages not enough
  5756 00006544 83C304              <1> 	add	ebx, 4
  5757                              <1> amb_10:
  5758 00006547 8B03                <1> 	mov	eax, [ebx]
  5759 00006549 21C0                <1> 	and 	eax, eax
  5760 0000654B 7408                <1>         jz      short amb_11 ; there is not a free page bit in this alloc dword
  5761 0000654D 40                  <1> 	inc	eax ; 0FFFFFFFFh -> 0
  5762 0000654E 740C                <1> 	jz	short amb_12 ; all of bits are set (32 free pages)
  5763 00006550 48                  <1> 	dec	eax
  5764 00006551 28C9                <1> 	sub	cl, cl ; 0
  5765 00006553 EBB9                <1> 	jmp	short amb_5
  5766                              <1> amb_11:
  5767 00006555 E8F0000000          <1> 	call	amb_26 ; set maximum memory aperture (free memory block size)
  5768 0000655A EBD8                <1> 	jmp	short amb_9	
  5769                              <1> amb_12:
  5770 0000655C 390D[F0950100]      <1> 	cmp	[mem_pg_count], ecx ; 32
  5771 00006562 7306                <1> 	jnb	short amb_13
  5772 00006564 8B0D[F0950100]      <1> 	mov	ecx, [mem_pg_count]
  5773                              <1> amb_13:
  5774 0000656A 010D[F4950100]      <1> 	add	[mem_aperture], ecx
  5775 00006570 290D[F0950100]      <1> 	sub	[mem_pg_count], ecx
  5776 00006576 7618                <1> 	jna	short amb_15
  5777 00006578 EBBA                <1> 	jmp	short amb_9 ; 01/05/2017
  5778                              <1> amb_14:
  5779 0000657A E8CB000000          <1> 	call	amb_26 ; 28/04/2017
  5780 0000657F A1[00960100]        <1> 	mov	eax, [mem_max_pg_pos] ; begin address of max. mem aperture	
  5781 00006584 8B0D[F8950100]      <1> 	mov	ecx, [mem_max_aperture] ; max. (largest) memory aperture
  5782 0000658A F9                  <1> 	stc
  5783 0000658B E9AF000000          <1>         jmp     amb_25
  5784                              <1> 
  5785                              <1> amb_15: ; OK !
  5786 00006590 A1[FC950100]        <1> 	mov	eax, [mem_pg_pos]    ; Beginning address as page number
  5787 00006595 8B0D[F4950100]      <1> 	mov	ecx, [mem_aperture]  ; Free contiguous page count (>=1)
  5788                              <1> amb_16:
  5789                              <1> 	; allocate contiguous memory pages (via memory allocation table bits)
  5790 0000659B 89C2                <1> 	mov	edx, eax
  5791                              <1> 	; 25/04/2017
  5792 0000659D C1EA03              <1> 	shr	edx, 3		 ; 8 pages in one allocation byte
  5793 000065A0 80E2FC              <1> 	and	dl, 0FCh	 ; clear lower 2 bits
  5794                              <1> 				 ; (for dword/32bit positioning)	
  5795                              <1> 
  5796 000065A3 BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL
  5797 000065A8 01D3                <1> 	add	ebx, edx
  5798 000065AA 83E01F              <1> 	and	eax, 1Fh ; 31
  5799                              <1> 	; 03/04/2016
  5800 000065AD BA20000000          <1> 	mov	edx, 32
  5801 000065B2 28C2                <1> 	sub	dl, al
  5802 000065B4 39CA                <1> 	cmp	edx, ecx	 ; ecx >= 1
  5803 000065B6 7602                <1> 	jna	short amb_17
  5804 000065B8 89CA                <1> 	mov	edx, ecx
  5805                              <1> amb_17:
  5806 000065BA 29D1                <1> 	sub	ecx, edx
  5807 000065BC 51                  <1> 	push	ecx ; ***
  5808 000065BD 89D1                <1> 	mov	ecx, edx
  5809                              <1> amb_18:		
  5810 000065BF 0FB303              <1> 	btr	[ebx], eax	 ; The destination bit indexed by the source value
  5811                              <1> 				 ; is copied into the Carry Flag and then cleared
  5812                              <1> 				 ; in the destination.
  5813 000065C2 FF0D[388A0100]      <1> 	dec     dword [free_pages] ; 1 page has been allocated (X = X-1) 
  5814 000065C8 49                  <1> 	dec	ecx
  5815 000065C9 7404                <1> 	jz	short amb_19
  5816 000065CB FEC0                <1> 	inc	al
  5817 000065CD EBF0                <1> 	jmp	short amb_18
  5818                              <1> amb_19:	
  5819 000065CF 59                  <1> 	pop	ecx ; ***
  5820 000065D0 21C9                <1> 	and	ecx, ecx ; 0 ?
  5821 000065D2 741E                <1> 	jz	short amb_22	
  5822                              <1> 	; 01/04/2016
  5823 000065D4 B020                <1> 	mov	al, 32
  5824                              <1> amb_20:
  5825 000065D6 83C304              <1> 	add	ebx, 4
  5826 000065D9 39C1                <1> 	cmp	ecx, eax ; 32
  5827 000065DB 7305                <1> 	jnb	short amb_21
  5828                              <1> 	; ECX < 32
  5829 000065DD 28C0                <1> 	sub	al, al ; 0
  5830 000065DF 50                  <1> 	push	eax ; 0 ***
  5831 000065E0 EBDD                <1> 	jmp	short amb_18
  5832                              <1> amb_21:
  5833 000065E2 2905[388A0100]      <1> 	sub	[free_pages], eax   ; [free_pages] = [free_pages] - 32
  5834 000065E8 C70300000000        <1> 	mov	dword [ebx], 0	    ; reset 32 bits
  5835 000065EE 29C1                <1> 	sub	ecx, eax ; 32
  5836 000065F0 75E4                <1> 	jnz	short amb_20
  5837                              <1> amb_22:
  5838 000065F2 A1[FC950100]        <1> 	mov	eax, [mem_pg_pos]   ; Beginning address as page number
  5839 000065F7 8B0D[F4950100]      <1> 	mov	ecx, [mem_aperture] ; Free contiguous page count
  5840                              <1> 	; [next_page] update
  5841 000065FD 89C2                <1> 	mov	edx, eax
  5842                              <1> 	; 03/04/2016
  5843 000065FF C1EA03              <1> 	shr	edx, 3		     ; to get offset to M.A.T.
  5844                              <1> 				     ; (1 allocation bit = 1 page)
  5845                              <1> 				     ; (1 allocation bytes = 8 pages)
  5846 00006602 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
  5847                              <1> 				     ; (to get 32 bit position)	
  5848 00006605 3B15[3C8A0100]      <1> 	cmp	edx, [next_page] ; first free page pointer offset
  5849 0000660B 7732                <1> 	ja	short amb_25
  5850 0000660D BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL
  5851 00006612 833C1300            <1> 	cmp	dword [ebx+edx], 0
  5852 00006616 7721                <1> 	ja	short amb_24
  5853 00006618 89C2                <1> 	mov	edx, eax
  5854 0000661A 01CA                <1> 	add	edx, ecx
  5855 0000661C C1EA03              <1> 	shr	edx, 3
  5856 0000661F 80E2FC              <1> 	and	dl, 0FCh
  5857                              <1> amb_23:
  5858 00006622 833C1300            <1> 	cmp	dword [ebx+edx], 0
  5859 00006626 7711                <1> 	ja	short amb_24
  5860 00006628 83C204              <1> 	add	edx, 4
  5861 0000662B 3B15[408A0100]      <1> 	cmp	edx, [last_page]    ; last page pointer offset
  5862 00006631 76EF                <1> 	jna	short amb_23
  5863 00006633 8B15[448A0100]      <1> 	mov	edx, [first_page]   ; (for) beginning of user's space
  5864                              <1> amb_24:
  5865 00006639 8915[3C8A0100]      <1> 	mov	[next_page], edx
  5866                              <1> amb_25:
  5867 0000663F 9C                  <1> 	pushf
  5868 00006640 C1E00C              <1> 	shl	eax, PAGE_SHIFT	     ; convert to phy. address in bytes
  5869 00006643 C1E10C              <1> 	shl	ecx, PAGE_SHIFT	     ; convert to byte counts
  5870 00006646 9D                  <1> 	popf
  5871 00006647 5B                  <1> 	pop	ebx ; **
  5872 00006648 5A                  <1> 	pop	edx ; *
  5873 00006649 C3                  <1> 	retn
  5874                              <1> 
  5875                              <1> amb_26:	; set maximum free memory aperture (free memory block size) 
  5876 0000664A 89DA                <1> 	mov	edx, ebx ; current address
  5877 0000664C 81EA00001000        <1> 	sub	edx, MEM_ALLOC_TBL ; MAT beginning address
  5878                              <1> 	; 02/04/2016 
  5879 00006652 C1E203              <1> 	shl	edx, 3 ; MAT byte offset * 8 = page number base
  5880 00006655 01CA                <1> 	add	edx, ecx ; current page number (ecx = 0 to 32)
  5881                              <1> 	;
  5882 00006657 A1[F4950100]        <1> 	mov	eax, [mem_aperture]
  5883 0000665C 21C0                <1> 	and	eax, eax
  5884 0000665E 7421                <1>         jz      short amb_27
  5885 00006660 C705[F4950100]0000- <1>         mov     dword [mem_aperture], 0
  5885 00006668 0000                <1>
  5886 0000666A 3B05[F8950100]      <1> 	cmp	eax, [mem_max_aperture]
  5887 00006670 760F                <1> 	jna	short amb_27
  5888 00006672 A3[F8950100]        <1> 	mov	[mem_max_aperture], eax
  5889                              <1> 	; 25/04/2017
  5890 00006677 A1[FC950100]        <1> 	mov	eax, [mem_pg_pos]
  5891                              <1> 	; EAX = Beginning page number of the max. aperture 
  5892 0000667C A3[00960100]        <1> 	mov	[mem_max_pg_pos], eax
  5893                              <1> amb_27: 
  5894 00006681 8915[FC950100]      <1> 	mov	[mem_pg_pos], edx ; current page
  5895                              <1> 
  5896 00006687 A1[EC950100]        <1> 	mov	eax, [mem_ipg_count] ; initial (reset) value of page count
  5897 0000668C A3[F0950100]        <1> 	mov	[mem_pg_count], eax
  5898                              <1> 
  5899 00006691 C3                  <1> 	retn
  5900                              <1> 
  5901                              <1> deallocate_memory_block:
  5902                              <1> 	; 03/04/2016
  5903                              <1> 	; 14/03/2016 (TRDOS 386 = TRDOS v2.0)
  5904                              <1> 	; Deallocating contiguous memory pages (in the kernel's memory space)
  5905                              <1> 	;
  5906                              <1> 	; INPUT -> 
  5907                              <1> 	;	EAX = Beginning address (physical)
  5908                              <1> 	;	ECX = Number of bytes to be deallocated
  5909                              <1> 	;
  5910                              <1> 	; OUTPUT ->
  5911                              <1> 	;	Memory Allocation Table bits will be updated
  5912                              <1> 	;	[free_pages] will be changed (increased)
  5913                              <1> 	;
  5914                              <1> 	; (Modified Registers -> EAX, ECX)
  5915                              <1> 	;
  5916                              <1> 	; PURPOSE: Unloading/Freeing a file -or an allocated memory block- 
  5917                              <1> 	; at memory after copying, running, saving, reading, writing etc.
  5918                              <1> 	;
  5919                              <1> 
  5920 00006692 52                  <1> 	push	edx ; *
  5921 00006693 53                  <1> 	push	ebx ; **
  5922                              <1> 
  5923 00006694 C1E80C              <1> 	shr	eax, PAGE_SHIFT	     ; 12
  5924 00006697 C1E90C              <1> 	shr	ecx, PAGE_SHIFT	     ; 12
  5925                              <1> 
  5926                              <1> 	; EAX = Beginning page number
  5927                              <1> 	; ECX = Number of contiguous pages to be deallocated
  5928                              <1> damb_0:
  5929                              <1> 	; deallocate contiguous memory pages (via memory allocation table bits)
  5930 0000669A 89C2                <1> 	mov	edx, eax
  5931 0000669C C1EA03              <1> 	shr	edx, 3		     ; to get offset to M.A.T.
  5932                              <1> 				     ; (1 allocation bit = 1 page)
  5933                              <1> 				     ; (1 allocation bytes = 8 pages)
  5934 0000669F 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
  5935                              <1> 				     ; (to get 32 bit position)	
  5936 000066A2 3B15[3C8A0100]      <1> 	cmp	edx, [next_page] ; next free page
  5937 000066A8 7306                <1> 	jnb	short damb_1
  5938 000066AA 8915[3C8A0100]      <1> 	mov	[next_page], edx
  5939                              <1> damb_1:
  5940 000066B0 BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL
  5941 000066B5 01D3                <1> 	add	ebx, edx
  5942 000066B7 83E01F              <1> 	and	eax, 1Fh ; 31
  5943                              <1> 
  5944                              <1> 	; 03/04/2016
  5945 000066BA BA20000000          <1> 	mov	edx, 32
  5946 000066BF 28C2                <1> 	sub	dl, al
  5947 000066C1 39CA                <1> 	cmp	edx, ecx
  5948 000066C3 7602                <1> 	jna	short damb_2
  5949 000066C5 89CA                <1> 	mov	edx, ecx
  5950                              <1> damb_2:
  5951 000066C7 29D1                <1> 	sub	ecx, edx
  5952 000066C9 51                  <1> 	push	ecx ; ***
  5953 000066CA 89D1                <1> 	mov	ecx, edx
  5954                              <1> damb_3:		
  5955 000066CC 0FAB03              <1> 	bts	[ebx], eax	     ; unlink/release/deallocate page
  5956                              <1> 				     ; set relevant bit to 1.
  5957                              <1> 				     ; set CF to the previous bit value	
  5958 000066CF FF05[388A0100]      <1> 	inc     dword [free_pages]   ; 1 page has been deallocated (X = X+1) 
  5959 000066D5 49                  <1> 	dec	ecx
  5960 000066D6 7404                <1> 	jz	short damb_4
  5961 000066D8 FEC0                <1> 	inc	al
  5962 000066DA EBF0                <1> 	jmp	short damb_3
  5963                              <1> damb_4:	
  5964 000066DC 59                  <1> 	pop	ecx ; ***
  5965 000066DD 21C9                <1> 	and	ecx, ecx ; 0 ?
  5966 000066DF 741E                <1> 	jz	short damb_7
  5967                              <1> 	; 03/04/2016
  5968 000066E1 B020                <1> 	mov	al, 32
  5969                              <1> damb_5:
  5970 000066E3 83C304              <1> 	add	ebx, 4
  5971 000066E6 39C1                <1> 	cmp	ecx, eax ; 32
  5972 000066E8 7305                <1> 	jnb	short damb_6
  5973                              <1> 	; ECX < 32
  5974 000066EA 28C0                <1> 	sub	al, al ; 0
  5975 000066EC 50                  <1> 	push	eax ; 0 ***
  5976 000066ED EBDD                <1> 	jmp	short damb_3
  5977                              <1> damb_6:
  5978 000066EF 0105[388A0100]      <1> 	add	[free_pages], eax ; [free_pages] = [free_pages] + 32
  5979 000066F5 C703FFFFFFFF        <1> 	mov	dword [ebx], 0FFFFFFFFh ; set 32 bits
  5980 000066FB 29C1                <1> 	sub	ecx, eax ; 32
  5981 000066FD 75E4                <1> 	jnz	short damb_5
  5982                              <1> damb_7:
  5983 000066FF 5B                  <1> 	pop	ebx ; **
  5984 00006700 5A                  <1> 	pop	edx ; *
  5985 00006701 C3                  <1> 	retn
  5986                              <1> 
  5987                              <1> direct_memory_access:
  5988                              <1> 	; 22/07/2017
  5989                              <1> 	; 12/05/2017
  5990                              <1> 	; 16/07/2016
  5991                              <1> 	; 12/07/2016 (TRDOS 386 = TRDOS v2.0)
  5992                              <1> 	; This processure will be called to map
  5993                              <1> 	; user's (ring 3) page tables to access phsical
  5994                              <1> 	; (flat/linear) memory addresses, directly (without
  5995                              <1> 	;  kernel's data transfer functions).
  5996                              <1> 	; 
  5997                              <1> 	; Purpose: Video memory access and shared memory access.
  5998                              <1> 	;
  5999                              <1> 	; INPUT -> 
  6000                              <1> 	;	EAX = Beginning address (physical).
  6001                              <1> 	;	EBX = User's buffer address ; 12/05/2017
  6002                              <1> 	;	ECX = Number of contiguous pages to be mapped.
  6003                              <1> 	; OUTPUT ->
  6004                              <1> 	;	User's page directory and pages tables
  6005                              <1> 	;	will be updated.
  6006                              <1> 	;	
  6007                              <1> 	;	If an old page table entry has valid page address, 
  6008                              <1> 	;	that page will be deallocated just before PTE will
  6009                              <1> 	;	be changed for direct (1 to 1) memory page access.
  6010                              <1> 	;
  6011                              <1> 	;	If old PTE value points to a swapped page,
  6012                              <1>         ;       that page (block) will be unlinked on swap disk. 
  6013                              <1> 	;
  6014                              <1> 	;	Newly allocated pages (except page tables) will not
  6015                              <1> 	;	be applied to Memory Allocation Table.
  6016                              <1> 	;	AVL bit 1 (PTE bit 10) of page table entry will be
  6017                              <1> 	;	used to indicate shared (direct) memory page; then,
  6018                              <1> 	;	this page will not be deallocated later during
  6019                              <1> 	;	process termination. (Memory Allocation Table and
  6020                              <1> 	;	free memory count will not be affected.
  6021                              <1> 	;	(Except deallocating page table's itself.)
  6022                              <1> 	;	
  6023                              <1> 	;      CF = 1 -> error (EAX = error code)
  6024                              <1> 	;      CF = 0 -> success (EAX = beginning address)
  6025                              <1> 	;
  6026                              <1> 	;; (Modified Registers -> none)
  6027                              <1> 	; Modified registers: ebp, edx, ecx, ebx, esi, edi	
  6028                              <1> 	;
  6029                              <1> 
  6030                              <1> 	;push	ebp
  6031                              <1> 	;push	ebx
  6032                              <1> 	;push	ecx
  6033                              <1> 	;push	edx
  6034 00006702 662500F0            <1> 	and	ax, PTE_A_CLEAR ; clear page offset
  6035 00006706 50                  <1> 	push	eax
  6036                              <1> 	;and	ecx, ecx ; page count
  6037                              <1> 	;jz	dmem_acc_7  ; 'insufficient memory' error
  6038 00006707 89C5                <1> 	mov	ebp, eax
  6039 00006709 81C300004000        <1> 	add	ebx, CORE ; 12/05/2017
  6040                              <1> dmem_acc_0: 
  6041 0000670F 891D[ECA00100]      <1> 	mov	[base_addr], ebx ; 12/05/2017
  6042 00006715 A1[B8030300]        <1> 	mov	eax, [u.pgdir] ; page dir address (physical)
  6043 0000671A E8D7F5FFFF          <1> 	call	get_pte
  6044                              <1> 		; EDX = Page table entry address (if CF=0)
  6045                              <1> 	        ;       Page directory entry address (if CF=1)
  6046                              <1> 		;       (Bit 0 value is 0 if PT is not present)
  6047                              <1> 		; EAX = Page table entry value (page address)
  6048                              <1> 		;	CF = 1 -> PDE not present or invalid ? 	
  6049 0000671F 7324                <1> 	jnc	short dmem_acc_1
  6050                              <1> 	;
  6051 00006721 E8B5F4FFFF          <1> 	call	allocate_page
  6052 00006726 0F82AB000000        <1>         jc      dmem_acc_7  ; 'insufficient memory' error
  6053                              <1> 	;
  6054 0000672C E824F5FFFF          <1> 	call 	clear_page
  6055                              <1> 	; EAX = Physical (base) address of the allocated (new) page
  6056 00006731 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER ; 4+2+1 = 7
  6057                              <1> 			   ; lower 3 bits are used as U/S, R/W, P flags
  6058                              <1> 			   ; (user, writable, present page)	
  6059 00006733 8902                <1> 	mov	[edx], eax ; Let's put the new page directory entry here !
  6060 00006735 A1[B8030300]        <1> 	mov	eax, [u.pgdir]	
  6061 0000673A E8B7F5FFFF          <1> 	call	get_pte
  6062 0000673F 0F8292000000        <1>         jc      dmem_acc_7 ; 'insufficient memory' error
  6063                              <1> dmem_acc_1:
  6064                              <1> 	; EAX = PTE value, EDX = PTE address
  6065 00006745 A801                <1> 	test 	al, PTE_A_PRESENT
  6066 00006747 750D                <1> 	jnz	short dmem_acc_2
  6067 00006749 09C0                <1> 	or	eax, eax
  6068 0000674B 7468                <1> 	jz	short dmem_acc_6   ; Change PTE
  6069 0000674D D1E8                <1> 	shr	eax, 1		; swap disk block (8 sectors) address
  6070                              <1> 	; unlink swap disk block
  6071 0000674F E80CFBFFFF          <1> 	call	unlink_swap_block
  6072 00006754 EB5F                <1> 	jmp	short dmem_acc_6
  6073                              <1> 
  6074                              <1> dmem_acc_2:
  6075 00006756 A802                <1> 	test	al, PTE_A_WRITE   ; bit 1, writable (r/w) flag
  6076                              <1> 				  ; (must be 1)
  6077 00006758 7550                <1> 	jnz	short dmem_acc_4
  6078                              <1> 	; Read only -duplicated- page (belongs to a parent or a child)
  6079 0000675A 66A90002            <1>         test    ax, PTE_DUPLICATED ; Was this page duplicated 
  6080                              <1> 				   ; as child's page ?
  6081 0000675E 7455                <1> 	jz	short dmem_acc_5 ; Change PTE but don't deallocate the page!
  6082                              <1> 
  6083                              <1> 	;push	edi
  6084                              <1> 	;push	esi
  6085                              <1> 
  6086 00006760 51                  <1> 	push	ecx
  6087                              <1> 	;push	ebx
  6088 00006761 8B1D[BC030300]      <1> 	mov	ebx, [u.ppgdir] ; parent's page dir address (physical)
  6089                              <1> 	
  6090                              <1> 	; check the parent's PTE value is read only & same page or not.. 
  6091 00006767 89EF                <1> 	mov	edi, ebp
  6092 00006769 C1EF16              <1> 	shr	edi, PAGE_D_SHIFT ; 22
  6093                              <1> 	; EDI = page directory entry index (0-1023)
  6094 0000676C 89EE                <1> 	mov	esi, ebp
  6095 0000676E C1EE0C              <1> 	shr	esi, PAGE_SHIFT ; 12	
  6096 00006771 81E6FF030000        <1> 	and	esi, PTE_MASK
  6097                              <1> 	; ESI = page table entry index (0-1023)
  6098                              <1> 
  6099 00006777 66C1E702            <1> 	shl	di, 2 ; * 4
  6100 0000677B 01FB                <1> 	add	ebx, edi ; PDE offset (for the parent)
  6101 0000677D 8B0F                <1> 	mov	ecx, [edi]
  6102 0000677F F6C101              <1> 	test	cl, PDE_A_PRESENT ; present (valid) or not ?
  6103 00006782 7425                <1> 	jz	short dmem_acc_3	; parent process does not use this page
  6104 00006784 6681E100F0          <1> 	and	cx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
  6105 00006789 66C1E602            <1> 	shl	si, 2 ; *4 
  6106 0000678D 01CE                <1> 	add	esi, ecx ; PTE offset (for the parent)
  6107 0000678F 8B1E                <1> 	mov	ebx, [esi]
  6108 00006791 F6C301              <1> 	test	bl, PTE_A_PRESENT ; present or not ?
  6109 00006794 7413                <1> 	jz	short dmem_acc_3	; parent process does not use this page
  6110 00006796 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; Clear attribute bits 
  6111 0000679A 6681E300F0          <1> 	and	bx, PTE_A_CLEAR ; 0F000h ; Clear attribute bits
  6112 0000679F 39D8                <1> 	cmp	eax, ebx	; parent's and child's pages are same ?
  6113 000067A1 7506                <1> 	jne	short dmem_acc_3	; not same page
  6114                              <1> 				; deallocate the child's page
  6115 000067A3 800E02              <1>         or      byte [esi], PTE_A_WRITE ; convert to writable page (parent)
  6116                              <1> 	;pop	ebx
  6117 000067A6 59                  <1> 	pop	ecx
  6118 000067A7 EB0C                <1> 	jmp	short dmem_acc_5
  6119                              <1> dmem_acc_3:
  6120                              <1> 	;pop	ebx
  6121 000067A9 59                  <1> 	pop	ecx
  6122                              <1> dmem_acc_4:	
  6123 000067AA 66A90004            <1> 	test	ax, PTE_SHARED ; shared or direct memory access indicator
  6124 000067AE 7505                <1> 	jnz	short dmem_acc_5   ; AVL bit 1 = 1, do not deallocate this page!
  6125                              <1> 	;
  6126                              <1> 	;and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
  6127 000067B0 E804F6FFFF          <1> 	call	deallocate_page
  6128                              <1> dmem_acc_5:
  6129                              <1> 	;pop	esi
  6130                              <1> 	;pop	edi
  6131                              <1> dmem_acc_6:
  6132 000067B5 89E8                <1> 	mov	eax, ebp ; physical page (offset=0) address
  6133                              <1> 	; EAX = memory page address
  6134                              <1> 	; EDX = PTE entry address (physical)
  6135 000067B7 660D0704            <1> 	or	ax, PTE_A_PRESENT+PTE_A_USER+PTE_A_WRITE+PTE_SHARED
  6136                              <1> 			; present flag, bit 0 = 1
  6137                              <1> 			; user flag, bit 2 = 1	
  6138                              <1> 			; writable flag, bit 1 = 1
  6139                              <1> 			; direct memory access flag, bit 10 = 1
  6140                              <1> 			; (This page must not be deallocated!)
  6141 000067BB 8902                <1> 	mov	[edx], eax  ; Update PTE value
  6142 000067BD 49                  <1> 	dec	ecx ; remain count of contiguous pages
  6143 000067BE 741E                <1> 	jz	short dmem_acc_8
  6144 000067C0 81C500100000        <1> 	add	ebp, PAGE_SIZE ; next physical page address
  6145                              <1> 	; 22/07/2017
  6146                              <1> 	;mov	eax, ebp
  6147                              <1> 	; 12/05/2017
  6148 000067C6 8B1D[ECA00100]      <1> 	mov	ebx, [base_addr] ; linear address (virtual+CORE)
  6149 000067CC 81C300100000        <1> 	add	ebx, PAGE_SIZE	; next linear address
  6150 000067D2 E938FFFFFF          <1>         jmp     dmem_acc_0
  6151                              <1> dmem_acc_7:  ; ERROR ! 
  6152 000067D7 C7042404000000      <1> 	mov	dword [esp], ERR_MINOR_IM 
  6153                              <1> 		; Insufficient memory (minor) error!
  6154                              <1> 		; Major error = 0 (No protection fault)	
  6155                              <1> 	; cf = 1
  6156                              <1> dmem_acc_8:
  6157 000067DE 58                  <1> 	pop	eax
  6158                              <1> 	;pop	edx
  6159                              <1> 	;pop	ecx
  6160                              <1> 	;pop	ebx
  6161                              <1> 	;pop	ebp
  6162 000067DF C3                  <1> 	retn
  6163                              <1> 
  6164                              <1> deallocate_user_pages:
  6165                              <1> 	; 20/05/2017
  6166                              <1> 	; 15/05/2017
  6167                              <1> 	; 20/02/2017
  6168                              <1> 	; 19/02/2017 (TRDOS 386 = TRDOS v2.0)
  6169                              <1> 	;
  6170                              <1> 	; Deallocate virtually contiguous user pages (memory block)
  6171                              <1> 	; (caller: 'sysdalloc' system call)
  6172                              <1> 	;
  6173                              <1> 	; INPUT ->
  6174                              <1> 	;	EBX = VIRTUAL ADDRESS (beginning address)
  6175                              <1> 	;	ECX = byte count
  6176                              <1> 	;	[u.pgdir] = user's page directory
  6177                              <1> 	;	[u.ppdir] = parent's page directory
  6178                              <1> 	;
  6179                              <1> 	; OUTPUT ->
  6180                              <1> 	;    If CF = 0 	
  6181                              <1> 	;	EAX = Deallocated memory bytes
  6182                              <1> 	;	  (Even if shared or read only pages will not be
  6183                              <1> 	;	   deallocated on M.A.T., this byte count will be
  6184                              <1> 	;	   returned as virtually deallocated bytes; in fact
  6185                              <1> 	;	   virtually deallocated user pages * 4096.) 
  6186                              <1> 	;	EBX = Virtual address (as rounded up)
  6187                              <1> 	;    If CF = 1    	
  6188                              <1> 	;	EAX = 0 (there is not any deallocated pages)
  6189                              <1> 	;
  6190                              <1> 	; Note: Empty page tables will not be deallocated!!!
  6191                              <1> 	;     (they will be deallocated at process termination stage)
  6192                              <1> 	;
  6193                              <1> 	; Modified Registers -> EAX, EDX, ESI, EDI, EBX, ECX, EBP
  6194                              <1> 	;
  6195 000067E0 89DE                <1> 	mov	esi, ebx
  6196 000067E2 89F7                <1> 	mov	edi, esi
  6197 000067E4 01CF                <1> 	add	edi, ecx
  6198 000067E6 81C6FF0F0000        <1> 	add	esi, PAGE_SIZE - 1  ; 4095 (round up)	
  6199 000067EC C1EE0C              <1> 	shr	esi, PAGE_SHIFT
  6200 000067EF C1EF0C              <1> 	shr	edi, PAGE_SHIFT
  6201 000067F2 89F8                <1> 	mov	eax, edi ; end page
  6202 000067F4 29F0                <1> 	sub	eax, esi ; end page - start page
  6203 000067F6 0F86D5000000        <1> 	jna	da_u_pd_err  ; < 1
  6204 000067FC 89F3                <1> 	mov	ebx, esi
  6205 000067FE C1E30C              <1> 	shl	ebx, PAGE_SHIFT ; virtual address (as rounded up)
  6206 00006801 53                  <1> 	push	ebx ; *
  6207 00006802 89C1                <1> 	mov	ecx, eax ; page count
  6208 00006804 C1E00C              <1> 	shl	eax, PAGE_SHIFT ; byte count as adjusted
  6209 00006807 50                  <1> 	push	eax ; **
  6210 00006808 8B1D[B8030300]      <1> 	mov	ebx, [u.pgdir] ; physical addr of user's page dir
  6211 0000680E 81C600040000        <1>  	add	esi, CORE/PAGE_SIZE 
  6212 00006814 89F7                <1> 	mov	edi, esi
  6213 00006816 81E7FF030000        <1> 	and	edi, PTE_MASK ; PTE entry in the page table
  6214 0000681C 57                  <1> 	push	edi ; *** ; PTE index (of page directory)
  6215 0000681D C1EE0A              <1> 	shr	esi, PAGE_D_SHIFT - PAGE_SHIFT ; 22-12=10
  6216 00006820 89F2                <1> 	mov	edx, esi 
  6217                              <1> 	; EDX = PDE index
  6218 00006822 C1E602              <1> 	shl	esi, 2 ; convert PDE index to dword offset
  6219 00006825 01DE                <1> 	add	esi, ebx ; add page directory address
  6220                              <1> da_u_pd_1:
  6221 00006827 AD                  <1> 	lodsd
  6222                              <1> 	;
  6223 00006828 89F5                <1> 	mov	ebp, esi ; 20/02/2017
  6224                              <1> 	; EBP = next PDE address
  6225                              <1> 	;
  6226 0000682A A801                <1> 	test	al, PDE_A_PRESENT ; bit 0, present flag (must be 1)
  6227 0000682C 0F8494000000        <1> 	jz	da_u_pd_3 ; 20/05/2017	
  6228 00006832 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
  6229                              <1> 	; EAX = PHYSICAL (flat) ADDRESS OF THE PAGE TABLE
  6230 00006836 8B3C24              <1> 	mov	edi, [esp] ; ***
  6231                              <1> 	; EDI = PTE index (of complete page directory)
  6232                              <1> 	;and	edi, PTE_MASK ; PTE entry in the page table
  6233 00006839 C1E702              <1> 	shl	edi, 2 ; convert PTE index to dword offset
  6234 0000683C 89FE                <1> 	mov	esi, edi ; PTE offset in page table (0-4092)
  6235 0000683E 01C6                <1> 	add	esi, eax ; now, esi points to requested PTE
  6236                              <1> da_u_pt_0:
  6237 00006840 AD                  <1> 	lodsd
  6238 00006841 A801                <1> 	test	al, PTE_A_PRESENT ; bit 0, present flag (must be 1)
  6239 00006843 743F                <1> 	jz	short da_u_pt_1
  6240                              <1> 	;
  6241 00006845 A802                <1> 	test	al, PTE_A_WRITE   ; bit 1, writable (r/w) flag
  6242                              <1> 				  ; (must be 1)
  6243 00006847 7549                <1> 	jnz	short da_u_pt_3
  6244                              <1> 	; Read only -duplicated- page (belongs to a parent or a child)
  6245 00006849 66A90002            <1>         test    ax, PTE_DUPLICATED ; Was this page duplicated 
  6246                              <1> 				   ; as child's page ?
  6247 0000684D 744E                <1> 	jz	short da_u_pt_4 ; Clear PTE but don't deallocate the page!
  6248                              <1> 	;
  6249                              <1> 	; check the parent's PTE value is read only & same page or not.. 
  6250                              <1> 	; EDX = page directory entry index (0-1023)
  6251 0000684F 52                  <1> 	push	edx ; ****
  6252                              <1> 	; EDI = page table entry offset (0-4092)
  6253 00006850 8B1D[BC030300]      <1> 	mov	ebx, [u.ppgdir] ; page directory of the parent process
  6254 00006856 66C1E202            <1> 	shl	dx, 2 ; *4 
  6255 0000685A 01D3                <1> 	add	ebx, edx ; PDE address (for the parent)
  6256 0000685C 8B13                <1> 	mov	edx, [ebx] ; page table address
  6257 0000685E F6C201              <1> 	test	dl, PDE_A_PRESENT ; present (valid) or not ?
  6258 00006861 742E                <1> 	jz	short da_u_pt_2	; parent process does not use this page
  6259 00006863 6681E200F0          <1> 	and	dx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
  6260                              <1> 	; EDI = page table entry offset (0-4092)
  6261 00006868 01D7                <1> 	add	edi, edx	; PTE address (for the parent)
  6262 0000686A 8B1F                <1> 	mov	ebx, [edi]
  6263 0000686C F6C301              <1> 	test	bl, PTE_A_PRESENT ; present or not ?
  6264 0000686F 7420                <1> 	jz	short da_u_pt_2	; parent process does not use this page
  6265 00006871 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; Clear attribute bits 
  6266 00006875 6681E300F0          <1> 	and	bx, PTE_A_CLEAR ; 0F000h ; Clear attribute bits
  6267 0000687A 39D8                <1> 	cmp	eax, ebx	; parent's and child's pages are same ?
  6268 0000687C 7513                <1> 	jne	short da_u_pt_2	; not same page
  6269                              <1> 				; deallocate the child's page
  6270 0000687E 800F02              <1>         or      byte [edi], PTE_A_WRITE ; convert to writable page (parent)
  6271 00006881 5A                  <1> 	pop	edx ; ****
  6272 00006882 EB19                <1> 	jmp	short da_u_pt_4
  6273                              <1> da_u_pt_1:
  6274 00006884 09C0                <1> 	or	eax, eax	; swapped page ?
  6275 00006886 741C                <1> 	jz	short da_u_pt_5	; no
  6276                              <1> 				; yes
  6277 00006888 D1E8                <1> 	shr	eax, 1
  6278 0000688A E8D1F9FFFF          <1> 	call	unlink_swap_block ; Deallocate swapped page block
  6279                              <1> 				  ; on the swap disk (or in file)
  6280 0000688F EB13                <1> 	jmp	short da_u_pt_5
  6281                              <1> da_u_pt_2:
  6282 00006891 5A                  <1> 	pop	edx ; ****
  6283                              <1> da_u_pt_3:
  6284 00006892 66A90004            <1> 	test	ax, PTE_SHARED	; shared or direct memory access indicator
  6285 00006896 7505                <1> 	jnz	short da_u_pt_4	; AVL bit 1 = 1, do not deallocate this page!
  6286                              <1> 	;
  6287                              <1> 	;and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
  6288 00006898 E81CF5FFFF          <1> 	call	deallocate_page ; set the mem allocation bit of this page
  6289                              <1> da_u_pt_4:
  6290 0000689D C746FC00000000      <1> 	mov	dword [esi-4], 0 ; clear/reset PTE (child, dupl. as parent)
  6291                              <1> da_u_pt_5:
  6292                              <1> 	; 20/05/2017
  6293 000068A4 58                  <1> 	pop	eax ; *** PTE index (of page directory)
  6294 000068A5 49                  <1> 	dec	ecx ; remain page count
  6295 000068A6 7426                <1> 	jz	short da_u_pd_4
  6296 000068A8 40                  <1> 	inc	eax ; next PTE
  6297 000068A9 6625FF03            <1> 	and	ax, PTE_MASK ; PTE entry index in the page table
  6298 000068AD 50                  <1> 	push	eax ; *** (save again)
  6299                              <1> 	;mov	edi, eax
  6300                              <1> 	;and 	di, PTE_MASK
  6301                              <1> 	;cmp	edi, PAGE_SIZE / 4 ; 1024
  6302                              <1> 	;jnb	short da_u_pd_2
  6303 000068AE 89C7                <1> 	mov	edi, eax
  6304 000068B0 C1E702              <1> 	shl	edi, 2 ; convert index to dword offset
  6305                              <1> 	;test	ax, PTE_MASK ; 3FFh
  6306 000068B3 09C0                <1> 	or	eax, eax
  6307 000068B5 7589                <1> 	jnz	short da_u_pt_0 ; 1-1023
  6308                              <1> da_u_pd_2:
  6309 000068B7 42                  <1> 	inc	edx
  6310                              <1> 	; 20/05/2017
  6311 000068B8 6681E2FF03          <1> 	and	dx, PTE_MASK  ; 3FFh
  6312 000068BD 740F                <1> 	jz	short da_u_pd_4  ; 0 (1024)
  6313                              <1> 	;cmp	edx, 1024
  6314                              <1> 	;jnb	short da_u_pd_4
  6315 000068BF 89EE                <1> 	mov	esi, ebp ; 20/02/2017
  6316 000068C1 E961FFFFFF          <1> 	jmp	da_u_pd_1
  6317                              <1> da_u_pd_3:
  6318                              <1> 	; 15/05/2017 (empty page directory entry)
  6319 000068C6 81E900040000        <1> 	sub	ecx, 1024
  6320 000068CC 77E9                <1> 	ja	short da_u_pd_2 ; 20/05/2017
  6321                              <1> da_u_pd_4:
  6322 000068CE 58                  <1> 	pop	eax ; **
  6323 000068CF 5B                  <1> 	pop	ebx ; *
  6324 000068D0 C3                  <1> 	retn
  6325                              <1> 
  6326                              <1> da_u_pd_err:
  6327 000068D1 31C0                <1> 	xor	eax, eax
  6328 000068D3 F9                  <1> 	stc	
  6329 000068D4 C3                  <1> 	retn
  6330                              <1> 
  6331                              <1> allocate_user_pages:
  6332                              <1> 	; 20/05/2017
  6333                              <1> 	; 01/05/2017, 02/05/2017, 15/05/2017
  6334                              <1> 	; 04/03/2017
  6335                              <1> 	; 20/02/2017 (TRDOS 386 = TRDOS v2.0)
  6336                              <1> 	;
  6337                              <1> 	; Allocate physically contiguous user pages (memory block)
  6338                              <1> 	; (caller: 'sysalloc' system call)
  6339                              <1> 	;
  6340                              <1> 	; Note: This procedure does not alloc a page's itself
  6341                              <1> 	;	(page bit) on Memory Allocation Table.
  6342                              <1> 	;	(allocate_memory_block is needed before this proc)
  6343                              <1> 	;
  6344                              <1> 	; INPUT ->
  6345                              <1> 	;	EAX = PHYSICAL ADDRESS (beginning address)
  6346                              <1> 	;	EBX = VIRTUAL ADDRESS (beginning address)
  6347                              <1> 	;	ECX = byte count (>=4096)
  6348                              <1> 	;	[u.pgdir] = user's page directory
  6349                              <1> 	;	
  6350                              <1> 	;	Note: All addresses are (must be) already adjusted
  6351                              <1> 	;	to page	borders, otherwise, lower 12bits of addresses
  6352                              <1> 	;	and byte count would be truncated.
  6353                              <1> 	;
  6354                              <1> 	; OUTPUT ->
  6355                              <1> 	;	none
  6356                              <1> 	;
  6357                              <1> 	;	CF = 1 -> insufficient memory error
  6358                              <1> 	;
  6359                              <1> 	; Note: All pages will be allocated in physical page order 
  6360                              <1> 	;	from the beginning page address. 
  6361                              <1> 	;	* A new page table will be added to the page dir
  6362                              <1> 	;	  when the requested PDE is invalid.
  6363                              <1> 	;	* Those pages will not be added to swap queue
  6364                              <1> 	;	  because main purpose of this allocation is to
  6365                              <1> 	;	  set a direct memory access (DMA controller) buffer.
  6366                              <1> 	;	 (Swapping out a page in a DMA buffer would be wrong!)
  6367                              <1> 	;	* Previous content of page tables (PTEs) would be
  6368                              <1> 	;	  (should be) deallocated before entering this
  6369                              <1> 	;	  procedure. So, new page table entries (PTEs)
  6370                              <1> 	;	  directly will be written without checking
  6371                              <1> 	;	  their previous content.	
  6372                              <1> 	;	* Only solution to increase free memory by removing
  6373                              <1> 	;	  that non-swappable memory block is to terminate
  6374                              <1> 	;	  the process or to wait until the process will 
  6375                              <1> 	;	  deallocate that memory block as itself. ('sysdalloc')
  6376                              <1> 	;	  (No problem, if the process does not grab all of
  6377                              <1> 	;	  -very big amount of- free memory by using
  6378                              <1> 	;	  'sysalloc' system call!?)
  6379                              <1> 	;	  (Even if the process has grabbed all of free memory, 
  6380                              <1> 	;	  no problem if the process is not running in 
  6381                              <1> 	;	  multitasking mode. No problem in multitasking
  6382                              <1> 	;	  mode if there is not another process which is running
  6383                              <1> 	;	  or waiting or sleeping for an event as it's pages
  6384                              <1> 	;	  are swapped-out. But a new process can not start to
  6385                              <1> 	;	  run if all of free memory has beeen allocated 
  6386                              <1> 	;	  by running processes. Deallocation -'sysdalloc'- 
  6387                              <1> 	;	  or terminate a running process is needed 
  6388                              <1> 	;	  in order to run a new process.) 
  6389                              <1> 	;
  6390                              <1> 	; Modified Registers -> EAX, EDX, ESI, EDI, EBX, ECX, EBP
  6391                              <1> 	;
  6392                              <1> 
  6393                              <1> 	; 01/05/2017
  6394 000068D5 662500F0            <1> 	and	ax, ~PAGE_OFF
  6395 000068D9 6681E300F0          <1> 	and	bx, ~PAGE_OFF
  6396                              <1> 	; 02/05/2017 
  6397 000068DE BD00F0FFFF          <1> 	mov	ebp, 0FFFFF000h ; 4 Giga Bytes - 4096 Bytes (for Stack)
  6398 000068E3 C1E90C              <1> 	shr	ecx, PAGE_SHIFT ; page count
  6399 000068E6 83F901              <1> 	cmp	ecx, 1
  6400 000068E9 7251                <1> 	jb	short a_u_im_retn
  6401 000068EB 89C2                <1> 	mov	edx, eax
  6402 000068ED 01CA                <1> 	add	edx, ecx
  6403 000068EF 724B                <1> 	jc	short a_u_im_retn
  6404 000068F1 39D5                <1> 	cmp	ebp, edx
  6405 000068F3 7247                <1> 	jb	short a_u_im_retn
  6406 000068F5 89DA                <1> 	mov	edx, ebx
  6407 000068F7 81C200004000        <1> 	add	edx, CORE
  6408 000068FD 723D                <1> 	jc	short a_u_im_retn	
  6409 000068FF 01CA                <1> 	add	edx, ecx
  6410 00006901 7239                <1> 	jc	short a_u_im_retn
  6411 00006903 39D5                <1> 	cmp	ebp, edx
  6412 00006905 7235                <1> 	jb	short a_u_im_retn
  6413                              <1> 	;
  6414 00006907 89C5                <1> 	mov	ebp, eax ; physical address
  6415 00006909 89DE                <1> 	mov	esi, ebx
  6416 0000690B 81C600004000        <1> 	add	esi, CORE ; start of user's memory (4M) 
  6417 00006911 C1EE0C              <1> 	shr	esi, PAGE_SHIFT ; higher 20 bits of the linear address
  6418                              <1> 	;shr	ecx, PAGE_SHIFT ; page count
  6419 00006914 8B1D[B8030300]      <1> 	mov	ebx, [u.pgdir] ; physical addr of user's page dir
  6420 0000691A 89F7                <1> 	mov	edi, esi
  6421 0000691C 81E7FF030000        <1> 	and	edi, PTE_MASK ; PTE entry index in the page table
  6422 00006922 57                  <1> 	push	edi  ; * ; PTE index (in page directory)
  6423 00006923 C1EE0A              <1> 	shr	esi, PAGE_D_SHIFT - PAGE_SHIFT ; 22-12=10
  6424 00006926 89F2                <1> 	mov	edx, esi 
  6425                              <1> 	; EDX = PDE index
  6426 00006928 C1E602              <1> 	shl	esi, 2 ; convert PDE index to dword offset
  6427 0000692B 01DE                <1> 	add	esi, ebx ; add page directory address
  6428                              <1> a_u_pd_0:
  6429 0000692D AD                  <1> 	lodsd
  6430                              <1> 	;
  6431 0000692E 89F3                <1> 	mov	ebx, esi ; next PDE address
  6432                              <1> 	;
  6433 00006930 A801                <1> 	test	al, PDE_A_PRESENT ; bit 0, present flag (must be 1)
  6434 00006932 7513                <1> 	jnz	short a_u_pd_2
  6435                              <1> 	;
  6436                              <1> 	; empty PDE (it does not point to valid page table address)
  6437 00006934 E8A2F2FFFF          <1> 	call	allocate_page  ; (allocate a new page table)
  6438 00006939 7302                <1> 	jnc	short a_u_pd_1 ; OK... now, we have a new page table.
  6439                              <1> 	; cf = 1
  6440                              <1> 	; There is not a free memory page to allocate a new page table !!!
  6441 0000693B 5E                  <1> 	pop	esi ; *
  6442                              <1> a_u_im_retn:
  6443 0000693C C3                  <1> 	retn	; return to 'sysalloc' with 'insufficient memory' error
  6444                              <1> 	;
  6445                              <1> a_u_pd_1: ; clear the new page table content 
  6446                              <1> 	; EAX = Physical (base) address of the new page table
  6447 0000693D E813F3FFFF          <1> 	call	clear_page ; Clear page content
  6448                              <1> 	;
  6449 00006942 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER
  6450                              <1> 		 ; set bit 0, bit 1 and bit 2 to 1
  6451                              <1> 		 ; (present, writable, user)
  6452 00006944 8946FC              <1> 	mov	[esi-4], eax
  6453                              <1> a_u_pd_2:
  6454 00006947 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
  6455                              <1> 	; EAX = PHYSICAL (flat) ADDRESS OF THE PAGE TABLE
  6456 0000694B 8B3C24              <1> 	mov	edi, [esp] ; *
  6457                              <1> 	; EDI = PTE index (of page directory)
  6458                              <1> 	;and	edi, PTE_MASK ; PTE entry index in the page table	
  6459                              <1> 	; EBX = next PDE address
  6460 0000694E 89FE                <1> 	mov	esi, edi ; PTE index in page table (0-1023)
  6461 00006950 C1E702              <1> 	shl	edi, 2 ; convert PTE index to dword offset
  6462 00006953 01C7                <1> 	add	edi, eax ; now, edi points to requested PTE
  6463                              <1> a_u_pt_0:
  6464                              <1> 	; 02/05/2017
  6465 00006955 8B07                <1> 	mov	eax, [edi]
  6466                              <1> 	;
  6467 00006957 A801                <1> 	test	al, PTE_A_PRESENT ; bit 0, present flag (must be 1)
  6468 00006959 7445                <1> 	jz	short a_u_pt_1
  6469                              <1> 	;
  6470 0000695B A802                <1> 	test	al, PTE_A_WRITE   ; bit 1, writable (r/w) flag
  6471                              <1> 				  ; (must be 1)
  6472 0000695D 7550                <1> 	jnz	short a_u_pt_3
  6473                              <1> 	; Read only -duplicated- page (belongs to a parent or a child)
  6474 0000695F 66A90002            <1>         test    ax, PTE_DUPLICATED ; Was this page duplicated 
  6475                              <1> 				   ; as child's page ?
  6476 00006963 7455                <1> 	jz	short a_u_pt_4	; Clear PTE but don't deallocate the page!
  6477                              <1> 	;
  6478                              <1> 	; check the parent's PTE value is read only & same page or not.. 
  6479                              <1> 	; EDX = page directory entry index (0-1023)
  6480 00006965 52                  <1> 	push	edx ; **
  6481 00006966 53                  <1> 	push	ebx ; ***
  6482                              <1> 	; ESI = page table entry index (0-1023)
  6483                              <1> 	;push	esi ; **** ; 20/05/2017
  6484 00006967 8B1D[BC030300]      <1> 	mov	ebx, [u.ppgdir] ; page directory of the parent process
  6485 0000696D 66C1E202            <1> 	shl	dx, 2 ; *4 
  6486 00006971 01D3                <1> 	add	ebx, edx ; PTE address,0 (for the parent)
  6487 00006973 8B13                <1> 	mov	edx, [ebx] ; page table address
  6488 00006975 F6C201              <1> 	test	dl, PDE_A_PRESENT ; present (valid) or not ?
  6489 00006978 7433                <1> 	jz	short a_u_pt_2	; parent process does not use this page
  6490 0000697A 6681E200F0          <1> 	and	dx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
  6491 0000697F 66C1E602            <1> 	shl	si, 2 ; *4
  6492                              <1> 	; ESI = page table entry offset (0-4092)
  6493 00006983 01D6                <1> 	add	esi, edx	; PTE address (for the parent)
  6494 00006985 8B1E                <1> 	mov	ebx, [esi]
  6495 00006987 F6C301              <1> 	test	bl, PTE_A_PRESENT ; present or not ?
  6496 0000698A 7421                <1> 	jz	short a_u_pt_2	; parent process does not use this page
  6497 0000698C 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; Clear attribute bits 
  6498 00006990 6681E300F0          <1> 	and	bx, PTE_A_CLEAR ; 0F000h ; Clear attribute bits
  6499 00006995 39D8                <1> 	cmp	eax, ebx	; parent's and child's pages are same ?
  6500 00006997 7514                <1> 	jne	short a_u_pt_2	; not same page
  6501                              <1> 				; deallocate the child's page
  6502 00006999 800E02              <1>         or      byte [esi], PTE_A_WRITE ; convert to writable page (parent)
  6503                              <1> 	;pop	esi ; **** ; 20/05/2017
  6504 0000699C 5B                  <1> 	pop	ebx ; ***
  6505 0000699D 5A                  <1> 	pop	edx ; **
  6506 0000699E EB1A                <1> 	jmp	short a_u_pt_4
  6507                              <1> a_u_pt_1:
  6508 000069A0 09C0                <1> 	or	eax, eax	; swapped page ?
  6509 000069A2 7416                <1> 	jz	short a_u_pt_4	; no
  6510                              <1> 				; yes
  6511 000069A4 D1E8                <1> 	shr	eax, 1
  6512 000069A6 E8B5F8FFFF          <1> 	call	unlink_swap_block ; Deallocate swapped page block
  6513                              <1> 				  ; on the swap disk (or in file)
  6514 000069AB EB0D                <1> 	jmp	short a_u_pt_4
  6515                              <1> a_u_pt_2:
  6516                              <1> 	;pop	esi ; **** ; 20/05/2017
  6517 000069AD 5B                  <1> 	pop	ebx ; ***
  6518 000069AE 5A                  <1> 	pop	edx ; **
  6519                              <1> a_u_pt_3:
  6520 000069AF 66A90004            <1> 	test	ax, PTE_SHARED	; shared or direct memory access indicator
  6521 000069B3 7505                <1> 	jnz	short a_u_pt_4	; AVL bit 1 = 1, do not deallocate this page!
  6522                              <1> 	;
  6523                              <1> 	;and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
  6524 000069B5 E8FFF3FFFF          <1> 	call	deallocate_page ; set the mem allocation bit of this page
  6525                              <1> 	;
  6526                              <1> a_u_pt_4:
  6527 000069BA 89E8                <1> 	mov	eax, ebp ; physical address
  6528 000069BC 0C07                <1> 	or	al, PTE_A_PRESENT + PTE_A_WRITE + PTE_A_USER ; 04/03/2017
  6529 000069BE AB                  <1> 	stosd
  6530 000069BF 5E                  <1> 	pop	esi ; * ; 20/05/2017
  6531 000069C0 49                  <1> 	dec	ecx ; remain page count
  6532 000069C1 7417                <1> 	jz	short a_u_pd_5
  6533 000069C3 81C500100000        <1> 	add	ebp, PAGE_SIZE
  6534 000069C9 46                  <1> 	inc	esi ; next PTE (index)
  6535                              <1> 	; 20/05/2017
  6536                              <1> 	;cmp	esi, PAGE_SIZE/4 ; 1024
  6537                              <1> 	;jb	short a_u_pt_0
  6538 000069CA 6681E6FF03          <1> 	and	si, PTE_MASK ; 3FFh (0 to 1023)
  6539 000069CF 56                  <1> 	push	esi ; *
  6540 000069D0 7583                <1> 	jnz	short a_u_pt_0 ; > 0 (<1024)
  6541                              <1> a_u_pd_3:
  6542 000069D2 42                  <1> 	inc	edx
  6543                              <1> ;	cmp	edx, 1024
  6544                              <1> ;	jnb	short a_u_pd_4 ; 02/05/2017 (error!, ecx > 0)
  6545 000069D3 89DE                <1> 	mov	esi, ebx ; the next PDE address
  6546 000069D5 E953FFFFFF          <1> 	jmp	a_u_pd_0
  6547                              <1> a_u_pd_4:
  6548                              <1> 	; 02/05/2017
  6549                              <1> ;	stc
  6550                              <1> a_u_pd_5:
  6551                              <1> 	; 20/05/2017
  6552                              <1> 	;pop	edi ; *
  6553 000069DA C3                  <1> 	retn
  6554                              <1> 
  6555                              <1> allocate_lfb_pages_for_kernel:
  6556                              <1> 	; 15/12/2020
  6557                              <1> 	; 14/12/2020 - TRDOS 386 v2.0.3
  6558                              <1> 	; Set kernel page tables for linear frame buffer 
  6559                              <1> 	; (this procedure will be called by kernel only)
  6560                              <1> 	;
  6561                              <1> 	; Input:
  6562                              <1> 	;	[LFB_ADDR] = linear frame buffer base address
  6563                              <1>  	;	[LFB_SIZE] = linear frame buffer size in bytes
  6564                              <1> 	; Output:
  6565                              <1> 	;	none
  6566                              <1> 	;	cf = 1 -> error
  6567                              <1> 	;
  6568                              <1> 	; Modified registers: eax, ecx, edx, edi
  6569                              <1> 
  6570 000069DB 8B3D[2C120300]      <1> 	mov	edi, [LFB_ADDR]
  6571 000069E1 8B15[30120300]      <1> 	mov	edx, [LFB_SIZE]
  6572                              <1> 
  6573 000069E7 C1EF16              <1> 	shr	edi, 22	; convert address to page number
  6574                              <1> 			; and then convert it to PDE entry offset
  6575                              <1> 			; (1 PDE is for 4MB, 22 bit shift)
  6576                              <1> 
  6577 000069EA 66C1E702            <1> 	shl	di, 2	; * 4 for offset 
  6578                              <1> 
  6579                              <1> 	;add	edx, 4095
  6580 000069EE C1EA0C              <1> 	shr	edx, 12	; convert LFB size to LFB page count
  6581                              <1> 	
  6582 000069F1 89D1                <1> 	mov	ecx, edx ; * ; LFB page count
  6583                              <1> 
  6584 000069F3 81C1FF030000        <1> 	add	ecx, 1023 ; page count + 1023
  6585 000069F9 C1E90A              <1> 	shr	ecx, 10 ; convert to page directory entry count	
  6586                              <1> 			; (page table count)
  6587 000069FC 51                  <1> 	push	ecx ; **
  6588 000069FD C1E10C              <1> 	shl	ecx, 12 ; convert to byte count
  6589                              <1> 
  6590 00006A00 31C0                <1> 	xor	eax, eax ; first available pages
  6591                              <1> 	
  6592                              <1> 	; allocate contiguous memory block for these kernel pages
  6593                              <1> 	
  6594 00006A02 E87EFAFFFF          <1> 	call	allocate_memory_block
  6595                              <1> 	; eax = start address of (contiguous) memory block
  6596 00006A07 59                  <1> 	pop	ecx ; ** ; PDE count
  6597 00006A08 7301                <1> 	jnc	short a_lfb_k_1
  6598                              <1> 	; error (cf=1)
  6599 00006A0A C3                  <1> 	retn
  6600                              <1> a_lfb_k_1:
  6601                              <1> 	; Allocate (new) page tables in kernel's page directory
  6602 00006A0B 51                  <1> 	push	ecx ; PDE (page table) count
  6603 00006A0C 50                  <1> 	push	eax ; start address of contiguous memory pages
  6604                              <1> 		    ; (at page boundary)	
  6605                              <1> 	; edi = 1st page directory entry offset
  6606 00006A0D 033D[308A0100]      <1> 	add	edi, [k_page_dir] ; Kernel's Page Dir Address
  6607                              <1> a_lfb_k_2:
  6608 00006A13 660D0304            <1> 	or	ax, PDE_A_PRESENT + PDE_A_WRITE + PDE_EXTERNAL
  6609                              <1> 				; supervisor + read&write + present 	
  6610                              <1> 				; + external memory block (LFB)
  6611 00006A17 AB                  <1> 	stosd
  6612 00006A18 0500100000          <1> 	add	eax, 4096
  6613 00006A1D E2F4                <1> 	loop	a_lfb_k_2
  6614                              <1> 	
  6615 00006A1F 5F                  <1> 	pop	edi ; start addr of contiguous memory pages
  6616 00006A20 59                  <1> 	pop	ecx ; page table (PDE) count
  6617                              <1> 
  6618                              <1> 	; Allocate pages in (new) kernel page tables
  6619                              <1> 	
  6620                              <1> 	; (Note: page tables are contiguous in pyhsical memory)
  6621 00006A21 C1E10A              <1> 	shl	ecx, 10 ; * 1024, convert to (total) PTE count 
  6622                              <1> 	
  6623 00006A24 A1[2C120300]        <1> 	mov	eax, [LFB_ADDR]
  6624                              <1> 	; edx = LFB page count
  6625                              <1> 	;and	ax, ~4095  ; lw of LFB address is 0
  6626                              <1> a_lfb_k_3:	
  6627 00006A29 660D0304            <1> 	or	ax, PTE_A_PRESENT + PTE_A_WRITE + PTE_EXTERNAL
  6628                              <1> 				; supervisor + read&write + present 	
  6629                              <1> 				; + external memory block (LFB)
  6630 00006A2D AB                  <1> 	stosd
  6631 00006A2E 4A                  <1> 	dec	edx
  6632 00006A2F 7408                <1> 	jz	short a_lfb_k_4 ; LFB size has been completed (!?)
  6633 00006A31 0500100000          <1> 	add	eax, 4096	
  6634 00006A36 E2F1                <1> 	loop	a_lfb_k_3
  6635                              <1> 
  6636 00006A38 C3                  <1> 	retn
  6637                              <1> 	
  6638                              <1> a_lfb_k_4:
  6639                              <1> 	; clear PTEs for empty/free pages 
  6640                              <1> 	; 	(if there are after LFB !?)
  6641 00006A39 31C0                <1> 	xor	eax, eax ; clear page table entry (empty)
  6642 00006A3B F3AB                <1> 	rep	stosd
  6643 00006A3D C3                  <1> 	retn
  6644                              <1> 
  6645                              <1> ;deallocate_lfb_pages_for_kernel:
  6646                              <1> 	; 15/12/2020
  6647                              <1> 	; 14/12/2020 - TRDOS 386 v2.0.3
  6648                              <1> 	; Reset/Release kernel page tables
  6649                              <1> 	;	 which are used for linear frame buffer 
  6650                              <1> 	; (this procedure will be called by kernel only)
  6651                              <1> 	;
  6652                              <1> 	; Input:
  6653                              <1> 	;	[LFB_ADDR] = linear frame buffer base address
  6654                              <1>  	;	[FFB_SIZE] = linear frame buffer size in bytes
  6655                              <1> 	; Output:
  6656                              <1> 	;	none
  6657                              <1> 	;
  6658                              <1> 	; Modified registers: eax, ecx, edi
  6659                              <1> 
  6660                              <1> 	;mov	edi, [LFB_ADDR]
  6661                              <1> 	;mov	ecx, [LFB_SIZE]
  6662                              <1> 	;
  6663                              <1> 	;shr	edi, 22	; convert address to page number
  6664                              <1> 	;		; and then convert it to PDE entry offset
  6665                              <1> 	;		; (1 PDE is for 4MB, 22 bit shift)
  6666                              <1> 	;
  6667                              <1> 	;shl	di, 2	; * 4 for offset 
  6668                              <1> 	;
  6669                              <1> 	;;add	ecx, 4095
  6670                              <1> 	;shr	ecx, 12	; convert LFB size to page count  
  6671                              <1> 	;
  6672                              <1> 	;add	ecx, 1023 ; page count + 1023
  6673                              <1> 	;shr	ecx, 10 ; convert to page directory entry count	
  6674                              <1> 	;		; (page table count)
  6675                              <1> 	;push	ecx ; *
  6676                              <1> 	;shl	ecx, 12 ; convert to byte count
  6677                              <1> 	;
  6678                              <1> 	;xor	eax, eax ; first available pages
  6679                              <1> 	;
  6680                              <1> 	;; deallocate contiguous memory block for kernel pages
  6681                              <1> 	;
  6682                              <1> 	;call	deallocate_memory_block
  6683                              <1> 	;
  6684                              <1> 	;pop	ecx ; * ; PDE count
  6685                              <1> 	;
  6686                              <1> 	;; Release/Free PDEs (page tables) in kernel's page dir
  6687                              <1> 	;; edi = 1st page directory entry offset
  6688                              <1> 	;add	edi, [k_page_dir] ; Kernel's Page Dir Address
  6689                              <1> 	;sub	eax, eax ; clear (also invalidate)
  6690                              <1> 	;rep	stosd
  6691                              <1> 	;
  6692                              <1> 	;retn
  6693                              <1> 
  6694                              <1> ; /// End Of MEMORY MANAGEMENT FUNCTIONS ///
  6695                              <1> 
  6696                              <1> ;; Data:
  6697                              <1> 
  6698                              <1> ; 09/03/2015
  6699                              <1> ;swpq_count: dw 0 ; count of pages on the swap que
  6700                              <1> ;swp_drv:    dd 0 ; logical drive description table address of the swap drive/disk
  6701                              <1> ;swpd_size:  dd 0 ; size of swap drive/disk (volume) in sectors (512 bytes). 		  				
  6702                              <1> ;swpd_free:  dd 0 ; free page blocks (4096 bytes) on swap disk/drive (logical)
  6703                              <1> ;swpd_next:  dd 0 ; next free page block
  6704                              <1> ;swpd_last:  dd 0 ; last swap page block
  2896                                  %include 'timer.s'   ; 17/01/2015
  2897                              <1> ; ****************************************************************************
  2898                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.0 - timer.s
  2899                              <1> ; ----------------------------------------------------------------------------
  2900                              <1> ; Last Update: 15/01/2017
  2901                              <1> ; ----------------------------------------------------------------------------
  2902                              <1> ; Beginning: 17/01/2016
  2903                              <1> ; ----------------------------------------------------------------------------
  2904                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
  2905                              <1> ; ----------------------------------------------------------------------------
  2906                              <1> ; Turkish Rational DOS
  2907                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
  2908                              <1> ;
  2909                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
  2910                              <1> ;
  2911                              <1> ; Derived from 'IBM PC-AT' BIOS source code (1985) 
  2912                              <1> ; ****************************************************************************
  2913                              <1> 
  2914                              <1> ; TRDOS 386  (TRDOS v2.0) Kernel - TIMER & REAL TIME CLOCK (BIOS) FUNCTIONS
  2915                              <1> 
  2916                              <1> ; IBM PC-AT BIOS Source Code ('BIOS2.ASM')
  2917                              <1> ; TITLE BIOS2 ---- 06/10/85 BIOS INTERRUPT ROUTINES
  2918                              <1> 
  2919                              <1> ;
  2920                              <1> ; ///////// TIMER (& REAL TIME CLOCK) FUNCTIONS ///////////////
  2921                              <1> 
  2922                              <1> int1Ah:
  2923                              <1> 	; 29/01/2016
  2924                              <1> 	; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
  2925 00006A3E 9C                  <1> 	pushfd
  2926 00006A3F 0E                  <1> 	push 	cs
  2927 00006A40 E801000000          <1> 	call 	TIME_OF_DAY_1
  2928 00006A45 C3                  <1> 	retn
  2929                              <1> 
  2930                              <1> ;--- INT  1A H -- (TIME OF DAY) -------------------------------------------------
  2931                              <1> ;       THIS BIOS ROUTINE ALLOWS THE CLOCKS TO BE SET OR READ			:
  2932                              <1> ;										:
  2933                              <1> ; PARAMETERS:									:
  2934                              <1> ;     (AH) = 00H  READ THE CURRENT SETTING AND RETURN WITH,			:
  2935                              <1> ;                      (CX) = HIGH PORTION OF COUNT				:
  2936                              <1> ;                      (DX) = LOW PORTION OF COUNT				:
  2937                              <1> ;                      (AL) = 0 TIMER HAS NOT PASSED 24 HOURS SINCE LAST READ	:
  2938                              <1> ;                             1 IF ON ANOTHER DAY. (RESET TO ZERO AFTER READ)	:
  2939                              <1> ;										:
  2940                              <1> ;     (AH) = 01H  SET THE CURRENT CLOCK USING,					:
  2941                              <1> ;		     (CX) = HIGH PORTION OF COUNT				:
  2942                              <1> ;		     (DX) = LOW PORTION OF COUNT.				:
  2943                              <1> ;										:
  2944                              <1> ;               NOTE: COUNTS OCCUR AT THE RATE OF 1193180/65536 COUNTS/SECOND	:
  2945                              <1> ;                            (OR ABOUT 18.2 PER SECOND -- SEE EQUATES)		:
  2946                              <1> ;										:
  2947                              <1> ;     (AH) = 02H  READ THE REAL TIME CLOCK AND RETURN WITH,			:
  2948                              <1> ;                      (CH) = HOURS IN BCD (00-23)				:
  2949                              <1> ;                      (CL) = MINUTES IN BCD (00-59)				:
  2950                              <1> ;                      (DH) = SECONDS IN BCD (00-59)				:
  2951                              <1> ;                      (DL) = DAYLIGHT SAVINGS ENABLE (00-01)			:
  2952                              <1> ;										:
  2953                              <1> ;     (AH) = 03H  SET THE REAL TIME CLOCK USING,				:
  2954                              <1> ;                     (CH) = HOURS IN BCD (00-23)				:
  2955                              <1> ;                     (CL) = MINUTES IN BCD (00-59)				:
  2956                              <1> ;                     (DH) = SECONDS IN BCD (00-59)				:
  2957                              <1> ;                     (DL) = 01 IF DAYLIGHT SAVINGS ENABLE OPTION, ELSE 00.	:
  2958                              <1> ;										:
  2959                              <1> ;             NOTE: (DL) = 00 IF DAYLIGHT SAVINGS TIME ENABLE IS NOT ENABLED.	:
  2960                              <1> ;                   (DL) = 01 ENABLES TWO SPECIAL UPDATES THE LAST SUNDAY IN	:
  2961                              <1> ;	           APRIL   (1:59:59 --> 3:00:00 AM) AND THE LAST SUNDAY IN	:
  2962                              <1> ;                   OCTOBER (1:59:59 --> 1:00:00 AM) THE FIRST TIME.		:
  2963                              <1> ;										:
  2964                              <1> ;     (AH) = 04H  READ THE DATE FROM THE REAL TIME CLOCK AND RETURN WITH,	:
  2965                              <1> ;                      (CH) = CENTURY IN BCD (19 OR 20)				:
  2966                              <1> ;                      (CL) = YEAR IN BCD (00-99)				:
  2967                              <1> ;                      (DH) = MONTH IN BCD (01-12)				:
  2968                              <1> ;                      (DL) = DAY IN BCD (01-31).				:
  2969                              <1> ;										:
  2970                              <1> ;     (AH) = 05H  SET THE DATE INTO THE REAL TIME CLOCK USING,			:
  2971                              <1> ;                     (CH) = CENTURY IN BCD (19 OR 20)				:
  2972                              <1> ;                     (CL) = YEAR IN BCD (00-99)				:
  2973                              <1> ;                     (DH) = MONTH IN BCD (01-12)				:
  2974                              <1> ;                     (DL) = DAY IN BCD (01-31).				:
  2975                              <1> ;										:
  2976                              <1> ;     (AH) = 06H  SET THE ALARM TO INTERRUPT AT SPECIFIED TIME,			:
  2977                              <1> ;                     (CH) = HOURS IN BCD (00-23 (OR FFH))			:
  2978                              <1> ;                     (CL) = MINUTES IN BCD (00-59 (OR FFH))			:
  2979                              <1> ;                     (DH) = SECONDS IN BCD (00-59 (OR FFH))			:
  2980                              <1> ;										:
  2981                              <1> ;     (AH) = 07H  RESET THE ALARM INTERRUPT FUNCTION.				:
  2982                              <1> ;										:
  2983                              <1> ; NOTES: FOR ALL RETURNS CY= 0 FOR SUCCESSFUL OPERATION.			:
  2984                              <1> ;        FOR (AH)= 2, 4, 6 - CARRY FLAG SET IF REAL TIME CLOCK NOT OPERATING.	:
  2985                              <1> ;        FOR (AH)= 6 - CARRY FLAG SET IF ALARM ALREADY ENABLED. 		:
  2986                              <1> ;        FOR THE ALARM FUNCTION (AH = 6) THE USER MUST SUPPLY A ROUTINE AND	:
  2987                              <1> ;         INTERCEPT THE CORRECT ADDRESS IN THE VECTOR TABLE FOR INTERRUPT 4AH.	:
  2988                              <1> ;         USE 0FFH FOR ANY "DO NOT CARE" POSITION FOR INTERVAL INTERRUPTS.	:
  2989                              <1> ;        INTERRUPTS ARE DISABLED DURING DATA MODIFICATION. 			:
  2990                              <1> ;        AH & AL ARE RETURNED MODIFIED AND NOT DEFINED EXCEPT WHERE INDICATED.	:
  2991                              <1> ;--------------------------------------------------------------------------------
  2992                              <1> 
  2993                              <1> ; 15/01/2017
  2994                              <1> ; 14/01/2017
  2995                              <1> ; 07/01/2017
  2996                              <1> ; 02/01/2017
  2997                              <1> ; 29/05/2016
  2998                              <1> ; 29/01/2016
  2999                              <1> ; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
  3000                              <1> 
  3001                              <1> ; 29/05/2016
  3002                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  3003                              <1> int35h:  ; Date/Time functions
  3004                              <1> 
  3005                              <1> TIME_OF_DAY_1:
  3006                              <1> 	;sti				; INTERRUPTS BACK ON
  3007                              <1> 	; 29/05/2016
  3008 00006A46 80642408FE          <1> 	and	byte [esp+8], 11111110b	; clear carry bit of eflags register
  3009                              <1> 	;
  3010 00006A4B 80FC08              <1> 	cmp	ah, (RTC_TBE-RTC_TB)/4	; CHECK IF COMMAND IN VALID RANGE (0-7)
  3011 00006A4E F5                  <1> 	cmc				; COMPLEMENT CARRY FOR ERROR EXIT
  3012                              <1> 	; (*) jc short TIME_9		; EXIT WITH CARRY = 1 IF NOT VALID
  3013 00006A4F 721A                <1> 	jc	short _TIME_9 ; 29/05/2016
  3014                              <1> 
  3015 00006A51 1E                  <1> 	push	ds
  3016 00006A52 56                  <1> 	push	esi
  3017 00006A53 66BE1000            <1> 	mov	si, KDATA		; kernel data segment
  3018 00006A57 8EDE                <1> 	mov	ds, si
  3019                              <1> 
  3020                              <1> 	;;15/01/2017
  3021                              <1> 	; 14/01/2017
  3022                              <1> 	; 02/01/2017
  3023                              <1> 	;;mov	byte [intflg], 35h	; date & time interrupt 
  3024                              <1> 	;sti
  3025                              <1> 	;
  3026 00006A59 C0E402              <1> 	shl	ah, 2			; convert function to dword offset
  3027 00006A5C 0FB6F4              <1> 	movzx	esi, ah			; PLACE INTO ADDRESSING REGISTER
  3028                              <1> 	;cli				; NO INTERRUPTS DURING TIME FUNCTIONS
  3029 00006A5F FF96[716A0000]      <1> 	call	[esi+RTC_TB]		; VECTOR TO FUNCTION REQUESTED WITH CY=0
  3030                              <1> 					; RETURN WITH CARRY FLAG SET FOR RESULT
  3031                              <1> 	;sti				; INTERRUPTS BACK ON
  3032 00006A65 B400                <1> 	mov	ah, 0			; CLEAR (AH) TO ZERO
  3033 00006A67 5E                  <1> 	pop	esi			; RECOVER USERS REGISTER
  3034 00006A68 1F                  <1> 	pop	ds			; RECOVER USERS SEGMENT SELECTOR
  3035                              <1> 
  3036                              <1> 	;;15/01/2017
  3037                              <1> 	; 02/01/2017
  3038                              <1> 	;;mov	byte [ss:intflg], 0 ; 07/01/2017
  3039                              <1> 
  3040                              <1> ;TIME_9:
  3041                              <1> 					; RETURN WITH CY= 0 IF NO ERROR
  3042                              <1> 	; (*) 29/05/2016
  3043                              <1> 	; (*) retf 4 ; skip eflags on stack
  3044 00006A69 7305                <1> 	jnc	short _TIME_10
  3045                              <1> _TIME_9:
  3046                              <1> 	; 29/05/2016 -set carry flag on stack-
  3047                              <1> 	; [esp] = EIP
  3048                              <1> 	; [esp+4] = CS
  3049                              <1> 	; [esp+8] = E-FLAGS
  3050 00006A6B 804C240801          <1> 	or	byte [esp+8], 1	 ; set carry bit of eflags register
  3051                              <1> 	; [esp+12] = ESP (user)
  3052                              <1> 	; [esp+16] = SS (User)
  3053                              <1> _TIME_10:
  3054 00006A70 CF                  <1> 	iretd
  3055                              <1> 	
  3056                              <1> 	; (*) 29/05/2016 - 'ref 4' intruction causes to stack fault
  3057                              <1> 	; (OUTER-PRIVILEGE-LEVEL)
  3058                              <1> 	; INTEL 80386 PROGRAMMER'S REFERENCE MANUAL 1986
  3059                              <1> 	; // RETF instruction:
  3060                              <1> 	;
  3061                              <1> 	; IF OperandMode=32 THEN
  3062                              <1>  	;    Load CS:EIP from stack;
  3063                              <1>  	;    Set CS RPL to CPL;
  3064                              <1>  	;    Increment eSP by 8 plus the immediate offset if it exists;
  3065                              <1>  	;    Load SS:eSP from stack;
  3066                              <1>  	; ELSE (* OperandMode=16 *)
  3067                              <1>  	;    Load CS:IP from stack;
  3068                              <1>  	;    Set CS RPL to CPL;
  3069                              <1>  	;    Increment eSP by 4 plus the immediate offset if it exists;
  3070                              <1> 	;    Load SS:eSP from stack;
  3071                              <1>  	; FI;
  3072                              <1> 	;
  3073                              <1> 	; //					
  3074                              <1> 					; ROUTINE VECTOR TABLE (AH)=
  3075                              <1> RTC_TB:
  3076 00006A71 [916A0000]          <1> 	dd	RTC_00			; 0 = READ CURRENT CLOCK COUNT
  3077 00006A75 [A46A0000]          <1> 	dd	RTC_10			; 1 = SET CLOCK COUNT
  3078 00006A79 [B26A0000]          <1> 	dd	RTC_20			; 2 = READ THE REAL TIME CLOCK TIME
  3079 00006A7D [E16A0000]          <1> 	dd	RTC_30			; 3 = SET REAL TIME CLOCK TIME
  3080 00006A81 [236B0000]          <1> 	dd	RTC_40			; 4 = READ THE REAL TIME CLOCK DATE
  3081 00006A85 [506B0000]          <1> 	dd	RTC_50			; 5 = SET REAL TIME CLOCK DATE
  3082 00006A89 [9D6B0000]          <1> 	dd	RTC_60			; 6 = SET THE REAL TIME CLOCK ALARM
  3083 00006A8D [F06B0000]          <1> 	dd	RTC_70			; 7 = RESET ALARM
  3084                              <1> 
  3085                              <1> RTC_TBE	equ	$
  3086                              <1> 
  3087                              <1> RTC_00:				; READ TIME COUNT
  3088 00006A91 A0[B48A0100]        <1> 	mov	al, [TIMER_OFL]		; GET THE OVERFLOW FLAG
  3089 00006A96 C605[B48A0100]00    <1> 	mov	byte [TIMER_OFL], 0	; AND THEN RESET THE OVERFLOW FLAG
  3090 00006A9D 8B0D[B08A0100]      <1>         mov     ecx, [TIMER_LH]         ; GET COUNT OF TIME
  3091 00006AA3 C3                  <1> 	retn
  3092                              <1> 
  3093                              <1> RTC_10:				; SET TIME COUNT
  3094 00006AA4 890D[B08A0100]      <1>         mov     [TIMER_LH], ecx         ; SET TIME COUNT
  3095 00006AAA C605[B48A0100]00    <1> 	mov	byte [TIMER_OFL], 0	; RESET OVERFLOW FLAG
  3096 00006AB1 C3                  <1> 	retn				; RETURN WITH NO CARRY
  3097                              <1> 
  3098                              <1> RTC_20:				; GET RTC TIME
  3099 00006AB2 E8EB010000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
  3100 00006AB7 7227                <1> 	jc	short RTC_29		; EXIT IF ERROR (CY= 1)
  3101                              <1> 
  3102 00006AB9 B000                <1> 	mov	al, CMOS_SECONDS	; SET ADDRESS OF SECONDS
  3103 00006ABB E8FD010000          <1> 	call	CMOS_READ		; GET SECONDS
  3104 00006AC0 88C6                <1> 	mov	dh, al			; SAVE
  3105 00006AC2 B00B                <1> 	mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
  3106 00006AC4 E8F4010000          <1> 	call	CMOS_READ		; READ CURRENT VALUE OF DSE BIT
  3107 00006AC9 2401                <1> 	and	al, 00000001b		; MASK FOR VALID DSE BIT
  3108 00006ACB 88C2                <1> 	mov	dl, al			; SET [DL] TO ZERO FOR NO DSE BIT
  3109 00006ACD B002                <1> 	mov	al, CMOS_MINUTES	; SET ADDRESS OF MINUTES
  3110 00006ACF E8E9010000          <1> 	call	CMOS_READ		; GET MINUTES
  3111 00006AD4 88C1                <1> 	mov	cl, al			; SAVE
  3112 00006AD6 B004                <1>         mov     al, CMOS_HOURS          ; SET ADDRESS OF HOURS
  3113 00006AD8 E8E0010000          <1> 	call	CMOS_READ		; GET HOURS
  3114 00006ADD 88C5                <1> 	mov	ch, al			; SAVE
  3115 00006ADF F8                  <1> 	clc				; SET CY= 0
  3116                              <1> RTC_29:
  3117 00006AE0 C3                  <1> 	retn				; RETURN WITH RESULT IN CARRY FLAG
  3118                              <1> 
  3119                              <1> RTC_30:				; SET RTC TIME
  3120 00006AE1 E8BC010000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
  3121 00006AE6 7305                <1> 	jnc	short RTC_35		; GO AROUND IF CLOCK OPERATING
  3122 00006AE8 E817010000          <1> 	call	RTC_STA			; ELSE TRY INITIALIZING CLOCK
  3123                              <1> RTC_35:
  3124 00006AED 88F4                <1> 	mov	ah, dh			; GET TIME BYTE - SECONDS
  3125 00006AEF B000                <1> 	mov	al, CMOS_SECONDS	; ADDRESS SECONDS
  3126 00006AF1 E8E0010000          <1> 	call	CMOS_WRITE		; UPDATE SECONDS
  3127 00006AF6 88CC                <1> 	mov	ah, cl			; GET TIME BYTE - MINUTES
  3128 00006AF8 B002                <1> 	mov	al, CMOS_MINUTES	; ADDRESS MINUTES
  3129 00006AFA E8D7010000          <1> 	call	CMOS_WRITE		; UPDATE MINUTES
  3130 00006AFF 88EC                <1> 	mov	ah, ch			; GET TIME BYTE - HOURS
  3131 00006B01 B004                <1> 	mov	al, CMOS_HOURS		; ADDRESS HOURS
  3132 00006B03 E8CE010000          <1> 	call	CMOS_WRITE		; UPDATE ADDRESS
  3133                              <1> 	;mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
  3134                              <1> 	;mov	ah, al
  3135 00006B08 66B80B0B            <1> 	mov	ax, CMOS_REG_B * 257
  3136 00006B0C E8AC010000          <1> 	call	CMOS_READ		; READ CURRENT TIME
  3137 00006B11 2462                <1> 	and	al, 01100010b		; MASK FOR VALID BIT POSITIONS
  3138 00006B13 0C02                <1> 	or	al, 00000010b		; TURN ON 24 HOUR MODE
  3139 00006B15 80E201              <1> 	and	dl, 00000001b		; USE ONLY THE DSE BIT
  3140 00006B18 08D0                <1> 	or	al, dl			; GET DAY LIGHT SAVINGS TIME BIT (OSE)
  3141 00006B1A 86E0                <1> 	xchg	ah, al			; PLACE IN WORK REGISTER AND GET ADDRESS
  3142 00006B1C E8B5010000          <1> 	call	CMOS_WRITE		; SET NEW ALARM SITS
  3143 00006B21 F8                  <1> 	clc				; SET CY= 0
  3144 00006B22 C3                  <1> 	retn				; RETURN WITH CY= 0
  3145                              <1> 
  3146                              <1> RTC_40:				; GET RTC DATE
  3147 00006B23 E87A010000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
  3148 00006B28 7225                <1> 	jc	short RTC_49		; EXIT IF ERROR (CY= 1)
  3149                              <1> 
  3150 00006B2A B007                <1> 	mov	al, CMOS_DAY_MONTH	; ADDRESS DAY OF MONTH
  3151 00006B2C E88C010000          <1> 	call	CMOS_READ		; READ DAY OF MONTH
  3152 00006B31 88C2                <1> 	mov	dl, al			; SAVE
  3153 00006B33 B008                <1> 	mov	al, CMOS_MONTH		; ADDRESS MONTH
  3154 00006B35 E883010000          <1> 	call	CMOS_READ		; READ MONTH
  3155 00006B3A 88C6                <1> 	mov	dh, al			; SAVE
  3156 00006B3C B009                <1> 	mov	al, CMOS_YEAR		; ADDRESS YEAR
  3157 00006B3E E87A010000          <1> 	call	CMOS_READ		; READ YEAR
  3158 00006B43 88C1                <1> 	mov	cl, al			; SAVE
  3159 00006B45 B032                <1> 	mov	al, CMOS_CENTURY	; ADDRESS CENTURY LOCATION
  3160 00006B47 E871010000          <1> 	call	CMOS_READ		; GET CENTURY BYTE
  3161 00006B4C 88C5                <1> 	mov	ch, al			; SAVE
  3162 00006B4E F8                  <1> 	clc				; SET CY=0
  3163                              <1> RTC_49:
  3164 00006B4F C3                  <1> 	retn				; RETURN WITH RESULTS IN CARRY FLAG
  3165                              <1> 
  3166                              <1> RTC_50:				; SET RTC DATE
  3167 00006B50 E84D010000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
  3168 00006B55 7305                <1> 	jnc	short RTC_55		; GO AROUND IF NO ERROR
  3169 00006B57 E8A8000000          <1> 	call	RTC_STA			; ELSE INITIALIZE CLOCK
  3170                              <1> RTC_55:
  3171 00006B5C 66B80600            <1> 	mov	ax, CMOS_DAY_WEEK	; ADDRESS OF DAY OF WEEK BYTE
  3172 00006B60 E871010000          <1> 	call	CMOS_WRITE		; LOAD ZEROS TO DAY OF WEEK
  3173 00006B65 88D4                <1> 	mov	ah, dl			; GET DAY OF MONTH BYTE
  3174 00006B67 B007                <1> 	mov	al, CMOS_DAY_MONTH	; ADDRESS DAY OF MONTH BYTE
  3175 00006B69 E868010000          <1> 	call	CMOS_WRITE		; WRITE OF DAY OF MONTH REGISTER
  3176 00006B6E 88F4                <1> 	mov	ah, dh			; GET MONTH
  3177 00006B70 B008                <1> 	mov	al, CMOS_MONTH		; ADDRESS MONTH BYTE
  3178 00006B72 E85F010000          <1> 	call	CMOS_WRITE		; WRITE MONTH REGISTER
  3179 00006B77 88CC                <1> 	mov	ah, cl			; GET YEAR BYTE
  3180 00006B79 B009                <1> 	mov	al, CMOS_YEAR		; ADDRESS YEAR REGISTER
  3181 00006B7B E856010000          <1> 	call	CMOS_WRITE		; WRITE YEAR REGISTER
  3182 00006B80 88EC                <1> 	mov	ah, ch			; GET CENTURY BYTE
  3183 00006B82 B032                <1> 	mov	al, CMOS_CENTURY	; ADDRESS CENTURY BYTE
  3184 00006B84 E84D010000          <1> 	call	CMOS_WRITE		; WRITE CENTURY LOCATION
  3185                              <1> 	;mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
  3186                              <1> 	;mov	ah, al
  3187 00006B89 66B80B0B            <1> 	mov	ax, CMOS_REG_B * 257
  3188 00006B8D E82B010000          <1> 	call	CMOS_READ		; READ WIRRENT SETTINGS
  3189 00006B92 247F                <1> 	and	al, 07Fh		; CLEAR 'SET BIT'
  3190 00006B94 86E0                <1> 	xchg	ah, al			; MOVE TO WORK REGISTER
  3191 00006B96 E83B010000          <1> 	call	CMOS_WRITE		; AND START CLOCK UPDATING
  3192 00006B9B F8                  <1> 	clc				; SET CY= 0
  3193 00006B9C C3                  <1> 	retn				; RETURN CY=0
  3194                              <1> 
  3195                              <1> RTC_60:				; SET RTC ALARM
  3196 00006B9D B00B                <1> 	mov	al, CMOS_REG_B		; ADDRESS ALARM
  3197 00006B9F E819010000          <1> 	call	CMOS_READ		; READ ALARM REGISTER
  3198 00006BA4 A820                <1> 	test	al, 20h			; CHECK FOR ALARM ALREADY ENABLED
  3199 00006BA6 F9                  <1> 	stc				; SET CARRY IN CASE OF ERROR
  3200 00006BA7 7542                <1> 	jnz	short RTC_69		; ERROR EXIT IF ALARM SET
  3201 00006BA9 E8F4000000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
  3202 00006BAE 7305                <1> 	jnc	short RTC_65		; SKIP INITIALIZATION IF NO ERROR
  3203 00006BB0 E84F000000          <1> 	call	RTC_STA			; ELSE INITIALIZE CLOCK
  3204                              <1> RTC_65:	
  3205 00006BB5 88F4                <1> 	mov	ah, dh			; GET SECONDS BYTE
  3206 00006BB7 B001                <1> 	mov	al, CMOS_SEC_ALARM	; ADDRESS THE SECONDS ALARM REGISTER
  3207 00006BB9 E818010000          <1> 	call	CMOS_WRITE		; INSERT SECONDS
  3208 00006BBE 88CC                <1> 	mov	ah, cl			; GET MINUTES PARAMETER
  3209 00006BC0 B003                <1> 	mov	al, CMOS_MIN_ALARM	; ADDRESS MINUTES ALARM REGISTER
  3210 00006BC2 E80F010000          <1> 	call	CMOS_WRITE		; INSERT MINUTES
  3211 00006BC7 88EC                <1> 	mov	ah, ch			; GET HOURS PARAMETER
  3212 00006BC9 B005                <1> 	mov	al, CMOS_HR_ALARM	; ADDRESS HOUR ALARM REGISTER
  3213 00006BCB E806010000          <1> 	call	CMOS_WRITE		; INSERT HOURS
  3214 00006BD0 E4A1                <1> 	in	al, INTB01		; READ SECOND INTERRUPT MASK REGISTER
  3215 00006BD2 24FE                <1> 	and	al, 0FEh		; ENABLE ALARM TIMER BIT (CY= 0)
  3216 00006BD4 E6A1                <1> 	out	INTB01, al		; WRITE UPDATED MASK
  3217                              <1> 	;mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
  3218                              <1> 	;mov	ah, al
  3219 00006BD6 66B80B0B            <1> 	mov	ax, CMOS_REG_B * 257
  3220 00006BDA E8DE000000          <1> 	call	CMOS_READ		; READ CURRENT ALARM REGISTER
  3221 00006BDF 247F                <1> 	and	al, 07Fh		; ENSURE SET BIT TURNED OFF
  3222 00006BE1 0C20                <1> 	or	al, 20h			; TURN ON ALARM ENABLE
  3223 00006BE3 86E0                <1> 	xchg	ah, al			; MOVE MASK TO OUTPUT REGISTER
  3224 00006BE5 E8EC000000          <1> 	call	CMOS_WRITE		; WRITE NEW ALARM MASK
  3225 00006BEA F8                  <1> 	clc				; SET CY= 0
  3226                              <1> RTC_69:
  3227 00006BEB 66B80000            <1> 	mov	ax, 0			; CLEAR AX REGISTER
  3228 00006BEF C3                  <1> 	retn				; RETURN WITH RESULTS IN CARRY FLAC
  3229                              <1> 
  3230                              <1> RTC_70:				; RESET ALARM
  3231                              <1> 	;mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
  3232                              <1> 	;mov	ah, al
  3233 00006BF0 66B80B0B            <1> 	mov	ax, CMOS_REG_B * 257	; ADDRESS ALARM REGISTER (TO BOTH AH,AL)
  3234 00006BF4 E8C4000000          <1> 	call	CMOS_READ		; READ ALARM REGISTER
  3235 00006BF9 2457                <1> 	and	al, 57h			; TURN OFF ALARM ENABLE
  3236 00006BFB 86E0                <1> 	xchg	ah, al			; SAVE DATA AND RECOVER ADDRESS
  3237 00006BFD E8D4000000          <1> 	call	CMOS_WRITE		; RESTORE NEW VALUE
  3238 00006C02 F8                  <1> 	clc				; SET CY= 0
  3239 00006C03 C3                  <1> 	retn				; RETURN WITH NO CARRY
  3240                              <1> 
  3241                              <1> RTC_STA:			; INITIALIZE REAL TIME CLOCK
  3242                              <1> 	;mov	al, CMOS_REG_A		; ADDRESS REGISTER A AND LOAD DATA MASK		
  3243                              <1> 	;mov	ah, 26h
  3244 00006C04 66B80A26            <1> 	mov	ax, (26h*100h)+CMOS_REG_A
  3245 00006C08 E8C9000000          <1> 	call	CMOS_WRITE		; INITIALIZE STATUS REGISTER A
  3246                              <1> 	;mov	al, CMOS_REG_B		; SET "SET BIT" FOR CLOCK INITIALIZATION	
  3247                              <1> 	;mov	ah, 82h
  3248 00006C0D 66B80B82            <1> 	mov	ax, (82h*100h)+CMOS_REG_B
  3249 00006C11 E8C0000000          <1> 	call	CMOS_WRITE		; AND 24 HOUR MODE TO REGISTER B
  3250 00006C16 B00C                <1> 	mov	al, CMOS_REG_C		; ADDRESS REGISTER C
  3251 00006C18 E8A0000000          <1> 	call	CMOS_READ		; READ REGISTER C TO INITIALIZE
  3252 00006C1D B00D                <1> 	mov	al, CMOS_REG_D		; ADDRESS REGISTER D
  3253 00006C1F E899000000          <1> 	call	CMOS_READ		; READ REGISTER D TO INITIALIZE
  3254 00006C24 C3                  <1> 	retn
  3255                              <1> 
  3256                              <1> ; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
  3257                              <1> 
  3258                              <1> ;--- HARDWARE INT  70 H -- ( IRQ LEVEL  8) --------------------------------------
  3259                              <1> ; ALARM INTERRUPT HANDLER (RTC)							:
  3260                              <1> ;       THIS ROUTINE HANDLES THE PERIODIC AND ALARM INTERRUPTS FROM THE CMOS	:
  3261                              <1> ;       TIMER. INPUT FREQUENCY IS 1.024 KHZ OR APPROXIMATELY 1024 INTERRUPTS	:
  3262                              <1> ;       EVERY SECOND FOR THE PERIODIC INTERRUPT. FOR THE ALARM FUNCTION,	:
  3263                              <1> ;       THE INTERRUPT WILL OCCUR AT THE DESIGNATED TIME.			:
  3264                              <1> ;										:
  3265                              <1> ;       INTERRUPTS ARE ENABLED WHEN THE EVENT OR ALARM FUNCTION IS ACTIVATED.	:
  3266                              <1> ;       FOR THE EVENT INTERRUPT, THE HANDLER WILL DECREMENT THE WAIT COUNTER	:
  3267                              <1> ;       AND WHEN IT EXPIRES WILL SET THE DESIGNATED LOCATION TO 80H. FOR	:
  3268                              <1> ;       THE ALARM INTERRUPT. THE USER MUST PROVIDE A ROUTINE TO INTERCEPT	:
  3269                              <1> ;       THE CORRECT ADDRESS FROM THE VECTOR TABLE INVOKED BY INTERRUPT 4AH	:
  3270                              <1> ;       PRIOR TO SETTING THE REAL TIME CLOCK ALARM (INT 1AH, AH= 06H).		:
  3271                              <1> ;--------------------------------------------------------------------------------
  3272                              <1> 
  3273                              <1> RTC_A_INT: ; 07/01/2017
  3274                              <1> ;RTC_INT:				; ALARM INTERRUPT
  3275 00006C25 1E                  <1> 	push	ds			; LEAVE INTERRUPTS DISABLED
  3276 00006C26 50                  <1> 	push	eax			; SAVE REGISTERS
  3277 00006C27 57                  <1> 	push	edi
  3278                              <1> RTC_I_1:				; CHECK FOR SECOND INTERRUPT
  3279 00006C28 66B88C8B            <1> 	mov	ax, 256*(CMOS_REG_B+NMI)+CMOS_REG_C+NMI ; ALARM AND STATUS
  3280 00006C2C E670                <1> 	out	CMOS_PORT, al		; WRITE ALARM FLAG MASK ADDRESS
  3281 00006C2E 90                  <1> 	nop				; I/O DELAY
  3282 00006C2F EB00                <1> 	jmp	short $+2
  3283 00006C31 E471                <1> 	in	al, CMOS_DATA		; READ AND RESET INTERRUPT REQUEST FLAGS
  3284 00006C33 A860                <1> 	test	al, 01100000b		; CHECK FOR EITHER INTERRUPT PENDING
  3285 00006C35 745D                <1> 	jz	short	RTC_I_9		; EXIT IF NOT A VALID RTC INTERRUPT
  3286                              <1> 
  3287 00006C37 86E0                <1> 	xchg	ah, al			; SAVE FLAGS AND GET ENABLE ADDRESS
  3288 00006C39 E670                <1> 	out	CMOS_PORT, al		; WRITE ALARM ENABLE MASK ADDRESS
  3289 00006C3B 90                  <1> 	nop				; I/O DELAY
  3290 00006C3C EB00                <1> 	jmp	short $+2	
  3291 00006C3E E471                <1> 	in	al, CMOS_DATA		; READ CURRENT ALARM ENABLE MASK
  3292 00006C40 20E0                <1> 	and	al, ah			; ALLOW ONLY SOURCES THAT ARE ENABLED
  3293 00006C42 A840                <1> 	test	al, 01000000b		; CHECK FOR PERIODIC INTERRUPT
  3294 00006C44 743B                <1> 	jz	short RTC_I_5		; SKIP IF NOT A PERIODIC INTERRUPT
  3295                              <1> 
  3296                              <1> ;-----	DECREMENT WAIT COUNT BY INTERRUPT INTERVAL
  3297                              <1> 
  3298 00006C46 66BF1000            <1> 	mov	di, KDATA		; kernel data segment
  3299 00006C4A 8EDF                <1> 	mov	ds, di
  3300                              <1> 	
  3301 00006C4C 812D[A88A0100]D003- <1> 	sub	dword [RTC_LH], 976	; DECREMENT COUNT BY 1/1024
  3301 00006C54 0000                <1>
  3302 00006C56 7329                <1> 	jnc	short RTC_I_5		; SKIP TILL 32 BIT WORD LESS THAN ZERO
  3303                              <1> 
  3304                              <1> ;-----	TURN OFF PERIODIC INTERRUPT ENABLE
  3305                              <1> 
  3306 00006C58 6650                <1> 	push	ax			; SAVE INTERRUPT FLAG MASK
  3307 00006C5A 66B88B8B            <1> 	mov	ax, 257*(CMOS_REG_B+NMI) ; INTERRUPT ENABLE REGISTER
  3308 00006C5E E670                <1> 	out	CMOS_PORT, al		; WRITE ADDRESS TO CMOS CLOCK
  3309 00006C60 90                  <1> 	nop				; I/O DELAY
  3310 00006C61 EB00                <1> 	jmp	short $+2
  3311 00006C63 E471                <1> 	in	al, CMOS_DATA		; READ CURRENT ENABLES
  3312 00006C65 24BF                <1> 	and	al, 0BFh		; TURN OFF PIE
  3313 00006C67 86C4                <1> 	xchg	al, ah			; GET CMOS ADDRESS AND SAVE VALUE
  3314 00006C69 E670                <1> 	out	CMOS_PORT, al		; ADDRESS REGISTER B
  3315 00006C6B 86C4                <1> 	xchg	al, ah			; GET NEW INTERRUPT ENABLE MASK
  3316 00006C6D E671                <1> 	out	CMOS_DATA, al		; SET MASK IN INTERRUPT ENABLE REGISTER
  3317 00006C6F C605[AC8A0100]00    <1> 	mov	byte [RTC_WAIT_FLAG], 0	; SET FUNCTION ACTIVE FLAG OFF
  3318 00006C76 8B3D[AD8A0100]      <1> 	mov	edi, [USER_FLAG]	; SET UP (DS:DI) TO POINT TO USER FLAG
  3319 00006C7C C60780              <1> 	mov	byte [edi], 80h		; TURN ON USERS FLAG
  3320 00006C7F 6658                <1> 	pop	ax			; GET INTERRUPT SOURCE BACK
  3321                              <1> RTC_I_5:
  3322 00006C81 A820                <1> 	test	al, 00100000b		; TEST FOR ALARM INTERRUPT
  3323 00006C83 740D                <1> 	jz	short RTC_I_7		; SKIP USER INTERRUPT CALL IF NOT ALARM
  3324                              <1> 
  3325 00006C85 B00D                <1> 	mov	al, CMOS_REG_D		; POINT TO DEFAULT READ ONLY REGISTER
  3326 00006C87 E670                <1> 	out	CMOS_PORT, al		; ENABLE NMI AND CMOS ADDRESS TO DEFAULT
  3327 00006C89 FB                  <1> 	sti				; INTERRUPTS BACK ON NOW
  3328 00006C8A 52                  <1> 	push	edx
  3329 00006C8B E82AC10000          <1> 	call	INT4Ah			; TRANSFER TO USER ROUTINE
  3330 00006C90 5A                  <1> 	pop	edx
  3331 00006C91 FA                  <1> 	cli				; BLOCK INTERRUPT FOR RETRY
  3332                              <1> RTC_I_7:				; RESTART ROUTINE TO HANDLE DELAYED
  3333 00006C92 EB94                <1> 	jmp	short RTC_I_1		;  ENTRY AND SECOND EVENT BEFORE DONE
  3334                              <1> 
  3335                              <1> RTC_I_9:				; EXIT - NO PENDING INTERRUPTS
  3336 00006C94 B00D                <1> 	mov	al, CMOS_REG_D		; POINT TO DEFAULT READ ONLY REGISTER
  3337 00006C96 E670                <1> 	out	CMOS_PORT, al		; ENABLE NMI AND CMOS ADDRESS TO DEFAULT
  3338 00006C98 B020                <1> 	mov	al, EOI			; END OF INTERRUPT MASK TO 8259 - 2
  3339 00006C9A E6A0                <1> 	out	INTB00, al		; TO 8259 - 2
  3340 00006C9C E620                <1> 	out	INTA00,	al		; TO 8259 - 1
  3341 00006C9E 5F                  <1> 	pop	edi			; RESTORE REGISTERS
  3342 00006C9F 58                  <1> 	pop	eax
  3343 00006CA0 1F                  <1> 	pop	ds
  3344 00006CA1 CF                  <1> 	iretd				; END OF INTERRUPT
  3345                              <1> 
  3346                              <1> 	
  3347                              <1> 	; 29/05/2016 - TRDOS 386 (TRDOS v2.0)
  3348                              <1> 	; 22/08/2014 (Retro UNIX 386 v1)
  3349                              <1> 	; IBM PC/AT BIOS source code ----- 10/06/85 (bios2.asm)
  3350                              <1> UPD_IPR:				; WAIT TILL UPDATE NOT IN PROGRESS
  3351 00006CA2 51                  <1> 	push	ecx
  3352                              <1> 
  3353                              <1> 	; 29/05/2016
  3354 00006CA3 B968110000          <1> 	mov	ecx, ((1984+244)*4)/2	; AWARD BIOS 1999, ATIME.ASM		
  3355                              <1> 					; 'WAITCPU_CK_UD_STAT'
  3356                              <1> 					; (244Us + 1984Us)
  3357                              <1> 					; (assume each read takes
  3358                              <1> 					;  2 microseconds).
  3359                              <1> 	;mov	ecx, 65535		
  3360                              <1> 		;mov cx, 800		; SET TIMEOUT LOOP COUNT (= 800)	
  3361                              <1> UPD_10:
  3362 00006CA8 B00A                <1> 	mov	al, CMOS_REG_A		; ADDRESS STATUS REGISTER A
  3363 00006CAA FA                  <1> 	cli				; NO TIMER INTERRUPTS DURING UPDATES
  3364 00006CAB E80D000000          <1> 	call	CMOS_READ		; READ UPDATE IN PROCESS FLAG
  3365 00006CB0 A880                <1> 	test	al, 80h			; IF UIP BIT IS ON ( CANNOT READ TIME )
  3366 00006CB2 7406                <1> 	jz	short UPD_90		; EXIT WITH CY= 0 IF CAN READ CLOCK NOW
  3367 00006CB4 FB                  <1> 	sti				; ALLOW INTERRUPTS WHILE WAITING
  3368 00006CB5 E2F1                <1> 	loop	UPD_10			; LOOP TILL READY OR TIMEOUT
  3369 00006CB7 31C0                <1> 	xor	eax, eax		; CLEAR RESULTS IF ERROR
  3370                              <1> 		; xor ax, ax
  3371 00006CB9 F9                  <1> 	stc				; SET CARRY FOR ERROR
  3372                              <1> UPD_90:
  3373 00006CBA 59                  <1> 	pop	ecx			; RESTORE CALLERS REGISTER
  3374 00006CBB FA                  <1> 	cli				; INTERRUPTS OFF DURING SET
  3375 00006CBC C3                  <1> 	retn				; RETURN WITH CY FLAG SET
  3376                              <1> 
  3377                              <1> 
  3378                              <1> 	; 29/05/2016 - TRDOS 386 (TRDOS v2.0) 
  3379                              <1> 	; 22/08/2014 (Retro UNIX 386 v1)
  3380                              <1> 	; IBM PC/AT BIOS source code ----- 10/06/85 (test4.asm)
  3381                              <1> 
  3382                              <1> ;--- CMOS_READ -----------------------------------------------------------------
  3383                              <1> ;		READ BYTE FROM CMOS_SYSTEM CLOCK CONFIGURATION TABLE	       :
  3384                              <1> ;									       :
  3385                              <1> ; INPUT: (AL)=	CMOS_TABLE ADDRESS TO BE READ				       :
  3386                              <1> ;		BIT    7 = 0 FOR NMI ENABLED AND 1 FOR NMI DISABLED ON EXIT    :
  3387                              <1> ;		BITS 6-0 = ADDRESS OF TABLE LOCATION TO READ		       :
  3388                              <1> ;									       :
  3389                              <1> ; OUTPUT: (AL)	VALUE AT LOCATION (AL) MOVED INTO (AL). IF BIT 7 OF (AL) WAS   :
  3390                              <1> ;		ON THEN NMI LEFT DISABLED, DURING THE CMOS READ BOTH NMI AND   :
  3391                              <1> ;		NORMAL INTERRUPTS ARE DISABLED TO PROTECT CMOS DATA INTEGRITY. :
  3392                              <1> ;		THE CMOS ADDRESS REGISTER IS POINTED TO A DEFAULT VALUE AND    :
  3393                              <1> ;		THE INTERRUPT FLAG RESTORED TO THE ENTRY STATE ON RETURN.      :
  3394                              <1> ;		ONLY THE (AL) REGISTER AND THE NMI STATE IS CHANGED.	       :
  3395                              <1> ;-------------------------------------------------------------------------------
  3396                              <1> 
  3397                              <1> CMOS_READ:
  3398 00006CBD 9C                  <1> 	pushf				; SAVE INTERRUPT ENABLE STATUS AND FLAGS
  3399 00006CBE D0C0                <1> 	rol	al, 1			; MOVE NMI BIT TO LOW POSITION
  3400 00006CC0 F9                  <1> 	stc				; FORCE NMI BIT ON IN CARRY FLAG
  3401 00006CC1 D0D8                <1> 	rcr	al, 1			; HIGH BIT ON TO DISABLE NMI - OLD IN CY
  3402 00006CC3 FA                  <1> 	cli				; DISABLE INTERRUPTS
  3403 00006CC4 E670                <1> 	out	CMOS_PORT, al		; ADDRESS LOCATION AND DISABLE NMI
  3404                              <1> 	; 29/05/2016
  3405                              <1> 	;nop				; I/O DELAY
  3406 00006CC6 E6EB                <1> 	out	0ebh,al	; NEWIODELAY ; AWARD BIOS 1999, ATIME.ASM
  3407                              <1> 	;
  3408 00006CC8 E471                <1> 	in	al, CMOS_DATA		; READ THE REQUESTED CMOS LOCATION
  3409 00006CCA 6650                <1> 	push	ax			; SAVE (AH) REGISTER VALUE AND CMOS BYTE
  3410                              <1> 	; 15/03/2015 ; IBM PC/XT Model 286 BIOS source code 
  3411                              <1> 		     ; ----- 10/06/85 (test4.asm)
  3412 00006CCC B01E                <1> 	mov	al, CMOS_SHUT_DOWN*2 	; GET ADDRESS OF DEFAULT LOCATION
  3413                              <1> 	;mov	al, CMOS_REG_D*2 	; GET ADDRESS OF DEFAULT LOCATION
  3414 00006CCE D0D8                <1> 	rcr	al, 1			; PUT ORIGINAL NMI MASK BIT INTO ADDRESS
  3415 00006CD0 E670                <1> 	out	CMOS_PORT, al		; SET DEFAULT TO READ ONLY REGISTER
  3416 00006CD2 6658                <1> 	pop	ax			; RESTORE (AH) AND (AL), CMOS BYTE
  3417 00006CD4 9D                  <1> 	popf	
  3418 00006CD5 C3                  <1> 	retn				; RETURN WITH FLAGS RESTORED
  3419                              <1> 
  3420                              <1> ; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
  3421                              <1> 
  3422                              <1> ;--- CMOS_WRITE ----------------------------------------------------------------
  3423                              <1> ;	WRITE BYTE TO CMOS SYSTEM CLOCK CONFIGURATION TABLE		       :
  3424                              <1> ;									       :
  3425                              <1> ; INPUT: (AL)=	CMOS TABLE ADDRESS TO BE WRITTEN TO			       :
  3426                              <1> ;		BIT    7 = 0 FOR NMI ENABLED AND 1 FOR NMI DISABLED ON EXIT    :
  3427                              <1> ;		BITS 6-0 = ADDRESS OF TABLE LOCATION TO WRITE		       :
  3428                              <1> ;	 (AH)=	NEW VALUE TO BE PLACED IN THE ADDRESSED TABLE LOCATION	       :
  3429                              <1> ;									       :
  3430                              <1> ; OUTPUT:	VALUE IN (AH) PLACED IN LOCATION (AL) WITH NMI LEFT DISABLED   :
  3431                              <1> ;		IF BIT 7 OF (AL) IS ON, DURING THE CMOS UPDATE BOTH NMI AND    :
  3432                              <1> ;		NORMAL INTERRUPTS ARE DISABLED TO PROTECT CMOS DATA INTEGRITY. :
  3433                              <1> ;		THE CMOS ADDRESS REGISTER IS POINTED TO A DEFAULT VALUE AND    :
  3434                              <1> ;		THE INTERRUPT FLAG RESTORED TO THE ENTRY STATE ON RETURN.      :
  3435                              <1> ;		ONLY THE CMOS LOCATION AND THE NMI STATE IS CHANGED.	       :
  3436                              <1> ;-------------------------------------------------------------------------------
  3437                              <1> 
  3438                              <1> CMOS_WRITE:				; WRITE (AH) TO LOCATION (AL)
  3439 00006CD6 9C                  <1> 	pushf				; SAVE INTERRUPT ENABLE STATUS AND FLAGS
  3440 00006CD7 6650                <1> 	push	ax			; SAVE WORK REGISTER VALUES
  3441 00006CD9 D0C0                <1> 	rol	al, 1			; MOVE NMI BIT TO LOW POSITION
  3442 00006CDB F9                  <1> 	stc				; FORCE NMI BIT ON IN CARRY FLAG
  3443 00006CDC D0D8                <1> 	rcr	al, 1			; HIGH BIT ON TO DISABLE NMI - OLD IN CY
  3444 00006CDE FA                  <1> 	cli				; DISABLE INTERRUPTS
  3445 00006CDF E670                <1> 	out	CMOS_PORT, al		; ADDRESS LOCATION AND DISABLE NMI
  3446 00006CE1 88E0                <1> 	mov	al, ah			; GET THE DATA BYTE TO WRITE
  3447 00006CE3 E671                <1> 	out	CMOS_DATA, al		; PLACE IN REQUESTED CMOS LOCATION
  3448 00006CE5 B01E                <1> 	mov	al, CMOS_SHUT_DOWN*2	; GET ADDRESS OF DEFAULT LOCATION
  3449                              <1> 	;mov	al, CMOS_REG_D*2 	; GET ADDRESS OF DEFAULT LOCATION
  3450 00006CE7 D0D8                <1> 	rcr	al, 1			; PUT ORIGINAL NMI MASK BIT INTO ADDRESS
  3451 00006CE9 E670                <1> 	out	CMOS_PORT, al		; SET DEFAULT TO READ ONLY REGISTER
  3452 00006CEB 90                  <1> 	nop				; I/O DELAY
  3453 00006CEC E471                <1> 	in	al, CMOS_DATA		; OPEN STANDBY LATCH
  3454 00006CEE 6658                <1> 	pop	ax			; RESTORE WORK REGISTERS
  3455 00006CF0 9D                  <1> 	popf
  3456 00006CF1 C3                  <1> 	retn
  3457                              <1> 
  3458                              <1> ; /// End Of TIMER FUNCTIONS ///
  2897                                  
  2898 00006CF2 90<rep Eh>              Align 16
  2899                                  
  2900                                  gdt:	; Global Descriptor Table
  2901                                  	; 02/12/2020
  2902                                  	; (30/07/2015, conforming cs)
  2903                                  	; (26/03/2015)
  2904                                  	; (24/03/2015, tss)
  2905                                  	; (19/03/2015)
  2906                                  	; (29/12/2013)
  2907                                  	;
  2908 00006D00 0000000000000000        	dw 0, 0, 0, 0		; NULL descriptor
  2909                                  gdt_kcode:
  2910                                  	; 18/08/2014
  2911                                  			; 8h kernel code segment, base = 00000000h		
  2912                                  	;dw 0FFFFh, 0, 9E00h, 00CFh	; KCODE  ; 30/12/2016	 
  2913 00006D08 FFFF0000009ACF00        	dw 0FFFFh, 0, 9A00h, 00CFh	; KCODE
  2914                                  gdt_kdata:
  2915                                  			; 10h kernel data segment, base = 00000000h	
  2916 00006D10 FFFF00000092CF00        	dw 0FFFFh, 0, 9200h, 00CFh	; KDATA
  2917                                  gdt_ucode:
  2918                                  			; 1Bh user code segment, base address = 400000h ; CORE
  2919                                  	;dw 0FBFFh, 0, 0FE40h, 00CFh	; UCODE  ; 30/12/2016	
  2920 00006D18 FFFB000040FACF00        	dw 0FBFFh, 0, 0FA40h, 00CFh	; UCODE
  2921                                  gdt_udata: 
  2922                                  			; 23h user data segment, base address = 400000h ; CORE
  2923 00006D20 FFFB000040F2CF00        	dw 0FBFFh, 0, 0F240h, 00CFh	; UDATA
  2924                                  gdt_tss:
  2925                                  			; Task State Segment
  2926 00006D28 6700                    	dw 0067h ; Limit = 103 ; (104-1, tss size = 104 byte, 
  2927                                  			       ;  no IO permission in ring 3)
  2928                                  gdt_tss0:
  2929 00006D2A 0000                    	dw 0  ; TSS base address, bits 0-15 
  2930                                  gdt_tss1:
  2931 00006D2C 00                      	db 0  ; TSS base address, bits 16-23 
  2932                                  	      		; 49h	
  2933 00006D2D E9                      	db 11101001b ; 0E9h => P=1/DPL=11/0/1/0/B/1 --> B = Task is busy (1)
  2934 00006D2E 00                      	db 0 ; G/0/0/AVL/LIMIT=0000 ; (Limit bits 16-19 = 0000) (G=0, 1 byte)
  2935                                  gdt_tss2:
  2936 00006D2F 00                      	db 0  ; TSS base address, bits 24-31 
  2937                                  
  2938                                  	; 30/11/2020
  2939                                  	; 29/11/2020 - TRDOS v2.0.3
  2940                                  	; VESA VBE3 VIDE BIOS 32 BIT PMI SEGMENTS (16 bit segments)
  2941                                  			; 30h ; VBE3CS
  2942                                  _vbe3_CS:  ; vesa vbe3 bios uses this as code seg (same addr with _vbe3_DS)
  2943                                  	; limit = 65536, base addr = 0, P/DPL/1/Type/C/R/A = 9Ah, 16 bit
  2944 00006D30 FFFF0000009A0000        	dw 0FFFFh, 0, 9A00h, 0 ; Note: base addr will be initialized
  2945                                  			; 38h ; VBE3BDS
  2946                                  _vbe3_BDS: ; vesa vbe3 bios uses this as equivalent of rombios data segment
  2947                                  	; limit = 1536, base addr = 0, P/DPL/1/Type/E/W/A = 92h, 16 bit
  2948 00006D38 FF05000000920000        	dw 05FFh, 0, 9200h, 0 ; Note: base addr will be initialized	
  2949                                  			; 40h ; VBE3A000 
  2950                                  _A0000Sel: ; VGA default video memory address
  2951                                  	; limit = 65536, base addr = 0A0000h, 16 bit
  2952 00006D40 FFFF00000A920000        	dw 0FFFFh, 0, 920Ah, 0
  2953                                  			; 48h ; VBE3B000 
  2954                                  _B0000Sel: ; MDA (monochrome) video memory address
  2955                                  	; limit = 65536, base addr = 0B0000h, 16 bit
  2956 00006D48 FFFF00000B920000        	dw 0FFFFh, 0, 920Bh, 0
  2957                                  			; 50h ; VBE3B800 
  2958                                  _B8000Sel: ; CGA video memory address
  2959                                  	; limit = 32768, base addr = 0B8000h, 16 bit
  2960 00006D50 FF7F00800B920000        	dw 07FFFh, 8000h, 920Bh, 0
  2961                                  			; 58h ; VBE3DS 
  2962                                  _vbe3_DS: ; vesa vbe3 bios uses this as data seg (CodeSegSel in PMInfoBlock)
  2963                                  	; limit = 65536, base addr = 0, P/DPL/1/Type/E/W/A = 92h, 16 bit
  2964 00006D58 FFFF000000920000        	dw 0FFFFh, 0, 9200h, 0 ; Note: base addr will be initialized
  2965                                  			; 60h ; VBE3SS   
  2966                                  _vbe3_SS: ; kernel's stack segment but 16 bit version (same stack addr)
  2967                                  	; limit = 1024, base addr = 0, P/DPL/1/Type/E/W/A = 92h, 16 bit
  2968 00006D60 FF03000000920000        	dw 03FFh, 0, 9200h, 0 ; Note: base addr will be initialized
  2969                                  			; 68h ; VBE3ES 	
  2970                                  _vbe3_ES: ; extra 16 bit segment points to buffers in kernel's mem space
  2971                                  	; limit = 2048, base addr = 0, P/DPL/1/Type/E/W/A = 92h, 16 bit
  2972 00006D68 FF07000000920000        	dw 07FFh, 0, 9200h,0 ; Note: base addr will be initialized
  2973                                  			; 70h ; KODE16	
  2974                                  _16bit_CS: ; 16 bit code segment points to kernel's far return addr
  2975                                  	; limit = 16M, base addr = 0, P/DPL/1/Type/E/W/A = 92h, 16 bit
  2976 00006D70 FFFF0000009AFF00        	dw 0FFFFh, 0, 9A00h, 00FFh ; Note: base addr will be initialized
  2977                                  
  2978                                  gdt_end:
  2979                                  	;; 9Eh = 1001 1110b (GDT byte 5) P=1/DPL=00/1/TYPE=1110, 
  2980                                  					;; Type= 1 (code)/C=1/R=1/A=0
  2981                                  		; P= Present, DPL=0=ring 0,  1= user (0= system)
  2982                                  		; 1= Code C= Conforming, R= Readable, A = Accessed
  2983                                  
  2984                                  	;; 9Ah = 1001 1010b (GDT byte 5) P=1/DPL=00/1/TYPE=1010, 
  2985                                  					;; Type= 1 (code)/C=0/R=1/A=0
  2986                                  		; P= Present, DPL=0=ring 0,  1= user (0= system)
  2987                                  		; 1= Code C= non-Conforming, R= Readable, A = Accessed
  2988                                  
  2989                                  	;; 92h = 1001 0010b (GDT byte 5) P=1/DPL=00/1/TYPE=1010, 
  2990                                  					;; Type= 0 (data)/E=0/W=1/A=0
  2991                                  		; P= Present, DPL=0=ring 0,  1= user (0= system)
  2992                                  		; 0= Data E= Expansion direction (1= down, 0= up)
  2993                                  		; W= Writeable, A= Accessed
  2994                                  
  2995                                  	;; FEh = 1111 1110b (GDT byte 5) P=1/DPL=11/1/TYPE=1110, 
  2996                                  					;; Type= 1 (code)/C=1/R=1/A=0
  2997                                  		; P= Present, DPL=3=ring 3,  1= user (0= system)
  2998                                  		; 1= Code C= Conforming, R= Readable, A = Accessed
  2999                                  	
  3000                                  	;; FAh = 1111 1010b (GDT byte 5) P=1/DPL=11/1/TYPE=1010, 
  3001                                  					;; Type= 1 (code)/C=0/R=1/A=0
  3002                                  		; P= Present, DPL=3=ring 3,  1= user (0= system)
  3003                                  		; 1= Code C= non-Conforming, R= Readable, A = Accessed
  3004                                  
  3005                                  	;; F2h = 1111 0010b (GDT byte 5) P=1/DPL=11/1/TYPE=0010, 
  3006                                  					;; Type= 0 (data)/E=0/W=1/A=0
  3007                                  		; P= Present, DPL=3=ring 3,  1= user (0= system)
  3008                                  		; 0= Data E= Expansion direction (1= down, 0= up)
  3009                                  	
  3010                                  	;; CFh = 1100 1111b (GDT byte 6) G=1/B=1/0/AVL=0, Limit=1111b (3)
  3011                                  
  3012                                  		;; Limit = FFFFFh (=> FFFFFh+1= 100000h) // bits 0-15, 48-51 //
  3013                                  		;	 = 100000h * 1000h (G=1) = 4GB
  3014                                  		;; Limit = FFBFFh (=> FFBFFh+1= FFC00h) // bits 0-15, 48-51 //
  3015                                  		;	 = FFC00h * 1000h (G=1) = 4GB - 4MB
  3016                                  		; G= Granularity (1= 4KB), B= Big (32 bit), 
  3017                                  		; AVL= Available to programmers	
  3018                                  
  3019                                  gdtd:
  3020 00006D78 7700                            dw gdt_end - gdt - 1    ; Limit (size)
  3021 00006D7A [006D0000]                      dd gdt			; Address of the GDT
  3022                                  
  3023                                  	; 20/08/2014
  3024                                  idtd:
  3025 00006D7E 7F02                            dw idt_end - idt - 1    ; Limit (size)
  3026 00006D80 [48870100]                      dd idt			; Address of the IDT
  3027                                  
  3028                                  ; 20/02/2017
  3029                                  ;;; 11/03/2015
  3030                                  %include 'diskdata.s'	; DISK (BIOS) DATA (initialized)
  3031                              <1> ; ****************************************************************************
  3032                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.0 - diskdata.s
  3033                              <1> ; ----------------------------------------------------------------------------
  3034                              <1> ; Last Update: 24/01/2016
  3035                              <1> ; ----------------------------------------------------------------------------
  3036                              <1> ; Beginning: 24/01/2016
  3037                              <1> ; ----------------------------------------------------------------------------
  3038                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
  3039                              <1> ; ----------------------------------------------------------------------------
  3040                              <1> ; Turkish Rational DOS
  3041                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
  3042                              <1> ;
  3043                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
  3044                              <1> ; diskdata.inc (11/03/2015)
  3045                              <1> ;
  3046                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
  3047                              <1> ; ****************************************************************************
  3048                              <1> 
  3049                              <1> ; Retro UNIX 386 v1 Kernel - DISKDATA.INC
  3050                              <1> ; Last Modification: 11/03/2015
  3051                              <1> ;	(Initialized Disk Parameters Data section for 'DISKIO.INC') 
  3052                              <1> ;
  3053                              <1> 
  3054                              <1> ;----------------------------------------
  3055                              <1> ;	80286 INTERRUPT LOCATIONS	:
  3056                              <1> ;	REFERENCED BY POST & BIOS	:
  3057                              <1> ;----------------------------------------
  3058                              <1> 
  3059 00006D84 [E76D0000]          <1> DISK_POINTER:	dd	MD_TBL6		; Pointer to Diskette Parameter Table
  3060                              <1> 
  3061                              <1> ; IBM PC-XT Model 286 source code ORGS.ASM (06/10/85) - 14/12/2014
  3062                              <1> ;----------------------------------------------------------------
  3063                              <1> ; DISK_BASE							:
  3064                              <1> ;	THIS IS THE SET OF PARAMETERS REQUIRED FOR		:
  3065                              <1> ;	DISKETTE OPERATION. THEY ARE POINTED AT BY THE		:
  3066                              <1> ;	DATA VARIABLE @DISK_POINTER. TO MODIFY THE PARAMETERS,	:
  3067                              <1> ;	BUILD ANOTHER PARAMETER BLOCK AND POINT AT IT		:
  3068                              <1> ;----------------------------------------------------------------
  3069                              <1> 
  3070                              <1> ;DISK_BASE:	
  3071                              <1> ;	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
  3072                              <1> ;	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
  3073                              <1> ;	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
  3074                              <1> ;	DB	2		; 512 BYTES/SECTOR
  3075                              <1> ;	;DB	15		; EOT (LAST SECTOR ON TRACK)
  3076                              <1> ;	db	18		; (EOT for 1.44MB diskette)
  3077                              <1> ;	DB	01BH		; GAP LENGTH
  3078                              <1> ;	DB	0FFH		; DTL
  3079                              <1> ;	;DB	054H		; GAP LENGTH FOR FORMAT
  3080                              <1> ;	db	06ch		; (for 1.44MB dsikette)
  3081                              <1> ;	DB	0F6H		; FILL BYTE FOR FORMAT
  3082                              <1> ;	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
  3083                              <1> ;	DB	8		; MOTOR START TIME (1/8 SECONDS)
  3084                              <1> 
  3085                              <1> ;----------------------------------------
  3086                              <1> ;	ROM BIOS DATA AREAS		:
  3087                              <1> ;----------------------------------------
  3088                              <1> 
  3089                              <1> ;DATA		SEGMENT AT 40H		; ADDRESS= 0040:0000
  3090                              <1> 
  3091                              <1> ;@EQUIP_FLAG	DW	?		; INSTALLED HARDWARE FLAGS
  3092                              <1> 
  3093                              <1> ;----------------------------------------
  3094                              <1> ;	DISKETTE DATA AREAS		:
  3095                              <1> ;----------------------------------------
  3096                              <1> 
  3097                              <1> ;@SEEK_STATUS	DB	?		; DRIVE RECALIBRATION STATUS
  3098                              <1> ;					; BIT 3-0 = DRIVE 3-0 RECALIBRATION
  3099                              <1> ;					; BEFORE NEXT SEEK IF BIT IS = 0
  3100                              <1> ;@MOTOR_STATUS	DB	?		; MOTOR STATUS
  3101                              <1> ;					; BIT 3-0 = DRIVE 3-0 CURRENTLY RUNNING
  3102                              <1> ;					; BIT 7 = CURRENT OPERATION IS A WRITE
  3103                              <1> ;@MOTOR_COUNT	DB	?		; TIME OUT COUNTER FOR MOTOR(S) TURN OFF
  3104                              <1> ;@DSKETTE_STATUS DB	?		; RETURN CODE STATUS BYTE
  3105                              <1> ;					; CMD_BLOCK  IN STACK FOR DISK OPERATION
  3106                              <1> ;@NEC_STATUS	DB	7 DUP(?)	; STATUS BYTES FROM DISKETTE OPERATION
  3107                              <1> 
  3108                              <1> ;----------------------------------------
  3109                              <1> ;	POST AND BIOS WORK DATA AREA	:
  3110                              <1> ;----------------------------------------
  3111                              <1> 
  3112                              <1> ;@INTR_FLAG	DB	?		; FLAG INDICATING AN INTERRUPT HAPPENED
  3113                              <1> 
  3114                              <1> ;----------------------------------------
  3115                              <1> ;	TIMER DATA AREA 		:
  3116                              <1> ;----------------------------------------
  3117                              <1> 
  3118                              <1> ; 17/12/2014  (IRQ 0 - INT 08H)
  3119                              <1> ;TIMER_LOW	equ	46Ch		; Timer ticks (counter)  @ 40h:006Ch
  3120                              <1> ;TIMER_HIGH	equ	46Eh		; (18.2 timer ticks per second)
  3121                              <1> ;TIMER_OFL	equ	470h		; Timer - 24 hours flag  @ 40h:0070h
  3122                              <1> 
  3123                              <1> ;----------------------------------------
  3124                              <1> ;	ADDITIONAL MEDIA DATA		:
  3125                              <1> ;----------------------------------------
  3126                              <1> 
  3127                              <1> ;@LASTRATE	DB	?		; LAST DISKETTE DATA RATE SELECTED
  3128                              <1> ;@DSK_STATE	DB	?		; DRIVE 0 MEDIA STATE
  3129                              <1> ;		DB	?		; DRIVE 1 MEDIA STATE
  3130                              <1> ;		DB	?		; DRIVE 0 OPERATION START STATE
  3131                              <1> ;		DB	?		; DRIVE 1 OPERATION START STATE
  3132                              <1> ;@DSK_TRK	DB	?		; DRIVE 0 PRESENT CYLINDER
  3133                              <1> ;		DB	?		; DRIVE 1 PRESENT CYLINDER
  3134                              <1> 
  3135                              <1> ;DATA		ENDS			; END OF BIOS DATA SEGMENT
  3136                              <1> 
  3137                              <1> ;--------------------------------------------------------
  3138                              <1> ;	DRIVE TYPE TABLE				:
  3139                              <1> ;--------------------------------------------------------
  3140                              <1> 		; 16/02/2015 (unix386.s, 32 bit modifications)
  3141                              <1> DR_TYPE:
  3142 00006D88 01                  <1> 		DB	01		;DRIVE TYPE, MEDIA TABLE
  3143                              <1>                 ;DW      MD_TBL1
  3144 00006D89 [A66D0000]          <1> 		dd	MD_TBL1
  3145 00006D8D 82                  <1> 		DB	02+BIT7ON
  3146                              <1> 		;DW      MD_TBL2
  3147 00006D8E [B36D0000]          <1>                 dd      MD_TBL2
  3148 00006D92 02                  <1> DR_DEFAULT:	DB	02
  3149                              <1>                 ;DW      MD_TBL3
  3150 00006D93 [C06D0000]          <1> 		dd      MD_TBL3
  3151 00006D97 03                  <1> 		DB	03
  3152                              <1>                 ;DW      MD_TBL4
  3153 00006D98 [CD6D0000]          <1> 		dd      MD_TBL4
  3154 00006D9C 84                  <1> 		DB	04+BIT7ON
  3155                              <1>                 ;DW      MD_TBL5
  3156 00006D9D [DA6D0000]          <1> 		dd      MD_TBL5
  3157 00006DA1 04                  <1> 		DB	04
  3158                              <1>                 ;DW      MD_TBL6
  3159 00006DA2 [E76D0000]          <1> 		dd      MD_TBL6
  3160                              <1> DR_TYPE_E       equ $                   ; END OF TABLE
  3161                              <1> ;DR_CNT		EQU	(DR_TYPE_E-DR_TYPE)/3
  3162                              <1> DR_CNT		equ	(DR_TYPE_E-DR_TYPE)/5
  3163                              <1> ;--------------------------------------------------------
  3164                              <1> ;	MEDIA/DRIVE PARAMETER TABLES			:
  3165                              <1> ;--------------------------------------------------------
  3166                              <1> ;--------------------------------------------------------
  3167                              <1> ;	360 KB MEDIA IN 360 KB DRIVE			:
  3168                              <1> ;--------------------------------------------------------
  3169                              <1> MD_TBL1:        
  3170 00006DA6 DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
  3171 00006DA7 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
  3172 00006DA8 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
  3173 00006DA9 02                  <1> 	DB	2		; 512 BYTES/SECTOR
  3174 00006DAA 09                  <1> 	DB	09		; EOT (LAST SECTOR ON TRACK)
  3175 00006DAB 2A                  <1> 	DB	02AH		; GAP LENGTH
  3176 00006DAC FF                  <1> 	DB	0FFH		; DTL
  3177 00006DAD 50                  <1> 	DB	050H		; GAP LENGTH FOR FORMAT
  3178 00006DAE F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
  3179 00006DAF 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
  3180 00006DB0 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
  3181 00006DB1 27                  <1> 	DB	39		; MAX. TRACK NUMBER
  3182 00006DB2 80                  <1> 	DB	RATE_250	; DATA TRANSFER RATE
  3183                              <1> ;--------------------------------------------------------
  3184                              <1> ;	360 KB MEDIA IN 1.2 MB DRIVE			:
  3185                              <1> ;--------------------------------------------------------
  3186                              <1> MD_TBL2:        
  3187 00006DB3 DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
  3188 00006DB4 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
  3189 00006DB5 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
  3190 00006DB6 02                  <1> 	DB	2		; 512 BYTES/SECTOR
  3191 00006DB7 09                  <1> 	DB	09		; EOT (LAST SECTOR ON TRACK)
  3192 00006DB8 2A                  <1> 	DB	02AH		; GAP LENGTH
  3193 00006DB9 FF                  <1> 	DB	0FFH		; DTL
  3194 00006DBA 50                  <1> 	DB	050H		; GAP LENGTH FOR FORMAT
  3195 00006DBB F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
  3196 00006DBC 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
  3197 00006DBD 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
  3198 00006DBE 27                  <1> 	DB	39		; MAX. TRACK NUMBER
  3199 00006DBF 40                  <1> 	DB	RATE_300	; DATA TRANSFER RATE
  3200                              <1> ;--------------------------------------------------------
  3201                              <1> ;	1.2 MB MEDIA IN 1.2 MB DRIVE			:
  3202                              <1> ;--------------------------------------------------------
  3203                              <1> MD_TBL3:
  3204 00006DC0 DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
  3205 00006DC1 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
  3206 00006DC2 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
  3207 00006DC3 02                  <1> 	DB	2		; 512 BYTES/SECTOR
  3208 00006DC4 0F                  <1> 	DB	15		; EOT (LAST SECTOR ON TRACK)
  3209 00006DC5 1B                  <1> 	DB	01BH		; GAP LENGTH
  3210 00006DC6 FF                  <1> 	DB	0FFH		; DTL
  3211 00006DC7 54                  <1> 	DB	054H		; GAP LENGTH FOR FORMAT
  3212 00006DC8 F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
  3213 00006DC9 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
  3214 00006DCA 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
  3215 00006DCB 4F                  <1> 	DB	79		; MAX. TRACK NUMBER
  3216 00006DCC 00                  <1> 	DB	RATE_500	; DATA TRANSFER RATE
  3217                              <1> ;--------------------------------------------------------
  3218                              <1> ;	720 KB MEDIA IN 720 KB DRIVE			:
  3219                              <1> ;--------------------------------------------------------
  3220                              <1> MD_TBL4:
  3221 00006DCD DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
  3222 00006DCE 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
  3223 00006DCF 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
  3224 00006DD0 02                  <1> 	DB	2		; 512 BYTES/SECTOR
  3225 00006DD1 09                  <1> 	DB	09		; EOT (LAST SECTOR ON TRACK)
  3226 00006DD2 2A                  <1> 	DB	02AH		; GAP LENGTH
  3227 00006DD3 FF                  <1> 	DB	0FFH		; DTL
  3228 00006DD4 50                  <1> 	DB	050H		; GAP LENGTH FOR FORMAT
  3229 00006DD5 F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
  3230 00006DD6 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
  3231 00006DD7 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
  3232 00006DD8 4F                  <1> 	DB	79		; MAX. TRACK NUMBER
  3233 00006DD9 80                  <1> 	DB	RATE_250	; DATA TRANSFER RATE
  3234                              <1> ;--------------------------------------------------------
  3235                              <1> ;	720 KB MEDIA IN 1.44 MB DRIVE			:
  3236                              <1> ;--------------------------------------------------------
  3237                              <1> MD_TBL5:
  3238 00006DDA DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
  3239 00006DDB 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
  3240 00006DDC 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
  3241 00006DDD 02                  <1> 	DB	2		; 512 BYTES/SECTOR
  3242 00006DDE 09                  <1> 	DB	09		; EOT (LAST SECTOR ON TRACK)
  3243 00006DDF 2A                  <1> 	DB	02AH		; GAP LENGTH
  3244 00006DE0 FF                  <1> 	DB	0FFH		; DTL
  3245 00006DE1 50                  <1> 	DB	050H		; GAP LENGTH FOR FORMAT
  3246 00006DE2 F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
  3247 00006DE3 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
  3248 00006DE4 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
  3249 00006DE5 4F                  <1> 	DB	79		; MAX. TRACK NUMBER
  3250 00006DE6 80                  <1> 	DB	RATE_250	; DATA TRANSFER RATE
  3251                              <1> ;--------------------------------------------------------
  3252                              <1> ;	1.44 MB MEDIA IN 1.44 MB DRIVE			:
  3253                              <1> ;--------------------------------------------------------
  3254                              <1> MD_TBL6:
  3255 00006DE7 AF                  <1> 	DB	10101111B	; SRT=A, HD UNLOAD=0F - 1ST SPECIFY BYTE
  3256 00006DE8 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
  3257 00006DE9 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
  3258 00006DEA 02                  <1> 	DB	2		; 512 BYTES/SECTOR
  3259 00006DEB 12                  <1> 	DB	18		; EOT (LAST SECTOR ON TRACK)
  3260 00006DEC 1B                  <1> 	DB	01BH		; GAP LENGTH
  3261 00006DED FF                  <1> 	DB	0FFH		; DTL
  3262 00006DEE 6C                  <1> 	DB	06CH		; GAP LENGTH FOR FORMAT
  3263 00006DEF F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
  3264 00006DF0 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
  3265 00006DF1 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
  3266 00006DF2 4F                  <1> 	DB	79		; MAX. TRACK NUMBER
  3267 00006DF3 00                  <1> 	DB	RATE_500	; DATA TRANSFER RATE
  3268                              <1> 
  3269                              <1> 
  3270                              <1> ; << diskette.inc >>
  3271                              <1> ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  3272                              <1> ;
  3273                              <1> ;----------------------------------------
  3274                              <1> ;	ROM BIOS DATA AREAS		:
  3275                              <1> ;----------------------------------------
  3276                              <1> 
  3277                              <1> ;DATA		SEGMENT AT 40H		; ADDRESS= 0040:0000
  3278                              <1> 
  3279                              <1> ;----------------------------------------
  3280                              <1> ;	FIXED DISK DATA AREAS		:
  3281                              <1> ;----------------------------------------
  3282                              <1> 
  3283                              <1> ;DISK_STATUS1:	DB	0		; FIXED DISK STATUS
  3284                              <1> ;HF_NUM:		DB	0		; COUNT OF FIXED DISK DRIVES
  3285                              <1> ;CONTROL_BYTE:	DB	0		; HEAD CONTROL BYTE
  3286                              <1> ;@PORT_OFF	DB	?		;  RESERVED (PORT OFFSET)
  3287                              <1> 
  3288                              <1> ;----------------------------------------
  3289                              <1> ;	ADDITIONAL MEDIA DATA		:
  3290                              <1> ;----------------------------------------
  3291                              <1> 
  3292                              <1> ;@LASTRATE	DB	?		; LAST DISKETTE DATA RATE SELECTED
  3293                              <1> ;HF_STATUS	DB	0		; STATUS REGISTER
  3294                              <1> ;HF_ERROR	DB	0		; ERROR REGISTER
  3295                              <1> ;HF_INT_FLAG	DB	0		; FIXED DISK INTERRUPT FLAG
  3296                              <1> ;HF_CNTRL	DB	0		; COMBO FIXED DISK/DISKETTE CARD BIT 0=1
  3297                              <1> ;@DSK_STATE	DB	?		; DRIVE 0 MEDIA STATE
  3298                              <1> ;		DB	?		; DRIVE 1 MEDIA STATE
  3299                              <1> ;		DB	?		; DRIVE 0 OPERATION START STATE
  3300                              <1> ;		DB	?		; DRIVE 1 OPERATION START STATE
  3301                              <1> ;@DSK_TRK	DB	?		; DRIVE 0 PRESENT CYLINDER
  3302                              <1> ;		DB	?		; DRIVE 1 PRESENT CYLINDER
  3303                              <1> 
  3304                              <1> ;DATA		ENDS			; END OF BIOS DATA SEGMENT
  3305                              <1> ;
  3306                              <1> ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  3307                              <1> 
  3308                              <1> ERR_TBL:
  3309 00006DF4 E0                  <1> 	db	NO_ERR
  3310 00006DF5 024001BB            <1> 	db	BAD_ADDR_MARK,BAD_SEEK,BAD_CMD,UNDEF_ERR
  3311 00006DF9 04BB100A            <1> 	db	RECORD_NOT_FND,UNDEF_ERR,BAD_ECC,BAD_SECTOR
  3312                              <1> 
  3313                              <1> ; 17/12/2014 (mov ax, [cfd])
  3314                              <1> ; 11/12/2014
  3315 00006DFD 00                  <1> cfd:		db 0			; current floppy drive (for GET_PARM)
  3316                              <1> ; 17/12/2014				; instead of 'DISK_POINTER'
  3317 00006DFE 01                  <1> pfd:		db 1			; previous floppy drive (for GET_PARM)
  3318                              <1> 					; (initial value of 'pfd 
  3319                              <1> 					; must be different then 'cfd' value
  3320                              <1> 					; to force updating/initializing
  3321                              <1> 					; current drive parameters) 
  3322 00006DFF 90                  <1> align 2
  3323                              <1> 
  3324 00006E00 F001                <1> HF_PORT:	dw 	1F0h  ; Default = 1F0h
  3325                              <1> 			      ; (170h)
  3326 00006E02 F603                <1> HF_REG_PORT:	dw	3F6h  ; HF_PORT + 206h
  3327                              <1> 
  3328                              <1> ; 05/01/2015 
  3329 00006E04 00                  <1> hf_m_s:         db      0     ; (0 = Master, 1 = Slave)
  3330                              <1> 
  3331                              <1> ; *****************************************************************************
  3031                                  
  3032 00006E05 90                      Align 2
  3033                                  
  3034                                  ; 04/11/2014 (Retro UNIX 386 v1)
  3035 00006E06 0000                    mem_1m_1k:   dw 0  ; Number of contiguous KB between
  3036                                                       ; 1 and 16 MB, max. 3C00h = 15 MB.
  3037 00006E08 0000                    mem_16m_64k: dw 0  ; Number of contiguous 64 KB blocks
  3038                                  		   ; between 16 MB and 4 GB.
  3039                                  
  3040                                  ; 12/11/2014 (Retro UNIX 386 v1)
  3041 00006E0A 00                      boot_drv:    db 0 ; boot drive number (physical)
  3042                                  ; 24/11/2014
  3043 00006E0B 00                      drv:	     db 0 
  3044 00006E0C 00                      last_drv:    db 0 ; last hdd
  3045 00006E0D 00                      hdc:         db 0  ; number of hard disk drives
  3046                                  		     ; (present/detected)
  3047                                  
  3048                                  ; 24/11/2014 (Retro UNIX 386 v1)
  3049                                  ; Physical drive type & flags
  3050 00006E0E 00                      fd0_type:    db 0  ; floppy drive type
  3051 00006E0F 00                      fd1_type:    db 0  ; 4 = 1.44 Mb, 80 track, 3.5" (18 spt)
  3052                                  		     ; 6 = 2.88 Mb, 80 track, 3.5" (36 spt)
  3053                                  		     ; 3 = 720 Kb, 80 track, 3.5" (9 spt)
  3054                                  		     ; 2 = 1.2 Mb, 80 track, 5.25" (15 spt)
  3055                                  		     ; 1 = 360 Kb, 40 track, 5.25" (9 spt)		
  3056 00006E10 00                      hd0_type:    db 0  ; EDD status for hd0 (bit 7 = present flag)
  3057 00006E11 00                      hd1_type:    db 0  ; EDD status for hd1 (bit 7 = present flag)
  3058 00006E12 00                      hd2_type:    db 0  ; EDD status for hd2 (bit 7 = present flag)
  3059 00006E13 00                      hd3_type:    db 0  ; EDD status for hd3 (bit 7 = present flag)
  3060                                  		     ; bit 0 - Fixed disk access subset supported
  3061                                  		     ; bit 1 - Drive locking and ejecting
  3062                                  		     ; bit 2 - Enhanced disk drive support
  3063                                  		     ; bit 3 = Reserved (64 bit EDD support)
  3064                                  		     ; (If bit 0 is '1' Retro UNIX 386 v1
  3065                                  		     ; will interpret it as 'LBA ready'!)
  3066                                  
  3067                                  ; 11/03/2015 - 10/07/2015
  3068 00006E14 000000000000000000-     drv.cylinders: dw 0,0,0,0,0,0,0
  3068 00006E1D 0000000000         
  3069 00006E22 000000000000000000-     drv.heads:     dw 0,0,0,0,0,0,0
  3069 00006E2B 0000000000         
  3070 00006E30 000000000000000000-     drv.spt:       dw 0,0,0,0,0,0,0
  3070 00006E39 0000000000         
  3071 00006E3E 000000000000000000-     drv.size:      dd 0,0,0,0,0,0,0
  3071 00006E47 000000000000000000-
  3071 00006E50 000000000000000000-
  3071 00006E59 00                 
  3072 00006E5A 00000000000000          drv.status:    db 0,0,0,0,0,0,0
  3073 00006E61 00000000000000          drv.error:     db 0,0,0,0,0,0,0	
  3074                                  
  3075                                  Align 2
  3076                                  
  3077                                  ;;; 11/03/2015
  3078                                  %include 'kybdata.s'	; KEYBOARD (BIOS) DATA
  3079                              <1> ; ****************************************************************************
  3080                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.0 - kybdata.s
  3081                              <1> ; ----------------------------------------------------------------------------
  3082                              <1> ; Last Update: 17/01/2016
  3083                              <1> ; ----------------------------------------------------------------------------
  3084                              <1> ; Beginning: 17/01/2016
  3085                              <1> ; ----------------------------------------------------------------------------
  3086                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
  3087                              <1> ; ----------------------------------------------------------------------------
  3088                              <1> ; Turkish Rational DOS
  3089                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
  3090                              <1> ;
  3091                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
  3092                              <1> ; kybdata.inc (11/03/2015)
  3093                              <1> ;
  3094                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
  3095                              <1> ; ****************************************************************************
  3096                              <1> 
  3097                              <1> ; Retro UNIX 386 v1 Kernel - KYBDATA.INC
  3098                              <1> ; Last Modification: 11/03/2015
  3099                              <1> ;		 (Data Section for 'KEYBOARD.INC')	
  3100                              <1> ;
  3101                              <1> ; ///////// KEYBOARD DATA ///////////////
  3102                              <1> 
  3103                              <1> ; 05/12/2014
  3104                              <1> ; 04/12/2014 (derived from pc-xt-286 bios source code -1986-) 
  3105                              <1> ; 03/06/86  KEYBOARD BIOS
  3106                              <1> 
  3107                              <1> ;---------------------------------------------------------------------------------
  3108                              <1> ;	KEY IDENTIFICATION SCAN TABLES
  3109                              <1> ;---------------------------------------------------------------------------------
  3110                              <1> 
  3111                              <1> ;-----	TABLES FOR ALT CASE ------------
  3112                              <1> ;-----	ALT-INPUT-TABLE 
  3113 00006E68 524F50514B          <1> K30:	db	82,79,80,81,75
  3114 00006E6D 4C4D474849          <1> 	db	76,77,71,72,73		; 10 NUMBER ON KEYPAD
  3115                              <1> ;-----	SUPER-SHIFT-TABLE 
  3116 00006E72 101112131415        <1> 	db	16,17,18,19,20,21	; A-Z TYPEWRITER CHARS
  3117 00006E78 161718191E1F        <1> 	db	22,23,24,25,30,31
  3118 00006E7E 202122232425        <1> 	db	32,33,34,35,36,37
  3119 00006E84 262C2D2E2F30        <1> 	db	38,44,45,46,47,48
  3120 00006E8A 3132                <1> 	db	49,50
  3121                              <1> 
  3122                              <1> ;-----	TABLE OF SHIFT KEYS AND MASK VALUES
  3123                              <1> ;-----	KEY_TABLE 
  3124 00006E8C 52                  <1> _K6:    db      INS_KEY                 ; INSERT KEY
  3125 00006E8D 3A4546381D          <1> 	db	CAPS_KEY,NUM_KEY,SCROLL_KEY,ALT_KEY,CTL_KEY
  3126 00006E92 2A36                <1>         db      LEFT_KEY,RIGHT_KEY
  3127                              <1> _K6L    equ     $-_K6
  3128                              <1> 
  3129                              <1> ;-----	MASK_TABLE
  3130 00006E94 80                  <1> _K7:    db      INS_SHIFT               ; INSERT MODE SHIFT
  3131 00006E95 4020100804          <1> 	db	CAPS_SHIFT,NUM_SHIFT,SCROLL_SHIFT,ALT_SHIFT,CTL_SHIFT
  3132 00006E9A 0201                <1> 	db	LEFT_SHIFT,RIGHT_SHIFT
  3133                              <1> 
  3134                              <1> ;-----	TABLES FOR CTRL CASE		;---- CHARACTERS ------
  3135 00006E9C 1BFF00FFFFFF        <1> _K8:	db	27,-1,0,-1,-1,-1	; Esc, 1, 2, 3, 4, 5
  3136 00006EA2 1EFFFFFFFF1F        <1> 	db 	30,-1,-1,-1,-1,31	; 6, 7, 8, 9, 0, -
  3137 00006EA8 FF7FFF111705        <1> 	db	-1,127,-1,17,23,5	; =, Bksp, Tab, Q, W, E
  3138 00006EAE 12141915090F        <1> 	db	18,20,25,21,9,15	; R, T, Y, U, I, O
  3139 00006EB4 101B1D0AFF01        <1> 	db	16,27,29,10,-1,1	; P, [, ], Enter, Ctrl, A
  3140 00006EBA 13040607080A        <1> 	db	19,4,6,7,8,10		; S, D, F, G, H, J
  3141 00006EC0 0B0CFFFFFFFF        <1> 	db	11,12,-1,-1,-1,-1	; K, L, :, ', `, LShift
  3142 00006EC6 1C1A18031602        <1> 	db	28,26,24,3,22,2		; Bkslash, Z, X, C, V, B
  3143 00006ECC 0E0DFFFFFFFF        <1> 	db	14,13,-1,-1,-1,-1	; N, M, ,, ., /, RShift
  3144 00006ED2 96FF20FF            <1> 	db	150,-1,' ',-1		; *, ALT, Spc, CL
  3145                              <1> 	;				;----- FUNCTIONS ------		
  3146 00006ED6 5E5F60616263        <1> 	db 	94,95,96,97,98,99	; F1 - F6
  3147 00006EDC 64656667FFFF        <1> 	db	100,101,102,103,-1,-1	; F7 - F10, NL, SL
  3148 00006EE2 778D848E738F        <1> 	db	119,141,132,142,115,143	; Home, Up, PgUp, -, Left, Pad5
  3149 00006EE8 749075917692        <1> 	db 	116,144,117,145,118,146 ; Right, +, End, Down, PgDn, Ins
  3150 00006EEE 93FFFFFF898A        <1> 	db	147,-1,-1,-1,137,138	; Del, SysReq, Undef, WT, F11, F12
  3151                              <1> 
  3152                              <1> ;-----	TABLES FOR LOWER CASE ----------
  3153 00006EF4 1B3132333435363738- <1> K10:	db 	27,'1234567890-=',8,9
  3153 00006EFD 39302D3D0809        <1>
  3154 00006F03 71776572747975696F- <1> 	db 	'qwertyuiop[]',13,-1,'asdfghjkl;',39
  3154 00006F0C 705B5D0DFF61736466- <1>
  3154 00006F15 67686A6B6C3B27      <1>
  3155 00006F1C 60FF5C7A786376626E- <1> 	db	96,-1,92,'zxcvbnm,./',-1,'*',-1,' ',-1
  3155 00006F25 6D2C2E2FFF2AFF20FF  <1>
  3156                              <1> ;-----	LC TABLE SCAN
  3157 00006F2E 3B3C3D3E3F          <1> 	db	59,60,61,62,63		; BASE STATE OF F1 - F10
  3158 00006F33 4041424344          <1> 	db	64,65,66,67,68
  3159 00006F38 FFFF                <1> 	db	-1,-1			; NL, SL
  3160                              <1> 
  3161                              <1> ;-----	KEYPAD TABLE
  3162 00006F3A 474849FF4BFF        <1> K15:	db	71,72,73,-1,75,-1	; BASE STATE OF KEYPAD KEYS
  3163 00006F40 4DFF4F50515253      <1> 	db	77,-1,79,80,81,82,83
  3164 00006F47 FFFF5C8586          <1> 	db	-1,-1,92,133,134	; SysRq, Undef, WT, F11, F12
  3165                              <1> 
  3166                              <1> ;-----	TABLES FOR UPPER CASE ----------
  3167 00006F4C 1B21402324255E262A- <1> K11:	db 	27,'!@#$%',94,'&*()_+',8,0
  3167 00006F55 28295F2B0800        <1>
  3168 00006F5B 51574552545955494F- <1> 	db 	'QWERTYUIOP{}',13,-1,'ASDFGHJKL:"'
  3168 00006F64 507B7D0DFF41534446- <1>
  3168 00006F6D 47484A4B4C3A22      <1>
  3169 00006F74 7EFF7C5A584356424E- <1> 	db	126,-1,'|ZXCVBNM<>?',-1,'*',-1,' ',-1
  3169 00006F7D 4D3C3E3FFF2AFF20FF  <1>
  3170                              <1> ;-----	UC TABLE SCAN
  3171 00006F86 5455565758          <1> K12:	db	84,85,86,87,88		; SHIFTED STATE OF F1 - F10
  3172 00006F8B 595A5B5C5D          <1> 	db	89,90,91,92,93
  3173 00006F90 FFFF                <1> 	db	-1,-1			; NL, SL
  3174                              <1> 
  3175                              <1> ;-----	NUM STATE TABLE
  3176 00006F92 3738392D3435362B31- <1> K14:	db 	'789-456+1230.'		; NUMLOCK STATE OF KEYPAD KEYS
  3176 00006F9B 3233302E            <1>
  3177                              <1> 	;
  3178 00006F9F FFFF7C8788          <1> 	db	-1,-1,124,135,136	; SysRq, Undef, WT, F11, F12
  3179                              <1> 
  3180                              <1> ; 26/08/2014
  3181                              <1> ; Retro UNIX 8086 v1 - UNIX.ASM (03/03/2014)
  3182                              <1> ; Derived from IBM "pc-at" 
  3183                              <1> ; rombios source code (06/10/1985)
  3184                              <1> ; 'dseg.inc'
  3185                              <1> 
  3186                              <1> ;---------------------------------------;
  3187                              <1> ;	SYSTEM DATA AREA		;
  3188                              <1> ;----------------------------------------
  3189 00006FA4 00                  <1> BIOS_BREAK	db	0		; BIT 7=1 IF BREAK KEY HAS BEEN PRESSED
  3190                              <1> 
  3191                              <1> ;----------------------------------------
  3192                              <1> ;	KEYBOARD DATA AREAS		;
  3193                              <1> ;----------------------------------------
  3194                              <1> 
  3195 00006FA5 00                  <1> KB_FLAG		db	0		; KEYBOARD SHIFT STATE AND STATUS FLAGS
  3196 00006FA6 00                  <1> KB_FLAG_1	db	0		; SECOND BYTE OF KEYBOARD STATUS
  3197 00006FA7 00                  <1> KB_FLAG_2	db	0		; KEYBOARD LED FLAGS
  3198 00006FA8 00                  <1> KB_FLAG_3	db	0		; KEYBOARD MODE STATE AND TYPE FLAGS
  3199 00006FA9 00                  <1> ALT_INPUT	db	0		; STORAGE FOR ALTERNATE KEY PAD ENTRY
  3200 00006FAA [BA6F0000]          <1> BUFFER_START	dd	KB_BUFFER 	; OFFSET OF KEYBOARD BUFFER START
  3201 00006FAE [DA6F0000]          <1> BUFFER_END	dd	KB_BUFFER + 32	; OFFSET OF END OF BUFFER
  3202 00006FB2 [BA6F0000]          <1> BUFFER_HEAD	dd	KB_BUFFER 	; POINTER TO HEAD OF KEYBOARD BUFFER
  3203 00006FB6 [BA6F0000]          <1> BUFFER_TAIL	dd	KB_BUFFER 	; POINTER TO TAIL OF KEYBOARD BUFFER
  3204                              <1> ; ------	HEAD = TAIL	INDICATES THAT THE BUFFER IS EMPTY
  3205 00006FBA 0000<rep 10h>       <1> KB_BUFFER	times	16 dw 0		; ROOM FOR 16 SCAN CODE ENTRIES
  3206                              <1> 
  3207                              <1> ; /// End Of KEYBOARD DATA ///
  3079                                  %include 'vidata.s'	; VIDEO (BIOS) DATA
  3080                              <1> ; ****************************************************************************
  3081                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.3 - vidata.s
  3082                              <1> ; ----------------------------------------------------------------------------
  3083                              <1> ; Last Update: 24/11/2020
  3084                              <1> ; ----------------------------------------------------------------------------
  3085                              <1> ; Beginning: 16/01/2016
  3086                              <1> ; ----------------------------------------------------------------------------
  3087                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
  3088                              <1> ; ----------------------------------------------------------------------------
  3089                              <1> ; Turkish Rational DOS
  3090                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
  3091                              <1> ;
  3092                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
  3093                              <1> ; vidata.inc (11/03/2015)
  3094                              <1> ;
  3095                              <1> ; Derived from 'IBM PC-AT' BIOS source code (1985) 
  3096                              <1> ; ****************************************************************************
  3097                              <1> 
  3098                              <1> ; Retro UNIX 386 v1 Kernel - VIDATA.S
  3099                              <1> ; Last Modification: 11/03/2015
  3100                              <1> ;		    (Data section for 'VIDEO.INC')	
  3101                              <1> ;
  3102                              <1> ; ///////// VIDEO DATA ///////////////
  3103                              <1> 
  3104                              <1> ;----------------------------------------
  3105                              <1> ;	VIDEO DISPLAY DATA AREA		;
  3106                              <1> ;----------------------------------------
  3107 00006FDA 03                  <1> CRT_MODE:	db	3	; CURRENT DISPLAY MODE (TYPE)
  3108 00006FDB 29                  <1> CRT_MODE_SET:	db	29h	; CURRENT SETTING OF THE 3X8 REGISTER
  3109                              <1> 				; (29h default setting for video mode 3)
  3110                              <1> 				; Mode Select register Bits
  3111                              <1> 				;   BIT 0 - 80x25 (1), 40x25 (0)
  3112                              <1> 				;   BIT 1 - ALPHA (0), 320x200 GRAPHICS (1)
  3113                              <1> 				;   BIT 2 - COLOR (0), BW (1)
  3114                              <1> 				;   BIT 3 - Video Sig. ENABLE (1), DISABLE (0)
  3115                              <1> 				;   BIT 4 - 640x200 B&W Graphics Mode (1)
  3116                              <1> 				;   BIT 5 - ALPHA mode BLINKING (1)
  3117                              <1> 				;   BIT 6, 7 - Not Used
  3118                              <1> 
  3119                              <1> ; Mode 0 - 2Ch = 101100b	; 40x25 text, 16 gray colors
  3120                              <1> ; Mode 1 - 28h = 101000b	; 40x25 text, 16 fore colors, 8 back colors
  3121                              <1> ; Mode 2 - 2Dh = 101101b	; 80x25 text, 16 gray colors	
  3122                              <1> ; Mode 3 - 29h = 101001b	; 80x25 text, 16 fore color, 8 back color
  3123                              <1> ; Mode 4 - 2Ah = 101010b	; 320x200 graphics, 4 colors
  3124                              <1> ; Mode 5 - 2Eh = 101110b	; 320x200 graphics, 4 gray colors
  3125                              <1> ; Mode 6 - 1Eh = 011110b	; 640x200 graphics, 2 colors
  3126                              <1> ; Mode 7 - 29h = 101001b	; 80x25 text, black & white colors
  3127                              <1> ; Mode & 37h = Video signal OFF
  3128                              <1> 
  3129                              <1> ; 24/06/2016
  3130 00006FDC 50                  <1> CRT_COLS:	db	80	; Number of columns
  3131                              <1> 
  3132                              <1> ; 01/07/2016
  3133 00006FDD 00                  <1> CRT_PALETTE:	db 	0	; Current palette setting
  3134                              <1> 
  3135                              <1> ; 03/07/2016
  3136 00006FDE 10                  <1> CHAR_HEIGHT:	db	16	; Default character height
  3137 00006FDF 60                  <1> VGA_VIDEO_CTL:	db	60h	; ROM BIOS DATA AREA Offset 87h
  3138 00006FE0 F9                  <1> VGA_SWITCHES:	db 	0F9h	; Feature Bit Switches (the basic screen)
  3139 00006FE1 51                  <1> VGA_MODESET_CTL: db	051h	; Basic mode set options (VGA video flags)
  3140                              <1> 				; ROM BIOS DATA AREA Offset 89h
  3141                              <1> 				; Bit 7, 4 : Mode
  3142                              <1> 				;	  01 : 400-line mode
  3143                              <1> 				; Bit 6	: Display switch enabled = 1			
  3144                              <1> 				; Bit 5	: Reserved = 0
  3145                              <1> 				; Bit 3	: Default palette loading 
  3146                              <1> 				;	  disabled = 0
  3147                              <1> 				; Bit 2 : Color monitor = 0
  3148                              <1> 				; Bit 1 = Gray scale summing 
  3149                              <1> 				;	  disabled = 0
  3150                              <1> 				; Bit 0 = VGA active = 1
  3151 00006FE2 19                  <1> VGA_ROWS:	db	25
  3152                              <1> 
  3153                              <1> ; 16/01/2016
  3154                              <1> chr_attrib:  ; Character color/attributes for video pages (0 to 7)
  3155 00006FE3 0707070707070707    <1> 	db	07h, 07h, 07h, 07h, 07h, 07h, 07h, 07h
  3156                              <1> ; 30/01/2016
  3157                              <1> vmode:
  3158 00006FEB 0303030303030303    <1> 	db	3,3,3,3,3,3,3,3 ; video modes for pseudo screens 
  3159                              <1> 
  3160                              <1> CURSOR_MODE: ; cursor start (ch) = 14, cursor end (cl) = 15
  3161 00006FF3 0F0E                <1> 	db	15, 14 ; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  3162                              <1> 
  3163                              <1> ;align 4
  3164                              <1> ;VGA_BASE: ; 26/07/2016
  3165                              <1> ;	dd	 0B8000h  ; (Mode < 0Dh) or 0A0000h (mode >= 0Dh)
  3166                              <1> 
  3167 00006FF5 90                  <1> align 2
  3168                              <1> 
  3169                              <1> vga_modes:
  3170                              <1> 	; 25/07/2016
  3171                              <1> 	; 09/07/2016
  3172                              <1> 	; 03/07/2016
  3173                              <1> 	; valid (implemented) video modes (>7, extension to IBM PC CGA modes)
  3174 00006FF6 0302010007040506    <1> 	db 	03h, 02h, 01h, 00h, 07h, 04h, 05h, 06h
  3175                              <1> vga_g_modes: ; 31/07/2016
  3176 00006FFE 13F0126A0D0E1011    <1> 	db	13h, 0F0h, 12h, 6Ah, 0Dh, 0Eh, 10h, 11h
  3177                              <1> vga_mode_count equ $ - vga_modes
  3178                              <1> vga_g_mode_count equ $ - vga_g_modes
  3179                              <1> 
  3180                              <1> vga_mode_tbl_ptr:
  3181                              <1> 	; 25/07/2016
  3182 00007006 [66700000]          <1> 	dd	vga_mode_03h
  3183 0000700A [66700000]          <1> 	dd	vga_mode_03h ; mode 02h -> mode 03h 
  3184 0000700E [A6700000]          <1> 	dd	vga_mode_01h
  3185 00007012 [A6700000]          <1> 	dd	vga_mode_01h ; mode 00h -> mode 01h
  3186                              <1> 	;dd	vga_mode_07h
  3187 00007016 [66700000]          <1> 	dd	vga_mode_03h ; mode 07h -> mode 03h
  3188 0000701A [E6700000]          <1> 	dd	vga_mode_04h
  3189 0000701E [E6700000]          <1> 	dd	vga_mode_04h ; mode 05h -> mode 04h	
  3190 00007022 [26710000]          <1> 	dd	vga_mode_06h
  3191 00007026 [66710000]          <1> 	dd	vga_mode_13h
  3192 0000702A [A6710000]          <1> 	dd	vga_mode_F0h
  3193 0000702E [E6710000]          <1> 	dd	vga_mode_12h
  3194 00007032 [26720000]          <1> 	dd	vga_mode_6Ah
  3195 00007036 [66720000]          <1> 	dd	vga_mode_0Dh
  3196 0000703A [A6720000]          <1> 	dd	vga_mode_0Eh
  3197 0000703E [E6720000]          <1> 	dd	vga_mode_10h
  3198 00007042 [26730000]          <1> 	dd	vga_mode_11h	
  3199                              <1> 
  3200                              <1> vga_memmodel: 
  3201                              <1> 	; 25/07/2016
  3202                              <1> 	; 07/07/2016
  3203                              <1> 	CTEXT	equ 0
  3204                              <1> 	;MTEXT	equ 1
  3205                              <1> 	MTEXT	equ 0 ; mode 07h -> mode 03h
  3206                              <1> 	CGA	equ 2
  3207                              <1> 	LINEAR8 equ 5
  3208                              <1> 	PLANAR4	equ 4
  3209                              <1> 	PLANAR1	equ 3
  3210 00007046 0000000000020202    <1> 	db	CTEXT, CTEXT, CTEXT, CTEXT, MTEXT, CGA, CGA, CGA
  3211                              <1> vga_g_memmodel: ; 31/07/2016
  3212 0000704E 0504040404040403    <1> 	db	LINEAR8, PLANAR4, PLANAR4, PLANAR4, PLANAR4, PLANAR4, PLANAR4, PLANAR1
  3213                              <1> ;vga_pixbits:
  3214                              <1> ;	; 25/07/2016
  3215                              <1> ;	; 08/07/2016
  3216                              <1> ;	db 	4, 4, 4, 4, 4, 2, 2, 1, 8, 4, 4, 4, 4, 4, 4, 1
  3217                              <1> vga_dac_s:
  3218 00007056 020202020001010103- <1> 	db	2, 2, 2, 2, 0, 1, 1, 1, 3, 3, 2, 2, 1, 1, 2, 2  
  3218 0000705F 03020201010202      <1>
  3219                              <1> 						; (vgatables.h, VGAMODES, dac) 
  3220                              <1> 						; 17/11/2020
  3221                              <1> vga_params:
  3222                              <1> 	; 23/11/2020
  3223                              <1> 	; 16/11/2020
  3224                              <1> 	; 09/11/2020, 10/11/2020, 11/11/2020 (TRDOS 386 v2.0.3)
  3225                              <1> 	; 25/07/2016 
  3226                              <1> 	; 19/07/2016
  3227                              <1> 	; 03/07/2016
  3228                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  3229                              <1> 	; vgabios-0.7a (2011)
  3230                              <1> 	; by the LGPL VGABios Developers Team (2001-2008)
  3231                              <1> 	; 'vgatables.h'
  3232                              <1> 	; Oracle VirtualBox 5.0.24 VGABios Source Code
  3233                              <1> 	; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
  3234                              <1> 
  3235                              <1> 	; 09/11/2020
  3236                              <1> 	; Block Structure of Video Parameter Table
  3237                              <1> 	;
  3238                              <1> 	; Offset	# Bytes		Contents
  3239                              <1> 	;
  3240                              <1> 	;  0		1		# columns
  3241                              <1> 	;  1		1  		# rows - 1 
  3242                              <1> 	;  2		1		Pixels/character
  3243                              <1> 	;  3-4		2		Page length		
  3244                              <1> 	;  5-8		4		Sequencer Registers
  3245                              <1> 	;  9		1		Miscellaneous Register	
  3246                              <1> 	;  10-34	25		CRTC Registers
  3247                              <1> 	;  35-54	20		Attribute Registers
  3248                              <1> 	;  55-63	9		Graphics Controller Registers
  3249                              <1> 	;
  3250                              <1> 	; Ref: Programmer's Guide to EGA, VGA, and Super VGA cards
  3251                              <1> 	; (Richard F. Ferraro, 1994)  
  3252                              <1> 
  3253                              <1> 	;
  3254                              <1> vga_mode_03h:  ; mode 03h, 80*25 text, CGA colors
  3255                              <1> 	; 11/11/2020
  3256 00007066 5018100010          <1>  	db	80, 24, 16, 00h, 10h ; tw, th-1, ch, slength (5)
  3257 0000706B 00030002            <1>  	db	00h, 03h, 00h, 02h ; sequ regs (4)
  3258 0000706F 67                  <1>  	db	67h	; misc reg (1)
  3259 00007070 5F4F50825581BF1F    <1>  	db	5Fh, 4Fh, 50h, 82h, 55h, 81h, 0BFh, 1Fh
  3260                              <1>  	; 09/11/2020
  3261                              <1> 	;db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh
  3262 00007078 004F                <1> 	db	00h, 4Fh
  3263                              <1> vga_p_cm_pos equ $ - vga_mode_03h
  3264 0000707A 0D0E00000000        <1> 	db	0Dh, 0Eh, 00h, 00h, 00h, 00h
  3265 00007080 9C8E8F281F96B9A3    <1>  	db	9Ch, 8Eh, 8Fh, 28h, 1Fh, 96h, 0B9h, 0A3h
  3266 00007088 FF                  <1> 	db	0FFh	; crtc_regs (25)
  3267 00007089 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
  3268 00007091 38393A3B3C3D3E3F    <1>  	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
  3269                              <1>  	;db	0Ch, 00h, 0Fh, 08h  ; actl regs (20)
  3270 00007099 0C000F00            <1> 	db	0Ch, 00h, 0Fh, 00h  ; 19/11/2020
  3271 0000709D 0000000000100E0FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 10h, 0Eh, 0Fh, 0FFh ; grdc regs (9)
  3272                              <1> 	; 09/11/2020
  3273                              <1> 	;db	00h, 00h, 00h, 00h, 00h, 10h, 0Eh, 00h, 0FFh ; grdc regs (9)
  3274                              <1> vga_mode_01h:	; mode 01h, 40*25 text, CGA colors
  3275 000070A6 2818100008          <1> 	db	40, 24, 16, 00h, 08h ; tw, th-1, ch, slength
  3276 000070AB 08030002            <1> 	db	08h, 03h, 00h, 02h  ; sequ regs
  3277 000070AF 67                  <1> 	db	67h	; misc reg
  3278 000070B0 2D2728902BA0BF1F    <1> 	db	2Dh, 27h, 28h, 90h, 2Bh, 0A0h, 0BFh, 1Fh
  3279 000070B8 004F0D0E00000000    <1> 	db	00h, 4Fh, 0Dh, 0Eh, 00h, 00h, 00h, 00h
  3280 000070C0 9C8E8F141F96B9A3    <1> 	db	9Ch, 8Eh, 8Fh, 14h, 1Fh, 96h, 0B9h, 0A3h
  3281 000070C8 FF                  <1> 	db	0FFh	; crtc_regs
  3282 000070C9 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
  3283 000070D1 38393A3B3C3D3E3F    <1> 	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
  3284                              <1>  	;db	0Ch, 00h, 0Fh, 08h  ; actl regs (20)
  3285 000070D9 0C000F00            <1> 	db	0Ch, 00h, 0Fh, 00h  ; 19/11/2020
  3286 000070DD 0000000000100E0FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 10h, 0Eh, 0Fh, 0FFh ; grdc regs
  3287                              <1> ;vga_mode_07h:	; mode 07h, 80*25 text, mono color
  3288                              <1> ;	db	80, 24, 16, 00h, 10h  ; tw, th-1, ch, slength
  3289                              <1> ;	db	00h, 03h, 00h, 02h ; sequ regs
  3290                              <1> ;	db	66h	; misc reg
  3291                              <1> ;	db	5Fh, 4Fh, 50h, 82h, 55h, 81h, 0BFh, 1Fh
  3292                              <1> ;	db	00h, 4Fh, 0Dh, 0Eh, 00h, 00h, 00h, 00h
  3293                              <1> ;	db	9Ch, 8Eh, 8Fh, 28h, 0Fh, 96h, 0B9h, 0A3h
  3294                              <1> ;	db	0FFh	; crtc regs
  3295                              <1> ;	db	00h, 08h, 08h, 08h, 08h, 08h, 08h, 08h
  3296                              <1> ;	db	10h, 18h, 18h, 18h, 18h, 18h, 18h, 18h
  3297                              <1> ;	db	0Eh, 00h, 0Fh, 08h  ; actl regs
  3298                              <1> ;	db	00h, 00h, 00h, 00h, 00h, 10h, 0Ah, 0Fh, 0FFh ; grdc regs
  3299                              <1> vga_mode_04h:	; 320*200 graphics, 4 colors, CGA
  3300                              <1> 	; 11/11/2020
  3301 000070E6 2818080040          <1> 	db	40, 24, 8, 00h, 40h ; tw, th-1, ch, slength
  3302 000070EB 09030002            <1> 	db	09h, 03h, 00h, 02h ; sequ regs
  3303 000070EF 63                  <1> 	db	63h	; misc reg
  3304 000070F0 2D2728902B80BF1F    <1> 	db	2Dh, 27h, 28h, 90h, 2Bh, 80h, 0BFh, 1Fh
  3305 000070F8 00C1000000000000    <1> 	db	00h, 0C1h, 00h, 00h, 00h, 00h, 00h, 00h
  3306 00007100 9C8E8F140096B9A2    <1> 	db	9Ch, 8Eh, 8Fh, 14h, 00h, 96h, 0B9h, 0A2h
  3307 00007108 FF                  <1> 	db	0FFh	; crtc_regs
  3308 00007109 0013151702040607    <1> 	db	00h, 13h, 15h, 17h, 02h, 04h, 06h, 07h
  3309 00007111 1011121314151617    <1> 	db	10h, 11h, 12h, 13h, 14h, 15h, 16h, 17h
  3310 00007119 01000300            <1> 	db	01h, 00h, 03h, 00h ; actl regs
  3311 0000711D 0000000000300F0FFF  <1> 	db 	00h, 00h, 00h, 00h, 00h, 30h, 0Fh, 0Fh, 0FFh ; grdc regs
  3312                              <1> vga_mode_06h:	; 640*200 graphics, 2 colors, CGA
  3313                              <1> 	; 11/11/2020
  3314 00007126 5018080040          <1> 	db	80, 24, 8, 00h, 40h   ;	tw, th-1, ch, slength
  3315 0000712B 01010006            <1> 	db	01h, 01h, 00h, 06h ; sequ regs
  3316 0000712F 63                  <1> 	db	63h	; misc reg
  3317 00007130 5F4F50825480BF1F    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh
  3318 00007138 00C1000000000000    <1> 	db	00h, 0C1h, 00h, 00h, 00h, 00h, 00h, 00h
  3319 00007140 9C8E8F280096B9C2    <1> 	db	9Ch, 8Eh, 8Fh, 28h, 00h, 96h, 0B9h, 0C2h
  3320 00007148 FF                  <1> 	db	0FFh	; crtc regs
  3321 00007149 0017171717171717    <1> 	db	00h, 17h, 17h, 17h, 17h, 17h, 17h, 17h
  3322 00007151 1717171717171717    <1> 	db	17h, 17h, 17h, 17h, 17h, 17h, 17h, 17h
  3323 00007159 01000100            <1> 	db	01h, 00h, 01, 00h  ; actl regs
  3324 0000715D 0000000000000D0FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 0Dh, 0Fh, 0FFh ; grdc regs
  3325                              <1> vga_mode_13h:  ; mode 13h, 300*200, 256 colors, linear
  3326                              <1> 	; 11/11/2020
  3327                              <1> 	;db 	40, 24, 8, 00h, 20h ; tw, th-1, ch, slength (5)
  3328                              <1> 	; 23/11/2020 - 10/11/2020
  3329 00007166 28180800FA          <1> 	db 	40, 24, 8, 00h, 0FAh ; tw, th-1, ch, slength (5)
  3330 0000716B 010F000E            <1> 	db	01h, 0Fh, 00h, 0Eh ; sequ regs (4)
  3331 0000716F 63                  <1> 	db	63h	; misc reg (1)
  3332 00007170 5F4F50825480BF1F    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh 
  3333 00007178 0041000000000000    <1> 	db 	00h, 041h, 00h, 00h, 00h, 00h, 00h, 00h
  3334 00007180 9C8E8F284096B9A3    <1> 	db	9Ch, 8Eh, 8Fh, 28h, 40h, 96h, 0B9h, 0A3h
  3335 00007188 FF                  <1> 	db	0FFh	; crtc regs (25)
  3336 00007189 0001020304050607    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 06h, 07h
  3337 00007191 08090A0B0C0D0E0F    <1>  	db	08h, 09h, 0Ah, 0Bh, 0Ch, 0Dh, 0Eh, 0Fh
  3338 00007199 41000F00            <1>  	db	41h, 00h, 0Fh, 00h  ; actl regs (20)
  3339                              <1> 	; 10/11/2020
  3340                              <1>  	;db	41h, 01h, 0Fh, 13h  ; actl regs (20) 
  3341 0000719D 000000000040050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 40h, 05h, 0Fh, 0FFh ; grdc regs (9)
  3342                              <1> vga_mode_setl equ $ - vga_mode_13h  ; = 64
  3343                              <1> vga_mode_F0h:  ; mode X ; 320*240, 256 colors, planar
  3344 000071A6 2818080000          <1> 	db 	40, 24, 8, 00h, 00h ; tw, th-1, ch, slength
  3345 000071AB 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
  3346 000071AF E3                  <1> 	db	0E3h	; misc reg
  3347 000071B0 5F4F508254800D3E    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0Dh, 3Eh 
  3348 000071B8 0041000000000000    <1>  	db 	00h, 41h, 00h, 00h, 00h, 00h, 00h, 00h
  3349 000071C0 EAACDF2800E706E3    <1> 	db	0EAh, 0ACh, 0DFh, 28h, 00h, 0E7h, 06h, 0E3h
  3350 000071C8 FF                  <1> 	db	0FFh	; crtc regs (25)
  3351 000071C9 0001020304050607    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 06h, 07h
  3352 000071D1 08090A0B0C0D0E0F    <1>  	db	08h, 09h, 0Ah, 0Bh, 0Ch, 0Dh, 0Eh, 0Fh
  3353 000071D9 41000F00            <1>  	db	41h, 00h, 0Fh, 00h  ; actl regs
  3354 000071DD 000000000040050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 40h, 05h, 0Fh, 0FFh ; grdc regs
  3355                              <1> vga_mode_12h:  ; mode 12h, 640*480, 16 colors, planar
  3356                              <1> 	; 11/11/2020
  3357                              <1>  	;db 	80, 29, 16, 0, 0 ; tw, th-1, ch, slength
  3358                              <1> 	; 09/11/2020
  3359 000071E6 501D1000A0          <1>  	db 	80, 29, 16, 00h, 0A0h ; tw, th-1, ch, slength
  3360 000071EB 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
  3361 000071EF E3                  <1> 	db 	0E3h	; misc reg
  3362 000071F0 5F4F508254800B3E    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0Bh, 3Eh
  3363                              <1> 	; 09/11/2020
  3364                              <1> 	;db	5Fh, 4Fh, 50h, 82h, 53h, 9Fh, 0Bh, 3Eh
  3365 000071F8 0040000000000000    <1> 	db	00h, 40h, 00h, 00h, 00h, 00h, 00h, 00h
  3366 00007200 EA8CDF2800E704E3    <1>  	db	0EAh, 8Ch, 0DFh, 28h, 00h, 0E7h, 04h, 0E3h
  3367                              <1> 	; 09/11/2020
  3368                              <1>  	;db	0E9h, 8Bh, 0DFh, 28h, 00h, 0E7h, 04h, 0E3h
  3369 00007208 FF                  <1> 	db	0FFh	; crtc regs
  3370 00007209 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
  3371 00007211 38393A3B3C3D3E3F    <1> 	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
  3372 00007219 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
  3373 0000721D 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
  3374                              <1> vga_mode_6Ah:  ; mode 6Ah, 800*600, 16 colors, planar
  3375                              <1> 	; 11/11/2020
  3376 00007226 6424100000          <1>  	db 	100, 36, 16, 00h, 00h ; tw, th-1, ch, slength
  3377 0000722B 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
  3378 0000722F E3                  <1> 	db 	0E3h	; misc reg
  3379 00007230 7F6363836B1B72F0    <1> 	db	7Fh, 63h, 63h, 83h, 6Bh, 1Bh, 72h, 0F0h
  3380 00007238 0060000000000000    <1> 	db	00h, 60h, 00h, 00h, 00h, 00h, 00h, 00h
  3381 00007240 598D5732005773E3    <1>  	db	59h, 8Dh, 57h, 32h, 00h, 57h, 73h, 0E3h
  3382 00007248 FF                  <1> 	db	0FFh	; crtc regs
  3383 00007249 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
  3384 00007251 38393A3B3C3D3E3F    <1> 	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
  3385 00007259 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
  3386 0000725D 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
  3387                              <1> vga_mode_0Dh:  ; mode 0Dh, 320*200, 16 colors, planar
  3388 00007266 2818080020          <1>  	db 	40, 24, 8, 00h, 20h ; tw, th-1, ch, slength
  3389 0000726B 090F0006            <1> 	db	09h, 0Fh, 00h, 06h ; sequ regs
  3390 0000726F 63                  <1> 	db 	63h	; misc reg
  3391 00007270 2D2728902B80BF1F    <1> 	db	2Dh, 27h, 28h, 90h, 2Bh, 80h, 0BFh, 1Fh
  3392 00007278 00C0000000000000    <1> 	db	00h, 0C0h, 00h, 00h, 00h, 00h, 00h, 00h
  3393 00007280 9C8E8F140096B9E3    <1>  	db	9Ch, 8Eh, 8Fh, 14h, 00h, 96h, 0B9h, 0E3h
  3394 00007288 FF                  <1> 	db	0FFh	; crtc regs
  3395 00007289 0001020304050607    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 06h, 07h
  3396 00007291 1011121314151617    <1> 	db	10h, 11h, 12h, 13h, 14h, 15h, 16h, 17h
  3397 00007299 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
  3398 0000729D 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
  3399                              <1> vga_mode_0Eh:  ; mode 0Eh, 640*200, 16 colors, planar
  3400 000072A6 5018080040          <1>  	db 	80, 24, 8, 00h, 40h ; tw, th-1, ch, slength
  3401 000072AB 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
  3402 000072AF 63                  <1> 	db 	63h	; misc reg
  3403 000072B0 5F4F50825480BF1F    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh
  3404 000072B8 00C0000000000000    <1> 	db	00h, 0C0h, 00h, 00h, 00h, 00h, 00h, 00h
  3405 000072C0 9C8E8F280096B9E3    <1>  	db	9Ch, 8Eh, 8Fh, 28h, 00h, 96h, 0B9h, 0E3h
  3406 000072C8 FF                  <1> 	db	0FFh	; crtc regs
  3407 000072C9 0001020304050607    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 06h, 07h
  3408 000072D1 1011121314151617    <1> 	db	10h, 11h, 12h, 13h, 14h, 15h, 16h, 17h
  3409 000072D9 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
  3410 000072DD 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
  3411                              <1> vga_mode_10h: ; mode 10h, 640*350, 16 colors, planar
  3412 000072E6 50180E0080          <1>  	db 	80, 24, 14, 00h, 80h ; tw, th-1, ch, slength
  3413 000072EB 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
  3414 000072EF A3                  <1> 	db 	0A3h	; misc reg
  3415 000072F0 5F4F50825480BF1F    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh
  3416 000072F8 0040000000000000    <1> 	db	00h, 40h, 00h, 00h, 00h, 00h, 00h, 00h
  3417 00007300 83855D280F63BAE3    <1>  	db	83h, 85h, 5Dh, 28h, 0Fh, 63h, 0BAh, 0E3h
  3418 00007308 FF                  <1> 	db	0FFh	; crtc regs
  3419 00007309 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
  3420 00007311 38393A3B3C3D3E3F    <1> 	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
  3421 00007319 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
  3422 0000731D 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
  3423                              <1> vga_mode_11h: ; mode 11h, 640*480, mono color, planar
  3424                              <1>  	; 11/11/2020
  3425 00007326 501D1000A0          <1> 	db 	80, 29, 16, 00h, 0A0h ; tw, th-1, ch, slength
  3426 0000732B 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
  3427 0000732F E3                  <1> 	db 	0E3h	; misc reg
  3428 00007330 5F4F508254800B3E    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0Bh, 3Eh
  3429 00007338 0040000000000000    <1> 	db	00h, 40h, 00h, 00h, 00h, 00h, 00h, 00h
  3430 00007340 EA8CDF2800E704C3    <1>  	db	0EAh, 8Ch, 0DFh, 28h, 00h, 0E7h, 04h, 0C3h ; 11/11/2020
  3431 00007348 FF                  <1> 	db	0FFh	; crtc regs
  3432 00007349 003F003F003F003F    <1> 	db	00h, 3Fh, 00h, 3Fh, 00h, 3Fh, 00h, 3Fh
  3433 00007351 003F003F003F003F    <1> 	db	00h, 3Fh, 00h, 3Fh, 00h, 3Fh, 00h, 3Fh
  3434 00007359 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
  3435 0000735D 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
  3436                              <1> end_of_vga_params:
  3437                              <1> 
  3438                              <1> ; /// End Of VIDEO DATA ///
  3439                              <1> 
  3440                              <1> ; 23/11/2020
  3441                              <1> ; VBE 2 BOCHS/QEMU emulator extensions 
  3442                              <1> ;	for TRDOS 386 v2 kernel (video bios)  
  3443                              <1> 
  3444                              <1> ; vbetables.h by Volker Rupper (02/01/2020)
  3445                              <1> 
  3446                              <1> b_vbe_modes:
  3447                              <1> 	;/* standard VESA modes */	
  3448 00007366 0001800290010800    <1> 	dw 100h,  640, 400,  8
  3449 0000736E 01018002E0010800    <1> 	dw 101h,  640, 480,  8
  3450 00007376 0301200358020800    <1> 	dw 103h,  800, 600,  8
  3451 0000737E 0501000400030800    <1> 	dw 105h, 1024, 768,  8
  3452 00007386 0E014001C8001000    <1> 	dw 10Eh,  320, 200, 16
  3453 0000738E 0F014001C8001800    <1> 	dw 10Fh,  320, 200, 24
  3454 00007396 11018002E0011000    <1> 	dw 111h,  640, 480, 16
  3455 0000739E 12018002E0011800    <1> 	dw 112h,  640, 480, 24
  3456 000073A6 1401200358021000    <1> 	dw 114h,  800, 600, 16
  3457 000073AE 1501200358021800    <1> 	dw 115h,  800, 600, 24
  3458 000073B6 1701000400031000    <1> 	dw 117h, 1024, 768, 16
  3459 000073BE 1801000400031800    <1> 	dw 118h, 1024, 768, 24
  3460                              <1> 
  3461                              <1> ;/* BOCHS/PLEX86 'own' mode numbers */
  3462 000073C6 40014001C8002000    <1> 	dw 140h,  320,  200, 32
  3463 000073CE 4101800290012000    <1> 	dw 141h,  640,  400, 32
  3464 000073D6 42018002E0012000    <1> 	dw 142h,  640,  480, 32
  3465 000073DE 4301200358022000    <1> 	dw 143h,  800,  600, 32
  3466 000073E6 4401000400032000    <1> 	dw 144h, 1024,  768, 32
  3467 000073EE 46014001C8000800    <1> 	dw 146h,  320,  200,  8
  3468 000073F6 8D010005D0021000    <1> 	dw 18Dh, 1280,  720, 16
  3469 000073FE 8E010005D0021800    <1> 	dw 18Eh, 1280,  720, 24
  3470 00007406 8F010005D0022000    <1> 	dw 18Fh, 1280,  720, 32
  3471 0000740E 9001800738041000    <1> 	dw 190h, 1920, 1080, 16
  3472 00007416 9101800738041800    <1> 	dw 191h, 1920, 1080, 24
  3473 0000741E 9201800738042000    <1> 	dw 192h, 1920, 1080, 32
  3474                              <1> 
  3475                              <1> end_of_b_vbe_modes:
  3476                              <1> 
  3477                              <1> MA1 equ VBE_MODE_ATTRIBUTE_SUPPORTED
  3478                              <1> MA2 equ VBE_MODE_ATTRIBUTE_EXTENDED_INFO_AVAILABLE
  3479                              <1> MA3 equ VBE_MODE_ATTRIBUTE_COLOR_MODE
  3480                              <1> MA4 equ VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE
  3481                              <1> MA5 equ	VBE_MODE_ATTRIBUTE_GRAPHICS_MODE
  3482                              <1> 
  3483                              <1> MODE_ATTRIBUTES equ MA1|MA2|MA3|MA4|MA5
  3484                              <1> 
  3485                              <1> WA1 equ VBE_WINDOW_ATTRIBUTE_RELOCATABLE
  3486                              <1> WA2 equ	VBE_WINDOW_ATTRIBUTE_READABLE
  3487                              <1> WA3 equ VBE_WINDOW_ATTRIBUTE_WRITEABLE
  3488                              <1> 
  3489                              <1> WINA_ATTRIBUTES equ WA1|WA2|WA3
  3490                              <1> 
  3491                              <1> ; 24/11/2020
  3492                              <1> 
  3493                              <1> %if 0
  3494                              <1> 
  3495                              <1> MODE_INFO_LIST: 
  3496                              <1> 
  3497                              <1> ; 24/11/2020
  3498                              <1> ; '%if 0' disables 24 mode info tables here, until %endif 
  3499                              <1> ; ('set_mode_info_list' will set only 1 list for selected mode)
  3500                              <1> ; (Purpose: To save about 1 KB kernel size by removing fixed data)
  3501                              <1> 
  3502                              <1> 			dw	0100h ; 640x400x8 
  3503                              <1> ModeAttributes1: 	dw	MODE_ATTRIBUTES
  3504                              <1> WinAAttributes1: 	db	WINA_ATTRIBUTES
  3505                              <1> WinBAttributes1: 	db	0
  3506                              <1> WinGranularity1: 	dw	VBE_DISPI_BANK_SIZE_KB
  3507                              <1> WinSize1: 		dw	VBE_DISPI_BANK_SIZE_KB
  3508                              <1> WinASegment1:		dw	VGAMEM_GRAPH
  3509                              <1> WinBSegment1:		dw	0000h
  3510                              <1> WinFuncPtr1:		dd	0
  3511                              <1> BytesPerScanLine1: 	dw	640
  3512                              <1> XResolution1:		dw	640
  3513                              <1> YResolution1:		dw	400
  3514                              <1> XCharSize1:		db	8
  3515                              <1> YCharSize1:		db	16
  3516                              <1> NumberOfPlanes1: 	db	1
  3517                              <1> BitsPerPixel1:		db	8
  3518                              <1> NumberOfBanks1:		db	4
  3519                              <1> MemoryModel1:		db	VBE_MEMORYMODEL_PACKED_PIXEL
  3520                              <1> BankSize1:		db	0
  3521                              <1> NumberOfImagePages1: 	db	64
  3522                              <1> Reserved_page1:		db	0
  3523                              <1> RedMaskSize1:		db	0
  3524                              <1> RedFieldPosition1: 	db	0
  3525                              <1> GreenMaskSize1:		db	0
  3526                              <1> GreenFieldPosition1: 	db	0
  3527                              <1> BlueMaskSize1:		db	0
  3528                              <1> BlueFieldPosition1: 	db	0
  3529                              <1> RsvdMaskSize1: 		db	0
  3530                              <1> RsvdFieldPosition1: 	db	0
  3531                              <1> DirectColorModeInfo1: 	db	0
  3532                              <1> PhysBasePtr1:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  3533                              <1> OffScreenMemOffset1: 	dd	0
  3534                              <1> OffScreenMemSize1: 	dw	0
  3535                              <1> LinBytesPerScanLine1: 	dw	640
  3536                              <1> BnkNumberOfPages1: 	db	0
  3537                              <1> LinNumberOfPages1: 	db	0
  3538                              <1> LinRedMaskSize1:	db	0
  3539                              <1> LinRedFieldPosition1: 	db	0
  3540                              <1> LinGreenMaskSize1: 	db	0
  3541                              <1> LinGreenFieldPosition1: db	0
  3542                              <1> LinBlueMaskSize1: 	db	0
  3543                              <1> LinBlueFieldPosition1: 	db	0
  3544                              <1> LinRsvdMaskSize1: 	db	0
  3545                              <1> LinRsvdFieldPosition1: 	db	0
  3546                              <1> MaxPixelClock1:		dd	0
  3547                              <1> 
  3548                              <1> 			dw	0101h ; 640x480x8
  3549                              <1> ModeAttributes2: 	dw	MODE_ATTRIBUTES
  3550                              <1> WinAAttributes2: 	db	WINA_ATTRIBUTES
  3551                              <1> WinBAttributes2: 	db	0
  3552                              <1> WinGranularity2: 	dw	VBE_DISPI_BANK_SIZE_KB
  3553                              <1> WinSize2: 		dw	VBE_DISPI_BANK_SIZE_KB
  3554                              <1> WinASegment2:		dw	VGAMEM_GRAPH
  3555                              <1> WinBSegment2:		dw	0000h
  3556                              <1> WinFuncPtr2:		dd	0
  3557                              <1> BytesPerScanLine2:	dw	640
  3558                              <1> XResolution2:		dw	640
  3559                              <1> YResolution2:		dw	480
  3560                              <1> XCharSize2:		db	8
  3561                              <1> YCharSize2:		db	16
  3562                              <1> NumberOfPlanes2:	db	1
  3563                              <1> BitsPerPixel2:		db	8
  3564                              <1> NumberOfBanks2:		db	5
  3565                              <1> MemoryModel2:		db	VBE_MEMORYMODEL_PACKED_PIXEL
  3566                              <1> BankSize2:		db	0
  3567                              <1> NumberOfImagePages2:	db	53
  3568                              <1> Reserved_page2:		db	0
  3569                              <1> RedMaskSize2:		db	0
  3570                              <1> RedFieldPosition2:	db	0
  3571                              <1> GreenMaskSize2:		db	0
  3572                              <1> GreenFieldPosition2:	db	0
  3573                              <1> BlueMaskSize2:		db	0
  3574                              <1> BlueFieldPosition2:	db	0
  3575                              <1> RsvdMaskSize2:		db	0
  3576                              <1> RsvdFieldPosition2:	db	0
  3577                              <1> DirectColorModeInfo2:	db	0
  3578                              <1> PhysBasePtr2:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  3579                              <1> OffScreenMemOffset2:	dd	0
  3580                              <1> OffScreenMemSize2:	dw	0
  3581                              <1> LinBytesPerScanLine2:	dw	640
  3582                              <1> BnkNumberOfPages2: 	db	0
  3583                              <1> LinNumberOfPages2: 	db	0
  3584                              <1> LinRedMaskSize2:	db	0
  3585                              <1> LinRedFieldPosition2: 	db	0
  3586                              <1> LinGreenMaskSize2: 	db	0
  3587                              <1> LinGreenFieldPosition2: db	0
  3588                              <1> LinBlueMaskSize2: 	db	0
  3589                              <1> LinBlueFieldPosition2: 	db	0
  3590                              <1> LinRsvdMaskSize2: 	db	0
  3591                              <1> LinRsvdFieldPosition2: 	db	0
  3592                              <1> MaxPixelClock2:		dd	0
  3593                              <1> 			
  3594                              <1> 			dw	0103h ; 800x600x8
  3595                              <1> ModeAttributes3: 	dw	MODE_ATTRIBUTES
  3596                              <1> WinAAttributes3: 	db	WINA_ATTRIBUTES
  3597                              <1> WinBAttributes3: 	db	0
  3598                              <1> WinGranularity3: 	dw	VBE_DISPI_BANK_SIZE_KB
  3599                              <1> WinSize3: 		dw	VBE_DISPI_BANK_SIZE_KB
  3600                              <1> WinASegment3:		dw	VGAMEM_GRAPH
  3601                              <1> WinBSegment3:		dw	0000h
  3602                              <1> WinFuncPtr3:		dd	0
  3603                              <1> BytesPerScanLine3:	dw	800
  3604                              <1> XResolution3:		dw	800
  3605                              <1> YResolution3:		dw	600
  3606                              <1> XCharSize3:		db	8
  3607                              <1> YCharSize3:		db	16
  3608                              <1> NumberOfPlanes3:	db	1
  3609                              <1> BitsPerPixel3:		db	8
  3610                              <1> NumberOfBanks3:		db	8
  3611                              <1> MemoryModel3:		db	VBE_MEMORYMODEL_PACKED_PIXEL
  3612                              <1> BankSize3:		db	0
  3613                              <1> NumberOfImagePages3:	db	33
  3614                              <1> Reserved_page3:		db	0
  3615                              <1> RedMaskSize3:		db	0
  3616                              <1> RedFieldPosition3:	db	0
  3617                              <1> GreenMaskSize3:		db	0
  3618                              <1> GreenFieldPosition3:	db	0
  3619                              <1> BlueMaskSize3:		db	0
  3620                              <1> BlueFieldPosition3:	db	0
  3621                              <1> RsvdMaskSize3:		db	0
  3622                              <1> RsvdFieldPosition3:	db	0
  3623                              <1> DirectColorModeInfo3:	db	0
  3624                              <1> PhysBasePtr3:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  3625                              <1> OffScreenMemOffset3:	dd	0
  3626                              <1> OffScreenMemSize3:	dw	0
  3627                              <1> LinBytesPerScanLine3:	dw	800
  3628                              <1> BnkNumberOfPages3: 	db	0
  3629                              <1> LinNumberOfPages3: 	db	0
  3630                              <1> LinRedMaskSize3:	db	0
  3631                              <1> LinRedFieldPosition3: 	db	0
  3632                              <1> LinGreenMaskSize3: 	db	0
  3633                              <1> LinGreenFieldPosition: 	db	0
  3634                              <1> LinBlueMaskSize: 	db	0
  3635                              <1> LinBlueFieldPosition: 	db	0
  3636                              <1> LinRsvdMaskSize: 	db	0
  3637                              <1> LinRsvdFieldPosition: 	db	0
  3638                              <1> MaxPixelClock:		dd	0
  3639                              <1> 			
  3640                              <1> 			dw	0105h ; 1024x768x8
  3641                              <1> ModeAttributes4: 	dw	MODE_ATTRIBUTES
  3642                              <1> WinAAttributes4: 	db	WINA_ATTRIBUTES
  3643                              <1> WinBAttributes4: 	db	0
  3644                              <1> WinGranularity4: 	dw	VBE_DISPI_BANK_SIZE_KB
  3645                              <1> WinSize4: 		dw	VBE_DISPI_BANK_SIZE_KB
  3646                              <1> WinASegment4:		dw	VGAMEM_GRAPH
  3647                              <1> WinBSegment4:		dw	0000h
  3648                              <1> WinFuncPtr4:		dd	0
  3649                              <1> BytesPerScanLine4:	dw	1024
  3650                              <1> XResolution4:		dw	1024
  3651                              <1> YResolution4:		dw	768
  3652                              <1> XCharSize4:		db	8
  3653                              <1> YCharSize4:		db	16
  3654                              <1> NumberOfPlanes4:	db	1
  3655                              <1> BitsPerPixel4:		db	8
  3656                              <1> NumberOfBanks4:		db	12
  3657                              <1> MemoryModel4:		db	VBE_MEMORYMODEL_PACKED_PIXEL
  3658                              <1> BankSize4:		db	0
  3659                              <1> NumberOfImagePages4:	db	20
  3660                              <1> Reserved_page4:		db	0
  3661                              <1> RedMaskSize4:		db	0
  3662                              <1> RedFieldPosition4:	db	0
  3663                              <1> GreenMaskSize4:		db	0
  3664                              <1> GreenFieldPosition4:	db	0
  3665                              <1> BlueMaskSize4:		db	0
  3666                              <1> BlueFieldPosition4:	db	0
  3667                              <1> RsvdMaskSize4:		db	0
  3668                              <1> RsvdFieldPosition4:	db	0
  3669                              <1> DirectColorModeInfo4:	db	0
  3670                              <1> PhysBasePtr4:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  3671                              <1> OffScreenMemOffset4:	dd	0
  3672                              <1> OffScreenMemSize4:	dw	0
  3673                              <1> LinBytesPerScanLine4:	dw	1024
  3674                              <1> BnkNumberOfPages4: 	db	0
  3675                              <1> LinNumberOfPages4: 	db	0
  3676                              <1> LinRedMaskSize4:	db	0
  3677                              <1> LinRedFieldPosition4: 	db	0
  3678                              <1> LinGreenMaskSize4: 	db	0
  3679                              <1> LinGreenFieldPosition4: db	0
  3680                              <1> LinBlueMaskSize4: 	db	0
  3681                              <1> LinBlueFieldPosition4: 	db	0
  3682                              <1> LinRsvdMaskSize4: 	db	0
  3683                              <1> LinRsvdFieldPosition4: 	db	0
  3684                              <1> MaxPixelClock4:		dd	0
  3685                              <1> 
  3686                              <1> 			dw	010Eh ; 320x200x16
  3687                              <1> ModeAttributes5: 	dw	MODE_ATTRIBUTES
  3688                              <1> WinAAttributes5: 	db	WINA_ATTRIBUTES
  3689                              <1> WinBAttributes5: 	db	0
  3690                              <1> WinGranularity5: 	dw	VBE_DISPI_BANK_SIZE_KB
  3691                              <1> WinSize5: 		dw	VBE_DISPI_BANK_SIZE_KB
  3692                              <1> WinASegment5:		dw	VGAMEM_GRAPH
  3693                              <1> WinBSegment5:		dw	0000h
  3694                              <1> WinFuncPtr5:		dd	0
  3695                              <1> BytesPerScanLine5:	dw	640
  3696                              <1> XResolution5:		dw	320
  3697                              <1> YResolution5:		dw	200
  3698                              <1> XCharSize5:		db	8
  3699                              <1> YCharSize5:		db	16
  3700                              <1> NumberOfPlanes5:	db	1
  3701                              <1> BitsPerPixel5:		db	16
  3702                              <1> NumberOfBanks5:		db	2
  3703                              <1> MemoryModel5:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  3704                              <1> BankSize5:		db	0
  3705                              <1> NumberOfImagePages5:	db	130
  3706                              <1> Reserved_page5:		db	0
  3707                              <1> RedMaskSize5:		db	5
  3708                              <1> RedFieldPosition5:	db	11
  3709                              <1> GreenMaskSize5:		db	6
  3710                              <1> GreenFieldPosition5:	db	5
  3711                              <1> BlueMaskSize5:		db	5
  3712                              <1> BlueFieldPosition5:	db	0
  3713                              <1> RsvdMaskSize5:		db	0
  3714                              <1> RsvdFieldPosition5:	db	0
  3715                              <1> DirectColorModeInfo5:	db	0
  3716                              <1> PhysBasePtr5:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  3717                              <1> OffScreenMemOffset5:	dd	0
  3718                              <1> OffScreenMemSize5:	dw	0
  3719                              <1> LinBytesPerScanLine5:	dw	640
  3720                              <1> BnkNumberOfPages5: 	db	0
  3721                              <1> LinNumberOfPages5: 	db	0
  3722                              <1> LinRedMaskSize5:	db	5
  3723                              <1> LinRedFieldPosition5:	db	11
  3724                              <1> LinGreenMaskSize5:	db	6
  3725                              <1> LinGreenFieldPosition5:	db	5
  3726                              <1> LinBlueMaskSize5:	db	5
  3727                              <1> LinBlueFieldPosition5:	db	0
  3728                              <1> LinRsvdMaskSize5:	db	0
  3729                              <1> LinRsvdFieldPosition5:	db	0
  3730                              <1> MaxPixelClock5:		dd	0
  3731                              <1> 	
  3732                              <1> 			dw	010Fh ; 320x200x24
  3733                              <1> ModeAttributes6: 	dw	MODE_ATTRIBUTES
  3734                              <1> WinAAttributes6: 	db	WINA_ATTRIBUTES
  3735                              <1> WinBAttributes6: 	db	0
  3736                              <1> WinGranularity6: 	dw	VBE_DISPI_BANK_SIZE_KB
  3737                              <1> WinSize6: 		dw	VBE_DISPI_BANK_SIZE_KB
  3738                              <1> WinASegment6:		dw	VGAMEM_GRAPH
  3739                              <1> WinBSegment6:		dw	0000h
  3740                              <1> WinFuncPtr6:		dd	0
  3741                              <1> BytesPerScanLine6:	dw	960
  3742                              <1> XResolution6:		dw	320
  3743                              <1> YResolution6:		dw	200
  3744                              <1> XCharSize6:		db	8
  3745                              <1> YCharSize6:		db	16
  3746                              <1> NumberOfPlanes6:	db	1
  3747                              <1> BitsPerPixel6:		db	24
  3748                              <1> NumberOfBanks6:		db	3
  3749                              <1> MemoryModel6:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  3750                              <1> BankSize6:		db	0
  3751                              <1> NumberOfImagePages6:	db	86
  3752                              <1> Reserved_page6:		db	0
  3753                              <1> RedMaskSize6:		db	8
  3754                              <1> RedFieldPosition6:	db	16
  3755                              <1> GreenMaskSize6:		db	8
  3756                              <1> GreenFieldPosition6:	db	8
  3757                              <1> BlueMaskSize6:		db	8
  3758                              <1> BlueFieldPosition6:	db	0
  3759                              <1> RsvdMaskSize6:		db	0
  3760                              <1> RsvdFieldPosition6:	db	0
  3761                              <1> DirectColorModeInfo6:	db	0
  3762                              <1> PhysBasePtr6:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  3763                              <1> OffScreenMemOffset6:	dd	0
  3764                              <1> OffScreenMemSize6:	dw	0
  3765                              <1> LinBytesPerScanLine6:	dw	960
  3766                              <1> BnkNumberOfPages6: 	db	0
  3767                              <1> LinNumberOfPages6: 	db	0
  3768                              <1> LinRedMaskSize6:	db	8
  3769                              <1> LinRedFieldPosition6:	db	16
  3770                              <1> LinGreenMaskSize6:	db	8
  3771                              <1> LinGreenFieldPosition6:	db	8
  3772                              <1> LinBlueMaskSize6:	db	8
  3773                              <1> LinBlueFieldPosition6:	db	0
  3774                              <1> LinRsvdMaskSize6:	db	0
  3775                              <1> LinRsvdFieldPosition6:	db	0
  3776                              <1> MaxPixelClock6:		dd	0
  3777                              <1> 	
  3778                              <1> 			dw	0111h ; 640x480x16
  3779                              <1> ModeAttributes7: 	dw	MODE_ATTRIBUTES
  3780                              <1> WinAAttributes7: 	db	WINA_ATTRIBUTES
  3781                              <1> WinBAttributes7: 	db	0
  3782                              <1> WinGranularity7: 	dw	VBE_DISPI_BANK_SIZE_KB
  3783                              <1> WinSize7: 		dw	VBE_DISPI_BANK_SIZE_KB
  3784                              <1> WinASegment7:		dw	VGAMEM_GRAPH
  3785                              <1> WinBSegment7:		dw	0000h
  3786                              <1> WinFuncPtr7:		dd	0
  3787                              <1> BytesPerScanLine7:	dw	1280
  3788                              <1> XResolution7:		dw	640
  3789                              <1> YResolution7:		dw	480
  3790                              <1> XCharSize7:		db	8
  3791                              <1> YCharSize7:		db	16
  3792                              <1> NumberOfPlanes7:	db	1
  3793                              <1> BitsPerPixel7:		db	16
  3794                              <1> NumberOfBanks7:		db	10
  3795                              <1> MemoryModel7:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  3796                              <1> BankSize7:		db	0
  3797                              <1> NumberOfImagePages7:	db	26
  3798                              <1> Reserved_page7:		db	0
  3799                              <1> RedMaskSize7:		db	5
  3800                              <1> RedFieldPosition7:	db	11
  3801                              <1> GreenMaskSize7:		db	6
  3802                              <1> GreenFieldPosition7:	db	5
  3803                              <1> BlueMaskSize7:		db	5
  3804                              <1> BlueFieldPosition7:	db	0
  3805                              <1> RsvdMaskSize7:		db	0
  3806                              <1> RsvdFieldPosition7:	db	0
  3807                              <1> DirectColorModeInfo7:	db	0
  3808                              <1> PhysBasePtr7:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS,
  3809                              <1> OffScreenMemOffset7:	dd	0
  3810                              <1> OffScreenMemSize7:	dw	0
  3811                              <1> LinBytesPerScanLine7:	dw	1280
  3812                              <1> BnkNumberOfPages7: 	db	0
  3813                              <1> LinNumberOfPages7: 	db	0
  3814                              <1> LinRedMaskSize7:	db	5
  3815                              <1> LinRedFieldPosition7:	db	11
  3816                              <1> LinGreenMaskSize7:	db	6
  3817                              <1> LinGreenFieldPosition7:	db	5
  3818                              <1> LinBlueMaskSize7:	db	5
  3819                              <1> LinBlueFieldPosition7:	db	0
  3820                              <1> LinRsvdMaskSize7:	db	0
  3821                              <1> LinRsvdFieldPosition7:	db	0
  3822                              <1> MaxPixelClock7:		dd	0
  3823                              <1> 
  3824                              <1> 			dw	0112h ; 640x480x24
  3825                              <1> ModeAttributes8: 	dw	MODE_ATTRIBUTES
  3826                              <1> WinAAttributes8: 	db	WINA_ATTRIBUTES
  3827                              <1> WinBAttributes8: 	db	0
  3828                              <1> WinGranularity8: 	dw	VBE_DISPI_BANK_SIZE_KB
  3829                              <1> WinSize8: 		dw	VBE_DISPI_BANK_SIZE_KB
  3830                              <1> WinASegment8:		dw	VGAMEM_GRAPH
  3831                              <1> WinBSegment8:		dw	0000h
  3832                              <1> WinFuncPtr8:		dd	0
  3833                              <1> BytesPerScanLine8:	dw	1920
  3834                              <1> XResolution8:		dw	640
  3835                              <1> YResolution8:		dw	480
  3836                              <1> XCharSize8:		db	8
  3837                              <1> YCharSize8:		db	16
  3838                              <1> NumberOfPlanes8:	db	1
  3839                              <1> BitsPerPixel8:		db	24
  3840                              <1> NumberOfBanks8:		db	15
  3841                              <1> MemoryModel8:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  3842                              <1> BankSize8:		db	0
  3843                              <1> NumberOfImagePages8:	db	17
  3844                              <1> Reserved_page8:		db	0
  3845                              <1> RedMaskSize8:		db	8
  3846                              <1> RedFieldPosition8:	db	16
  3847                              <1> GreenMaskSize8:		db	8
  3848                              <1> GreenFieldPosition8:	db	8
  3849                              <1> BlueMaskSize8:		db	8
  3850                              <1> BlueFieldPosition8:	db	0
  3851                              <1> RsvdMaskSize8:		db	0
  3852                              <1> RsvdFieldPosition8:	db	0
  3853                              <1> DirectColorModeInfo8:	db	0
  3854                              <1> PhysBasePtr8:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  3855                              <1> OffScreenMemOffset8:	dd	0
  3856                              <1> OffScreenMemSize8:	dw	0
  3857                              <1> LinBytesPerScanLine8:	dw	1920
  3858                              <1> BnkNumberOfPages8: 	db	0
  3859                              <1> LinNumberOfPages8: 	db	0
  3860                              <1> LinRedMaskSize8:	db	8
  3861                              <1> LinRedFieldPosition8:	db	16
  3862                              <1> LinGreenMaskSize8:	db	8
  3863                              <1> LinGreenFieldPosition8:	db	8
  3864                              <1> LinBlueMaskSize8:	db	8
  3865                              <1> LinBlueFieldPosition8:	db	0
  3866                              <1> LinRsvdMaskSize8:	db	0
  3867                              <1> LinRsvdFieldPosition8:	db	0
  3868                              <1> MaxPixelClock8:		dd	0
  3869                              <1> 
  3870                              <1> 			dw	0114h ; 800x600x16
  3871                              <1> ModeAttributes9: 	dw	MODE_ATTRIBUTES
  3872                              <1> WinAAttributes9: 	db	WINA_ATTRIBUTES
  3873                              <1> WinBAttributes9: 	db	0
  3874                              <1> WinGranularity9: 	dw	VBE_DISPI_BANK_SIZE_KB
  3875                              <1> WinSize9: 		dw	VBE_DISPI_BANK_SIZE_KB
  3876                              <1> WinASegment9:		dw	VGAMEM_GRAPH
  3877                              <1> WinBSegment9:		dw	0000h
  3878                              <1> WinFuncPtr9:		dd	0
  3879                              <1> BytesPerScanLine9:	dw	1600
  3880                              <1> XResolution9:		dw	800
  3881                              <1> YResolution9:		dw	600
  3882                              <1> XCharSize9:		db	8
  3883                              <1> YCharSize9:		db	16
  3884                              <1> NumberOfPlanes9:	db	1
  3885                              <1> BitsPerPixel9:		db	16
  3886                              <1> NumberOfBanks9:		db	15
  3887                              <1> MemoryModel9:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  3888                              <1> BankSize9:		db	0
  3889                              <1> NumberOfImagePages9:	db	16
  3890                              <1> Reserved_page9:		db	0
  3891                              <1> RedMaskSize9:		db	5
  3892                              <1> RedFieldPosition9:	db	11
  3893                              <1> GreenMaskSize9:		db	6
  3894                              <1> GreenFieldPosition9:	db	5
  3895                              <1> BlueMaskSize9:		db	5
  3896                              <1> BlueFieldPosition9:	db	0
  3897                              <1> RsvdMaskSize9:		db	0
  3898                              <1> RsvdFieldPosition9:	db	0
  3899                              <1> DirectColorModeInfo9:	db	0
  3900                              <1> PhysBasePtr9:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  3901                              <1> OffScreenMemOffset9:	dd	0
  3902                              <1> OffScreenMemSize9:	dw	0
  3903                              <1> LinBytesPerScanLine9:	dw	1600
  3904                              <1> BnkNumberOfPages9: 	db	0
  3905                              <1> LinNumberOfPages9: 	db	0
  3906                              <1> LinRedMaskSize9:	db	5
  3907                              <1> LinRedFieldPosition9:	db	11
  3908                              <1> LinGreenMaskSize9:	db	6
  3909                              <1> LinGreenFieldPosition9:	db	5
  3910                              <1> LinBlueMaskSize9:	db	5
  3911                              <1> LinBlueFieldPosition9:	db	0
  3912                              <1> LinRsvdMaskSize9:	db	0
  3913                              <1> LinRsvdFieldPosition9:	db	0
  3914                              <1> MaxPixelClock9:		dd	0
  3915                              <1> 	
  3916                              <1> 			dw	0115h ; 800x600x24
  3917                              <1> ModeAttributes10: 	dw	MODE_ATTRIBUTES
  3918                              <1> WinAAttributes10: 	db	WINA_ATTRIBUTES
  3919                              <1> WinBAttributes10: 	db	0
  3920                              <1> WinGranularity10: 	dw	VBE_DISPI_BANK_SIZE_KB
  3921                              <1> WinSize10: 		dw	VBE_DISPI_BANK_SIZE_KB
  3922                              <1> WinASegment10:		dw	VGAMEM_GRAPH
  3923                              <1> WinBSegment10:		dw	0000h
  3924                              <1> WinFuncPtr10:		dd	0
  3925                              <1> BytesPerScanLine10:	dw	2400
  3926                              <1> XResolution10:		dw	800
  3927                              <1> YResolution10:		dw	600
  3928                              <1> XCharSize10:		db	8
  3929                              <1> YCharSize10:		db	16
  3930                              <1> NumberOfPlanes10:	db	1
  3931                              <1> BitsPerPixel10:		db	24
  3932                              <1> NumberOfBanks10:	db	22
  3933                              <1> MemoryModel10:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  3934                              <1> BankSize10:		db	0
  3935                              <1> NumberOfImagePages10:	db	10
  3936                              <1> Reserved_page10:	db	0
  3937                              <1> RedMaskSize10:		db	8
  3938                              <1> RedFieldPosition10:	db	16
  3939                              <1> GreenMaskSize10:	db	8
  3940                              <1> GreenFieldPosition10:	db	8
  3941                              <1> BlueMaskSize10:		db	8
  3942                              <1> BlueFieldPosition10:	db	0
  3943                              <1> RsvdMaskSize10:		db	0
  3944                              <1> RsvdFieldPosition10:	db	0
  3945                              <1> DirectColorModeInfo10:	db	0
  3946                              <1> PhysBasePtr10:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  3947                              <1> OffScreenMemOffset10:	dd	0
  3948                              <1> OffScreenMemSize10:	dw	0
  3949                              <1> LinBytesPerScanLine10:	dw	2400
  3950                              <1> BnkNumberOfPages10: 	db	0
  3951                              <1> LinNumberOfPages10: 	db	0
  3952                              <1> LinRedMaskSize10:	db	8
  3953                              <1> LinRedFieldPosition10:	db	16
  3954                              <1> LinGreenMaskSize10:	db	8
  3955                              <1> LinGreenFieldPosition10:db	8
  3956                              <1> LinBlueMaskSize10:	db	8
  3957                              <1> LinBlueFieldPosition10:	db	0
  3958                              <1> LinRsvdMaskSize10:	db	0
  3959                              <1> LinRsvdFieldPosition10:	db	0
  3960                              <1> MaxPixelClock10:	dd	0
  3961                              <1> 
  3962                              <1> 			dw	0117h ; 1024x768x16
  3963                              <1> ModeAttributes11: 	dw	MODE_ATTRIBUTES
  3964                              <1> WinAAttributes11: 	db	WINA_ATTRIBUTES
  3965                              <1> WinBAttributes11: 	db	0
  3966                              <1> WinGranularity11: 	dw	VBE_DISPI_BANK_SIZE_KB
  3967                              <1> WinSize11: 		dw	VBE_DISPI_BANK_SIZE_KB
  3968                              <1> WinASegment11:		dw	VGAMEM_GRAPH
  3969                              <1> WinBSegment11:		dw	0000h
  3970                              <1> WinFuncPtr11:		dd	0
  3971                              <1> BytesPerScanLine11:	dw	2048
  3972                              <1> XResolution11:		dw	1024
  3973                              <1> YResolution11:		dw	768
  3974                              <1> XCharSize11:		db	8
  3975                              <1> YCharSize11:		db	16
  3976                              <1> NumberOfPlanes11:	db	1
  3977                              <1> BitsPerPixel11:		db	16
  3978                              <1> NumberOfBanks11:	db	24
  3979                              <1> MemoryModel11:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  3980                              <1> BankSize11:		db	0
  3981                              <1> NumberOfImagePages11:	db	9
  3982                              <1> Reserved_page11:	db	0
  3983                              <1> RedMaskSize11:		db	5
  3984                              <1> RedFieldPosition11:	db	11
  3985                              <1> GreenMaskSize11:	db	6
  3986                              <1> GreenFieldPosition11:	db	5
  3987                              <1> BlueMaskSize11:		db	5
  3988                              <1> BlueFieldPosition11:	db	0
  3989                              <1> RsvdMaskSize11:		db	0
  3990                              <1> RsvdFieldPosition11:	db	0
  3991                              <1> DirectColorModeInfo11:	db	0
  3992                              <1> PhysBasePtr11:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS,
  3993                              <1> OffScreenMemOffset11:	dd	0
  3994                              <1> OffScreenMemSize11:	dw	0
  3995                              <1> LinBytesPerScanLine11:	dw	2048
  3996                              <1> BnkNumberOfPages11: 	db	0
  3997                              <1> LinNumberOfPages11: 	db	0
  3998                              <1> LinRedMaskSize11:	db	5
  3999                              <1> LinRedFieldPosition11:	db	11
  4000                              <1> LinGreenMaskSize11:	db	6
  4001                              <1> LinGreenFieldPosition11:db	5
  4002                              <1> LinBlueMaskSize11:	db	5
  4003                              <1> LinBlueFieldPosition11:	db	0
  4004                              <1> LinRsvdMaskSize11:	db	0
  4005                              <1> LinRsvdFieldPosition11:	db	0
  4006                              <1> MaxPixelClock11:	dd	0
  4007                              <1> 
  4008                              <1> 			dw	0118h ; 1024x768x24
  4009                              <1> ModeAttributes12: 	dw	MODE_ATTRIBUTES
  4010                              <1> WinAAttributes12: 	db	WINA_ATTRIBUTES
  4011                              <1> WinBAttributes12: 	db	0
  4012                              <1> WinGranularity12: 	dw	VBE_DISPI_BANK_SIZE_KB
  4013                              <1> WinSize12: 		dw	VBE_DISPI_BANK_SIZE_KB
  4014                              <1> WinASegment12:		dw	VGAMEM_GRAPH
  4015                              <1> WinBSegment12:		dw	0000h
  4016                              <1> WinFuncPtr12:		dd	0
  4017                              <1> BytesPerScanLine12:	dw	3072
  4018                              <1> XResolution12:		dw	1024
  4019                              <1> YResolution12:		dw	768
  4020                              <1> XCharSize12:		db	8
  4021                              <1> YCharSize12:		db	16
  4022                              <1> NumberOfPlanes12:	db	1
  4023                              <1> BitsPerPixel12:		db	24
  4024                              <1> NumberOfBanks12:	db	36
  4025                              <1> MemoryModel12:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  4026                              <1> BankSize12:		db	0
  4027                              <1> NumberOfImagePages12:	db	6
  4028                              <1> Reserved_page12:	db	0
  4029                              <1> RedMaskSize12:		db	8
  4030                              <1> RedFieldPosition12:	db	16
  4031                              <1> GreenMaskSize12:	db	8
  4032                              <1> GreenFieldPosition12:	db	8
  4033                              <1> BlueMaskSize12:		db	8
  4034                              <1> BlueFieldPosition12:	db	0
  4035                              <1> RsvdMaskSize12:		db	0
  4036                              <1> RsvdFieldPosition12:	db	0
  4037                              <1> DirectColorModeInfo12:	db	0
  4038                              <1> PhysBasePtr12:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  4039                              <1> OffScreenMemOffset12:	dd	0
  4040                              <1> OffScreenMemSize12:	dw	0
  4041                              <1> LinBytesPerScanLine12:	dw	3072
  4042                              <1> BnkNumberOfPages12: 	db	0
  4043                              <1> LinNumberOfPages12: 	db	0
  4044                              <1> LinRedMaskSize12:	db	8
  4045                              <1> LinRedFieldPosition12:	db	16
  4046                              <1> LinGreenMaskSize12:	db	8
  4047                              <1> LinGreenFieldPosition12:db	8
  4048                              <1> LinBlueMaskSize12:	db	8
  4049                              <1> LinBlueFieldPosition12:	db	0
  4050                              <1> LinRsvdMaskSize12:	db	0
  4051                              <1> LinRsvdFieldPosition12:	db	0
  4052                              <1> MaxPixelClock12:	dd	0
  4053                              <1> 
  4054                              <1> 			dw	0140h ; 320x200x32
  4055                              <1> ModeAttributes13: 	dw	MODE_ATTRIBUTES
  4056                              <1> WinAAttributes13: 	db	WINA_ATTRIBUTES
  4057                              <1> WinBAttributes13: 	db	0
  4058                              <1> WinGranularity13: 	dw	VBE_DISPI_BANK_SIZE_KB
  4059                              <1> WinSize13: 		dw	VBE_DISPI_BANK_SIZE_KB
  4060                              <1> WinASegment13:		dw	VGAMEM_GRAPH
  4061                              <1> WinBSegment13:		dw	0000h
  4062                              <1> WinFuncPtr13:		dd	0
  4063                              <1> BytesPerScanLine13:	dw	1280
  4064                              <1> XResolution13:		dw	320
  4065                              <1> YResolution13:		dw	200
  4066                              <1> XCharSize13:		db	8
  4067                              <1> YCharSize13:		db	16
  4068                              <1> NumberOfPlanes13:	db	1
  4069                              <1> BitsPerPixel13:		db	32
  4070                              <1> NumberOfBanks13:	db	4
  4071                              <1> MemoryModel13:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  4072                              <1> BankSize13:		db	0
  4073                              <1> NumberOfImagePages13:	db	64
  4074                              <1> Reserved_page13:	db	0
  4075                              <1> RedMaskSize13:		db	8
  4076                              <1> RedFieldPosition13:	db	16
  4077                              <1> GreenMaskSize13:	db	8
  4078                              <1> GreenFieldPosition13:	db	8
  4079                              <1> BlueMaskSize13:		db	8
  4080                              <1> BlueFieldPosition13:	db	0
  4081                              <1> RsvdMaskSize13:		db	8
  4082                              <1> RsvdFieldPosition13:	db	24
  4083                              <1> DirectColorModeInfo13:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
  4084                              <1> PhysBasePtr13:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  4085                              <1> OffScreenMemOffset13:	dd	0
  4086                              <1> OffScreenMemSize13:	dw	0
  4087                              <1> LinBytesPerScanLine13:	dw	1280
  4088                              <1> BnkNumberOfPages13: 	db	0
  4089                              <1> LinNumberOfPages13: 	db	0
  4090                              <1> LinRedMaskSize13:	db	8
  4091                              <1> LinRedFieldPosition13:	db	16
  4092                              <1> LinGreenMaskSize13:	db	8
  4093                              <1> LinGreenFieldPosition13:db	8
  4094                              <1> LinBlueMaskSize13:	db	8
  4095                              <1> LinBlueFieldPosition13:	db	0
  4096                              <1> LinRsvdMaskSize13:	db	8
  4097                              <1> LinRsvdFieldPosition13:	db	24
  4098                              <1> MaxPixelClock13:	dd	0
  4099                              <1> 
  4100                              <1> 			dw	0141h ; 640x400x32
  4101                              <1> ModeAttributes14: 	dw	MODE_ATTRIBUTES
  4102                              <1> WinAAttributes14: 	db	WINA_ATTRIBUTES
  4103                              <1> WinBAttributes14: 	db	0
  4104                              <1> WinGranularity14: 	dw	VBE_DISPI_BANK_SIZE_KB
  4105                              <1> WinSize14: 		dw	VBE_DISPI_BANK_SIZE_KB
  4106                              <1> WinASegment14:		dw	VGAMEM_GRAPH
  4107                              <1> WinBSegment14:		dw	0000h
  4108                              <1> WinFuncPtr14:		dd	0
  4109                              <1> BytesPerScanLine14:	dw	2560
  4110                              <1> XResolution14:		dw	640
  4111                              <1> YResolution14:		dw	400
  4112                              <1> XCharSize14:		db	8
  4113                              <1> YCharSize14:		db	16
  4114                              <1> NumberOfPlanes14:	db	1
  4115                              <1> BitsPerPixel14:		db	32
  4116                              <1> NumberOfBanks14:	db	16
  4117                              <1> MemoryModel14:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  4118                              <1> BankSize14:		db	0
  4119                              <1> NumberOfImagePages14:	db	15
  4120                              <1> Reserved_page14:	db	0
  4121                              <1> RedMaskSize14:		db	8
  4122                              <1> RedFieldPosition14:	db	16
  4123                              <1> GreenMaskSize14:	db	8
  4124                              <1> GreenFieldPosition14:	db	8
  4125                              <1> BlueMaskSize14:		db	8
  4126                              <1> BlueFieldPosition14:	db	0
  4127                              <1> RsvdMaskSize14:		db	8
  4128                              <1> RsvdFieldPosition14:	db	24
  4129                              <1> DirectColorModeInfo14:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
  4130                              <1> PhysBasePtr14:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  4131                              <1> OffScreenMemOffset14:	dd  	0
  4132                              <1> OffScreenMemSize14:	dw	0
  4133                              <1> LinBytesPerScanLine14:	dw	2560
  4134                              <1> BnkNumberOfPages14: 	db	0
  4135                              <1> LinNumberOfPages14: 	db	0
  4136                              <1> LinRedMaskSize14:	db	8
  4137                              <1> LinRedFieldPosition14:	db	16
  4138                              <1> LinGreenMaskSize14:	db	8
  4139                              <1> LinGreenFieldPosition14:db	8
  4140                              <1> LinBlueMaskSize14:	db	8
  4141                              <1> LinBlueFieldPosition14:	db	0
  4142                              <1> LinRsvdMaskSize14:	db	8
  4143                              <1> LinRsvdFieldPosition14:	db	24
  4144                              <1> MaxPixelClock14:	dd	0
  4145                              <1> 
  4146                              <1> 			dw	0142 ; 640x480x32
  4147                              <1> ModeAttributes15: 	dw	MODE_ATTRIBUTES
  4148                              <1> WinAAttributes15: 	db	WINA_ATTRIBUTES
  4149                              <1> WinBAttributes15: 	db	0
  4150                              <1> WinGranularity15: 	dw	VBE_DISPI_BANK_SIZE_KB
  4151                              <1> WinSize15: 		dw	VBE_DISPI_BANK_SIZE_KB
  4152                              <1> WinASegment15:		dw	VGAMEM_GRAPH
  4153                              <1> WinBSegment15:		dw	0000h
  4154                              <1> WinFuncPtr15:		dd	0
  4155                              <1> BytesPerScanLine15:	dw	2560
  4156                              <1> XResolution15:		dw	640
  4157                              <1> YResolution15:		dw	480
  4158                              <1> XCharSize15:		db	8
  4159                              <1> YCharSize15:		db	16
  4160                              <1> NumberOfPlanes15:	db	1
  4161                              <1> BitsPerPixel15:		db	32
  4162                              <1> NumberOfBanks15:	db	19
  4163                              <1> MemoryModel15:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  4164                              <1> BankSize15:		db	0
  4165                              <1> NumberOfImagePages15:	db	12
  4166                              <1> Reserved_page15:	db	0
  4167                              <1> RedMaskSize15:		db	8
  4168                              <1> RedFieldPosition15:	db	16
  4169                              <1> GreenMaskSize15:	db	8
  4170                              <1> GreenFieldPosition15:	db	8
  4171                              <1> BlueMaskSize15:		db	8
  4172                              <1> BlueFieldPosition15:	db	0
  4173                              <1> RsvdMaskSize15:		db	8
  4174                              <1> RsvdFieldPosition15:	db	24
  4175                              <1> DirectColorModeInfo15:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE,
  4176                              <1> PhysBasePtr15:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS,
  4177                              <1> OffScreenMemOffset15:	dd	0
  4178                              <1> OffScreenMemSize15:	dw	0
  4179                              <1> LinBytesPerScanLine15:	dw	2560
  4180                              <1> BnkNumberOfPages15: 	db	0
  4181                              <1> LinNumberOfPages15: 	db	0
  4182                              <1> LinRedMaskSize15:	db	8
  4183                              <1> LinRedFieldPosition15:	db	16
  4184                              <1> LinGreenMaskSize15:	db	8
  4185                              <1> LinGreenFieldPosition15:db	8
  4186                              <1> LinBlueMaskSize15:	db	8
  4187                              <1> LinBlueFieldPosition15:	db	0
  4188                              <1> LinRsvdMaskSize15:	db	8
  4189                              <1> LinRsvdFieldPosition15:	db	24
  4190                              <1> MaxPixelClock15:	dd	0
  4191                              <1> 
  4192                              <1> 			dw	0143h ; 800x600x32
  4193                              <1> ModeAttributes16: 	dw	MODE_ATTRIBUTES
  4194                              <1> WinAAttributes16: 	db	WINA_ATTRIBUTES
  4195                              <1> WinBAttributes16: 	db	0
  4196                              <1> WinGranularity16: 	dw	VBE_DISPI_BANK_SIZE_KB
  4197                              <1> WinSize16: 		dw	VBE_DISPI_BANK_SIZE_KB
  4198                              <1> WinASegment16:		dw	VGAMEM_GRAPH
  4199                              <1> WinBSegment16:		dw	0000h
  4200                              <1> WinFuncPtr16:		dd	0
  4201                              <1> BytesPerScanLine16:	dw	3200
  4202                              <1> XResolution16:		dw	800
  4203                              <1> YResolution16:		dw	600
  4204                              <1> XCharSize16:		db	8
  4205                              <1> YCharSize16:		db	16
  4206                              <1> NumberOfPlanes16:	db	1
  4207                              <1> BitsPerPixel16:		db	32
  4208                              <1> NumberOfBanks16:	db	30
  4209                              <1> MemoryModel16:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  4210                              <1> BankSize16:		db	0
  4211                              <1> NumberOfImagePages16:	db	7
  4212                              <1> Reserved_page16:	db	0
  4213                              <1> RedMaskSize16:		db	8
  4214                              <1> RedFieldPosition16:	db	16
  4215                              <1> GreenMaskSize16:	db	8
  4216                              <1> GreenFieldPosition16:	db	8
  4217                              <1> BlueMaskSize16:		db	8
  4218                              <1> BlueFieldPosition16:	db	0
  4219                              <1> RsvdMaskSize16:		db	8
  4220                              <1> RsvdFieldPosition16:	db	24
  4221                              <1> DirectColorModeInfo16:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE,
  4222                              <1> PhysBasePtr16:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS,
  4223                              <1> OffScreenMemOffset16:	dd	0
  4224                              <1> OffScreenMemSize16:	dw	0
  4225                              <1> LinBytesPerScanLine16:	dw	3200
  4226                              <1> BnkNumberOfPages16: 	db	0
  4227                              <1> LinNumberOfPages16: 	db	0
  4228                              <1> LinRedMaskSize16:	db	8
  4229                              <1> LinRedFieldPosition16:	db	16
  4230                              <1> LinGreenMaskSize16:	db	8
  4231                              <1> LinGreenFieldPosition16:db	8
  4232                              <1> LinBlueMaskSize16:	db	8
  4233                              <1> LinBlueFieldPosition16:	db	0
  4234                              <1> LinRsvdMaskSize16:	db	8
  4235                              <1> LinRsvdFieldPosition16:	db	24
  4236                              <1> MaxPixelClock16:	dd	0
  4237                              <1> 	
  4238                              <1> 			dw	0144h ; 1024x768x32
  4239                              <1> ModeAttributes17: 	dw	MODE_ATTRIBUTES
  4240                              <1> WinAAttributes17: 	db	WINA_ATTRIBUTES
  4241                              <1> WinBAttributes17: 	db	0
  4242                              <1> WinGranularity17: 	dw	VBE_DISPI_BANK_SIZE_KB
  4243                              <1> WinSize17: 		dw	VBE_DISPI_BANK_SIZE_KB
  4244                              <1> WinASegment17:		dw	VGAMEM_GRAPH
  4245                              <1> WinBSegment17:		dw	0000h
  4246                              <1> WinFuncPtr17:		dd	0
  4247                              <1> BytesPerScanLine17:	dw	4096
  4248                              <1> XResolution17:		dw	1024
  4249                              <1> YResolution17:		dw	768
  4250                              <1> XCharSize17:		db	8
  4251                              <1> YCharSize17:		db	16
  4252                              <1> NumberOfPlanes17:	db	1
  4253                              <1> BitsPerPixel17:		db	32
  4254                              <1> NumberOfBanks17:	db	48
  4255                              <1> MemoryModel17:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  4256                              <1> BankSize17:		db	0
  4257                              <1> NumberOfImagePages17:	db	4
  4258                              <1> Reserved_page17:	db	0
  4259                              <1> RedMaskSize17:		db	8
  4260                              <1> RedFieldPosition17:	db	16
  4261                              <1> GreenMaskSize17:	db	8
  4262                              <1> GreenFieldPosition17:	db	8
  4263                              <1> BlueMaskSize17:		db	8
  4264                              <1> BlueFieldPosition17:	db	0
  4265                              <1> RsvdMaskSize17:		db	8
  4266                              <1> RsvdFieldPosition17:	db	24
  4267                              <1> DirectColorModeInfo17:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
  4268                              <1> PhysBasePtr17:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  4269                              <1> OffScreenMemOffset17:	dd	0
  4270                              <1> OffScreenMemSize17:	dw	0
  4271                              <1> LinBytesPerScanLine17:	dw	4096
  4272                              <1> BnkNumberOfPages17: 	db	0
  4273                              <1> LinNumberOfPages17: 	db	0
  4274                              <1> LinRedMaskSize17:	db	8
  4275                              <1> LinRedFieldPosition17:	db	16
  4276                              <1> LinGreenMaskSize17:	db	8
  4277                              <1> LinGreenFieldPosition17:db	8
  4278                              <1> LinBlueMaskSize17:	db	8
  4279                              <1> LinBlueFieldPosition17:	db	0
  4280                              <1> LinRsvdMaskSize17:	db	8
  4281                              <1> LinRsvdFieldPosition17:	db	24
  4282                              <1> MaxPixelClock17:	dd	0
  4283                              <1> 	
  4284                              <1> 			dw	0146h ; 320x200x8
  4285                              <1> ModeAttributes18: 	dw	MODE_ATTRIBUTES
  4286                              <1> WinAAttributes18: 	db	WINA_ATTRIBUTES
  4287                              <1> WinBAttributes18: 	db	0
  4288                              <1> WinGranularity18: 	dw	VBE_DISPI_BANK_SIZE_KB
  4289                              <1> WinSize18: 		dw	VBE_DISPI_BANK_SIZE_KB
  4290                              <1> WinASegment18:		dw	VGAMEM_GRAPH
  4291                              <1> WinBSegment18:		dw	0000h
  4292                              <1> WinFuncPtr18:		dd	0
  4293                              <1> BytesPerScanLine18:	dw	320
  4294                              <1> XResolution18:		dw	320
  4295                              <1> YResolution18:		dw	200
  4296                              <1> XCharSize18:		db	8
  4297                              <1> YCharSize18:		db	16
  4298                              <1> NumberOfPlanes18:	db	1
  4299                              <1> BitsPerPixel18:		db	8
  4300                              <1> NumberOfBanks18:	db	1
  4301                              <1> MemoryModel18:		db	VBE_MEMORYMODEL_PACKED_PIXEL
  4302                              <1> BankSize18:		db	0
  4303                              <1> NumberOfImagePages18:	db	255 ; 261 in vbetables.h (03/01/2020) !
  4304                              <1> Reserved_page18:	db	0
  4305                              <1> RedMaskSize18:		db	0
  4306                              <1> RedFieldPosition18:	db	0
  4307                              <1> GreenMaskSize18:	db	0
  4308                              <1> GreenFieldPosition18:	db	0
  4309                              <1> BlueMaskSize18:		db	0
  4310                              <1> BlueFieldPosition18:	db	0
  4311                              <1> RsvdMaskSize18:		db	0
  4312                              <1> RsvdFieldPosition18:	db	0
  4313                              <1> DirectColorModeInfo18:	db	0
  4314                              <1> PhysBasePtr18:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  4315                              <1> OffScreenMemOffset18:	dd	0
  4316                              <1> OffScreenMemSize18:	dw	0
  4317                              <1> LinBytesPerScanLine18:	dw	320
  4318                              <1> BnkNumberOfPages18: 	db	0
  4319                              <1> LinNumberOfPages18: 	db	0
  4320                              <1> LinRedMaskSize18:	db	0
  4321                              <1> LinRedFieldPosition18: 	db	0
  4322                              <1> LinGreenMaskSize18: 	db	0
  4323                              <1> LinGreenFieldPosition18:db	0
  4324                              <1> LinBlueMaskSize18: 	db	0
  4325                              <1> LinBlueFieldPosition18: db	0
  4326                              <1> LinRsvdMaskSize18: 	db	0
  4327                              <1> LinRsvdFieldPosition18: db	0
  4328                              <1> MaxPixelClock18:	dd	0
  4329                              <1> 
  4330                              <1> 			dw	018Dh ; 1280x720x16
  4331                              <1> ModeAttributes19: 	dw	MODE_ATTRIBUTES
  4332                              <1> WinAAttributes19: 	db	WINA_ATTRIBUTES
  4333                              <1> WinBAttributes19: 	db	0
  4334                              <1> WinGranularity19: 	dw	VBE_DISPI_BANK_SIZE_KB
  4335                              <1> WinSize19: 		dw	VBE_DISPI_BANK_SIZE_KB
  4336                              <1> WinASegment19:		dw	VGAMEM_GRAPH
  4337                              <1> WinBSegment19:		dw	0000h
  4338                              <1> WinFuncPtr19:		dd	0
  4339                              <1> BytesPerScanLine19:	dw	2560
  4340                              <1> XResolution19:		dw	1280
  4341                              <1> YResolution19:		dw	720
  4342                              <1> XCharSize19:		db	8
  4343                              <1> YCharSize19:		db	16
  4344                              <1> NumberOfPlanes19:	db	1
  4345                              <1> BitsPerPixel19:		db	16
  4346                              <1> NumberOfBanks19:	db	29
  4347                              <1> MemoryModel19:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  4348                              <1> BankSize19:		db	0
  4349                              <1> NumberOfImagePages19:	db	8
  4350                              <1> Reserved_page19:	db	0
  4351                              <1> RedMaskSize19:		db	5
  4352                              <1> RedFieldPosition19:	db	11
  4353                              <1> GreenMaskSize19:	db	6
  4354                              <1> GreenFieldPosition19:	db	5
  4355                              <1> BlueMaskSize19:		db	5
  4356                              <1> BlueFieldPosition19:	db	0
  4357                              <1> RsvdMaskSize19:		db	0
  4358                              <1> RsvdFieldPosition19:	db	0
  4359                              <1> DirectColorModeInfo19:	db	0
  4360                              <1> PhysBasePtr19:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  4361                              <1> OffScreenMemOffset19:	dd	0
  4362                              <1> OffScreenMemSize19:	dw	0
  4363                              <1> LinBytesPerScanLine19:	dw	2560
  4364                              <1> BnkNumberOfPages19: 	db	0
  4365                              <1> LinNumberOfPages19: 	db	0
  4366                              <1> LinRedMaskSize19:	db	5
  4367                              <1> LinRedFieldPosition19:	db	11
  4368                              <1> LinGreenMaskSize19:	db	6
  4369                              <1> LinGreenFieldPosition19:db	5
  4370                              <1> LinBlueMaskSize19:	db	5
  4371                              <1> LinBlueFieldPosition19:	db	0
  4372                              <1> LinRsvdMaskSize19:	db	0
  4373                              <1> LinRsvdFieldPosition19:	db	0
  4374                              <1> MaxPixelClock19:	dd	0
  4375                              <1> 
  4376                              <1> 			dw	018Eh ; 1280x720x24
  4377                              <1> ModeAttributes20: 	dw	MODE_ATTRIBUTES
  4378                              <1> WinAAttributes20: 	db	WINA_ATTRIBUTES
  4379                              <1> WinBAttributes20: 	db	0
  4380                              <1> WinGranularity20: 	dw	VBE_DISPI_BANK_SIZE_KB
  4381                              <1> WinSize20: 		dw	VBE_DISPI_BANK_SIZE_KB
  4382                              <1> WinASegment20:		dw	VGAMEM_GRAPH
  4383                              <1> WinBSegment20:		dw	0000h
  4384                              <1> WinFuncPtr20:		dd	0
  4385                              <1> BytesPerScanLine20:	dw	3840
  4386                              <1> XResolution20:		dw	1280
  4387                              <1> YResolution20:		dw	720
  4388                              <1> XCharSize20:		db	8
  4389                              <1> YCharSize20:		db	16
  4390                              <1> NumberOfPlanes20:	db	1
  4391                              <1> BitsPerPixel20:		db	24
  4392                              <1> NumberOfBanks20:	db	43
  4393                              <1> MemoryModel20:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  4394                              <1> BankSize20:		db	0
  4395                              <1> NumberOfImagePages20:	db	5
  4396                              <1> Reserved_page20:	db	0
  4397                              <1> RedMaskSize20:		db	8
  4398                              <1> RedFieldPosition20:	db	16
  4399                              <1> GreenMaskSize20:	db	8
  4400                              <1> GreenFieldPosition20:	db	8
  4401                              <1> BlueMaskSize20:		db	8
  4402                              <1> BlueFieldPosition20:	db	0
  4403                              <1> RsvdMaskSize20:		db	0
  4404                              <1> RsvdFieldPosition20:	db	0
  4405                              <1> DirectColorModeInfo20:	db	0
  4406                              <1> PhysBasePtr20:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  4407                              <1> OffScreenMemOffset20:	dd	0
  4408                              <1> OffScreenMemSize20:	dw	0
  4409                              <1> LinBytesPerScanLine20:	dw	3840
  4410                              <1> BnkNumberOfPages20: 	db	0
  4411                              <1> LinNumberOfPages20: 	db	0
  4412                              <1> LinRedMaskSize20:	db	8
  4413                              <1> LinRedFieldPosition20:	db	16
  4414                              <1> LinGreenMaskSize20:	db	8
  4415                              <1> LinGreenFieldPosition20:db	8
  4416                              <1> LinBlueMaskSize20:	db	8
  4417                              <1> LinBlueFieldPosition20:	db	0
  4418                              <1> LinRsvdMaskSize20:	db	0
  4419                              <1> LinRsvdFieldPosition20:	db	0
  4420                              <1> MaxPixelClock20:	dd	0
  4421                              <1> 	
  4422                              <1> 			dw	018Fh ; 1280x720x32
  4423                              <1> ModeAttributes21: 	dw	MODE_ATTRIBUTES
  4424                              <1> WinAAttributes21: 	db	WINA_ATTRIBUTES
  4425                              <1> WinBAttributes21: 	db	0
  4426                              <1> WinGranularity21: 	dw	VBE_DISPI_BANK_SIZE_KB
  4427                              <1> WinSize21: 		dw	VBE_DISPI_BANK_SIZE_KB
  4428                              <1> WinASegment21:		dw	VGAMEM_GRAPH
  4429                              <1> WinBSegment21:		dw	0000h
  4430                              <1> WinFuncPtr21:		dd	0
  4431                              <1> BytesPerScanLine21:	dw	5120
  4432                              <1> XResolution21:		dw	1280
  4433                              <1> YResolution21:		dw	720
  4434                              <1> XCharSize21:		db	8
  4435                              <1> YCharSize21:		db	16
  4436                              <1> NumberOfPlanes21:	db	1
  4437                              <1> BitsPerPixel21:		db	32
  4438                              <1> NumberOfBanks21:	db	57
  4439                              <1> MemoryModel21:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  4440                              <1> BankSize21:		db	0
  4441                              <1> NumberOfImagePages21:	db	3
  4442                              <1> Reserved_page21:	db	0
  4443                              <1> RedMaskSize21:		db	8
  4444                              <1> RedFieldPosition21:	db	16
  4445                              <1> GreenMaskSize21:	db	8
  4446                              <1> GreenFieldPosition21:	db	8
  4447                              <1> BlueMaskSize21:		db	8
  4448                              <1> BlueFieldPosition21:	db	0
  4449                              <1> RsvdMaskSize21:		db	8
  4450                              <1> RsvdFieldPosition21:	db	24
  4451                              <1> DirectColorModeInfo21:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
  4452                              <1> PhysBasePtr21:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  4453                              <1> OffScreenMemOffset21:	dd	0
  4454                              <1> OffScreenMemSize21:	dw	0
  4455                              <1> LinBytesPerScanLine21:	dw	5120
  4456                              <1> BnkNumberOfPages21: 	db	0
  4457                              <1> LinNumberOfPages21: 	db	0
  4458                              <1> LinRedMaskSize21:	db	8
  4459                              <1> LinRedFieldPosition21:	db	16
  4460                              <1> LinGreenMaskSize21:	db	8
  4461                              <1> LinGreenFieldPosition21:db	8
  4462                              <1> LinBlueMaskSize21:	db	8
  4463                              <1> LinBlueFieldPosition21:	db	0
  4464                              <1> LinRsvdMaskSize21:	db	8
  4465                              <1> LinRsvdFieldPosition21:	db	24
  4466                              <1> MaxPixelClock21:	dd	0
  4467                              <1> 			
  4468                              <1> 			dw	0190h ; 1920x1080x16
  4469                              <1> ModeAttributes22: 	dw	MODE_ATTRIBUTES
  4470                              <1> WinAAttributes22: 	db	WINA_ATTRIBUTES
  4471                              <1> WinBAttributes22: 	db	0
  4472                              <1> WinGranularity22: 	dw	VBE_DISPI_BANK_SIZE_KB
  4473                              <1> WinSize22: 		dw	VBE_DISPI_BANK_SIZE_KB
  4474                              <1> WinASegment22:		dw	VGAMEM_GRAPH
  4475                              <1> WinBSegment22:		dw	0000h
  4476                              <1> WinFuncPtr22:		dd	0
  4477                              <1> BytesPerScanLine22:	dw	3840
  4478                              <1> XResolution22:		dw	1920
  4479                              <1> YResolution22:		dw	1080
  4480                              <1> XCharSize22:		db	8
  4481                              <1> YCharSize22:		db	16
  4482                              <1> NumberOfPlanes22:	db	1
  4483                              <1> BitsPerPixel22:		db	16
  4484                              <1> NumberOfBanks22:	db	64
  4485                              <1> MemoryModel22:		db	VBE_MEMORYMODEL_DIRECT_COLOR,
  4486                              <1> BankSize22:		db	0
  4487                              <1> NumberOfImagePages22:	db	3
  4488                              <1> Reserved_page22:	db	0
  4489                              <1> RedMaskSize22:		db	5
  4490                              <1> RedFieldPosition22:	db	11
  4491                              <1> GreenMaskSize22:	db	6
  4492                              <1> GreenFieldPosition22:	db	5
  4493                              <1> BlueMaskSize22:		db	5
  4494                              <1> BlueFieldPosition22:	db	0
  4495                              <1> RsvdMaskSize22:		db	0
  4496                              <1> RsvdFieldPosition22:	db	0
  4497                              <1> DirectColorModeInfo22:	db	0
  4498                              <1> PhysBasePtr22:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  4499                              <1> OffScreenMemOffset22:	dd	0
  4500                              <1> OffScreenMemSize22:	dw	0
  4501                              <1> LinBytesPerScanLine22:	dw	3840
  4502                              <1> BnkNumberOfPages22: 	db	0
  4503                              <1> LinNumberOfPages22: 	db	0
  4504                              <1> LinRedMaskSize22:	db	5
  4505                              <1> LinRedFieldPosition22:	db	11
  4506                              <1> LinGreenMaskSize22:	db	6
  4507                              <1> LinGreenFieldPosition22:db	5
  4508                              <1> LinBlueMaskSize22:	db	5
  4509                              <1> LinBlueFieldPosition22:	db	0
  4510                              <1> LinRsvdMaskSize22:	db	0
  4511                              <1> LinRsvdFieldPosition22:	db	0
  4512                              <1> MaxPixelClock22:	dd	0
  4513                              <1> 			
  4514                              <1> 			dw	0191h ; 1920x1080x24
  4515                              <1> ModeAttributes23: 	dw	MODE_ATTRIBUTES
  4516                              <1> WinAAttributes23: 	db	WINA_ATTRIBUTES
  4517                              <1> WinBAttributes23: 	db	0
  4518                              <1> WinGranularity23: 	dw	VBE_DISPI_BANK_SIZE_KB
  4519                              <1> WinSize23: 		dw	VBE_DISPI_BANK_SIZE_KB
  4520                              <1> WinASegment23:		dw	VGAMEM_GRAPH
  4521                              <1> WinBSegment23:		dw	0000h
  4522                              <1> WinFuncPtr23:		dd	0
  4523                              <1> BytesPerScanLine23:	dw	5760
  4524                              <1> XResolution23:		dw	1920
  4525                              <1> YResolution23:		dw	1080
  4526                              <1> XCharSize23:		db	8
  4527                              <1> YCharSize23:		db	16
  4528                              <1> NumberOfPlanes23:	db	1
  4529                              <1> BitsPerPixel23:		db	24
  4530                              <1> NumberOfBanks23:	db	95
  4531                              <1> MemoryModel23:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  4532                              <1> BankSize23:		db	0
  4533                              <1> NumberOfImagePages23:	db	1
  4534                              <1> Reserved_page23:	db	0
  4535                              <1> RedMaskSize23:		db	8
  4536                              <1> RedFieldPosition23:	db	16
  4537                              <1> GreenMaskSize23:	db	8
  4538                              <1> GreenFieldPosition23:	db	8
  4539                              <1> BlueMaskSize23:		db	8
  4540                              <1> BlueFieldPosition23:	db	0
  4541                              <1> RsvdMaskSize23:		db	0
  4542                              <1> RsvdFieldPosition23:	db	0
  4543                              <1> DirectColorModeInfo23:	db	0
  4544                              <1> PhysBasePtr23:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  4545                              <1> OffScreenMemOffset23:	dd	0
  4546                              <1> OffScreenMemSize23:	dw	0
  4547                              <1> LinBytesPerScanLine23:	dw	5760
  4548                              <1> BnkNumberOfPages23: 	db	0
  4549                              <1> LinNumberOfPages23: 	db	0
  4550                              <1> LinRedMaskSize23:	db	8
  4551                              <1> LinRedFieldPosition23:	db	16
  4552                              <1> LinGreenMaskSize23:	db	8
  4553                              <1> LinGreenFieldPosition23:db	8
  4554                              <1> LinBlueMaskSize23:	db	8
  4555                              <1> LinBlueFieldPosition23:	db	0
  4556                              <1> LinRsvdMaskSize23:	db	0
  4557                              <1> LinRsvdFieldPosition23:	db	0
  4558                              <1> MaxPixelClock23:	dd	0
  4559                              <1> 
  4560                              <1> 			dw	0192h ; 1920x1080x32
  4561                              <1> ModeAttributes24: 	dw	MODE_ATTRIBUTES
  4562                              <1> WinAAttributes24: 	db	WINA_ATTRIBUTES
  4563                              <1> WinBAttributes24: 	db	0
  4564                              <1> WinGranularity24: 	dw	VBE_DISPI_BANK_SIZE_KB
  4565                              <1> WinSize24: 		dw	VBE_DISPI_BANK_SIZE_KB
  4566                              <1> WinASegment24:		dw	VGAMEM_GRAPH
  4567                              <1> WinBSegment24:		dw	0000h
  4568                              <1> WinFuncPtr24:		dd	0
  4569                              <1> BytesPerScanLine24:	dw	7680
  4570                              <1> XResolution24:		dw	1920
  4571                              <1> YResolution24:		dw	1080
  4572                              <1> XCharSize24:		db	8
  4573                              <1> YCharSize24:		db	16
  4574                              <1> NumberOfPlanes24:	db	1
  4575                              <1> BitsPerPixel24:		db	32
  4576                              <1> NumberOfBanks24:	db	127
  4577                              <1> MemoryModel24:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  4578                              <1> BankSize24:		db	0
  4579                              <1> NumberOfImagePages24:	db	1
  4580                              <1> Reserved_page24:	db	0
  4581                              <1> RedMaskSize24:		db	8
  4582                              <1> RedFieldPosition24:	db	16
  4583                              <1> GreenMaskSize24:	db	8
  4584                              <1> GreenFieldPosition24:	db	8
  4585                              <1> BlueMaskSize24:		db	8
  4586                              <1> BlueFieldPosition24:	db	0
  4587                              <1> RsvdMaskSize24:		db	8
  4588                              <1> RsvdFieldPosition24:	db	24
  4589                              <1> DirectColorModeInfo24:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
  4590                              <1> PhysBasePtr24:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  4591                              <1> OffScreenMemOffset24:	dd	0
  4592                              <1> OffScreenMemSize24:	dw	0
  4593                              <1> LinBytesPerScanLine24:	dw 	7680
  4594                              <1> BnkNumberOfPages24: 	db	0
  4595                              <1> LinNumberOfPages24: 	db	0
  4596                              <1> LinRedMaskSize24:	db	8
  4597                              <1> LinRedFieldPosition24:	db	16
  4598                              <1> LinGreenMaskSize24:	db	8
  4599                              <1> LinGreenFieldPosition24:db	8
  4600                              <1> LinBlueMaskSize24:	db	8
  4601                              <1> LinBlueFieldPosition24:	db	0
  4602                              <1> LinRsvdMaskSize24:	db	8
  4603                              <1> LinRsvdFieldPosition24:	db	24
  4604                              <1> MaxPixelClock24:	dd	0
  4605                              <1> 
  4606                              <1> VBE_VESA_MODE_END_OF_LIST: dw	0
  4607                              <1> 
  4608                              <1> %endif
  4609                              <1> 
  4610                              <1> ; 24/11/2020
  4611                              <1> 
  4612                              <1> direct_color_fields:
  4613                              <1> 	; 24/11/2020
  4614                              <1> 
  4615                              <1> ; (vbetables-gen.c)
  4616                              <1> ; // Direct Color fields 
  4617                              <1> ; (required for direct/6 and YUV/7 memory models)
  4618                              <1> ; switch(pm->depth) {
  4619                              <1>     
  4620                              <1> ;case 8:
  4621 00007426 00                  <1> r_size_8:  db 0
  4622 00007427 00                  <1> r_pos_8:   db 0
  4623 00007428 00                  <1> g_size_8:  db 0
  4624 00007429 00                  <1> g_pos_8:   db 0
  4625 0000742A 00                  <1> b_size_8:  db 0
  4626 0000742B 00                  <1> b_pos_8:   db 0
  4627 0000742C 00                  <1> a_size_8:  db 0
  4628 0000742D 00                  <1> a_pos_8:   db 0
  4629                              <1> 
  4630                              <1> ;case 16:
  4631 0000742E 05                  <1> r_size_16:  db 5
  4632 0000742F 0B                  <1> r_pos_16:   db 11
  4633 00007430 06                  <1> g_size_16:  db 6
  4634 00007431 05                  <1> g_pos_16:   db 5
  4635 00007432 05                  <1> b_size_16:  db 5
  4636 00007433 00                  <1> b_pos_16:   db 0
  4637 00007434 00                  <1> a_size_16:  db 0
  4638 00007435 00                  <1> a_pos_16:   db 0
  4639                              <1> 
  4640                              <1> ;case 24:
  4641 00007436 08                  <1> r_size_24:  db 8
  4642 00007437 10                  <1> r_pos_24:   db 16
  4643 00007438 08                  <1> g_size_24:  db 8
  4644 00007439 08                  <1> g_pos_24:   db 8
  4645 0000743A 08                  <1> b_size_24:  db 8
  4646 0000743B 00                  <1> b_pos_24:   db 0
  4647 0000743C 00                  <1> a_size_24:  db 0
  4648 0000743D 00                  <1> a_pos_24:   db 0
  4649                              <1> 
  4650                              <1> ;case 32:
  4651 0000743E 08                  <1> r_size_32:  db 8
  4652 0000743F 10                  <1> r_pos_32:   db 16
  4653 00007440 08                  <1> g_size_32:  db 8
  4654 00007441 08                  <1> g_pos_32:   db 8
  4655 00007442 08                  <1> b_size_32:  db 8
  4656 00007443 00                  <1> b_pos_32:   db 0
  4657 00007444 08                  <1> a_size_32:  db 8
  4658 00007445 18                  <1> a_pos_32:   db 24
  3080                                  ;%include 'diskdata.s'	; DISK (BIOS) DATA (initialized)
  3081                                  ;;;
  3082                                  
  3083                                  Align 2
  3084                                  
  3085                                  %include 'sysdefs.s' ; 24/01/2015
  3086                              <1> ; ****************************************************************************
  3087                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - SYSTEM DEFINITIONS : sysdefs.s
  3088                              <1> ; ----------------------------------------------------------------------------
  3089                              <1> ; Last Update: 31/12/2017
  3090                              <1> ; ----------------------------------------------------------------------------
  3091                              <1> ; Beginning: 24/01/2016
  3092                              <1> ; ----------------------------------------------------------------------------
  3093                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
  3094                              <1> ; ----------------------------------------------------------------------------
  3095                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
  3096                              <1> ; sysdefs.inc (14/11/2015)
  3097                              <1> ; ****************************************************************************
  3098                              <1> 
  3099                              <1> ; Retro UNIX 386 v1 Kernel - SYSDEFS.INC
  3100                              <1> ; Last Modification: 14/11/2015
  3101                              <1> ;
  3102                              <1> ; ///////// RETRO UNIX 386 V1 SYSTEM DEFINITIONS ///////////////
  3103                              <1> ; (Modified from 
  3104                              <1> ;	Retro UNIX 8086 v1 system definitions in 'UNIX.ASM', 01/09/2014)
  3105                              <1> ; ((UNIX.ASM (RETRO UNIX 8086 V1 Kernel), 11/03/2013 - 01/09/2014))
  3106                              <1> ; 	UNIX.ASM (MASM 6.11) --> SYSDEFS.INC (NASM 2.11)
  3107                              <1> ; ----------------------------------------------------------------------------
  3108                              <1> ;
  3109                              <1> ; Derived from UNIX Operating System (v1.0 for PDP-11) 
  3110                              <1> ; (Original) Source Code by Ken Thompson (1971-1972)
  3111                              <1> ; <Bell Laboratories (17/3/1972)>
  3112                              <1> ; <Preliminary Release of UNIX Implementation Document>
  3113                              <1> ;
  3114                              <1> ; ****************************************************************************
  3115                              <1> 
  3116                              <1> nproc 	equ	16  ; number of processes
  3117                              <1> nfiles 	equ	50
  3118                              <1> ntty	equ     8   ; 8+1 -> 8 (10/05/2013)
  3119                              <1> nbuf	equ	4   ; 6 ;; 21/08/2015 - 'namei' buffer problem when nbuf > 4 	
  3120                              <1> 		; NOTE: If fd0 super block buffer addres is beyond of the 1st
  3121                              <1> 		; 32K, DMA r/w routine or someting else causes a jump to 
  3122                              <1> 		; kernel panic routine (in 'alloc' routine, in u5.s)
  3123                              <1> 		; because of invalid buffer content (r/w error). 
  3124                              <1> 		; When all buffers are set before the end of the 1st 32k,
  3125                              <1> 		; there is no problem!? (14/11/2015) 
  3126                              <1> 
  3127                              <1> ;csgmnt	equ	2000h	; 26/05/2013 (segment of process 1)
  3128                              <1> ;core	equ 	0  	    ; 19/04/2013	
  3129                              <1> ;ecore	equ	32768 - 64  ; 04/06/2013 (24/05/2013)
  3130                              <1> 	; (if total size of argument list and arguments is 128 bytes)
  3131                              <1> 	; maximum executable file size = 32768-(64+40+128-6) = 32530 bytes
  3132                              <1> 	; maximum stack size = 40 bytes (+6 bytes for 'IRET' at 32570)	
  3133                              <1> 	; initial value of user's stack pointer = 32768-64-128-2 = 32574
  3134                              <1> 	; 	(sp=32768-args_space-2 at the beginning of execution)
  3135                              <1> 	; argument list offset = 32768-64-128 = 32576 (if it is 128 bytes)
  3136                              <1> 	; 'u' structure offset (for the '/core' dump file) = 32704
  3137                              <1> 	; '/core' dump file size = 32768 bytes
  3138                              <1>  
  3139                              <1> ; 08/03/2014 
  3140                              <1> ;sdsegmnt equ	6C0h  ; 256*16 bytes (swap data segment size for 16 processes)		 	 
  3141                              <1> ; 19/04/2013 Retro UNIX 8086 v1 feaure only !
  3142                              <1> ;;sdsegmnt equ 	740h  ; swap data segment (for user structures and registers)
  3143                              <1> 
  3144                              <1> ; 30/08/2013
  3145                              <1> time_count equ 4 ; 10 --> 4 01/02/2014
  3146                              <1> 
  3147                              <1> ; 05/02/2014
  3148                              <1> ; process status
  3149                              <1> ;SFREE 	equ 0
  3150                              <1> ;SRUN	equ 1
  3151                              <1> ;SWAIT	equ 2
  3152                              <1> ;SZOMB	equ 3
  3153                              <1> ;SSLEEP	equ 4 ; Retro UNIX 8086 V1 extension (for sleep and wakeup)
  3154                              <1> 
  3155                              <1> ; 09/03/2015
  3156                              <1> userdata equ 80000h ; user structure data address for current user ; temporary
  3157                              <1> swap_queue equ 90000h - 2000h ; swap queue address ; temporary
  3158                              <1> swap_alloc_table equ 0D0000h  ;  swap allocation table address ; temporary
  3159                              <1> 
  3160                              <1> ; 17/09/2015
  3161                              <1> ESPACE equ 48 ; [u.usp] (at 'sysent') - [u.sp] value for error return
  3162                              <1> 
  3163                              <1> ; 31/12/2017
  3164                              <1> ; 19/02/2017
  3165                              <1> ; 15/10/2016
  3166                              <1> ; 20/05/2016
  3167                              <1> ; 19/05/2016
  3168                              <1> ; 18/05/2016
  3169                              <1> ; 29/04/2016 
  3170                              <1> ; TRDOS 386 (TRDOS v2.0) system calls - temporary List 
  3171                              <1> ; 14/07/2013 - 21/09/2015 (Retro UNIX 8086 & 386 system calls) 
  3172                              <1> _ver 	equ 0 ; Get TRDOS version (v2.0)
  3173                              <1> _exit 	equ 1
  3174                              <1> _fork 	equ 2
  3175                              <1> _read 	equ 3
  3176                              <1> _write	equ 4
  3177                              <1> _open	equ 5
  3178                              <1> _close 	equ 6
  3179                              <1> _wait 	equ 7
  3180                              <1> _creat 	equ 8
  3181                              <1> _rename	equ 9  ; TRDOS 386, Rename File (31/12/2017)	
  3182                              <1> _delete	equ 10 ; TRDOS 386, Delete File (29/12/2017)
  3183                              <1> _exec	equ 11
  3184                              <1> _chdir	equ 12
  3185                              <1> _time 	equ 13 ; TRDOS 386, Get Sys Date&Time (30/12/2017)
  3186                              <1> _mkdir 	equ 14
  3187                              <1> _chmod	equ 15 ; TRDOS 386, Change Attributes (30/12/2017) 
  3188                              <1> _rmdir	equ 16 ; TRDOS 386, Remove Directory (29/12/2017)
  3189                              <1> _break	equ 17
  3190                              <1> _drive	equ 18 ; TRDOS 386, Get/Set Current Drv (30/12/2017) 
  3191                              <1> _seek	equ 19
  3192                              <1> _tell 	equ 20
  3193                              <1> _mem	equ 21 ; TRDOS 386, Get Total&Free Mem (31/12/2017)
  3194                              <1> _prompt	equ 22 ; TRDOS 386, Change Cmd Prompt (31/12/2017)
  3195                              <1> _path	equ 23 ; TRDOS 386, Get/Set Run Path (31/12/2017)
  3196                              <1> _env	equ 24 ; TRDOS 386, Get/Set Env Vars (31/12/2017)
  3197                              <1> _stime	equ 25 ; TRDOS 386, Set Sys Date&Time (30/12/2017)
  3198                              <1> _quit	equ 26	
  3199                              <1> _intr	equ 27
  3200                              <1> _dir	equ 28 ; TRDOS 386, Get Curr Drive&Dir (30/12/2017) 
  3201                              <1> _emt 	equ 29
  3202                              <1> _ldrvt 	equ 30 ; TRDOS 386, Get Logical DOS DDT (30/12/2017)
  3203                              <1> _video  equ 31 ; TRDOS 386 Video Functions (16/05/2016)
  3204                              <1> _audio	equ 32 ; TRDOS 386 Video Functions (16/05/2016)
  3205                              <1> _timer	equ 33 ; TRDOS 386 Timer Functions (18/05/2016)
  3206                              <1> _sleep	equ 34 ; Retro UNIX 8086 v1 feature only !
  3207                              <1> _msg	equ 35 ; Retro UNIX 386 v1 feature only !
  3208                              <1> _geterr	equ 36 ; Retro UNIX 386 v1 feature only !
  3209                              <1> _fpsave equ 37 ; TRDOS 386 FPU state option (28/02/2017)
  3210                              <1> _pri 	equ 38 ; change priority - TRDOS 386 (20/05/2016)
  3211                              <1> _rele	equ 39 ; TRDOS 386 (19/05/2016)
  3212                              <1> _fff	equ 40 ; Find First File - TRDOS 386 (15/10/2016)
  3213                              <1> _fnf	equ 41 ; Find Next File - TRDOS 386 (15/10/2016)
  3214                              <1> _alloc	equ 42 ; Allocate memory - TRDOS 386 (19/02/2017)
  3215                              <1> 	       ; TRDOS 386 (19/02/2017) DMA buff fuctions		
  3216                              <1> _dalloc equ 43 ; Deallocate mem - TRDOS 386 (19/02/2017)
  3217                              <1> _calbac equ 44 ; Set IRQ callback - TRDOS 386 (20/02/2017)  				
  3218                              <1> _dma	equ 45 ; DMA service - TRDOS 386 (20/08/2017)  
  3219                              <1> 
  3220                              <1> %macro sys 1-4
  3221                              <1>     ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)	
  3222                              <1>     ; 03/09/2015	
  3223                              <1>     ; 13/04/2015
  3224                              <1>     ; Retro UNIX 386 v1 system call.		
  3225                              <1>     %if %0 >= 2   
  3226                              <1>         mov ebx, %2
  3227                              <1>         %if %0 >= 3    
  3228                              <1>             mov ecx, %3
  3229                              <1>             %if %0 = 4
  3230                              <1>                mov edx, %4   
  3231                              <1>             %endif
  3232                              <1>         %endif
  3233                              <1>     %endif
  3234                              <1>     mov eax, %1
  3235                              <1>     ;int 30h
  3236                              <1>     int 40h ; TRDOS 386 (TRDOS v2.0)		   
  3237                              <1> %endmacro
  3238                              <1> 
  3239                              <1> ; TRDOS 386 system calls, interrupt number
  3240                              <1> ; 25/12/2016
  3241                              <1> SYSCALL_INT_NUM   equ '40' ; '40h'
  3242                              <1> 
  3243                              <1> ; 13/05/2015 - ERROR CODES
  3244                              <1> ERR_FILE_NOT_OPEN  equ 10 ; 'file not open !' error
  3245                              <1> ERR_FILE_ACCESS    equ 11 ; 'permission denied !' error
  3246                              <1> ; 14/05/2015
  3247                              <1> ERR_DIR_ACCESS     equ 11 ; 'permission denied !' error
  3248                              <1> ERR_FILE_NOT_FOUND equ 12 ; 'file not found !' error
  3249                              <1> ERR_TOO_MANY_FILES equ 13 ; 'too many open files !' error
  3250                              <1> ERR_DIR_EXISTS     equ 14 ; 'directory already exists !' error 	
  3251                              <1> ; 16/05/2015		
  3252                              <1> ERR_DRV_NOT_RDY    equ 15 ; 'drive not ready !' error
  3253                              <1> ; 18/05/2015
  3254                              <1> ERR_DEV_NOT_RDY    equ 15 ; 'device not ready !' error
  3255                              <1> ERR_DEV_ACCESS     equ 11 ; 'permission denied !' error 
  3256                              <1> ERR_DEV_NOT_OPEN   equ 10 ; 'device not open !' error	
  3257                              <1> ; 07/06/2015
  3258                              <1> ERR_FILE_EOF	   equ 16 ; 'end of file !' error
  3259                              <1> ERR_DEV_VOL_SIZE   equ 16 ; 'out of volume !' error
  3260                              <1> ; 09/06/2015
  3261                              <1> ERR_DRV_READ	   equ 17 ; 'disk read error !'
  3262                              <1> ERR_DRV_WRITE	   equ 18 ; 'disk write error !'
  3263                              <1> ; 16/06/2015
  3264                              <1> ERR_NOT_DIR	   equ 19 ; 'not a (valid) directory !' error
  3265                              <1> ERR_FILE_SIZE	   equ 20 ; 'file size error !'	
  3266                              <1> ; 22/06/2015
  3267                              <1> ERR_NOT_SUPERUSER  equ 11 ; 'permission denied !' error
  3268                              <1> ERR_NOT_OWNER      equ 11 ; 'permission denied !' error
  3269                              <1> ERR_NOT_FILE       equ 11 ; 'permission denied !' error	
  3270                              <1> ; 23/06/2015
  3271                              <1> ERR_FILE_EXISTS    equ 14 ; 'file already exists !' error
  3272                              <1> ERR_DRV_NOT_SAME   equ 21 ; 'not same drive !' error
  3273                              <1> ERR_DIR_NOT_FOUND  equ 12 ; 'directory not found !' error
  3274                              <1> ERR_NOT_EXECUTABLE equ 22 ; 'not executable file !' error
  3275                              <1> ; 27/06/2015
  3276                              <1> ERR_INV_PARAMETER  equ 23 ; 'invalid parameter !' error
  3277                              <1> ERR_INV_DEV_NAME   equ 24 ; 'invalid device name !' error
  3278                              <1> ; 29/06/2015
  3279                              <1> ERR_TIME_OUT	   equ 25 ; 'time out !' error			
  3280                              <1> ERR_DEV_NOT_RESP   equ 25 ; 'device not responding !' error
  3281                              <1> ; 10/10/2016
  3282                              <1> ERR_INV_FILE_NAME  equ 26 ; 'invalid file name !' error
  3283                              <1> ERR_INV_FLAGS	   equ 23 ; 'invalid flags !' error
  3284                              <1> ; For code compatibility with previous version of TRDOS (2011)
  3285                              <1> ; (Temporary error codes for current TRDOS 386 -2016- version) 
  3286                              <1> ERR_NO_MORE_FILES  equ 12 ; 'no more files !' error
  3287                              <1> ERR_PATH_NOT_FOUND equ  3 ; 'path not found !' error 
  3288                              <1> 			  ; 'dir not found !' ; TRDOS 8086
  3289                              <1> ERR_NOT_FOUND:	   equ  2 ; 'file not found !' ; TRDOS 8086
  3290                              <1> ERR_DISK_SPACE	   equ 39 ; 'out of volume !' TRDOS 8086
  3291                              <1> 			  ; 'insufficient disk space !' ; 27h
  3292                              <1> ERR_DISK_WRITE	   equ 30 ; 'disk write protected !' ; 16/10/2016
  3293                              <1> ERR_ACCESS_DENIED  equ  5 ; 'access denied !' ; TRDOS 8086 	
  3294                              <1> ; 28/02/2017
  3295                              <1> ERR_PERM_DENIED	   equ 11 ; 'permission denied !' error  	
  3296                              <1> ; 18/05/2016
  3297                              <1> ERR_MISC	   equ 27 ; miscellaneous/other errors
  3298                              <1> ; 15/10/2016
  3299                              <1> ; TRDOS 8086 -> TRDOS 386 (0Bh -> 28)
  3300                              <1> ERR_INV_FORMAT	   equ 28 ; 'invalid format !' error
  3301                              <1> ; TRDOS 8086 -> TRDOS 386 (0Dh -> 29)
  3302                              <1> ERR_INV_DATA	   equ 29 ; 'invalid data !' error
  3303                              <1> ; TRDOS 8086 -> TRDOS 386 (0Eh -> 20)
  3304                              <1> ERR_ZERO_LENGTH	   equ 20  ; 'zero length !' error 	
  3305                              <1> ; TRDOS 8086 -> TRDOS 386 (15h -> 17, 1Dh -> 18, 1Eh -> 17) 	
  3306                              <1> ERR_DRV_NR_READ	   equ 17 ; 'drive not ready or read error !'
  3307                              <1> ERR_DRV_NR_WRITE   equ 18 ; 'drive not ready or write error !'		
  3308                              <1> ; 15/10/2016
  3309                              <1> ERR_INV_PATH_NAME  equ 19 ; 'bad path name !' error
  3310                              <1> ERR_BAD_CMD_ARG	   equ  1 ; 'bad command argument !' ; TRDOS 8086
  3311                              <1> ERR_INV_FNUMBER	   equ  1 ; 'invalid function number !' ; TRDOS 8086
  3312                              <1> ERR_BIG_FILE	   equ  8 ; 'big file & out of memory ! ; TRDOS 8086 	
  3313                              <1> ERR_BIG_DATA	   equ  8 ; 'big data & out of memory ! ; TRDOS 8086
  3314                              <1> ERR_CLUSTER	   equ 35 ; 'cluster not available !' ; TRDOS 8086
  3315                              <1> ERR_OUT_OF_MEMORY  equ  4 ; 'out of memory !'
  3316                              <1> 			  ; 'insufficient memory !'
  3317                              <1> ERR_P_VIOLATION	   equ	6 ; 'protection violation !'
  3318                              <1> ERR_PAGE_FAULT	   equ 224 ;'page fault !' ;0E0h						 
  3319                              <1> ERR_SWP_DISK_READ  	   equ 40
  3320                              <1> ERR_SWP_DISK_NOT_PRESENT   equ 41
  3321                              <1> ERR_SWP_SECTOR_NOT_PRESENT equ 42
  3322                              <1> ERR_SWP_NO_FREE_SPACE      equ 43
  3323                              <1> ERR_SWP_DISK_WRITE         equ 44
  3324                              <1> ERR_SWP_NO_PAGE_TO_SWAP    equ 45
  3325                              <1> ; 10/04/2017
  3326                              <1> ERR_BUFFER	   equ 46  ; 'buffer error !'
  3327                              <1> ; 28/08/2017 (20/08/2017)
  3328                              <1> ERR_DMA		   equ -1  ; DMA buffer (allocation/misc.) error!
  3329                              <1> 
  3330                              <1> ; 26/08/2015
  3331                              <1> ; 24/07/2015
  3332                              <1> ; 24/06/2015
  3333                              <1> MAX_ARG_LEN	   equ 256 ; max. length of sys exec arguments
  3334                              <1> ; 01/07/2015
  3335                              <1> MAX_MSG_LEN	   equ 255 ; max. msg length for 'sysmsg'
  3336                              <1> ;	
  3337                              <1> ; 06/10/2016
  3338                              <1> OPENFILES	   equ 10  ; max. number of open files (system)
  3339                              <1> ; 07/10/2016
  3340                              <1> ;NUMOFDEVICES	   equ 20  ; max. num of available devices (sys)
  3341                              <1> 			 		
  3086                                  %include 'trdosk0.s' ; 04/01/2016 
  3087                              <1> ; ****************************************************************************
  3088                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - DEFINITIONS : trdosk0.s
  3089                              <1> ; ----------------------------------------------------------------------------
  3090                              <1> ; Last Update: 29/02/2016
  3091                              <1> ; ----------------------------------------------------------------------------
  3092                              <1> ; Beginning: 04/01/2016
  3093                              <1> ; ----------------------------------------------------------------------------
  3094                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
  3095                              <1> ; ----------------------------------------------------------------------------
  3096                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
  3097                              <1> ; TRDOS2.ASM (09/11/2011)
  3098                              <1> ; ****************************************************************************
  3099                              <1> ; TRDOS2.ASM (c) 2004-2011 Erdogan TAN [ 17/01/2004 ] Last Update: 09/11/2011
  3100                              <1> ;
  3101                              <1> ; Masterboot / Partition Table at Beginning+1BEh
  3102                              <1> ptBootable       equ 0
  3103                              <1> ptBeginHead      equ 1
  3104                              <1> ptBeginSector    equ 2
  3105                              <1> ptBeginCylinder  equ 3
  3106                              <1> ptFileSystemID   equ 4
  3107                              <1> ptEndHead        equ 5
  3108                              <1> ptEndSector      equ 6
  3109                              <1> ptEndCylinder    equ 7
  3110                              <1> ptStartSector    equ 8
  3111                              <1> ptSectors        equ 12
  3112                              <1> 
  3113                              <1> ; Boot Sector Parameters at 7C00h
  3114                              <1> DataArea1     equ -4
  3115                              <1> DataArea2     equ -2
  3116                              <1> BootStart     equ 0h
  3117                              <1> OemName       equ 03h
  3118                              <1> BytesPerSec   equ 0Bh
  3119                              <1> SecPerClust   equ 0Dh
  3120                              <1> ResSectors    equ 0Eh
  3121                              <1> FATs          equ 10h
  3122                              <1> RootDirEnts   equ 11h
  3123                              <1> Sectors       equ 13h
  3124                              <1> Media         equ 15h
  3125                              <1> FATSecs       equ 16h
  3126                              <1> SecPerTrack   equ 18h
  3127                              <1> Heads         equ 1Ah 
  3128                              <1> Hidden1       equ 1Ch
  3129                              <1> Hidden2       equ 1Eh
  3130                              <1> HugeSec1      equ 20h
  3131                              <1> HugeSec2      equ 22h
  3132                              <1> DriveNumber   equ 24h
  3133                              <1> Reserved1     equ 25h
  3134                              <1> bootsignature equ 26h                 
  3135                              <1> VolumeID      equ 27h
  3136                              <1> VolumeLabel   equ 2Bh
  3137                              <1> FileSysType   equ 36h          
  3138                              <1> Reserved2     equ 3Eh                           ; Starting cluster of P2000
  3139                              <1> 
  3140                              <1> ; FAT32 BPB Structure
  3141                              <1> FAT32_FAT_Size equ 36
  3142                              <1> FAT32_RootFClust equ 44
  3143                              <1> FAT32_FSInfoSec equ 48
  3144                              <1> FAT32_DrvNum equ 64
  3145                              <1> FAT32_BootSig equ 66
  3146                              <1> FAT32_VolID equ 67
  3147                              <1> FAT32_VolLab equ 71
  3148                              <1> FAT32_FilSysType equ 82
  3149                              <1> 
  3150                              <1> ; BIOS Disk Parameters
  3151                              <1> DPDiskNumber  equ 0h
  3152                              <1> DPDType       equ 1h
  3153                              <1> DPReturn      equ 2h
  3154                              <1> DPHeads       equ 3h
  3155                              <1> DPCylinders   equ 4h
  3156                              <1> DPSecPerTrack equ 6h
  3157                              <1> DPDisks       equ 7h
  3158                              <1> DPTableOff    equ 8h
  3159                              <1> DPTableSeg    equ 0Ah
  3160                              <1> DPNumOfSecs   equ 0Ch
  3161                              <1> 
  3162                              <1> ; BIOS INT 13h Extensions (LBA extensions)
  3163                              <1> ; Just After DP Data (DPDiskNumber+)
  3164                              <1> DAP_PacketSize equ 10h  ; If extensions present, this byte will be >=10h
  3165                              <1> DAP_Reserved1 equ 11h   ; Reserved Byte 
  3166                              <1> DAP_NumOfBlocks equ 12h ; Value of this byte must be 0 to 127
  3167                              <1> DAP_Reserved2 equ 13h   ; Reserved Byte
  3168                              <1> DAP_Destination equ 14h ; Address of Transfer Buffer as SEGMENT:OFFSET
  3169                              <1> DAP_LBA_Address equ 18h ; LBA=(C1*H0+H1)*S0+S1-1
  3170                              <1>                         ; C1= Selected Cylinder Number
  3171                              <1>                         ; H0= Number Of Heads (Maximum Head Number + 1)
  3172                              <1>                         ; H1= Selected Head Number
  3173                              <1>                         ; S0= Maximum Sector Number
  3174                              <1>                         ; S1= Selected Sector Number
  3175                              <1>                         ; QUAD WORD
  3176                              <1> ; DAP_Flat_Destination equ 20h ; 64 bit address, if value in 4h is FFFF:FFFFh
  3177                              <1>                              ; QUAD WORD (Also, value in 0h must be 18h) 
  3178                              <1>                              ; TR-DOS will not use 64 bit Flat Address
  3179                              <1> 
  3180                              <1> ; INT 13h Function 48h "Get Enhanced Disk Drive Parameters"
  3181                              <1> ; Just After DP Data (DPDiskNumber+)
  3182                              <1> GetDParams_48h equ 20h ; Word. Data Length, must be 26 (1Ah) for short data.
  3183                              <1> GDP_48h_InfoFlag equ 22h ; Word
  3184                              <1> ; Bit 1 = 1 -> The geometry returned in bytes 4-15 is valid.
  3185                              <1> GDP_48h_NumOfPCyls equ 24h ; Double Word. Number physical cylinders.
  3186                              <1> GDP_48h_NumOfPHeads equ 28h ; Double Word. Number of physical heads.
  3187                              <1> GDP_48h_NumOfPSpT equ 2Ch ; Double word. Num of physical sectors per track.
  3188                              <1> GDP_48h_LBA_Sectors equ 30h ; 8 bytes. Number of physical/LBA sectors.
  3189                              <1> GDP_48h_BytesPerSec equ 38h ; Word. Number of bytes in a sector.
  3190                              <1> 
  3191                              <1> ; TR-DOS Standalone Program Extensions to the DiskParams Block
  3192                              <1> ; Just After DP Data (DPDiskNumber+)
  3193                              <1> TRDP_CurrentSector equ 3Ah  ; DX:AX (LBA)
  3194                              <1> TRDP_SectorCount equ 3Eh    ; CX (or Counter)
  3195                              <1> 
  3196                              <1> 
  3197                              <1> ; DOS Logical Disks
  3198                              <1> LD_Name equ 0
  3199                              <1> LD_DiskType equ 1
  3200                              <1> LD_PhyDrvNo equ 2
  3201                              <1> LD_FATType equ 3
  3202                              <1> LD_FSType equ 4
  3203                              <1> LD_LBAYes equ 5
  3204                              <1> LD_BPB equ 6
  3205                              <1> LD_FATBegin equ 96
  3206                              <1> LD_ROOTBegin equ 100
  3207                              <1> LD_DATABegin equ 104
  3208                              <1> LD_StartSector equ 108
  3209                              <1> LD_TotalSectors equ 112
  3210                              <1> LD_FreeSectors equ 116
  3211                              <1> LD_Clusters equ 120
  3212                              <1> LD_PartitionEntry equ 124
  3213                              <1> LD_DParamEntry equ 125
  3214                              <1> LD_MediaChanged equ 126
  3215                              <1> LD_CDirLevel equ 127
  3216                              <1> LD_CurrentDirectory equ 128
  3217                              <1> 
  3218                              <1> ; Singlix FS Extensions to DOS Logical Disks
  3219                              <1> ; 03/01/2010 (LD_BPB compatibility for CHS r/w)
  3220                              <1> 
  3221                              <1> LD_FS_Name equ 0
  3222                              <1> LD_FS_DiskType equ 1
  3223                              <1> LD_FS_PhyDrvNo equ 2
  3224                              <1> LD_FS_FATType equ 3
  3225                              <1> LD_FS_FSType equ 4
  3226                              <1> LD_FS_LBAYes equ 5
  3227                              <1> LD_FS_BPB equ 6
  3228                              <1> LD_FS_MediaAttrib equ 6
  3229                              <1> LD_FS_VersionMajor equ 7
  3230                              <1> LD_FS_RootDirD equ 8
  3231                              <1> LD_FS_MATLocation equ 12
  3232                              <1> LD_FS_Reserved1 equ 16 ;1 reserved byte
  3233                              <1> LD_FS_BytesPerSec equ 17 ; LD_BPB + 0Bh
  3234                              <1> LD_FS_Reserved2 equ 19 ;2 reserved byte
  3235                              <1> LD_FS_DATLocation equ 20
  3236                              <1> LD_FS_DATSectors equ 24
  3237                              <1> LD_FS_Reserved3 equ 28 ;3 reserved word
  3238                              <1> LD_FS_SecPerTrack equ 30 ; LD_BPB + 18h
  3239                              <1> LD_FS_NumHeads equ 32    ; LD_BPB + 1Ah
  3240                              <1> LD_FS_UnDelDirD equ 34
  3241                              <1> LD_FS_Reserved4 equ 38 ;4 reserved word
  3242                              <1> LD_FS_VolumeSerial equ 40
  3243                              <1> LD_FS_VolumeName equ 44
  3244                              <1> LD_FS_BeginSector equ 108
  3245                              <1> LD_FS_VolumeSize equ 112
  3246                              <1> LD_FS_FreeSectors equ 116
  3247                              <1> LD_FS_FirstFreeSector equ 120
  3248                              <1> LD_FS_PartitionEntry equ 124
  3249                              <1> LD_FS_DParamEntry equ 125
  3250                              <1> LD_FS_MediaChanged equ 126
  3251                              <1> LD_FS_CDirLevel equ 127
  3252                              <1> LD_FS_CDIR_Converted equ 128
  3253                              <1> 
  3254                              <1> ; Valid FAT Types
  3255                              <1> FS_FAT12 equ 1
  3256                              <1> FS_FAT16_CHS equ 2
  3257                              <1> FS_FAT32_CHS equ 3
  3258                              <1> FS_FAT16_LBA equ 4
  3259                              <1> FS_FAT32_LBA equ 5
  3260                              <1> 
  3261                              <1> ; Cursor Location
  3262                              <1> CCCpointer equ  0450h   ; BIOS data, current cursor column
  3263                              <1> ; FAT Clusters EOC sign
  3264                              <1> FAT12EOC equ 0FFFh
  3265                              <1> FAT16EOC equ 0FFFFh
  3266                              <1> ;FAT32EOC equ 0FFFFFFFh ; It is not direct usable for 8086 code
  3267                              <1> ; BAD Cluster
  3268                              <1> FAT12BADC equ 0FF7h
  3269                              <1> FAT16BADC equ 0FFF7h
  3270                              <1> ;FAT32BADC equ 0FFFFFF7h ; It is not direct usable for 8086 code
  3271                              <1> ; MS-DOS FAT16 FS (Maximum Possible) Last Cluster Number= 0FFF6h 
  3272                              <1> 
  3273                              <1> ; TRFS
  3274                              <1> 
  3275                              <1> bs_FS_JmpBoot equ 0 ; jmp short bsBootCode
  3276                              <1>                 ; db 0EBh, db 3Fh, db 90h
  3277                              <1> bs_FS_Identifier equ 3  ; db 'FS', db 0
  3278                              <1> bs_FS_BytesPerSec equ 6 ; dw 512
  3279                              <1> bs_FS_MediaAttrib equ 8 ; db 3
  3280                              <1> bs_FS_PartitionID equ 9 ; db 0A1h
  3281                              <1> bs_FS_VersionMaj equ 10 ; db 01h
  3282                              <1> bs_FS_VersionMin equ 11 ; db 0
  3283                              <1> bs_FS_BeginSector equ 12   ; dd 0 
  3284                              <1> bs_FS_VolumeSize equ 16 ; dd 2880
  3285                              <1> bs_FS_StartupFD equ 20 ; dd 0
  3286                              <1> bs_FS_MATLocation equ 24 ; dd 1
  3287                              <1> bs_FS_RootDirD equ 28 ; dd 8
  3288                              <1> bs_FS_SystemConfFD equ 32 ; dd 0
  3289                              <1> bs_FS_SwapFD equ 36 ; dd 0
  3290                              <1> bs_FS_UnDelDirD equ 40 ; dd 0
  3291                              <1> bs_FS_DriveNumber equ 44 ; db 0
  3292                              <1> bs_FS_LBA_Ready equ 45 ; db 0
  3293                              <1> bs_FS_MagicWord equ 46 
  3294                              <1> bs_FS_SecPerTrack equ 46 ; db 0A1h
  3295                              <1> bs_FS_Heads equ 47 ; db 01h 
  3296                              <1> bs_FS_OperationSys equ 48 ; db "TR-SINGLIX v1.0b"
  3297                              <1> bs_FS_Terminator equ 64 ; db 0
  3298                              <1> bs_FS_BootCode equ 65 
  3299                              <1> 
  3300                              <1> FS_MAT_DATLocation equ 12
  3301                              <1> FS_MAT_DATScount equ 16
  3302                              <1> FS_MAT_FreeSectors equ 20
  3303                              <1> FS_MAT_FirstFreeSector equ 24
  3304                              <1> FS_RDT_VolumeSerialNo equ 28
  3305                              <1> FS_RDT_VolumeName equ 64
  3306                              <1> 
  3307                              <1> ; FAT12 + FAT16 + FAT32
  3308                              <1> BS_JmpBoot equ 0
  3309                              <1> BS_OEMName equ 3
  3310                              <1> BPB_BytsPerSec equ 11
  3311                              <1> BPB_SecPerClust equ 13
  3312                              <1> BPB_RsvdSecCnt equ 14
  3313                              <1> BPB_NumFATs equ 16
  3314                              <1> BPB_RootEntCnt equ 17
  3315                              <1> BPB_TotalSec16 equ 19
  3316                              <1> BPB_Media equ 21
  3317                              <1> BPB_FATSz16 equ 22
  3318                              <1> BPB_SecPerTrk equ 24
  3319                              <1> BPB_NumHeads equ 26
  3320                              <1> BPB_HiddSec equ 28
  3321                              <1> BPB_TotalSec32 equ 32
  3322                              <1> 
  3323                              <1> ; FAT12 and FAT16 only
  3324                              <1> BS_DrvNum equ 36
  3325                              <1> BS_Reserved1 equ 37
  3326                              <1> BS_BootSig equ 38
  3327                              <1> BS_VolID equ 39
  3328                              <1> BS_VolLab equ 43
  3329                              <1> BS_FilSysType equ 54 ; 8 bytes
  3330                              <1> BS_BootCode equ 62
  3331                              <1> 
  3332                              <1> ; FAT32 only
  3333                              <1> BPB_FATSz32 equ 36 ; FAT32, 4 bytes
  3334                              <1> BPB_ExtFlags equ 40 ; FAT32, 2 bytes
  3335                              <1> BPB_FSVer equ 42 ; FAT32, 2 bytes
  3336                              <1> BPB_RootClus equ 44 ; FAT32, 4 bytes
  3337                              <1> BPB_FSInfo equ 48 ; FAT 32, 2 bytes 
  3338                              <1> BPB_BkBootSec equ 50 ; FAT32, 2 bytes
  3339                              <1> BPB_Reserved equ 52 ; FAT32, 12 bytes
  3340                              <1> BS_FAT32_DrvNum equ 64 ; FAT32, 1 byte
  3341                              <1> BS_FAT32_Reserved1 equ 65 ; FAT32, 1 byte
  3342                              <1> BS_FAT32_BootSig equ 66 ; FAT32, 1 byte
  3343                              <1> BS_FAT32_VolID equ 67 ; FAT32, 4 bytes
  3344                              <1> BS_FAT32_VolLab equ 71 ; FAT32, 11 bytes
  3345                              <1> BS_FAT32_FilSysType equ 82 ; FAT32, 8 bytes
  3346                              <1> BS_FAT32_BootCode equ 90
  3347                              <1> 
  3348                              <1> ; 29/02/2016
  3349                              <1> ;(FAT32 Free Cluster Count & First Free Cluster values)
  3350                              <1> ;[BPB_Reserved] = Free Cluster Count (offset 52)
  3351                              <1> ;[BPB_Reserved+4] = First Free Cluster (offset 56)
  3352                              <1> 
  3353                              <1> BS_Validation equ 510
  3354                              <1> 
  3355                              <1> ; 15/02/2016
  3356                              <1> ; FILE.ASM - 09/10/2011
  3357                              <1> ; Directory Entry Structure
  3358                              <1> ; 29/10/2009 (According to Microsoft FAT32 File System Specification)
  3359                              <1> DirEntry_Name equ 0
  3360                              <1> DirEntry_Attr equ 11
  3361                              <1> DirEntry_NTRes equ 12
  3362                              <1> DirEntry_CrtTimeTenth equ 13
  3363                              <1> DirEntry_CrtTime equ 14
  3364                              <1> DirEntry_CrtDate equ 16
  3365                              <1> DirEntry_LastAccDate equ 18
  3366                              <1> DirEntry_FstClusHI equ 20
  3367                              <1> DirEntry_WrtTime equ 22
  3368                              <1> DirEntry_WrtDate equ 24
  3369                              <1> DirEntry_FstClusLO equ 26
  3370                              <1> DirEntry_FileSize equ 28
  3087                                  %include 'trdosk1.s' ; 04/01/2016 
  3088                              <1> ; ****************************************************************************
  3089                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.3) - SYS INIT : trdosk1.s
  3090                              <1> ; ----------------------------------------------------------------------------
  3091                              <1> ; Last Update: 06/12/2020
  3092                              <1> ; ----------------------------------------------------------------------------
  3093                              <1> ; Beginning: 04/01/2016
  3094                              <1> ; ----------------------------------------------------------------------------
  3095                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
  3096                              <1> ; ----------------------------------------------------------------------------
  3097                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
  3098                              <1> ; TRDOS2.ASM (09/11/2011)
  3099                              <1> ; ****************************************************************************
  3100                              <1> ; TRDOS2.ASM (c) 2004-2011 Erdogan TAN [ 17/01/2004 ] Last Update: 09/11/2011
  3101                              <1> ;
  3102                              <1> 
  3103                              <1> sys_init:
  3104                              <1> 	; 20/01/2018  (v2.0.1)
  3105                              <1> 	; 23/01/2017  (v2.0.0)
  3106                              <1> 	; 07/05/2016
  3107                              <1> 	; 02/05/2016
  3108                              <1> 	; 24/04/2016
  3109                              <1> 	; 14/04/2016
  3110                              <1> 	; 13/04/2016
  3111                              <1> 	; 30/03/2016
  3112                              <1> 	; 24/01/2016
  3113                              <1> 	; 06/01/2016
  3114                              <1> 	; 04/01/2016
  3115                              <1> 
  3116                              <1> 	; 23/01/2017 - reset timer frequency (to 18.2Hz)
  3117 00007446 B036                <1> 	mov	al, 00110110b ; 36h
  3118 00007448 E643                <1>  	out	43h, al
  3119 0000744A 31C0                <1> 	xor	eax, eax  ; sub	al, al ; 0
  3120 0000744C E640                <1> 	out	40h, al ; LB
  3121 0000744E E640                <1> 	out	40h, al ; HB
  3122                              <1>  	; 
  3123                              <1> 	; 30/03/2016
  3124                              <1> 	; Clear Logical DOS Disk Description Tables Area
  3125                              <1> 	;xor	eax, eax
  3126 00007450 BF00010900          <1> 	mov	edi, Logical_DOSDisks
  3127 00007455 B980060000          <1> 	mov	ecx, 6656/4 ; 26*256 = 6656 bytes
  3128 0000745A F3AB                <1> 	rep	stosd ; 1664 times 4 bytes
  3129                              <1> 
  3130 0000745C B83F3A2F00          <1> 	mov	eax, '?:/'
  3131 00007461 A3[F78A0100]        <1> 	mov	[Current_Dir_Drv], eax
  3132                              <1> 
  3133                              <1> 	; Logical DRV INIT (only for hard disks)
  3134 00007466 E825040000          <1> 	call 	ldrv_init  ; trdosk2.s
  3135                              <1> 	
  3136                              <1> 	; When floppy_drv_init call is disabled
  3137                              <1> 	; media changed sign is needed
  3138                              <1> 	; for proper drive initialization
  3139                              <1>         
  3140 0000746B BE00010900          <1> 	mov 	esi, Logical_DOSDisks
  3141 00007470 B001                <1> 	mov 	al, 1 ; Initialization sign (invalid_fd_parameter)
  3142 00007472 83C67E              <1> 	add 	esi, LD_MediaChanged ; Media Change Status = 1 (init needed)
  3143 00007475 8806                <1> 	mov 	[esi], al ; A:
  3144 00007477 81C600010000        <1> 	add 	esi, 100h 
  3145 0000747D 8806                <1> 	mov 	[esi], al ; B: 
  3146                              <1>            
  3147                              <1> _current_drive_bootdisk:
  3148 0000747F 8A15[0A6E0000]      <1> 	mov 	dl, [boot_drv] ; physical drive number
  3149 00007485 80FAFF              <1> 	cmp 	dl, 0FFh
  3150 00007488 740A                <1> 	je 	short _last_dos_diskno_check
  3151                              <1> _boot_drive_check:
  3152 0000748A 80FA80              <1> 	cmp 	dl, 80h
  3153 0000748D 7218                <1> 	jb 	short _current_drive_a
  3154 0000748F 80EA7E              <1> 	sub 	dl, 7Eh ; C = 2 , D = 3
  3155 00007492 EB13                <1> 	jmp 	short _current_drive_a 
  3156                              <1> 
  3157                              <1> _last_dos_diskno_check:
  3158 00007494 8A15[C2400100]      <1> 	mov 	dl, [Last_DOS_DiskNo]
  3159 0000749A 80FA02              <1> 	cmp 	dl, 2
  3160 0000749D 7706                <1> 	ja 	short _current_drive_c
  3161 0000749F 7406                <1> 	je 	short _current_drive_a
  3162 000074A1 30D2                <1> 	xor 	dl, dl ; A:
  3163 000074A3 EB02                <1> 	jmp 	short _current_drive_a
  3164                              <1> 
  3165                              <1> _current_drive_c:
  3166 000074A5 B202                <1> 	mov 	dl, 2 ; C:
  3167                              <1> 
  3168                              <1> _current_drive_a:
  3169 000074A7 8815[0B6E0000]      <1> 	mov	[drv], dl
  3170 000074AD BE[C4400100]        <1>         mov     esi, msg_CRLF_temp
  3171 000074B2 E8AE000000          <1> 	call 	print_msg
  3172                              <1> 
  3173 000074B7 8A15[0B6E0000]      <1> 	mov	dl, [drv]
  3174                              <1> _default_drive_c:
  3175 000074BD E82C0C0000          <1> 	call 	change_current_drive
  3176 000074C2 731C                <1> 	jnc 	short _start_mainprog
  3177                              <1> 
  3178                              <1> _drv_not_ready_error: 
  3179 000074C4 BE[7F430100]        <1> 	mov 	esi, msgl_drv_not_ready
  3180 000074C9 E897000000          <1> 	call 	print_msg
  3181                              <1>         ;jmp	_end_of_mainprog
  3182                              <1> 
  3183                              <1> 	; 20/01/2018
  3184 000074CE B202                <1> 	mov	dl, 2
  3185 000074D0 3815[0B6E0000]      <1> 	cmp	[drv], dl
  3186 000074D6 736B                <1> 	jnb	short _end_of_mainprog
  3187 000074D8 8815[0B6E0000]      <1> 	mov	[drv], dl
  3188 000074DE EBDD                <1> 	jmp	short _default_drive_c
  3189                              <1> 
  3190                              <1> _start_mainprog:
  3191                              <1> 	; 07/01/2017
  3192                              <1> 	; 07/05/2016
  3193                              <1> 	; 02/05/2016
  3194                              <1> 	; 24/04/2016
  3195                              <1> 	; Retro UNIX 386 v1, 'sys_init' (u0.s)
  3196                              <1> 	; 23/06/2015
  3197                              <1> 
  3198                              <1> 	; 02/05/2016
  3199                              <1> 	; 24/04/2016
  3200 000074E0 66B80100            <1> 	mov	ax, 1
  3201 000074E4 A2[B3030300]        <1> 	mov	[u.uno], al
  3202 000074E9 66A3[4E030300]      <1> 	mov	[mpid], ax
  3203 000074EF 66A3[20000300]      <1> 	mov	[p.pid], ax
  3204 000074F5 A2[B0000300]        <1> 	mov	[p.stat], al
  3205 000074FA C605[A8030300]04    <1> 	mov	byte [u.quant], time_count  ; 07/01/2017
  3206                              <1> 	;
  3207 00007501 A1[308A0100]        <1> 	mov	eax, [k_page_dir]
  3208 00007506 A3[B8030300]        <1> 	mov	[u.pgdir], eax ; reset
  3209                              <1> 	;
  3210 0000750B E8CBE6FFFF          <1> 	call	allocate_page
  3211 00007510 0F82B5000000        <1> 	jc	panic
  3212 00007516 A3[B4030300]        <1> 	mov	[u.upage], eax ; user structure page	
  3213 0000751B A3[C0000300]        <1> 	mov	[p.upage], eax
  3214 00007520 E830E7FFFF          <1> 	call	clear_page
  3215                              <1> 	;
  3216                              <1> 	; 24/08/2015
  3217 00007525 FE0D[5B030300]      <1> 	dec 	byte [sysflg] ; FFh = ready for system call
  3218                              <1> 			      ; 0 = executing a system call
  3219                              <1> 	; 13/04/2016
  3220                              <1> 	; Clear Environment Variables Page/Area
  3221 0000752B BF00300900          <1> 	mov	edi, Env_Page ; 93000h
  3222 00007530 B980000000          <1> 	mov	ecx, Env_Page_Size / 4 	; 512/4  (4096/4)				 	  		 	  
  3223 00007535 31C0                <1> 	xor	eax, eax
  3224 00007537 F3AB                <1> 	rep	stosd
  3225                              <1> 
  3226                              <1> 	; 14/04/2016
  3227 00007539 E807350000          <1>  	call	mainprog_startup_configuration
  3228                              <1> 
  3229 0000753E E8EC0C0000          <1>         call    dos_prompt
  3230                              <1>               
  3231                              <1> _end_of_mainprog:
  3232 00007543 BE[C4400100]        <1>         mov     esi, msg_CRLF_temp
  3233 00007548 E818000000          <1> 	call 	print_msg
  3234 0000754D BE[CA400100]        <1> 	mov 	esi, mainprog_Version
  3235 00007552 E80E000000          <1> 	call 	print_msg
  3236                              <1> 	; 24/01/2016
  3237 00007557 28E4                <1> 	sub	ah, ah
  3238 00007559 E88F99FFFF          <1> 	call	int16h ; call getch
  3239 0000755E E96F9EFFFF          <1> 	jmp	cpu_reset
  3240                              <1> 
  3241 00007563 EBFE                <1> infinitiveloop: jmp short infinitiveloop
  3242                              <1> 
  3243                              <1> print_msg:
  3244                              <1> 	; 13/05/2016
  3245                              <1> 	; 04/01/2016
  3246                              <1> 	; 01/07/2015
  3247                              <1> 	; 13/03/2015 (Retro UNIX 386 v1)
  3248                              <1> 	; 07/03/2014 (Retro UNIX 8086 v1)
  3249                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX, ESI, EDI)
  3250                              <1> 	;
  3251 00007565 8A3D[5E8A0100]      <1> 	mov	bh, [ACTIVE_PAGE] ; 04/01/2016 (ptty)
  3252                              <1> 	;mov	bl, 07h ; Black background, light gray forecolor
  3253                              <1> 
  3254 0000756B AC                  <1> 	lodsb
  3255                              <1> pmsg1:
  3256 0000756C 56                  <1> 	push 	esi
  3257                              <1> 	;mov	bh, [ACTIVE_PAGE] ; 04/01/2016 (ptty)
  3258 0000756D B307                <1> 	mov	bl, 07h ; Black background, light gray forecolor
  3259 0000756F E891ADFFFF          <1> 	call 	_write_tty
  3260 00007574 5E                  <1> 	pop	esi
  3261 00007575 AC                  <1> 	lodsb
  3262 00007576 20C0                <1> 	and 	al, al
  3263 00007578 75F2                <1> 	jnz 	short pmsg1
  3264 0000757A C3                  <1> 	retn
  3265                              <1> 
  3266                              <1> clear_screen:
  3267                              <1> 	; 06/12/2020 
  3268                              <1> 	; 03/12/2020 (TRDOS 386 v2.0.3)
  3269                              <1> 	; 13/05/2016
  3270                              <1> 	; 30/01/2016
  3271                              <1> 	; 24/01/2016
  3272                              <1> 	; 04/01/2016
  3273 0000757B 0FB61D[5E8A0100]    <1> 	movzx	ebx, byte [ACTIVE_PAGE] ; video page number (0 to 7)
  3274 00007582 8AA3[EB6F0000]      <1> 	mov 	ah, [ebx+vmode] ; default = 03h (80x25 text)
  3275 00007588 80FC04              <1> 	cmp	ah, 4
  3276 0000758B 7205                <1> 	jb	short cls1
  3277 0000758D 80FC07              <1> 	cmp	ah, 7
  3278 00007590 7530                <1> 	jne	short vga_clear
  3279                              <1> cls1:
  3280                              <1> 	;mov	bh, bl
  3281                              <1> 	;mov	bl, 7
  3282 00007592 3A25[DA6F0000]      <1> 	cmp	ah, [CRT_MODE] ; current video mode ? 
  3283 00007598 740E                <1> 	je	short cls2 ; yes (current video mode = 3)
  3284                              <1> 	;;call	set_mode_3 ; set video mode to 3 (& clear screen)
  3285                              <1> 	;;retn
  3286                              <1> 	; 06/12/2020
  3287 0000759A 803D[1C120300]00    <1> 	cmp	byte [pmi32], 0
  3288 000075A1 771F                <1> 	ja	short vga_clear 	
  3289 000075A3 E967ADFFFF          <1> 	jmp	set_mode_3
  3290                              <1> cls2:
  3291 000075A8 88DF                <1> 	mov	bh, bl ; video page (0 to 7)
  3292 000075AA B307                <1> 	mov	bl, 07h ; attribute to be used on blanked line
  3293 000075AC 28C0                <1> 	sub 	al, al ; 0 =  entire window
  3294 000075AE 6631C9              <1> 	xor 	cx, cx
  3295 000075B1 66BA4F18            <1> 	mov 	dx, 184Fh
  3296 000075B5 E88BAAFFFF          <1> 	call	_scroll_up ; 24/01/2016
  3297                              <1> 	;
  3298                              <1> 	;mov	bh, [ACTIVE_PAGE] ; video page number (0 to 7)
  3299 000075BA 6631D2              <1> 	xor 	dx, dx
  3300                              <1> 	;call	_set_cpos ; 24/01/2016 
  3301                              <1> 	;;retn
  3302                              <1> 	; 03/12/2020
  3303 000075BD E9DDADFFFF          <1> 	jmp	_set_cpos ; returns to the caller of this proc
  3304                              <1> ;cls3:
  3305                              <1> ;	retn
  3306                              <1> 	; 06/12/2020
  3307                              <1> vga_clear:
  3308                              <1> 	; 03/12/2020
  3309                              <1> 	; set mode by using _int10h
  3310                              <1> 	; (also clears screen)
  3311 000075C2 88E0                <1> 	mov	al, ah
  3312 000075C4 28E4                <1> 	sub	ah, ah  ; set current video mode
  3313                              <1> 	;call	_int10h ; simulates int 10h in TRDOS 386 kernel
  3314                              <1> 	;jmp	short cls3
  3315 000075C6 E9A6A1FFFF          <1> 	jmp	_int10h ; returns to the caller of this proc
  3316                              <1> 
  3317                              <1> panic:
  3318                              <1> 	; 13/05/2016 (TRDOS 386 = TRDOS v2)
  3319                              <1> 	; 13/03/2015 (Retro UNIX 386 v1)
  3320                              <1> 	; 07/03/2014 (Retro UNIX 8086 v1)
  3321 000075CB BE[874D0100]        <1> 	mov 	esi, panic_msg
  3322 000075D0 E890FFFFFF          <1> 	call 	print_msg
  3323                              <1> key_to_reboot:
  3324                              <1>         ; 24/01/2016
  3325 000075D5 28E4                <1>         sub     ah, ah
  3326 000075D7 E81199FFFF          <1>         call    int16h ; call   getch
  3327                              <1>         ; wait for a character from the current tty
  3328                              <1> 	;
  3329 000075DC B00A                <1> 	mov	al, 0Ah
  3330 000075DE 8A3D[5E8A0100]      <1> 	mov	bh, [ptty] ; [ACTIVE_PAGE]
  3331 000075E4 B307                <1> 	mov	bl, 07h ; Black background, 
  3332                              <1> 			; light gray forecolor
  3333 000075E6 E81AADFFFF          <1> 	call 	_write_tty
  3334 000075EB E9E29DFFFF          <1> 	jmp	cpu_reset 
  3335                              <1> 
  3336                              <1> ctrlbrk:
  3337                              <1> 	; 12/11/2015
  3338                              <1> 	; 13/03/2015 (Retro UNIX 386 v1)
  3339                              <1> 	; 06/12/2013 (Retro UNIX 8086 v1)
  3340                              <1> 	;
  3341                              <1> 	; INT 1Bh (control+break) handler		
  3342                              <1> 	;
  3343                              <1>       	; Retro Unix 8086 v1 feature only!
  3344                              <1>       	;
  3345 000075F0 66833D[AA030300]00  <1> 	cmp 	word [u.intr], 0
  3346 000075F8 7645                <1> 	jna 	short cbrk4
  3347                              <1> cbrk0:
  3348                              <1> 	; 12/11/2015
  3349                              <1> 	; 06/12/2013
  3350 000075FA 66833D[AC030300]00  <1> 	cmp 	word [u.quit], 0
  3351 00007602 743B                <1> 	jz	short cbrk4
  3352                              <1> 	;
  3353                              <1> 	; 20/09/2013	
  3354 00007604 6650                <1> 	push 	ax
  3355 00007606 A0[5E8A0100]        <1> 	mov	al, [ptty]
  3356                              <1> 	;
  3357                              <1> 	; 12/11/2015
  3358                              <1> 	;
  3359                              <1> 	; ctrl+break (EOT, CTRL+D) from serial port
  3360                              <1> 	; or ctrl+break from console (pseudo) tty
  3361                              <1> 	; (!redirection!)
  3362                              <1> 	;
  3363 0000760B 3C08                <1> 	cmp	al, 8 ; serial port tty nums > 7
  3364 0000760D 7211                <1>         jb      short cbrk1 ; console (pseudo) tty
  3365                              <1> 	;	
  3366                              <1> 	; Serial port interrupt handler sets [ptty]
  3367                              <1> 	; to the port's tty number (as temporary).
  3368                              <1> 	;
  3369                              <1> 	; If active process is using a stdin or 
  3370                              <1> 	; stdout redirection (by the shell),
  3371                              <1>         ; console tty keyboard must be available
  3372                              <1> 	; to terminate running process,
  3373                              <1> 	; in order to prevent a deadlock. 
  3374                              <1> 	;
  3375 0000760F 52                  <1> 	push	edx
  3376 00007610 0FB615[B3030300]    <1> 	movzx	edx, byte [u.uno]
  3377 00007617 3A82[7F000300]      <1> 	cmp     al, [edx+p.ttyc-1] ; console tty (rw)
  3378 0000761D 5A                  <1> 	pop	edx
  3379 0000761E 7412                <1> 	je	short cbrk2
  3380                              <1> cbrk1:
  3381 00007620 FEC0                <1> 	inc 	al  ; [u.ttyp] : 1 based tty number
  3382                              <1> 	; 06/12/2013
  3383 00007622 3A05[94030300]      <1> 	cmp	al, [u.ttyp] ; recent open tty (r)
  3384 00007628 7408                <1> 	je	short cbrk2	
  3385 0000762A 3A05[95030300]      <1>         cmp     al, [u.ttyp+1] ; recent open tty (w)
  3386 00007630 750B                <1> 	jne	short cbrk3	
  3387                              <1> cbrk2:
  3388                              <1> 	;; 06/12/2013
  3389                              <1> 	;mov	ax, [u.quit]
  3390                              <1> 	;and	ax, ax
  3391                              <1> 	;jz	short cbrk3
  3392                              <1> 	;
  3393 00007632 6631C0              <1> 	xor	ax, ax ; 0
  3394 00007635 6648                <1> 	dec	ax
  3395                              <1> 	; 0FFFFh = 'ctrl+brk' keystroke
  3396 00007637 66A3[AC030300]      <1> 	mov	[u.quit], ax
  3397                              <1> cbrk3:
  3398 0000763D 6658                <1> 	pop	ax
  3399                              <1> cbrk4:
  3400 0000763F C3                  <1> 	retn
  3401                              <1> 
  3402                              <1> 
  3403                              <1> ; 31/12/2017
  3404                              <1> ; TRDOS 386 - 30/12/2017
  3405                              <1> %define get_rtc_date RTC_40
  3406                              <1> %define get_rtc_time RTC_20
  3407                              <1> %define	set_rtc_date RTC_50
  3408                              <1> %define set_rtc_time RTC_30	
  3409                              <1> get_rtc_date_time:
  3410                              <1> ; Retro UNIX 8086 v1 - UNIX.ASM (01/09/2014)
  3411                              <1> ;epoch:
  3412                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0)
  3413                              <1> 	; 15/03/2015 (Retro UNIX 386 v1 - 32 bit version)
  3414                              <1> 	; 09/04/2013 (Retro UNIX 8086 v1 - UNIX.ASM)
  3415                              <1> 	; 'epoch' procedure prototype: 
  3416                              <1> 	; 	            UNIXCOPY.ASM, 10/03/2013
  3417                              <1> 	; 14/11/2012
  3418                              <1> 	; unixboot.asm (boot file configuration)
  3419                              <1> 	; version of "epoch" procedure in "unixproc.asm"
  3420                              <1> 	; 21/7/2012
  3421                              <1> 	; 15/7/2012
  3422                              <1> 	; 14/7/2012		
  3423                              <1> 	; Erdogan Tan - RETRO UNIX v0.1
  3424                              <1> 	; compute current date and time as UNIX Epoch/Time
  3425                              <1> 	; UNIX Epoch: seconds since 1/1/1970 00:00:00
  3426                              <1> 	;
  3427                              <1>         ;  ((Modified registers: EAX, EDX, ECX, EBX))  
  3428                              <1> 	;
  3429                              <1> 
  3430 00007640 E86DF4FFFF          <1> 	call 	get_rtc_time		; Return Current Time
  3431 00007645 86E9                <1>         xchg 	ch,cl
  3432 00007647 66890D[FE860100]    <1>         mov 	[hour], cx
  3433 0000764E 86F2                <1>         xchg 	dh,dl
  3434 00007650 668915[02870100]    <1>         mov 	[second], dx
  3435                              <1> 	;
  3436 00007657 E8C7F4FFFF          <1>         call 	get_rtc_date		; Return Current Date
  3437 0000765C 86E9                <1>         xchg 	ch,cl
  3438 0000765E 66890D[F8860100]    <1>         mov 	[year], cx
  3439 00007665 86F2                <1>         xchg 	dh,dl
  3440 00007667 668915[FA860100]    <1>         mov 	[month], dx
  3441                              <1> 	;
  3442 0000766E 66B93030            <1> 	mov 	cx, 3030h
  3443                              <1> 	;
  3444 00007672 A0[FE860100]        <1> 	mov 	al, [hour] ; Hour
  3445                              <1>         	; AL <= BCD number)
  3446 00007677 D410                <1>         db 	0D4h,10h		; Undocumented inst. AAM
  3447                              <1> 					; AH = AL / 10h
  3448                              <1> 					; AL = AL MOD 10h
  3449 00007679 D50A                <1>         aad 	; AX= AH*10+AL
  3450 0000767B A2[FE860100]        <1> 	mov 	[hour], al
  3451 00007680 A0[FF860100]        <1> 	mov 	al, [hour+1] ; Minute
  3452                              <1>         	; AL <= BCD number)
  3453 00007685 D410                <1>         db 	0D4h,10h		; Undocumented inst. AAM
  3454                              <1> 					; AH = AL / 10h
  3455                              <1> 					; AL = AL MOD 10h
  3456 00007687 D50A                <1>         aad 	; AX= AH*10+AL
  3457 00007689 A2[00870100]        <1> 	mov 	[minute], al
  3458 0000768E A0[02870100]        <1> 	mov 	al, [second] ; Second
  3459                              <1>         	; AL <= BCD number)
  3460 00007693 D410                <1>         db 	0D4h,10h		; Undocumented inst. AAM
  3461                              <1> 					; AH = AL / 10h
  3462                              <1> 					; AL = AL MOD 10h
  3463 00007695 D50A                <1>         aad 	; AX= AH*10+AL
  3464 00007697 A2[02870100]        <1> 	mov 	[second], al
  3465 0000769C 66A1[F8860100]      <1> 	mov 	ax, [year] ; Year (century)
  3466 000076A2 6650                <1>         push 	ax
  3467                              <1> 	   	; AL <= BCD number)
  3468 000076A4 D410                <1>         db 	0D4h,10h		; Undocumented inst. AAM
  3469                              <1> 					; AH = AL / 10h
  3470                              <1> 					; AL = AL MOD 10h
  3471 000076A6 D50A                <1>         aad 	; AX= AH*10+AL
  3472 000076A8 B464                <1> 	mov 	ah, 100
  3473 000076AA F6E4                <1> 	mul 	ah
  3474 000076AC 66A3[F8860100]      <1> 	mov 	[year], ax
  3475 000076B2 6658                <1> 	pop	ax
  3476 000076B4 88E0                <1> 	mov	al, ah
  3477                              <1>         	; AL <= BCD number)
  3478 000076B6 D410                <1>         db 	0D4h,10h		; Undocumented inst. AAM
  3479                              <1> 					; AH = AL / 10h
  3480                              <1> 					; AL = AL MOD 10h
  3481 000076B8 D50A                <1>         aad 	; AX= AH*10+AL
  3482 000076BA 660105[F8860100]    <1> 	add 	[year], ax
  3483 000076C1 A0[FA860100]        <1> 	mov 	al, [month] ; Month
  3484                              <1>            	; AL <= BCD number)
  3485 000076C6 D410                <1>         db 	0D4h,10h		; Undocumented inst. AAM
  3486                              <1> 					; AH = AL / 10h
  3487                              <1> 					; AL = AL MOD 10h
  3488 000076C8 D50A                <1>         aad 	; AX= AH*10+AL
  3489 000076CA A2[FA860100]        <1> 	mov 	[month], al	
  3490 000076CF A0[FB860100]        <1>         mov     al, [month+1]      	; Day
  3491                              <1>            	; AL <= BCD number)
  3492 000076D4 D410                <1>         db 	0D4h,10h		; Undocumented inst. AAM
  3493                              <1> 					; AH = AL / 10h
  3494                              <1> 					; AL = AL MOD 10h
  3495 000076D6 D50A                <1>         aad 	; AX= AH*10+AL
  3496 000076D8 A2[FC860100]        <1>         mov     [day], al
  3497                              <1> 	
  3498 000076DD C3                  <1> 	retn	; 30/12/2017
  3499                              <1> 
  3500                              <1> epoch:
  3501 000076DE E85DFFFFFF          <1> 	call	get_rtc_date_time ; TRDOS 386 - 30/12/2017
  3502                              <1> 
  3503                              <1> convert_to_epoch:
  3504                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0)
  3505                              <1> 	; 15/03/2015 (Retro UNIX 386 v1 - 32 bit modification)
  3506                              <1> 	; 09/04/2013 (Retro UNIX 8086 v1)
  3507                              <1> 	;
  3508                              <1> 	; ((Modified registers: EAX, EDX, EBX)) 
  3509                              <1> 	;
  3510                              <1> 	; Derived from DALLAS Semiconductor
  3511                              <1> 	; Application Note 31 (DS1602/DS1603)
  3512                              <1> 	; 6 May 1998
  3513 000076E3 29C0                <1> 	sub 	eax, eax
  3514 000076E5 66A1[F8860100]      <1> 	mov 	ax, [year]
  3515 000076EB 662DB207            <1> 	sub 	ax, 1970
  3516 000076EF BA6D010000          <1> 	mov 	edx, 365
  3517 000076F4 F7E2                <1> 	mul 	edx
  3518 000076F6 31DB                <1> 	xor 	ebx, ebx
  3519 000076F8 8A1D[FA860100]      <1> 	mov 	bl, [month]
  3520 000076FE FECB                <1> 	dec 	bl
  3521 00007700 D0E3                <1> 	shl 	bl, 1
  3522                              <1> 	;sub	edx, edx
  3523 00007702 668B93[04870100]    <1> 	mov 	dx, [EBX+DMonth]
  3524 00007709 8A1D[FC860100]      <1>         mov     bl, [day]
  3525 0000770F FECB                <1> 	dec 	bl
  3526 00007711 01D0                <1> 	add 	eax, edx
  3527 00007713 01D8                <1> 	add 	eax, ebx
  3528                              <1> 			; EAX = days since 1/1/1970
  3529 00007715 668B15[F8860100]    <1> 	mov 	dx, [year]
  3530 0000771C 6681EAB107          <1> 	sub 	dx, 1969
  3531 00007721 66D1EA              <1> 	shr 	dx, 1
  3532 00007724 66D1EA              <1> 	shr 	dx, 1		
  3533                              <1> 		; (year-1969)/4
  3534 00007727 01D0                <1> 	add 	eax, edx
  3535                              <1> 			; + leap days since 1/1/1970
  3536 00007729 803D[FA860100]02    <1> 	cmp 	byte [month], 2	; if past february
  3537 00007730 7610                <1> 	jna 	short cte1
  3538 00007732 668B15[F8860100]    <1> 	mov 	dx, [year]
  3539 00007739 6683E203            <1> 	and 	dx, 3 ; year mod 4
  3540 0000773D 7503                <1> 	jnz 	short cte1		
  3541                              <1> 			; and if leap year
  3542 0000773F 83C001              <1> 	add 	eax, 1 	; add this year's leap day (february 29)
  3543                              <1> cte1: 			; compute seconds since 1/1/1970
  3544 00007742 BA18000000          <1> 	mov 	edx, 24
  3545 00007747 F7E2                <1> 	mul	edx
  3546 00007749 8A15[FE860100]      <1> 	mov 	dl, [hour]
  3547 0000774F 01D0                <1> 	add 	eax, edx
  3548                              <1> 		; EAX = hours since 1/1/1970 00:00:00
  3549                              <1> 	;mov	ebx, 60
  3550 00007751 B33C                <1> 	mov	bl, 60
  3551 00007753 F7E3                <1> 	mul	ebx
  3552 00007755 8A15[00870100]      <1> 	mov 	dl, [minute]
  3553 0000775B 01D0                <1> 	add 	eax, edx
  3554                              <1> 		; EAX = minutes since 1/1/1970 00:00:00
  3555                              <1> 	;mov 	ebx, 60
  3556 0000775D F7E3                <1> 	mul	ebx
  3557 0000775F 8A15[02870100]      <1> 	mov 	dl, [second]
  3558 00007765 01D0                <1> 	add 	eax, edx
  3559                              <1>  		; EAX -> seconds since 1/1/1970 00:00:00
  3560 00007767 C3                  <1> 	retn
  3561                              <1> 
  3562                              <1> ;set_date_time:
  3563                              <1> convert_from_epoch:
  3564                              <1> 	; 31/12/2017 (v2.0.0)
  3565                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0)
  3566                              <1> 	; 15/03/2015 (Retro UNIX 386 v1 - 32 bit version)
  3567                              <1> 	; 20/06/2013 (Retro UNIX 8086 v1)
  3568                              <1> 	; 'convert_from_epoch' procedure prototype: 
  3569                              <1> 	; 	            UNIXCOPY.ASM, 10/03/2013
  3570                              <1> 	;
  3571                              <1> 	; ((Modified registers: EAX, EDX, ECX, EBX))	
  3572                              <1> 	;
  3573                              <1> 	; Derived from DALLAS Semiconductor
  3574                              <1> 	; Application Note 31 (DS1602/DS1603)
  3575                              <1> 	; 6 May 1998
  3576                              <1> 	;
  3577                              <1> 	; INPUT:
  3578                              <1> 	; EAX = Unix (Epoch) Time
  3579                              <1> 	;
  3580 00007768 31D2                <1> 	xor 	edx, edx
  3581 0000776A B93C000000          <1> 	mov 	ecx, 60
  3582 0000776F F7F1                <1> 	div	ecx
  3583                              <1> 	;mov 	[imin], eax   ; whole minutes
  3584                              <1> 			  ; since 1/1/1970
  3585 00007771 668915[02870100]    <1> 	mov 	[second], dx  ; leftover seconds
  3586 00007778 29D2                <1> 	sub 	edx, edx
  3587 0000777A F7F1                <1> 	div	ecx
  3588                              <1> 	;mov 	[ihrs], eax   ; whole hours
  3589                              <1> 	;		      ; since 1/1/1970
  3590 0000777C 668915[00870100]    <1> 	mov 	[minute], dx  ; leftover minutes
  3591 00007783 31D2                <1> 	xor	edx, edx
  3592                              <1> 	;mov 	cx, 24
  3593 00007785 B118                <1> 	mov 	cl, 24
  3594 00007787 F7F1                <1> 	div	ecx
  3595                              <1> 	;mov 	[iday], ax   ; whole days
  3596                              <1> 			     ; since 1/1/1970
  3597 00007789 668915[FE860100]    <1> 	mov 	[hour], dx   ; leftover hours
  3598 00007790 05DB020000          <1> 	add 	eax, 365+366 ; whole day since
  3599                              <1> 			     ; 1/1/1968 	
  3600                              <1> 	;mov 	[iday], ax
  3601 00007795 50                  <1> 	push 	eax
  3602 00007796 29D2                <1> 	sub	edx, edx
  3603 00007798 B9B5050000          <1> 	mov 	ecx, (4*365)+1 ; 4 years = 1461 days
  3604 0000779D F7F1                <1> 	div	ecx
  3605 0000779F 59                  <1> 	pop 	ecx
  3606                              <1> 	;mov 	[lday], ax   ; count of quadyrs (4 years)
  3607 000077A0 6652                <1> 	push 	dx
  3608                              <1> 	;mov 	[qday], dx   ; days since quadyr began
  3609 000077A2 6683FA3C            <1> 	cmp 	dx, 31 + 29  ; if past feb 29 then
  3610 000077A6 F5                  <1> 	cmc		     ; add this quadyr's leap day
  3611 000077A7 83D000              <1> 	adc 	eax, 0	     ; to # of qadyrs (leap days)
  3612                              <1> 	;mov 	[lday], ax   ; since 1968			  
  3613                              <1> 	;mov 	cx, [iday]
  3614 000077AA 91                  <1> 	xchg 	ecx, eax     ; ECX = lday, EAX = iday		  
  3615 000077AB 29C8                <1> 	sub 	eax, ecx     ; iday - lday
  3616 000077AD B96D010000          <1> 	mov 	ecx, 365
  3617 000077B2 31D2                <1> 	xor	edx, edx
  3618                              <1> 	; EAX = iday-lday, EDX = 0
  3619 000077B4 F7F1                <1> 	div	ecx
  3620                              <1> 	;mov 	[iyrs], ax   ; whole years since 1968
  3621                              <1> 	;jday = iday - (iyrs*365) - lday
  3622                              <1> 	;mov [jday], dx      ; days since 1/1 of current year
  3623                              <1> 	;add	eax, 1968
  3624 000077B6 6605B007            <1> 	add 	ax, 1968     ; compute year
  3625 000077BA 66A3[F8860100]      <1> 	mov 	[year], ax
  3626 000077C0 6689D1              <1> 	mov 	cx, dx
  3627                              <1> 	;mov 	dx, [qday]
  3628 000077C3 665A                <1> 	pop 	dx
  3629 000077C5 6681FA6D01          <1> 	cmp 	dx, 365	     ; if qday <= 365 and qday >= 60	
  3630 000077CA 7709                <1> 	ja 	short cfe1   ; jday = jday +1
  3631 000077CC 6683FA3C            <1> 	cmp 	dx, 60       ; if past 2/29 and leap year then
  3632 000077D0 F5                  <1>         cmc		     ; add a leap day to the # of whole
  3633 000077D1 6683D100            <1> 	adc 	cx, 0        ; days since 1/1 of current year
  3634                              <1> cfe1:			
  3635                              <1> 	;mov 	[jday], cx
  3636 000077D5 66BB0C00            <1> 	mov 	bx, 12       ; estimate month
  3637 000077D9 66BA6E01            <1> 	mov 	dx, 366      ; mday, max. days since 1/1 is 365
  3638 000077DD 6683E003            <1> 	and 	ax, 11b      ; year mod 4 (and dx, 3) 
  3639                              <1> cfe2:	; Month calculation  ; 0 to 11  (11 to 0)	
  3640 000077E1 6639D1              <1> 	cmp 	cx, dx       ; mday = # of days passed from 1/1
  3641 000077E4 731D                <1> 	jnb 	short cfe3
  3642 000077E6 664B                <1> 	dec 	bx           ; month = month - 1
  3643 000077E8 66D1E3              <1> 	shl 	bx, 1 
  3644 000077EB 668B93[04870100]    <1> 	mov 	dx, [EBX+DMonth] ; # elapsed days at 1st of month
  3645 000077F2 66D1EB              <1> 	shr 	bx, 1        ; bx = month - 1 (0 to 11)
  3646 000077F5 6683FB01            <1> 	cmp	bx, 1        ; if month > 2 and year mod 4  = 0	
  3647 000077F9 76E6                <1> 	jna 	short cfe2   ; then mday = mday + 1
  3648 000077FB 08C0                <1> 	or 	al, al       ; if past 2/29 and leap year then
  3649 000077FD 75E2                <1> 	jnz 	short cfe2   ; add leap day (to mday)
  3650 000077FF 6642                <1> 	inc 	dx           ; mday = mday + 1
  3651 00007801 EBDE                <1> 	jmp 	short cfe2
  3652                              <1> cfe3:
  3653 00007803 6643                <1> 	inc 	bx	     ; -> bx = month, 1 to 12
  3654 00007805 66891D[FA860100]    <1> 	mov 	[month], bx
  3655 0000780C 6629D1              <1> 	sub 	cx, dx	     ; day = jday - mday + 1	
  3656 0000780F 6641                <1> 	inc 	cx 			  
  3657 00007811 66890D[FC860100]    <1> 	mov 	[day], cx
  3658                              <1> 	
  3659                              <1> 	; eax, ebx, ecx, edx is changed at return
  3660                              <1> 	; output ->
  3661                              <1> 	; [year], [month], [day], [hour], [minute], [second]
  3662                              <1> 
  3663 00007818 C3                  <1> 	retn	; 31/12/2017 (TRDOS 386)
  3664                              <1> 
  3665                              <1> set_rtc_date_time:
  3666                              <1> 	; 31/12/2017 (v2.0.0)
  3667                              <1> 	; 30/12/2017 (TRDOS 386)
  3668                              <1> 	; 15/03/2015 (Retro UNIX 386 v1 - 32 bit version)
  3669                              <1> 	; 20/06/2013 (Retro UNIX 8086 v1)
  3670 00007819 E80F000000          <1> 	call	set_date_bcd
  3671                              <1> 	; Set real-time clock date
  3672 0000781E E82DF3FFFF          <1> 	call	set_rtc_date ; RTC_50
  3673                              <1> 	; Set real-time clock time
  3674 00007823 E832000000          <1> 	call	set_time_bcd
  3675 00007828 E9B4F2FFFF          <1> 	jmp	set_rtc_time ; RTC_30	
  3676                              <1> 
  3677                              <1> ; 31/12/2017
  3678                              <1> set_date_bcd:
  3679 0000782D A0[F9860100]        <1>         mov     al, [year+1]
  3680 00007832 D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
  3681 00007834 D510                <1> 	db 	0D5h,10h     ; Undocumented inst. AAD
  3682                              <1> 			     ; AL = AH * 10h + AL
  3683 00007836 88C5                <1> 	mov 	ch, al ; century (BCD)
  3684 00007838 A0[F8860100]        <1> 	mov 	al, [year]
  3685 0000783D D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
  3686 0000783F D510                <1> 	db 	0D5h,10h     ; Undocumented inst. AAD
  3687                              <1> 			     ; AL = AH * 10h + AL
  3688 00007841 88C1                <1> 	mov 	cl, al ; year (BCD)
  3689 00007843 A0[FA860100]        <1>         mov 	al, [month]
  3690 00007848 D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
  3691 0000784A D510                <1> 	db 	0D5h,10h     ; Undocumented inst. AAD
  3692                              <1> 			     ; AL = AH * 10h + AL
  3693 0000784C 88C6                <1> 	mov 	dh, al ; month (BCD)
  3694 0000784E A0[FC860100]        <1> 	mov 	al, [day]
  3695 00007853 D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
  3696 00007855 D510                <1> 	db 	0D5h,10h     ; Undocumented inst. AAD
  3697                              <1> 			     ; AL = AH * 10h + AL
  3698 00007857 88C6                <1> 	mov 	dh, al ; day (BCD)
  3699 00007859 C3                  <1> 	retn	; 30/12/2017
  3700                              <1> 
  3701                              <1> ; 31/12/2017
  3702                              <1> set_time_bcd:
  3703                              <1>         ; Read real-time clock time 
  3704                              <1> 	; (get day light saving time bit status)
  3705 0000785A FA                  <1>  	cli
  3706 0000785B E842F4FFFF          <1> 	CALL	UPD_IPR 		; CHECK FOR UPDATE IN PROCESS
  3707                              <1> 	; cf = 1 -> al = 0
  3708 00007860 7207                <1>         jc      short stime1
  3709 00007862 B00B                <1> 	MOV	AL,CMOS_REG_B		; ADDRESS ALARM REGISTER
  3710 00007864 E854F4FFFF          <1> 	CALL	CMOS_READ		; READ CURRENT VALUE OF DSE BIT
  3711                              <1> stime1:
  3712 00007869 FB                  <1> 	sti
  3713 0000786A 2401                <1> 	AND	AL,00000001B		; MASK FOR VALID DSE BIT
  3714 0000786C 88C2                <1> 	MOV	DL,AL			; SET [DL] TO ZERO FOR NO DSE BIT
  3715                              <1> 	; DL = 1 or 0 (day light saving time)
  3716                              <1> 	;	
  3717 0000786E A0[FE860100]        <1> 	mov 	al, [hour]
  3718 00007873 D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
  3719 00007875 D510                <1> 	db 	0D5h,10h     ; Undocumented inst. AAD
  3720                              <1> 			     ; AL = AH * 10h + AL
  3721 00007877 88C5                <1> 	mov 	ch, al ; hour (BCD)
  3722 00007879 A0[00870100]        <1>         mov     al, [minute]
  3723 0000787E D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
  3724 00007880 D510                <1> 	db 	0D5h,10h     ; Undocumented inst. AAD
  3725                              <1> 			     ; AL = AH * 10h + AL
  3726 00007882 88C1                <1> 	mov 	cl, al       ; minute (BCD)
  3727 00007884 A0[02870100]        <1>         mov     al, [second]
  3728 00007889 D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
  3729 0000788B D510                <1> 	db 	0D5h,10h     ; Undocumented inst. AAD
  3730                              <1> 			     ; AL = AH * 10h + AL
  3731 0000788D 88C6                <1> 	mov 	dh, al	     ; second (BCD)
  3732 0000788F C3                  <1> 	retn	; 30/12/2017
  3088                                  %include 'trdosk2.s' ; 04/01/2016
  3089                              <1> ; ****************************************************************************
  3090                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.2) - DRV INIT : trdosk2.s
  3091                              <1> ; ----------------------------------------------------------------------------
  3092                              <1> ; Last Update: 30/08/2020
  3093                              <1> ; ----------------------------------------------------------------------------
  3094                              <1> ; Beginning: 04/01/2016
  3095                              <1> ; ----------------------------------------------------------------------------
  3096                              <1> ; Assembler: NASM version 2.14 (trdos386.s)
  3097                              <1> ; ----------------------------------------------------------------------------
  3098                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
  3099                              <1> ; TRDOS2.ASM (09/11/2011)
  3100                              <1> ; ****************************************************************************
  3101                              <1> ; DRV_INIT.ASM (c) 2009-2011 Erdogan TAN  [26/09/2009] Last Update: 07/08/2011
  3102                              <1> ;
  3103                              <1> 
  3104                              <1> ldrv_init: ; Logical Drive Initialization
  3105                              <1> 	; 30/08/2020
  3106                              <1> 	; 25/08/2020
  3107                              <1> 	; 11/08/2020, 13/08/2020
  3108                              <1> 	; 17/07/2020, 20/07/2020
  3109                              <1> 	; 14/07/2020, 15/07/2020
  3110                              <1> 	; 30/01/2018
  3111                              <1> 	; 27/12/2017
  3112                              <1> 	; 12/02/2016
  3113                              <1> 	; 06/01/2016
  3114                              <1> 	;  	('diskinit.inc', 'diskio.inc' integration)
  3115                              <1> 	; 04/01/2016 (TRDOS 386 = TRDOS v2.0)
  3116                              <1> 	; 07/08/2011
  3117                              <1> 	; 20/09/2009
  3118                              <1> 	; 2005
  3119                              <1> 
  3120                              <1> 	; 15/07/2020
  3121                              <1> 	;movzx	ecx, byte [HF_NUM] ; number of fixed disks
  3122                              <1> 	;cmp	cl, 1
  3123                              <1> 	;jnb	short load_hd_partition_tables
  3124                              <1> 
  3125 00007890 A0[CC8A0100]        <1> 	mov	al, [HF_NUM] ; number of fixed disks
  3126 00007895 20C0                <1> 	and 	al, al
  3127 00007897 7501                <1> 	jnz	short load_hd_partition_tables
  3128                              <1> 
  3129                              <1> 	; no any hard disks
  3130 00007899 C3                  <1> 	retn			
  3131                              <1> 
  3132                              <1> load_hd_partition_tables:
  3133                              <1> 	;mov	esi, [HDPM_TBL_VEC] ; primary master disk FDPT
  3134                              <1> 	; 15/07/2020
  3135 0000789A BE[D08A0100]        <1> 	mov	esi, HDPM_TBL_VEC
  3136 0000789F BF[F68E0100]        <1> 	mov 	edi, PTable_hd0
  3137 000078A4 B280                <1> 	mov 	dl, 80h
  3138                              <1> 	; 15/07/2020
  3139 000078A6 A2[0D6E0000]        <1> 	mov	[hdc], al
  3140                              <1> 	;xor	ecx, ecx ; 0
  3141                              <1> load_next_hd_partition_table:
  3142                              <1> 	; 20/07/2020
  3143 000078AB 31C9                <1> 	xor	ecx, ecx ; 0
  3144                              <1> 	;push	ecx
  3145 000078AD 57                  <1> 	push	edi ; *
  3146                              <1> 	;push	esi ; FDPT (+ DPTE) address
  3147                              <1> 	; 15/07/2020
  3148 000078AE AD                  <1> 	lodsd
  3149 000078AF 56                  <1> 	push	esi ; ** ; next FDPT (+ DPTE) address ptr
  3150                              <1> 	
  3151                              <1> 	;mov	al, [esi+20] ; DPTE offset 4
  3152                              <1> 	;and	al, 40h ;  LBA bit (bit 6)
  3153                              <1> 	;;shr	al, 6
  3154                              <1> 	;mov 	[HD_LBA_yes], al
  3155                              <1> 	
  3156                              <1> 	; 15/07/2020
  3157 000078B0 8A4814              <1> 	mov	cl, [eax+20]
  3158 000078B3 80E140              <1> 	and	cl, 40h
  3159 000078B6 880D[FA8F0100]      <1> 	mov	[HD_LBA_yes], cl
  3160                              <1> 	
  3161 000078BC E844040000          <1> 	call	load_masterboot
  3162                              <1> 	;jc	short pass_pt_this_hard_disk
  3163                              <1> 	; 13/08/2020
  3164 000078C1 0F828A000000        <1> 	jc	pass_pt_this_hard_disk
  3165                              <1> 
  3166 000078C7 BB[B48E0100]        <1> 	mov	ebx, PartitionTable
  3167 000078CC 89DE                <1> 	mov	esi, ebx
  3168                              <1> 	;mov	ecx, 16
  3169 000078CE B110                <1> 	mov	cl, 16
  3170 000078D0 F3A5                <1> 	rep 	movsd
  3171 000078D2 89DE                <1> 	mov 	esi, ebx 
  3172                              <1> 	;mov 	byte [hdc], 4 ; 4 - partition index
  3173                              <1> 	; 15/07/2020
  3174 000078D4 C605[FB8F0100]04    <1> 	mov	byte [PP_Counter], 4
  3175                              <1> loc_validate_hdp_partition:
  3176                              <1> 	;cmp 	byte [esi+ptFileSystemID], 0
  3177                              <1> 	;jna	short loc_validate_next_hdp_partition2
  3178                              <1> 	; 13/08/2020
  3179 000078DB 8A4604              <1> 	mov	al, [esi+ptFileSystemID]
  3180 000078DE 20C0                <1> 	and	al, al
  3181 000078E0 7457                <1> 	jz	short loc_validate_next_hdp_partition2
  3182                              <1> 
  3183 000078E2 56                  <1> 	push	esi ; *** ; Masterboot partition table offset
  3184 000078E3 52                  <1> 	push	edx ; **** ; dl = Physical drive number
  3185                              <1> 
  3186                              <1> 	; 13/08/2020
  3187 000078E4 3C05                <1> 	cmp	al, 05h  ; Extended partition CHS
  3188 000078E6 7404                <1>  	je	short loc_set_ep_counter
  3189 000078E8 3C0F                <1> 	cmp	al, 0Fh  ; Extended partition LBA
  3190 000078EA 7511                <1>  	jne	short loc_validate_next_hdp_partition0
  3191                              <1> 	
  3192                              <1> 	;;inc	byte [PP_Counter]
  3193                              <1> 	; 15/07/2020
  3194                              <1> 	;inc 	byte [EP_Counter] ; disk has valid partition(s)
  3195                              <1> 
  3196                              <1> loc_set_ep_counter:
  3197                              <1> 	; 13/08/2020
  3198 000078EC 803D[FC8F0100]80    <1> 	cmp	byte [EP_Counter], 80h
  3199 000078F3 7342                <1> 	jnb	short loc_validate_next_hdp_partition1
  3200                              <1> 
  3201 000078F5 8815[FC8F0100]      <1> 	mov	byte [EP_Counter], dl ; disk drv has extd. part.
  3202                              <1> 
  3203 000078FB EB3A                <1> 	jmp	short loc_validate_next_hdp_partition1
  3204                              <1> 
  3205                              <1> loc_validate_next_hdp_partition0:
  3206 000078FD 31FF                <1> 	xor	edi, edi ; 0  
  3207                              <1> 	; Input -> ESI = PartitionTable offset
  3208                              <1> 	; DL = Hard disk drive number 
  3209                              <1> 	; EDI = 0 -> Primary Partition
  3210                              <1> 	; EDI > 0 -> Extended Partition's Start Sector   
  3211 000078FF E885010000          <1> 	call 	validate_hd_fat_partition
  3212 00007904 730E                <1> 	jnc 	short loc_set_valid_hdp_partition_entry
  3213                              <1> 
  3214                              <1> 	;pop	edx
  3215                              <1> 	;push	edx
  3216 00007906 8B1424              <1> 	mov	edx, [esp]  ; ****
  3217 00007909 8B742404            <1> 	mov	esi, [esp+4] ; *** ; 30/01/2018
  3218 0000790D E8D1020000          <1> 	call	validate_hd_fs_partition
  3219 00007912 7223                <1> 	jc	short loc_validate_next_hdp_partition1
  3220                              <1> loc_set_valid_hdp_partition_entry:
  3221 00007914 8A0D[C2400100]      <1> 	mov 	cl, [Last_DOS_DiskNo] 
  3222 0000791A 80C141              <1> 	add 	cl, 'A'
  3223                              <1> 	; ESI = Logical dos drive description table address
  3224 0000791D 880E                <1> 	mov	[esi+LD_Name], cl
  3225                              <1> 	; 15/07/2020
  3226 0000791F 8A4602              <1> 	mov	al, [esi+LD_PhyDrvNo] ; Physical drive number
  3227                              <1> 	;mov	al, [esp] ; ****
  3228 00007922 2C7F                <1> 	sub	al, 7Fh
  3229                              <1> 		; AL = 1 to 4	
  3230 00007924 C0E002              <1> 	shl	al, 2 ; AL = 4 to 16
  3231                              <1> 
  3232 00007927 8A15[FB8F0100]      <1> 	mov	dl, [PP_Counter]
  3233                              <1> 
  3234                              <1> 	;sub	al, [PP_Counter]
  3235 0000792D 28D0                <1> 	sub	al, dl ; [PP_Counter] ; 4 - partition index
  3236                              <1> 
  3237                              <1> 	; AL = Partition entry/index, 0 based
  3238                              <1> 	;  0 -> hd 0, Partition Table offset = 0
  3239                              <1> 	; 15 -> hd 3, Partition Table offset = 3
  3240                              <1> 
  3241                              <1> 	;mov	[esi+LD_PartitionEntry], al 
  3242                              <1> 	
  3243                              <1> 	; 15/07/2020
  3244 0000792F B404                <1> 	mov	ah, 4
  3245                              <1> 	;sub	ah, [PP_Counter]
  3246 00007931 28D4                <1> 	sub	ah, dl
  3247                              <1> 
  3248                              <1> 	; AH = Primary partition index, 0 to 3 ; pt entry
  3249                              <1> 	;		(4 to 7 for logical disk partitions)
  3250                              <1> 
  3251                              <1> 	;mov 	[esi+LD_DParamEntry], ah 
  3252 00007933 6689467C            <1> 	mov 	[esi+LD_PartitionEntry], ax
  3253                              <1> 
  3254                              <1> loc_validate_next_hdp_partition1:
  3255 00007937 5A                  <1> 	pop 	edx ; **** ; dl = Physical drive number 
  3256 00007938 5E                  <1> 	pop	esi ; *** ; Masterboot partition table offset
  3257                              <1> 
  3258                              <1> loc_validate_next_hdp_partition2:
  3259                              <1> 	; ESI = PartitionTable offset
  3260                              <1> 	; DL = Hard/Fixed disk drive number
  3261                              <1> 	
  3262                              <1> 	;dec	byte [hdc] ; 4 - partition index
  3263                              <1> 	;jz	short pass_pt_this_hard_disk
  3264                              <1> 	; 15/07/2020
  3265 00007939 FE0D[FB8F0100]      <1> 	dec	byte [PP_Counter] ; 4 - partition index
  3266 0000793F 7410                <1> 	jz	short pass_pt_this_hard_disk
  3267                              <1> 	
  3268 00007941 83C610              <1> 	add	esi, 16 ; 10h
  3269 00007944 EB95                <1> 	jmp	short loc_validate_hdp_partition
  3270                              <1> 
  3271                              <1> loc_not_any_extd_partitions:
  3272                              <1> 	; 15/07/2020
  3273 00007946 C3                  <1> 	retn	
  3274                              <1> 
  3275                              <1> loc_next_hd_partition_table:
  3276 00007947 FEC2                <1> 	inc	dl
  3277                              <1> 	; 15/07/2020
  3278                              <1> 	;add	esi, 32 ; next FDPT address
  3279 00007949 83C740              <1> 	add	edi, 64 ; next partition table destination
  3280 0000794C E95AFFFFFF          <1>         jmp     load_next_hd_partition_table
  3281                              <1> 
  3282                              <1> pass_pt_this_hard_disk:
  3283                              <1> 	;pop	esi ; FDPT (+ DPTE) address
  3284                              <1> 	; 15/07/2020
  3285 00007951 5E                  <1> 	pop	esi ; ** ; next FDPT (+ DPTE) address ptr
  3286 00007952 5F                  <1> 	pop	edi ; * ; Ptable_hd?
  3287                              <1> 	;pop	ecx
  3288                              <1> 	;loop	loc_next_hd_partition_table
  3289 00007953 FE0D[0D6E0000]      <1> 	dec	byte [hdc]
  3290 00007959 75EC                <1> 	jnz	short loc_next_hd_partition_table
  3291                              <1> 
  3292                              <1> 	;cmp	byte [PP_Counter], 1
  3293                              <1> 	;jnb	short load_extended_dos_partitions
  3294                              <1> 	;; Empty partition table
  3295                              <1> 	;retn
  3296                              <1> 
  3297                              <1> 	; 11/08/2020
  3298                              <1> 	; 17/07/2020
  3299                              <1> check_extended_partitions:
  3300                              <1> 	; 15/07/2020
  3301                              <1> 	;cmp	byte [EP_Counter], 0
  3302                              <1> 	;jna	short loc_not_any_extd_partitions
  3303                              <1> 	; 13/08/2020
  3304 0000795B A0[FC8F0100]        <1> 	mov	al, [EP_Counter] ; 1st disk drv has extd partition
  3305 00007960 08C0                <1> 	or	al, al ; 0 ?
  3306 00007962 74E2                <1> 	jz	short loc_not_any_extd_partitions
  3307                              <1> 
  3308                              <1> load_extended_dos_partitions:
  3309                              <1> 	;mov	byte [hdc], 80h
  3310                              <1> 	; 13/08/2020
  3311 00007964 A2[0D6E0000]        <1> 	mov	byte [hdc], al ; 1st disk drv has extd partition
  3312                              <1> 	; 25/08/2020
  3313 00007969 2C80                <1> 	sub	al, 80h
  3314 0000796B 740E                <1> 	jz	short loc_set_ext_ptable_hd0
  3315 0000796D C0E006              <1> 	shl	al, 6 ; * 64
  3316 00007970 0FB6F0              <1> 	movzx	esi, al
  3317 00007973 81C6[F68E0100]      <1> 	add	esi, PTable_hd0
  3318 00007979 EB05                <1> 	jmp 	short next_hd_extd_partition
  3319                              <1> 
  3320                              <1> 	; 25/08/2020
  3321                              <1> loc_set_ext_ptable_hd0:
  3322 0000797B BE[F68E0100]        <1> 	mov	esi, PTable_hd0
  3323                              <1> 
  3324                              <1> next_hd_extd_partition:
  3325                              <1> 	; 17/07/2020
  3326                              <1> 	;mov 	byte [EP_Counter], 0 ; Reset for each physical disk
  3327                              <1> 	; 13/08/2020
  3328                              <1> 	;mov	byte [LD_Counter], 0 ; Reset logical drive index
  3329 00007980 66C705[FC8F0100]00- <1> 	mov 	word [EP_Counter], 0 ; Reset EP index and LD index	
  3329 00007988 00                  <1>
  3330                              <1> 
  3331 00007989 56                  <1> 	push	esi ; **** ; PTable_hd? offset
  3332                              <1> 	
  3333 0000798A C605[FB8F0100]04    <1> 	mov 	byte [PP_Counter], 4 
  3334                              <1> 				; set for each extd partition table
  3335                              <1> 	;;mov	ecx, 4
  3336                              <1> 	;mov	cl, 4
  3337 00007991 8A15[0D6E0000]      <1> 	mov	dl, [hdc]
  3338                              <1> hd_check_fs_id_05h:
  3339 00007997 8A4604              <1> 	mov	al, [esi+ptFileSystemID]
  3340 0000799A 3C05                <1> 	cmp	al, 05h ; Is it an extended dos partition ?
  3341 0000799C 7411                <1> 	je	short loc_set_ep_start_sector ; yes
  3342                              <1> hd_check_fs_id_0Fh:
  3343 0000799E 3C0F                <1> 	cmp	al, 0Fh ; Is it an extended win4 (LBA mode) partition ?
  3344 000079A0 740D                <1> 	je	short loc_set_ep_start_sector ; yes
  3345                              <1> 
  3346                              <1> continue_to_check_ep:
  3347                              <1> 	;add	esi, 16
  3348                              <1> 	;loop	hd_check_fs_id_05h
  3349                              <1> 	; 15/07/2020
  3350                              <1> 	;dec	cl
  3351                              <1> 	;jz	short continue_check_ep_next_disk
  3352 000079A2 FE0D[FB8F0100]      <1> 	dec	byte [PP_Counter] ; 4 --> 0
  3353 000079A8 742D                <1> 	jz	short continue_check_ep_next_disk
  3354 000079AA 83C610              <1> 	add	esi, 16
  3355 000079AD EBE8                <1> 	jmp	short hd_check_fs_id_05h
  3356                              <1> 
  3357                              <1> loc_set_ep_start_sector:
  3358                              <1> 	; dl = [hdc] ; Drive number
  3359                              <1> 	; 15/07/2020
  3360 000079AF 8B4E08              <1> 	mov	ecx, [esi+ptStartSector]
  3361                              <1> 	; 30/08/2020
  3362 000079B2 890D[FE8F0100]      <1> 	mov	[MBR_EP_StartSector], ecx 
  3363                              <1> 	; 20/07/2020
  3364                              <1> loc_validate_hde_partition_next:
  3365 000079B8 890D[02900100]      <1> 	mov	[EP_StartSector], ecx ; Extended partition's start sector
  3366 000079BE BB[F68C0100]        <1>         mov	ebx, MasterBootBuff
  3367 000079C3 803D[FA8F0100]01    <1> 	cmp	byte [HD_LBA_yes], 1 ; LBA ready = Yes
  3368 000079CA 7227                <1> 	jb	short loc_hd_load_ep_05h ; cf = 1 ; 20/07/2020 
  3369                              <1> 	; 11/08/2020
  3370                              <1> 	; (BugFix for extended partition type 05h beyond CHS limit)
  3371                              <1> 	; (Infact if extended partition starts at the beyond of CHS limit,
  3372                              <1> 	;  it's partition ID must be 0Fh but they/somebodies had used 05h.)
  3373                              <1> 	;cmp	al, 05h
  3374                              <1> 	;je	short loc_hd_load_ep_05h
  3375                              <1> loc_hd_load_ep_0Fh:
  3376                              <1> 	; 04/01/2016
  3377                              <1> 	;push	ecx
  3378                              <1> 	; 15/07/2020
  3379                              <1> 	;mov	ecx, [esi+ptStartSector] ; sector number
  3380                              <1> 	;mov	ebx, MasterBootBuff ; buffer address
  3381                              <1> 	; LBA read/write (with private LBA function) 
  3382                              <1> 	;((Retro UNIX 386 v1 - DISK I/O code by Erdogan Tan))
  3383                              <1> 	; dl = physical drive number (0,1, 80h, 81h, 82h, 83h)
  3384                              <1> 	;mov	ah, 1Bh ; LBA read
  3385                              <1> 	;mov	al, 1 ; sector count
  3386 000079CC 66B8011B            <1> 	mov	ax, 1B01h
  3387 000079D0 E85CD8FFFF          <1> 	call	int13h
  3388                              <1> 	;pop	ecx
  3389                              <1> 	;jnc	short loc_hd_move_ep_table
  3390                              <1> 	; 15/07/2020
  3391 000079D5 732E                <1> 	jnc	short loc_validate_hde_partition
  3392                              <1> 
  3393                              <1> continue_check_ep_next_disk:
  3394                              <1> 	; 15/07/2020
  3395                              <1> 	;pop	edi ; PTable_ep?
  3396 000079D7 5E                  <1> 	pop	esi ; **** ; PTable_hd?
  3397 000079D8 A0[CC8A0100]        <1> 	mov	al, [HF_NUM] ; number of hard disks
  3398 000079DD 047F                <1> 	add	al, 7Fh
  3399 000079DF 3805[0D6E0000]      <1> 	cmp	[hdc], al
  3400 000079E5 730B                <1> 	jnb	short loc_validating_hd_partitions_ok
  3401 000079E7 83C640              <1> 	add	esi, 64
  3402                              <1> 	; 15/07/2020
  3403                              <1> 	;add	edi, 64
  3404 000079EA FE05[0D6E0000]      <1> 	inc	byte [hdc]
  3405 000079F0 EB8E                <1> 	jmp	short next_hd_extd_partition
  3406                              <1> 
  3407                              <1> loc_validating_hd_partitions_ok:
  3408                              <1> 	; 15/07/2020
  3409                              <1> 	;mov	al, [Last_DOS_DiskNo]
  3410                              <1> loc_drv_init_retn:
  3411 000079F2 C3                  <1> 	retn
  3412                              <1> 	
  3413                              <1> loc_hd_load_ep_05h:
  3414                              <1> 	; 20/07/2020 ('diskio.s', int13h, cf = 1 -> bugfix)
  3415                              <1> 	;clc    ; (Bug: int13h would not clear carry flag bit, 
  3416                              <1> 	;	; even if there would not be an error)
  3417                              <1> 	;	; ((Fix: now, int13h procedure clears carry flag
  3418                              <1> 	;	;  at the entrance of it.. 20/07/2020))
  3419                              <1> 	; 15/07/2020
  3420                              <1> 	;push	ecx 
  3421 000079F3 8A7601              <1> 	mov	dh, [esi+ptBeginHead]
  3422 000079F6 668B4E02            <1>         mov     cx, [esi+ptBeginSector]
  3423 000079FA 66B80102            <1> 	mov	ax, 0201h ; Read 1 sector
  3424                              <1> 	;mov	ebx, MasterBootBuff
  3425 000079FE E82ED8FFFF          <1> 	call	int13h ; 20/07/2020
  3426                              <1> 		       ; 'diskio.s' modification, 'clc'
  3427                              <1> 	;pop	ecx  
  3428 00007A03 72D2                <1> 	jc	short continue_check_ep_next_disk
  3429                              <1> 	; 15/07/2020
  3430                              <1> 	;jmp	short loc_validate_hde_partition
  3431                              <1> 
  3432                              <1> 	; 15/07/2020
  3433                              <1> ;loc_hd_move_ep_table:
  3434                              <1> 	;;pop	edi
  3435                              <1> 	;;push	edi  ; PTable_ep?
  3436                              <1> 	;mov	edi, [esp]        
  3437                              <1>         ;mov	esi, PartitionTable ; Extended
  3438                              <1> 	;mov	ebx, esi
  3439                              <1> 	;;mov	ecx, 16
  3440                              <1> 	;mov	cl, 16
  3441                              <1>        	;rep	movsd
  3442                              <1> 	;mov	esi, ebx 
  3443                              <1> ;loc_set_hde_sub_partition_count:
  3444                              <1> 	;mov	byte [PP_Counter], 4
  3445                              <1> 	;mov	byte [EP_Counter], 0
  3446                              <1> 
  3447                              <1> loc_validate_hde_partition:
  3448                              <1> 	; 13/08/2020
  3449                              <1> 	; 15/07/2020
  3450                              <1> 	;mov	byte [PP_Counter], 4
  3451 00007A05 BE[B48E0100]        <1> 	mov	esi, PartitionTable ; (in MasterBootBuff)
  3452                              <1> 	; 13/08/2020
  3453                              <1> 	;jmp	short get_minidisk_partition_entry
  3454                              <1> 
  3455                              <1> ;get_minidisk_partition_entry:
  3456                              <1> ;	; 20/07/2020
  3457                              <1> ;	cmp	byte [esi+ptFileSystemID], 0
  3458                              <1> ;	ja	short loc_validate_minidisk_partition
  3459                              <1> ;	; 13/08/2020
  3460                              <1> ;	jmp	short continue_check_ep_next_disk
  3461                              <1> 
  3462                              <1> ;	; 11/08/2020
  3463                              <1> ;get_minidisk_partition_entry_next:
  3464                              <1> ;	; 13/08/2020
  3465                              <1> ;	;dec 	byte [PP_Counter]
  3466                              <1> ;	;jz	short continue_check_ep_next_disk
  3467                              <1> ;	; 20/07/2020
  3468                              <1> ;;get_minidisk_partition_entry_next:
  3469                              <1> ;	; 13/08/2020
  3470                              <1> ;	cmp	esi, PartitionTable+64 
  3471                              <1> ;	jnb	short continue_check_ep_next_disk
  3472                              <1> ;	
  3473                              <1> ;	add 	esi, 16 ; 10h
  3474                              <1> ;	;jmp	short get_minidisk_partition_entry
  3475                              <1> 
  3476                              <1> 	; 13/08/2020
  3477                              <1> get_minidisk_partition_entry:
  3478                              <1> 	; 20/07/2020
  3479 00007A0A 807E0400            <1> 	cmp	byte [esi+ptFileSystemID], 0
  3480 00007A0E 76C7                <1> 	jna	short continue_check_ep_next_disk ; 13/08/2020
  3481                              <1> 
  3482                              <1> loc_validate_minidisk_partition:
  3483                              <1> 	; 13/08/2020
  3484                              <1> 	; 20/07/2020
  3485                              <1> 	;push	esi ; *** ; Extended partition table offset
  3486                              <1> 
  3487                              <1> 	; 13/08/2020
  3488 00007A10 FE05[FC8F0100]      <1> 	inc	byte [EP_Counter] ; current (sub partition) index 
  3489                              <1> 				  ; in current extended partition
  3490                              <1> 
  3491 00007A16 BF[02900100]        <1> 	mov	edi, EP_StartSector
  3492                              <1> 
  3493                              <1> 	; Input -> ESI = PartitionTable offset
  3494                              <1> 	; DL = Hard disk drive number   
  3495                              <1> 	; EDI = Extended partition start sector pointer
  3496 00007A1B E869000000          <1> 	call	validate_hd_fat_partition
  3497                              <1> 	;pop	ecx ; *
  3498 00007A20 7308                <1> 	jnc	short loc_set_valid_hde_partition_entry
  3499                              <1> 			 ; jump down to deep !!!
  3500                              <1> 
  3501                              <1> 	;pop	esi ; *** ; Extended partition table offset
  3502                              <1> 	; 13/08/2020
  3503                              <1> 	;mov	esi, PartitionTable
  3504                              <1> 
  3505                              <1> 	; 11/08/2020
  3506                              <1> 	; ESI = Extended partition table offset
  3507 00007A22 8A15[0D6E0000]      <1> 	mov	dl, [hdc]
  3508                              <1> 
  3509                              <1> 	;; DL = Hard disk drive number
  3510                              <1> 	;dec	byte [PP_Counter]
  3511                              <1> 	;jz	short continue_check_ep_next_disk
  3512                              <1> 	;add 	esi, 16 ; 10h
  3513                              <1> 	;mov	dl, [hdc]
  3514                              <1> 	;jmp	short get_minidisk_partition_entry
  3515                              <1> 
  3516                              <1> 	; 11/08/2020
  3517                              <1> 	;jmp	short get_minidisk_partition_entry_next
  3518                              <1> 
  3519                              <1> 	; 23/08/2020
  3520 00007A28 EB3D                <1> 	jmp	short validate_next_minidisk_partition_ok
  3521                              <1> 
  3522                              <1> 	; 17/07/2020
  3523                              <1> 	;; jumping down to deep levels !!!
  3524                              <1> 	; ((That is a pitty microsoft preferred ep table chain
  3525                              <1> 	; instead of a single table as mbr partition table!?))
  3526                              <1> 
  3527                              <1> loc_set_valid_hde_partition_entry:
  3528                              <1> 	; 15/07/2020
  3529 00007A2A A0[0D6E0000]        <1> 	mov	al, [hdc] ; Hard disk drive number (>=80h)
  3530 00007A2F 88C2                <1> 	mov	dl, al ; mov dl, [hdc]
  3531 00007A31 2C7F                <1> 	sub	al, 7Fh
  3532                              <1> 		    ; 1 to 4	
  3533 00007A33 C0E002              <1> 	shl	al, 2 ; 4 to 16
  3534 00007A36 2A05[FB8F0100]      <1> 	sub	al, [PP_Counter] ; al - (4 - partition index)
  3535                              <1> 			; (disk number * 4) + partition index
  3536                              <1> 	
  3537                              <1> 	; AL = Partition entry/index, 0 based
  3538                              <1>         ;  0 -> hd 0, Partition Table offset = 0
  3539                              <1>         ; 15 -> hd 3, Partition Table offset = 3
  3540                              <1> 
  3541                              <1> 	;mov	ah, 4 ; Logical dos partition (>= 4)
  3542                              <1> 	;add	ah, [EP_Counter]
  3543                              <1> 		; Logical disk partition index = 4 to 7
  3544                              <1> 		; (Primary disk partition index = 0 to 3)
  3545                              <1> 
  3546                              <1> 	; 13/08/2020
  3547 00007A3C 8A25[FD8F0100]      <1> 	mov	ah, [LD_Counter] ; Logical drive index number
  3548                              <1> 				; (in current extended partition)
  3549 00007A42 80C404              <1> 	add	ah, 4 ; 4 to 7
  3550                              <1> 	
  3551                              <1> 	; 15/07/2020
  3552                              <1> 	; CX -> AX
  3553                              <1> 	;; 06/01/2016 (TRDOS v2.0)
  3554                              <1> 	;; BUGFIX *
  3555                              <1> 	;;mov	[esi+LD_PartitionEntry], cl 
  3556                              <1> 	;;mov	[esi+LD_DParamEntry], ch 
  3557                              <1> 	;mov	[esi+LD_PartitionEntry], cx 
  3558 00007A45 6689467C            <1> 	mov	[esi+LD_PartitionEntry], ax 	
  3559                              <1> 
  3560 00007A49 8A0D[C2400100]      <1> 	mov	cl, [Last_DOS_DiskNo] 
  3561 00007A4F 80C141              <1> 	add	cl, 'A'
  3562 00007A52 880E                <1> 	mov	[esi+LD_Name], cl
  3563                              <1> 
  3564                              <1> 	; 17/07/2020
  3565                              <1> 	;cmp	cl, 'Z'
  3566                              <1> 	;jb	short logical_drive_count_ok_for_next
  3567                              <1> 	;pop	esi ; ***
  3568                              <1> 	;pop	esi ; ****
  3569                              <1> 	;retn
  3570                              <1> 
  3571                              <1> ;logical_drive_count_ok_for_next:
  3572                              <1> 
  3573                              <1> 	;; 15/07/2020
  3574                              <1> 	;inc	byte [EP_Counter]
  3575                              <1> 	; 13/08/2020
  3576 00007A54 FE05[FD8F0100]      <1> 	inc	byte [LD_Counter]	
  3577                              <1> 
  3578                              <1> 	;mov	dl, [hdc]
  3579                              <1> 
  3580                              <1> 	; 17/07/2020
  3581                              <1> 	;; Now, 
  3582                              <1> 	;; we are swimming in deep of an extended partition !!!
  3583                              <1> 	; (! sub or chained extended partition tables !)
  3584                              <1> 	; ((Logical dos partitions in extended partition were called
  3585                              <1> 	;  as 'mini disk partition' in msdos 6.0 source code.))
  3586                              <1> 
  3587                              <1> validate_next_minidisk_partition:
  3588                              <1> 	; 13/08/2020
  3589                              <1> 	;pop	esi ; *** ; Extended partition table offset
  3590                              <1> 
  3591                              <1> 	; 17/07/2020
  3592                              <1> 	;cmp	byte [EP_Counter], 4
  3593                              <1> 	; 13/08/2020
  3594 00007A5A 803D[FD8F0100]04    <1> 	cmp	byte [LD_Counter], 4 ; maximum 4 logical disks
  3595                              <1> 				     ; per extended partition
  3596 00007A61 0F8370FFFFFF        <1> 	jnb	continue_check_ep_next_disk
  3597                              <1> 
  3598                              <1> validate_next_minidisk_partition_ok:
  3599                              <1> 	; 13/08/2020
  3600                              <1> 	;dec	byte [PP_Counter] ; 4 --> 0
  3601                              <1> 	;jz	continue_check_ep_next_disk
  3602                              <1> 	
  3603                              <1> 	;cmp	esi, PartitionTable+64 
  3604                              <1> 	;jnb	continue_check_ep_next_disk
  3605                              <1> 
  3606                              <1> 	;add	esi, 16
  3607                              <1> 	; 13/08/2020
  3608 00007A67 BE[C48E0100]        <1> 	mov	esi, PartitionTable+16
  3609                              <1> 
  3610                              <1> 	; 20/07/2020
  3611 00007A6C 8A4604              <1> 	mov	al, [esi+ptFileSystemID]
  3612                              <1> 
  3613                              <1> 	; 20/07/2020
  3614 00007A6F 3C05                <1> 	cmp	al, 05h ; Is it an extended dos partition ?
  3615 00007A71 7408                <1> 	je	short loc_minidisk_next_ep_lba_chs ; 17/07/2020
  3616 00007A73 3C0F                <1> 	cmp	al, 0Fh ; Is it an extended win4 (LBA mode) partition ?
  3617 00007A75 0F855CFFFFFF        <1> 	jne	continue_check_ep_next_disk ; AL must be 0 here
  3618                              <1> 					; (when it is not 05h or 0Fh)
  3619                              <1> 					; If AL is not ZERO -> EP Bug!
  3620                              <1> 					; (!Microsoft DOS convention!)
  3621                              <1> loc_minidisk_next_ep_lba_chs:
  3622                              <1> 	; 17/07/2020
  3623 00007A7B 8B4E08              <1> 	mov	ecx, [esi+ptStartSector] ; relative start sector number
  3624                              <1> 	;add	ecx, [EP_StartSector]
  3625                              <1> 	; 30/08/2020	
  3626 00007A7E 030D[FE8F0100]      <1> 	add	ecx, [MBR_EP_StartSector] 
  3627                              <1> 	; 20/07/2020
  3628 00007A84 E92FFFFFFF          <1> 	jmp	loc_validate_hde_partition_next
  3629                              <1> 
  3630                              <1> validate_hd_fat_partition:
  3631                              <1> 	; 17/07/2020
  3632                              <1> 	; 15/07/2020
  3633                              <1> 	;	(optimization)
  3634                              <1> 	; 14/07/2020
  3635                              <1> 	;	(fat16 -big- partition search bugfix)
  3636                              <1> 	; 27/12/2017
  3637                              <1> 	; 12/02/2016
  3638                              <1> 	; 07/01/2016 (TRDOS 386 = TRDOS v2.0)
  3639                              <1> 	; 07/08/2011
  3640                              <1> 	; 23/07/2011
  3641                              <1> 	; Input
  3642                              <1> 	;   DL = Hard/Fixed Disk Drive Number
  3643                              <1> 	;   ESI = PartitionTable offset
  3644                              <1> 	;   EDI = Extend. Part. Start Sector Pointer
  3645                              <1> 	;   EDI = 0 -> Primary Partition 
  3646                              <1> 	;   byte [Last_DOS_DiskNo]
  3647                              <1>  	; Output
  3648                              <1> 	;  cf=0 -> Validated
  3649                              <1> 	;   ESI = Logical dos drv desc. table
  3650                              <1> 	;   EBX = FAT boot sector buffer
  3651                              <1> 	;   byte [Last_DOS_DiskNo]
  3652                              <1> 	;  cf=1 -> Not a valid FAT partition
  3653                              <1> 	; EAX, EDX, ECX, EDI -> changed 
  3654                              <1> 	
  3655                              <1> 	;mov 	esi, PartitionTable
  3656 00007A89 8A6604              <1> 	mov 	ah, [esi+ptFileSystemID]
  3657 00007A8C B002                <1> 	mov	al, 2 ; 27/12/2017
  3658 00007A8E 80FC06              <1> 	cmp 	ah, 06h ; FAT16 CHS partition (>=32MB)
  3659                              <1> 	; 12/02/2016
  3660                              <1> 	;;jb	short loc_not_a_valid_fat_partition2
  3661                              <1>  	;jnb	short vhdp_FAT16_32
  3662                              <1> 	; 14/07/2020 (BugFix)
  3663 00007A91 7711                <1> 	ja	short vhdp_FAT16_32
  3664 00007A93 7425                <1> 	je	short loc_set_valid_hd_partition_params
  3665                              <1> 
  3666                              <1> vhdp_FAT12_16:
  3667                              <1> 	; 27/12/2017
  3668 00007A95 FEC8                <1> 	dec	al ; mov al, 1
  3669 00007A97 38C4                <1> 	cmp	ah, al ; 1 ; FAT12 partition
  3670 00007A99 741F                <1> 	je	short loc_set_valid_hd_partition_params
  3671                              <1> 	;
  3672 00007A9B FEC0                <1> 	inc	al ; mov al, 2
  3673 00007A9D 80FC04              <1> 	cmp	ah, 04h ; FAT16 CHS partition (< 32MB)
  3674 00007AA0 7418                <1> 	je	short loc_set_valid_hd_partition_params
  3675                              <1> 	
  3676                              <1> 	; 15/07/2020
  3677                              <1> 	; (ah = 05h, 02h or 03h)
  3678                              <1> loc_not_a_valid_fat_partition1:
  3679 00007AA2 F9                  <1> 	stc
  3680                              <1> 	; cf=1
  3681 00007AA3 C3                  <1> 	retn
  3682                              <1> 
  3683                              <1> vhdp_FAT16_32:
  3684                              <1> 	; 15/07/2020
  3685                              <1> 	;mov	al, 3
  3686 00007AA4 FEC0                <1> 	inc	al
  3687 00007AA6 80FC0C              <1> 	cmp	ah, 0Ch ; FAT32 LBA partition
  3688 00007AA9 740F                <1> 	je	short loc_set_valid_hd_partition_params
  3689 00007AAB 7706                <1> 	ja	short vhdp_check_FAT16_lba
  3690                              <1> 
  3691                              <1> vhdp_check_FAT32_chs:
  3692 00007AAD 80FC0B              <1> 	cmp	ah, 0Bh ; FAT32 CHS partition 
  3693 00007AB0 7408                <1> 	je	short loc_set_valid_hd_partition_params
  3694                              <1> 	;jne	short loc_not_a_valid_fat_partition1
  3695                              <1> 
  3696                              <1> 	;stc
  3697                              <1> loc_not_a_valid_fat_partition2:
  3698 00007AB2 C3                  <1> 	retn
  3699                              <1> 
  3700                              <1> vhdp_check_FAT16_lba:
  3701 00007AB3 80FC0E              <1> 	cmp	ah, 0Eh ; FAT16 LBA partition
  3702 00007AB6 75EA                <1> 	jne	short loc_not_a_valid_fat_partition1
  3703                              <1> 
  3704                              <1> 	;mov	al, 2
  3705 00007AB8 FEC8                <1> 	dec	al
  3706                              <1> 
  3707                              <1> loc_set_valid_hd_partition_params:
  3708                              <1> 	; 15/07/2020
  3709                              <1> 	;inc 	byte [Last_DOS_DiskNo] ; > 1
  3710                              <1> 	;
  3711 00007ABA 31DB                <1> 	xor	ebx, ebx
  3712 00007ABC 8A3D[C2400100]      <1> 	mov	bh, [Last_DOS_DiskNo] ; * 256	
  3713 00007AC2 FEC7                <1> 	inc	bh ; 15/07/2020
  3714 00007AC4 81C300010900        <1> 	add	ebx, Logical_DOSDisks
  3715                              <1> 	;
  3716 00007ACA C6430102            <1> 	mov	byte [ebx+LD_DiskType], 2
  3717 00007ACE 885302              <1> 	mov	byte [ebx+LD_PhyDrvNo], dl
  3718                              <1> 	;mov	byte [ebx+LD_FATType], al ; 2 or 3
  3719                              <1> 	;mov	byte [ebx+LD_FSType], ah ; 06h, 0Eh, 0Bh, 0Ch
  3720 00007AD1 66894303            <1> 	mov	word [ebx+LD_FATType], ax
  3721                              <1> 	;
  3722 00007AD5 8B4E08              <1> 	mov	ecx, [esi+ptStartSector]
  3723 00007AD8 09FF                <1> 	or	edi, edi 
  3724 00007ADA 7402                <1> 	jz	short pass_hd_FAT_ep_start_sector_adding
  3725                              <1> loc_add_hd_FAT_ep_start_sector:
  3726                              <1> 	; 17/07/2020
  3727 00007ADC 030F                <1> 	add	ecx, [edi]
  3728                              <1> pass_hd_FAT_ep_start_sector_adding:
  3729 00007ADE 894B6C              <1> 	mov	[ebx+LD_StartSector], ecx
  3730                              <1> loc_hd_FAT_logical_drv_init:
  3731 00007AE1 89DD                <1> 	mov	ebp, ebx
  3732                              <1> 	;mov	dl, [ebx+LD_PhyDrvNo]
  3733 00007AE3 A0[FA8F0100]        <1> 	mov	al, [HD_LBA_yes] ; 07/01/2016
  3734 00007AE8 884305              <1> 	mov	[ebx+LD_LBAYes], al
  3735 00007AEB BB[06900100]        <1> 	mov	ebx, DOSBootSectorBuff ; buffer address
  3736 00007AF0 08C0                <1> 	or	al, al
  3737 00007AF2 740C                <1> 	jz	short loc_hd_FAT_drv_init_load_bs_chs
  3738                              <1> loc_hd_FAT_drv_init_load_bs_lba:
  3739                              <1> 	; DL = Physical drive number
  3740                              <1>    	;mov	ecx, [esi+ptStartSector] ; sector number
  3741                              <1> 	;mov	ebx, DOSBootSectorBuff ; buffer address
  3742                              <1> 	; LBA read/write (with private LBA function) 
  3743                              <1> 	;((Retro UNIX 386 v1 - DISK I/O code by Erdogan Tan))
  3744                              <1> 	; dl = physical drive number (0,1, 80h, 81h, 82h, 83h)
  3745 00007AF4 B41B                <1> 	mov	ah, 1Bh ; LBA read
  3746 00007AF6 B001                <1> 	mov	al, 1 ; sector count
  3747 00007AF8 E834D7FFFF          <1> 	call	int13h
  3748 00007AFD 7313                <1> 	jnc	short loc_hd_drv_FAT_boot_validation
  3749                              <1> loc_not_a_valid_fat_partition3:
  3750 00007AFF C3                  <1> 	retn
  3751                              <1> loc_hd_FAT_drv_init_load_bs_chs:
  3752 00007B00 8A7601              <1> 	mov	dh, [esi+ptBeginHead]
  3753 00007B03 668B4E02            <1> 	mov	cx, [esi+ptBeginSector]
  3754 00007B07 66B80102            <1> 	mov	ax, 0201h ; Read 1 sector
  3755                              <1> 	;mov	ebx, DOSBootSectorBuff
  3756 00007B0B E821D7FFFF          <1> 	call	int13h
  3757 00007B10 72ED                <1> 	jc	short loc_not_a_valid_fat_partition3
  3758                              <1> loc_hd_drv_FAT_boot_validation:
  3759                              <1> 	;mov	esi, DOSBootSectorBuff
  3760 00007B12 89DE                <1> 	mov	esi, ebx
  3761 00007B14 6681BEFE01000055AA  <1> 	cmp	word [esi+BS_Validation], 0AA55h
  3762 00007B1D 7512                <1> 	jne	short loc_not_a_valid_fat_partition4
  3763 00007B1F 807E15F8            <1> 	cmp	byte [esi+BPB_Media], 0F8h
  3764 00007B23 750C                <1> 	jne	short loc_not_a_valid_fat_partition4
  3765                              <1> 
  3766                              <1> 	; 27/12/2017
  3767 00007B25 807D0303            <1> 	cmp	byte [ebp+LD_FATType], 3
  3768 00007B29 7508                <1> 	jne	short loc_hd_FAT16_BPB
  3769                              <1> 
  3770                              <1> loc_hd_drv_FAT32_boot_validation:
  3771 00007B2B 807E4229            <1> 	cmp	byte [esi+BS_FAT32_BootSig], 29h
  3772 00007B2F 7416                <1> 	je	short loc_hd_FAT32_BPB
  3773                              <1> 
  3774                              <1> loc_not_a_valid_fat_partition4:
  3775 00007B31 F9                  <1> 	stc
  3776 00007B32 C3                  <1> 	retn
  3777                              <1> 
  3778                              <1> loc_hd_FAT16_BPB:
  3779 00007B33 807E2629            <1> 	cmp	byte [esi+BS_BootSig], 29h
  3780 00007B37 75F8                <1> 	jne	short loc_not_a_valid_fat_partition4
  3781                              <1> 
  3782 00007B39 66837E1600          <1> 	cmp	word [esi+BPB_FATSz16], 0
  3783 00007B3E 7607                <1> 	jna	short loc_hd_big_FAT16_BPB
  3784 00007B40 B920000000          <1> 	mov	ecx, 32
  3785 00007B45 EB05                <1> 	jmp	short loc_hd_move_FAT_BPB
  3786                              <1> 
  3787                              <1> loc_hd_FAT32_BPB:
  3788                              <1> 	;cmp	word [esi+BPB_FATSz16], 0
  3789                              <1> 	;ja	short loc_not_a_valid_fat_partition4
  3790                              <1> loc_hd_big_FAT16_BPB:
  3791 00007B47 B92D000000          <1> 	mov	ecx, 45
  3792                              <1> 	
  3793                              <1> loc_hd_move_FAT_BPB:
  3794 00007B4C 89EF                <1> 	mov 	edi, ebp
  3795                              <1> 	;mov	esi, ebx ; Boot sector
  3796 00007B4E 57                  <1> 	push	edi
  3797 00007B4F 83C706              <1> 	add	edi, LD_BPB
  3798 00007B52 F366A5              <1> 	rep	movsw 
  3799 00007B55 5E                  <1> 	pop	esi
  3800 00007B56 0FB74614            <1> 	movzx	eax, word [esi+LD_BPB+BPB_RsvdSecCnt]
  3801 00007B5A 03466C              <1> 	add	eax, [esi+LD_StartSector]
  3802 00007B5D 894660              <1> 	mov	[esi+LD_FATBegin], eax
  3803 00007B60 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3
  3804 00007B64 7224                <1> 	jb	short loc_set_FAT16_RootDirLoc
  3805                              <1> loc_set_FAT32_RootDirLoc:
  3806 00007B66 8B462A              <1> 	mov	eax, [esi+LD_BPB+BPB_FATSz32]
  3807 00007B69 0FB65E16            <1>         movzx	ebx, byte [esi+LD_BPB+BPB_NumFATs]
  3808 00007B6D F7E3                <1> 	mul	ebx
  3809 00007B6F 034660              <1> 	add	eax, [esi+LD_FATBegin]
  3810                              <1> loc_set_FAT32_data_begin:
  3811 00007B72 894668              <1> 	mov	[esi+LD_DATABegin], eax
  3812 00007B75 894664              <1> 	mov	[esi+LD_ROOTBegin], eax
  3813                              <1> 	; If Root Directory Cluster <> 2 then
  3814                              <1> 	; change the beginning sector value 
  3815                              <1> 	; of the root dir by adding sector offset.
  3816 00007B78 8B4632              <1> 	mov	eax, [esi+LD_BPB+BPB_RootClus]
  3817 00007B7B 83E802              <1> 	sub	eax, 2
  3818 00007B7E 7435                <1> 	jz	short short loc_set_32bit_FAT_total_sectors  
  3819                              <1> 	;movzx	ebx, byte [esi+LD_BPB+BPB_SecPerClust]
  3820 00007B80 8A5E13              <1> 	mov	bl, [esi+LD_BPB+BPB_SecPerClust] 
  3821 00007B83 F7E3                <1> 	mul	ebx
  3822 00007B85 014664              <1> 	add	[esi+LD_ROOTBegin], eax
  3823 00007B88 EB2B                <1> 	jmp	short loc_set_32bit_FAT_total_sectors
  3824                              <1> 	;
  3825                              <1> loc_set_FAT16_RootDirLoc:
  3826 00007B8A 0FB64616            <1> 	movzx	eax, byte [esi+LD_BPB+BPB_NumFATs]
  3827 00007B8E 0FB7561C            <1> 	movzx	edx, word [esi+LD_BPB+BPB_FATSz16]
  3828 00007B92 F7E2                <1> 	mul	edx
  3829 00007B94 034660              <1> 	add	eax, [esi+LD_FATBegin]  
  3830 00007B97 894664              <1> 	mov	[esi+LD_ROOTBegin], eax
  3831                              <1> loc_set_FAT16_data_begin:
  3832 00007B9A 894668              <1> 	mov	[esi+LD_DATABegin], eax 
  3833                              <1> 	;mov	eax, 20h  ; Size of a directory entry
  3834                              <1> 	;;movzx	edx, word [esi+LD_BPB+BPB_RootEntCnt]
  3835                              <1>         ;mov     dx, [esi+LD_BPB+BPB_RootEntCnt]
  3836                              <1>         ;mul	edx
  3837                              <1> 	;;mov	ecx, 511
  3838                              <1> 	;mov	cx, 511
  3839                              <1> 	;add	eax, ecx
  3840                              <1> 	;inc	ecx ; 512
  3841                              <1> 	;div	ecx
  3842                              <1> 	; 14/07/2020
  3843 00007B9D 0FB74617            <1> 	movzx	eax, word [esi+LD_BPB+BPB_RootEntCnt]
  3844 00007BA1 6683C00F            <1> 	add	ax, 15
  3845 00007BA5 66C1E804            <1> 	shr	ax, 4 ; / 16 ; (16 entries per sector)
  3846 00007BA9 014668              <1> 	add	[esi+LD_DATABegin], eax
  3847                              <1> 	;movzx	eax, word [esi+LD_BPB+BPB_TotalSec16]
  3848 00007BAC 668B4619            <1> 	mov	ax, [esi+LD_BPB+BPB_TotalSec16]
  3849 00007BB0 6685C0              <1> 	test	ax, ax
  3850                              <1> 	;jz	short loc_set_32bit_FAT_total_sectors
  3851                              <1> ;loc_set_16bit_FAT_total_sectors:
  3852                              <1> 	;mov	[esi+LD_TotalSectors], eax
  3853                              <1> 	;jmp	short loc_set_hd_FAT_cluster_count
  3854                              <1> 	; 14/07/2020
  3855 00007BB3 7503                <1> 	jnz	short loc_set_hd_FAT_cluster_count
  3856                              <1> loc_set_32bit_FAT_total_sectors:
  3857 00007BB5 8B4626              <1> 	mov	eax, [esi+LD_BPB+BPB_TotalSec32]
  3858                              <1> 	;mov	[esi+LD_TotalSectors], eax
  3859                              <1> loc_set_hd_FAT_cluster_count:
  3860 00007BB8 894670              <1> 	mov	[esi+LD_TotalSectors], eax ; 14/07/2020
  3861 00007BBB 8B5668              <1> 	mov	edx, [esi+LD_DATABegin]
  3862 00007BBE 2B566C              <1> 	sub	edx, [esi+LD_StartSector]
  3863 00007BC1 29D0                <1> 	sub	eax, edx
  3864 00007BC3 31D2                <1> 	xor	edx, edx ; 0
  3865 00007BC5 0FB64E13            <1>         movzx   ecx, byte [esi+LD_BPB+BPB_SecPerClust]
  3866 00007BC9 F7F1                <1>         div	ecx 
  3867 00007BCB 894678              <1> 	mov	[esi+LD_Clusters], eax
  3868                              <1> 	; Maximum Valid Cluster Number= EAX +1
  3869                              <1> 	; with 2 reserved clusters= EAX +2
  3870                              <1> loc_set_hd_FAT_fs_free_sectors:
  3871                              <1> 	;mov	dword [esi+LD_FreeSectors], 0
  3872 00007BCE E855010000          <1> 	call	get_free_FAT_sectors
  3873 00007BD3 720D                <1> 	jc	short loc_validate_hd_FAT_partition_retn
  3874 00007BD5 894674              <1> 	mov	[esi+LD_FreeSectors], eax
  3875 00007BD8 C6467E06            <1> 	mov	byte [esi+LD_MediaChanged], 6  ; Volume Name Reset
  3876                              <1> 
  3877                              <1> 	; 15/07/2020
  3878 00007BDC FE05[C2400100]      <1> 	inc 	byte [Last_DOS_DiskNo] ; > 1
  3879                              <1> 
  3880                              <1> 	;mov	cl, [Last_DOS_DiskNo] 
  3881                              <1> 	;add	cl, 'A'
  3882                              <1> 	;mov	[esi+LD_FS_Name], cl
  3883                              <1> 
  3884                              <1> loc_validate_hd_FAT_partition_retn:         
  3885 00007BE2 C3                  <1> 	retn
  3886                              <1> 
  3887                              <1> validate_hd_fs_partition:
  3888                              <1> 	; 03/02/2018
  3889                              <1> 	; 09/12/2017
  3890                              <1> 	; 13/02/2016
  3891                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
  3892                              <1> 	; 29/01/2011
  3893                              <1> 	; 23/07/2011
  3894                              <1> 	; Input
  3895                              <1> 	;   DL = Hard/Fixed Disk Drive Number
  3896                              <1> 	;   ESI = PartitionTable offset
  3897                              <1> 	;   byte [Last_DOS_DiskNo]
  3898                              <1> 	; Output
  3899                              <1> 	;  cf=0 -> Validated
  3900                              <1> 	;   ESI = Logical dos drv desc. table
  3901                              <1> 	;   EBX = Singlix FS boot sector buffer
  3902                              <1> 	;   byte [Last_DOS_DiskNo]
  3903                              <1> 	;  cf=1 -> Not a valid 'Singlix FS' partition
  3904                              <1> 	; EAX, EDX, ECX, EDI -> changed 
  3905                              <1> 
  3906                              <1> 	;mov	esi, PartitionTable
  3907 00007BE3 8A6604              <1> 	mov	ah, [esi+ptFileSystemID]
  3908 00007BE6 80FCA1              <1> 	cmp	ah, 0A1h ; SINGLIX FS1 (trfs1) partition
  3909 00007BE9 7549                <1> 	jne	short loc_validate_hd_fs_partition_stc_retn
  3910                              <1> loc_set_valid_hd_fs_partition_params:
  3911 00007BEB FE05[C2400100]      <1> 	inc	byte [Last_DOS_DiskNo] ; > 1
  3912 00007BF1 30C0                <1> 	xor	al, al ; mov al, 0
  3913                              <1> 	;mov	[drv], dl
  3914 00007BF3 29DB                <1> 	sub	ebx, ebx ; 0
  3915 00007BF5 8A3D[C2400100]      <1> 	mov	bh, [Last_DOS_DiskNo] 
  3916 00007BFB 81C300010900        <1> 	add	ebx, Logical_DOSDisks
  3917 00007C01 C6430102            <1> 	mov	byte [ebx+LD_DiskType], 2
  3918 00007C05 885302              <1> 	mov	[ebx+LD_PhyDrvNo], dl
  3919                              <1> 	;mov	[ebx+LD_FATType], al ; 0
  3920                              <1> 	;mov	[ebx+LD_FSType], ah
  3921 00007C08 66894303            <1> 	mov	[ebx+LD_FATType], ax
  3922                              <1> 	;mov	eax, [esi+ptStartSector]
  3923                              <1> 	;mov	[ebx+LD_StartSector], eax
  3924                              <1> loc_hd_fs_logical_drv_init:
  3925 00007C0C 89DD                <1> 	mov	ebp, ebx ; 10/01/2016
  3926                              <1> 	;mov	dl, [ebx+LD_PhyDrvNo]
  3927 00007C0E A0[FA8F0100]        <1> 	mov	al, [HD_LBA_yes] ; 10/01/2016
  3928 00007C13 884305              <1> 	mov	[ebx+LD_LBAYes], al
  3929 00007C16 89DE                <1> 	mov	esi, ebx
  3930 00007C18 BB[06900100]        <1> 	mov	ebx, DOSBootSectorBuff ; buffer address
  3931 00007C1D 08C0                <1> 	or	al, al
  3932 00007C1F 7515                <1> 	jnz	short loc_hd_fs_drv_init_load_bs_lba
  3933                              <1> loc_hd_fs_drv_init_load_bs_chs:
  3934 00007C21 8A7601              <1> 	mov	dh, [esi+ptBeginHead]
  3935 00007C24 668B4E02            <1> 	mov	cx, [esi+ptBeginSector]
  3936 00007C28 66B80102            <1> 	mov	ax, 0201h ; Read 1 sector
  3937                              <1> 	;mov	ebx, DOSBootSectorBuff
  3938 00007C2C E800D6FFFF          <1> 	call	int13h
  3939 00007C31 7311                <1> 	jnc	short loc_hd_drv_fs_boot_validation
  3940                              <1> loc_validate_hd_fs_partition_err_retn:
  3941 00007C33 C3                  <1> 	retn
  3942                              <1> loc_validate_hd_fs_partition_stc_retn:
  3943 00007C34 F9                  <1> 	stc
  3944 00007C35 C3                  <1> 	retn
  3945                              <1> loc_hd_fs_drv_init_load_bs_lba:
  3946                              <1> 	; DL = Physical drive number
  3947                              <1> 	;mov	esi, ebx
  3948 00007C36 8B4E08              <1>    	mov	ecx, [esi+ptStartSector] ; sector number
  3949                              <1> 	;mov	ebx, DOSBootSectorBuff ; buffer address
  3950                              <1> 	; LBA read/write (with private LBA function) 
  3951                              <1> 	;((Retro UNIX 386 v1 - DISK I/O code by Erdogan Tan))
  3952                              <1> 	; dl = physical drive number (0,1, 80h, 81h, 82h, 83h)
  3953 00007C39 B41B                <1> 	mov	ah, 1Bh ; LBA read
  3954 00007C3B B001                <1> 	mov	al, 1 ; sector count
  3955 00007C3D E8EFD5FFFF          <1> 	call	int13h
  3956 00007C42 72EF                <1> 	jc	short loc_validate_hd_fs_partition_err_retn
  3957                              <1> loc_hd_drv_fs_boot_validation:
  3958                              <1> 	;mov	esi, DOSBootSectorBuff
  3959 00007C44 89DE                <1> 	mov	esi, ebx ; Boot sector buffer
  3960 00007C46 6681BEFE01000055AA  <1> 	cmp	word [esi+BS_Validation], 0AA55h
  3961 00007C4F 75E3                <1> 	jne	short loc_validate_hd_fs_partition_stc_retn
  3962                              <1>         ;
  3963                              <1> 	;Singlix FS Extensions to TR-DOS (7/6/2009) 
  3964 00007C51 66817E034653        <1> 	cmp	word [esi+bs_FS_Identifier], 'FS' ; 03/02/2018
  3965 00007C57 75DB                <1> 	jne	short loc_validate_hd_fs_partition_stc_retn
  3966                              <1>         ;'A1h' check is not necessary
  3967                              <1> 	;  if 'FS' check is passed as OK/Yes.
  3968 00007C59 807E09A1            <1> 	cmp	byte [esi+bs_FS_PartitionID], 0A1h
  3969 00007C5D 75D5                <1> 	jne	short loc_validate_hd_fs_partition_stc_retn
  3970                              <1> 	;
  3971 00007C5F 89EF                <1> 	mov	edi, ebp ; 10/01/2016
  3972                              <1> 	;
  3973 00007C61 8A462D              <1> 	mov	al, byte [esi+bs_FS_LBA_Ready]
  3974 00007C64 884705              <1> 	mov	[edi+LD_FS_LBAYes], al
  3975                              <1> 	;
  3976                              <1> 	; 03/01/2010 CHS -> DOS FAT/BPB compatibility fix
  3977 00007C67 8A4608              <1> 	mov	al, [esi+bs_FS_MediaAttrib]
  3978 00007C6A 884706              <1> 	mov	byte [edi+LD_FS_MediaAttrib], al
  3979                              <1> 	;
  3980 00007C6D 8A460A              <1> 	mov	al, [esi+bs_FS_VersionMaj]
  3981 00007C70 884707              <1> 	mov	[edi+LD_FS_VersionMajor], al
  3982                              <1> 	;
  3983 00007C73 668B4606            <1> 	mov	ax, [esi+bs_FS_BytesPerSec]
  3984 00007C77 66894711            <1> 	mov	[edi+LD_FS_BytesPerSec], ax
  3985 00007C7B 8A462E              <1> 	mov	al, [esi+bs_FS_SecPerTrack]
  3986 00007C7E 30E4                <1> 	xor	ah, ah ; 09/12/2017
  3987 00007C80 6689471E            <1> 	mov	[edi+LD_FS_SecPerTrack], ax
  3988 00007C84 8A462F              <1> 	mov	al, [esi+bs_FS_Heads]
  3989 00007C87 66894720            <1> 	mov	[edi+LD_FS_NumHeads], ax
  3990                              <1> 	;
  3991 00007C8B 8B4628              <1> 	mov	eax, [esi+bs_FS_UnDelDirD]
  3992 00007C8E 894722              <1> 	mov	[edi+LD_FS_UnDelDirD], eax
  3993 00007C91 8B5618              <1> 	mov	edx, [esi+bs_FS_MATLocation]
  3994 00007C94 89570C              <1> 	mov	[edi+LD_FS_MATLocation], edx
  3995 00007C97 8B461C              <1> 	mov	eax, [esi+bs_FS_RootDirD]
  3996 00007C9A 894708              <1> 	mov	[edi+LD_FS_RootDirD], eax
  3997 00007C9D 8B460C              <1> 	mov	eax, [esi+bs_FS_BeginSector]
  3998 00007CA0 89476C              <1> 	mov	[edi+LD_FS_BeginSector], eax
  3999 00007CA3 8B4710              <1> 	mov	eax, [edi+bs_FS_VolumeSize]
  4000 00007CA6 894770              <1> 	mov	[edi+LD_FS_VolumeSize], eax
  4001                              <1> 	;
  4002 00007CA9 89D0                <1> 	mov	eax, edx ; [edi+LD_FS_MATLocation]
  4003 00007CAB 03476C              <1> 	add	eax, [edi+LD_FS_BeginSector]
  4004 00007CAE 89FE                <1> 	mov	esi, edi
  4005                              <1> mread_hd_fs_MAT_sector:
  4006                              <1>        ;mov	ebx, DOSBootSectorBuff
  4007 00007CB0 B901000000          <1> 	mov	ecx, 1
  4008 00007CB5 E803AF0000          <1> 	call	disk_read
  4009 00007CBA 7248                <1> 	jc	short loc_validate_hd_fs_partition_retn
  4010                              <1> 	; EDI will not be changed
  4011 00007CBC 89DE                <1> 	mov	esi, ebx
  4012                              <1> use_hdfs_mat_sector_params:
  4013 00007CBE 8B460C              <1> 	mov	eax, [esi+FS_MAT_DATLocation]
  4014 00007CC1 894714              <1> 	mov	[edi+LD_FS_DATLocation], eax
  4015 00007CC4 8B4610              <1> 	mov	eax, [esi+FS_MAT_DATScount]
  4016 00007CC7 894718              <1> 	mov	[edi+LD_FS_DATSectors], eax
  4017 00007CCA 8B4614              <1> 	mov	eax, [esi+FS_MAT_FreeSectors]
  4018 00007CCD 894774              <1>         mov     [edi+LD_FS_FreeSectors], eax
  4019 00007CD0 8B4618              <1> 	mov	eax, [esi+FS_MAT_FirstFreeSector]
  4020 00007CD3 894778              <1> 	mov	[edi+LD_FS_FirstFreeSector], eax
  4021 00007CD6 8B4708              <1> 	mov	eax, [edi+LD_FS_RootDirD]
  4022 00007CD9 03476C              <1> 	add	eax, [edi+LD_FS_BeginSector]
  4023 00007CDC 89FE                <1> 	mov	esi, edi   
  4024                              <1> read_hd_fs_RDT_sector:
  4025 00007CDE BB[06900100]        <1> 	mov	ebx, DOSBootSectorBuff
  4026                              <1> 	;mov	ecx, 1
  4027 00007CE3 B101                <1> 	mov	cl, 1
  4028 00007CE5 E8D3AE0000          <1> 	call	disk_read
  4029 00007CEA 7218                <1> 	jc	short loc_validate_hd_fs_partition_retn
  4030                              <1> 	; EDI will not be changed
  4031 00007CEC 89DE                <1> 	mov	esi, ebx
  4032                              <1> use_hdfs_RDT_sector_params:
  4033 00007CEE 8B461C              <1> 	mov	eax, [esi+FS_RDT_VolumeSerialNo]
  4034 00007CF1 894728              <1> 	mov	[edi+LD_FS_VolumeSerial], eax
  4035 00007CF4 57                  <1> 	push	edi
  4036                              <1> 	;mov	ecx, 16
  4037 00007CF5 B110                <1> 	mov	cl, 16
  4038 00007CF7 83C640              <1> 	add	esi, FS_RDT_VolumeName
  4039 00007CFA 83C72C              <1> 	add	edi, LD_FS_VolumeName
  4040 00007CFD F3A5                <1> 	rep	movsd ; 64 bytes
  4041 00007CFF 5E                  <1> 	pop	esi
  4042                              <1> 		; Volume Name Reset
  4043 00007D00 C6467E06            <1>         mov     byte [esi+LD_FS_MediaChanged], 6
  4044                              <1> 	;
  4045                              <1>         ;mov	cl, [Last_DOS_DiskNo] 
  4046                              <1> 	;add	cl, 'A'
  4047                              <1> 	;mov	[esi+LD_FS_Name], cl
  4048                              <1> 
  4049                              <1> loc_validate_hd_fs_partition_retn:
  4050 00007D04 C3                  <1> 	retn
  4051                              <1> 
  4052                              <1> load_masterboot:
  4053                              <1> 	; 14/07/2020 (Reset function has been removed)
  4054                              <1> 	;
  4055                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
  4056                              <1> 	; 2005 - 2011
  4057                              <1> 	; input -> DL = drive number
  4058                              <1> ;	mov	ah, 0Dh ; Alternate disk reset
  4059                              <1> ;	call	int13h
  4060                              <1> ;	jnc	short pass_reset_error
  4061                              <1> ;harddisk_error:
  4062                              <1> ;  	retn
  4063                              <1> ;pass_reset_error:
  4064 00007D05 BB[F68C0100]        <1> 	mov	ebx, MasterBootBuff
  4065 00007D0A 66B80102            <1> 	mov	ax, 0201h
  4066 00007D0E 66B90100            <1> 	mov	cx, 1
  4067 00007D12 30F6                <1> 	xor	dh, dh
  4068 00007D14 E818D5FFFF          <1>  	call	int13h
  4069 00007D19 720C                <1> 	jc	short harddisk_error
  4070                              <1> 	;
  4071 00007D1B 66813D[F48E0100]55- <1> 	cmp	word [MBIDCode], 0AA55h
  4071 00007D23 AA                  <1>
  4072 00007D24 7401                <1> 	je	short load_masterboot_ok
  4073 00007D26 F9                  <1> 	stc
  4074                              <1> harddisk_error:
  4075                              <1> load_masterboot_ok:
  4076 00007D27 C3                  <1> 	retn
  4077                              <1> 
  4078                              <1> get_free_FAT_sectors:
  4079                              <1> 	; 21/12/2017
  4080                              <1> 	; 29/02/2016
  4081                              <1> 	; 13/02/2016
  4082                              <1> 	; 04/02/2016
  4083                              <1> 	; 07/01/2016 (TRDOS 386 = TRDOS v2.0)
  4084                              <1> 	; 11/07/2010
  4085                              <1> 	; 21/06/2009
  4086                              <1> 	; INPUT: ESI = Logical DOS Drive Description Table address
  4087                              <1> 	; OUTPUT: STC => Error
  4088                              <1>         ;	cf = 0 and EAX = Free FAT sectors
  4089                              <1> 	; Also, related parameters and FAT buffer will be reset and updated
  4090                              <1> 
  4091 00007D28 31C0                <1> 	xor	eax, eax
  4092                              <1> 	;mov	[esi+LD_FreeSectors], eax ; Reset
  4093                              <1> 	
  4094 00007D2A 807E0302            <1>         cmp     byte [esi+LD_FATType], 2
  4095 00007D2E 7654                <1> 	jna	short loc_gfc_get_fat_free_clusters
  4096                              <1> 
  4097                              <1> 	; 29/02/2016
  4098 00007D30 48                  <1> 	dec	eax ; 0FFFFFFFFh
  4099 00007D31 89463A              <1> 	mov	[esi+LD_BPB+BPB_Reserved], eax ; Free cluster count (reset)
  4100 00007D34 89463E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], eax ; First Free Cluster (reset)
  4101 00007D37 40                  <1> 	inc	eax ; 0
  4102                              <1> 	;
  4103 00007D38 668B4636            <1> 	mov	ax, [esi+LD_BPB+BPB_FSInfo]
  4104 00007D3C 03466C              <1> 	add	eax, [esi+LD_StartSector]
  4105                              <1> 
  4106 00007D3F BB[06900100]        <1> 	mov	ebx, DOSBootSectorBuff
  4107 00007D44 B901000000          <1> 	mov	ecx, 1
  4108 00007D49 E86FAE0000          <1>  	call	disk_read
  4109 00007D4E 7301                <1> 	jnc	short loc_gfc_check_fsinfo_signs
  4110                              <1> retn_gfc_get_fsinfo_sec:
  4111 00007D50 C3                  <1> 	retn
  4112                              <1> 
  4113                              <1> loc_gfc_check_fsinfo_signs:
  4114 00007D51 BB[06900100]        <1> 	mov 	ebx, DOSBootSectorBuff ; 13/02/2016
  4115 00007D56 813B52526141        <1>         cmp     dword [ebx], 41615252h
  4116 00007D5C 7524                <1> 	jne	short retn_gfc_get_fsinfo_stc
  4117                              <1> 	;add	ebx, 484
  4118                              <1> 	;cmp	dword [ebx], 61417272h
  4119 00007D5E 81BBE4010000727241- <1> 	cmp	dword [ebx+484], 61417272h
  4119 00007D67 61                  <1>
  4120 00007D68 7518                <1> 	jne	short retn_gfc_get_fsinfo_stc
  4121                              <1> 	;add	ebx, 4
  4122                              <1> 	;mov	eax, [ebx]
  4123 00007D6A 8B83E8010000        <1> 	mov	eax, [ebx+488]
  4124                              <1> 	; 29/02/2016
  4125 00007D70 89463A              <1> 	mov	[esi+LD_BPB+BPB_Reserved], eax ; Free cluster count
  4126 00007D73 8B93EC010000        <1> 	mov	edx,  [ebx+492] 
  4127 00007D79 89463E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], eax ; First Free Cluster
  4128                              <1> 	; 21/12/2017
  4129 00007D7C 89C3                <1> 	mov	ebx, eax ; (initial value = 0FFFFFFFFh)
  4130 00007D7E 43                  <1> 	inc	ebx ; 0FFFFFFFFh -> 0  
  4131 00007D7F 7513                <1> 	jnz	short short retn_from_get_free_fat32_clusters
  4132 00007D81 C3                  <1> 	retn
  4133                              <1> 
  4134                              <1> retn_gfc_get_fsinfo_stc:
  4135 00007D82 F9                  <1> 	stc
  4136 00007D83 C3                  <1> 	retn
  4137                              <1> 
  4138                              <1> loc_gfc_get_fat_free_clusters:
  4139                              <1> 	;mov	eax, 2
  4140 00007D84 B002                <1> 	mov	al, 2
  4141                              <1> 	;mov	[FAT_CurrentCluster], eax
  4142                              <1> loc_gfc_loop_get_next_cluster:
  4143 00007D86 E8EB4F0000          <1> 	call	get_next_cluster
  4144 00007D8B 730E                <1> 	jnc	short loc_gfc_free_fat_clusters_cont
  4145 00007D8D 21C0                <1> 	and	eax, eax
  4146 00007D8F 7411                <1> 	jz	short loc_gfc_pass_inc_free_cluster_count
  4147                              <1>  
  4148                              <1> retn_from_get_free_fat_clusters:
  4149 00007D91 8B4674              <1> 	mov	eax, [esi+LD_FreeSectors] ; Free clusters !
  4150                              <1> retn_from_get_free_fat32_clusters:
  4151 00007D94 0FB65E13            <1>         movzx	ebx, byte [esi+LD_BPB+BPB_SecPerClust]
  4152 00007D98 F7E3                <1>       	mul	ebx
  4153                              <1> 	;mov	[esi+LD_FreeSectors], eax ; Free sectors
  4154                              <1> retn_get_free_sectors_calc:
  4155 00007D9A C3                  <1> 	retn
  4156                              <1> 
  4157                              <1> loc_gfc_free_fat_clusters_cont:
  4158 00007D9B 09C0                <1> 	or	eax, eax
  4159 00007D9D 7503                <1> 	jnz	short loc_gfc_pass_inc_free_cluster_count
  4160 00007D9F FF4674              <1> 	inc	dword [esi+LD_FreeSectors] ; Free clusters !
  4161                              <1>    
  4162                              <1> loc_gfc_pass_inc_free_cluster_count:
  4163                              <1> 	;mov	eax, [FAT_CurrentCluster]
  4164 00007DA2 89C8                <1> 	mov	eax, ecx ; [FAT_CurrentCluster]
  4165 00007DA4 3B4678              <1> 	cmp	eax, [esi+LD_Clusters]
  4166 00007DA7 77E8                <1> 	ja	short retn_from_get_free_fat_clusters
  4167 00007DA9 40                  <1> 	inc	eax
  4168                              <1> 	;mov	[FAT_CurrentCluster], eax
  4169 00007DAA EBDA                <1> 	jmp	short loc_gfc_loop_get_next_cluster
  4170                              <1> 
  4171                              <1> floppy_drv_init:
  4172                              <1> 	; 09/12/2017
  4173                              <1> 	; 06/07/2016
  4174                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
  4175                              <1> 	; 24/07/2011
  4176                              <1> 	; 04/07/2009
  4177                              <1> 	; INPUT ->
  4178                              <1> 	;	DL = Drive number (0,1)
  4179                              <1> 	; OUTPUT ->
  4180                              <1> 	;	BL = drive name
  4181                              <1> 	;	BH = drive number
  4182                              <1> 	;	ESI = Logical DOS drv description table
  4183                              <1> 	;	EAX = Volume serial number
  4184                              <1>  
  4185 00007DAC BE[0E6E0000]        <1> 	mov	esi, fd0_type ; 10/01/2016
  4186 00007DB1 BF00010900          <1> 	mov	edi, Logical_DOSDisks
  4187 00007DB6 08D2                <1> 	or	dl, dl
  4188 00007DB8 7407                <1> 	jz	short loc_drv_init_fd0_fd1
  4189 00007DBA 81C700010000        <1> 	add	edi, 100h
  4190 00007DC0 46                  <1> 	inc	esi ; fd1_type ; 10/01/2016
  4191                              <1> loc_drv_init_fd0_fd1:
  4192 00007DC1 C6477E00            <1> 	mov	byte [edi+LD_MediaChanged], 0
  4193 00007DC5 803E01              <1> 	cmp	byte [esi], 1 ; type (>0 if it is existing) 
  4194                              <1> 		; 4 = 1.44 MB, 80 track, 3 1/2"
  4195 00007DC8 7221                <1> 	jb	short read_fd_boot_sector_retn
  4196 00007DCA 885702              <1> 	mov	[edi+LD_PhyDrvNo], dl
  4197                              <1> read_fd_boot_sector:
  4198 00007DCD 30F6                <1> 	xor	dh, dh
  4199 00007DCF B904000000          <1> 	mov	ecx, 4 ; Retry Count
  4200                              <1> read_fd_boot_sector_again:
  4201 00007DD4 51                  <1> 	push 	ecx
  4202                              <1> 	;mov	cx, 1
  4203 00007DD5 B101                <1> 	mov	cl, 1
  4204 00007DD7 66B80102            <1> 	mov	ax, 0201h ; Read 1 sector
  4205 00007DDB BB[06900100]        <1> 	mov	ebx, DOSBootSectorBuff
  4206 00007DE0 E84CD4FFFF          <1> 	call	int13h
  4207 00007DE5 59                  <1> 	pop	ecx
  4208 00007DE6 7304                <1> 	jnc	short use_fd_boot_sector_params
  4209 00007DE8 E2EA                <1> 	loop	read_fd_boot_sector_again
  4210                              <1> 
  4211                              <1> read_fd_boot_sector_stc_retn:
  4212 00007DEA F9                  <1> 	stc
  4213                              <1> read_fd_boot_sector_retn:
  4214 00007DEB C3                  <1> 	retn
  4215                              <1> 
  4216                              <1> use_fd_boot_sector_params:
  4217                              <1> 	;mov	esi, DOSBootSectorBuff
  4218 00007DEC 89DE                <1> 	mov	esi, ebx
  4219 00007DEE 6681BEFE01000055AA  <1> 	cmp	word [esi+BS_Validation], 0AA55h
  4220 00007DF7 75F1                <1> 	jne	short read_fd_boot_sector_stc_retn
  4221 00007DF9 66817E035346        <1>         cmp     word [esi+bs_FS_Identifier], 'SF'
  4222 00007DFF 0F85A2000000        <1>         jne     use_fd_fatfs_boot_sector_params
  4223                              <1> 	;
  4224 00007E05 8A462D              <1> 	mov	al, [esi+bs_FS_LBA_Ready]
  4225 00007E08 884705              <1> 	mov	[edi+LD_FS_LBAYes], al
  4226                              <1> 	;
  4227                              <1> 	; 03/01/2010 CHS -> DOS FAT/BPB compatibility fix
  4228 00007E0B 8A4608              <1> 	mov	al, [esi+bs_FS_MediaAttrib]
  4229 00007E0E 884706              <1> 	mov	[edi+LD_FS_MediaAttrib], al
  4230                              <1> 	;
  4231 00007E11 8A460A              <1>         mov	al, [esi+bs_FS_VersionMaj]
  4232 00007E14 884707              <1> 	mov	byte [edi+LD_FS_VersionMajor], al
  4233 00007E17 668B4606            <1> 	mov	ax, [esi+bs_FS_BytesPerSec]
  4234 00007E1B 66894711            <1> 	mov	[edi+LD_FS_BytesPerSec], ax
  4235 00007E1F 8A462E              <1> 	mov	al, [esi+bs_FS_SecPerTrack]
  4236 00007E22 28E4                <1> 	sub	ah, ah ; 09/12/2017
  4237 00007E24 6689471E            <1> 	mov	[edi+LD_FS_SecPerTrack], ax
  4238 00007E28 8A462F              <1> 	mov	al, [esi+bs_FS_Heads]
  4239 00007E2B 66894720            <1> 	mov	[edi+LD_FS_NumHeads], ax
  4240                              <1> 	;
  4241 00007E2F 8B4628              <1> 	mov	eax, [esi+bs_FS_UnDelDirD]
  4242 00007E32 894722              <1> 	mov	[edi+LD_FS_UnDelDirD], eax
  4243 00007E35 8B4618              <1> 	mov	eax, [esi+bs_FS_MATLocation]
  4244 00007E38 89470C              <1> 	mov	[edi+LD_FS_MATLocation], eax
  4245 00007E3B 8B461C              <1> 	mov	eax, [esi+bs_FS_RootDirD]
  4246 00007E3E 894708              <1> 	mov	[edi+LD_FS_RootDirD], eax
  4247 00007E41 8B460C              <1> 	mov	eax, [esi+bs_FS_BeginSector]
  4248 00007E44 89476C              <1> 	mov	[edi+LD_FS_BeginSector], eax
  4249 00007E47 8B4610              <1> 	mov	eax, [esi+bs_FS_VolumeSize]
  4250 00007E4A 894770              <1> 	mov	[edi+LD_FS_VolumeSize], eax
  4251                              <1> 	;		
  4252 00007E4D 89FE                <1> 	mov	esi, edi
  4253 00007E4F 8B460C              <1>  	mov	eax, [esi+LD_FS_MATLocation]
  4254                              <1> 	;add	eax, [edi+LD_FS_BeginSector]
  4255                              <1> read_fd_MAT_sector_again:
  4256                              <1> 	;mov	ebx, DOSBootSectorBuff
  4257                              <1> 	;mov	ecx, 1
  4258 00007E52 B101                <1> 	mov	cl, 1
  4259 00007E54 E86AAD0000          <1> 	call	chs_read
  4260 00007E59 89DE                <1> 	mov	esi, ebx
  4261 00007E5B 7301                <1> 	jnc	short use_fdfs_mat_sector_params
  4262                              <1> 	;jmp	short read_fd_boot_sector_retn
  4263 00007E5D C3                  <1> 	retn
  4264                              <1> use_fdfs_mat_sector_params:
  4265 00007E5E 8B460C              <1> 	mov	eax, [esi+FS_MAT_DATLocation]
  4266 00007E61 894714              <1> 	mov	[edi+LD_FS_DATLocation], eax
  4267 00007E64 8B4610              <1> 	mov	eax, [esi+FS_MAT_DATScount]
  4268 00007E67 894718              <1> 	mov	[edi+LD_FS_DATSectors], eax
  4269 00007E6A 8B4714              <1> 	mov	eax, [edi+FS_MAT_FreeSectors]
  4270 00007E6D 894774              <1> 	mov	[edi+LD_FS_FreeSectors], eax
  4271 00007E70 8B4618              <1> 	mov	eax, [esi+FS_MAT_FirstFreeSector]
  4272 00007E73 894778              <1> 	mov	[edi+LD_FS_FirstFreeSector], eax
  4273                              <1> 	;
  4274 00007E76 89FE                <1> 	mov	esi, edi
  4275 00007E78 8B4608              <1>  	mov	eax, [esi+LD_FS_RootDirD]
  4276                              <1> read_fd_RDT_sector_again:
  4277                              <1> 	;mov	ebx, DOSBootSectorBuff
  4278                              <1> 	;mov	cx, 1
  4279 00007E7B B101                <1> 	mov	cl, 1
  4280 00007E7D E841AD0000          <1> 	call	chs_read
  4281 00007E82 89DE                <1> 	mov	esi, ebx
  4282 00007E84 7220                <1> 	jc	short read_fd_RDT_sector_retn
  4283                              <1> use_fdfs_RDT_sector_params:
  4284 00007E86 8B461C              <1> 	mov	eax, [esi+FS_RDT_VolumeSerialNo]
  4285 00007E89 894728              <1> 	mov	[edi+LD_FS_VolumeSerial], eax
  4286 00007E8C 57                  <1> 	push	edi
  4287                              <1> 	;mov	ecx, 16
  4288 00007E8D B110                <1> 	mov	cl, 16	
  4289 00007E8F 83C640              <1> 	add	esi, FS_RDT_VolumeName
  4290 00007E92 83C72C              <1> 	add	edi, LD_FS_VolumeName
  4291 00007E95 F3A5                <1> 	rep	movsd ; 64 bytes
  4292 00007E97 5E                  <1> 	pop	esi
  4293 00007E98 C6460300            <1> 	mov	byte [esi+LD_FATType], 0
  4294 00007E9C C64604A1            <1> 	mov	byte [esi+LD_FSType], 0A1h  
  4295 00007EA0 E9A5000000          <1>         jmp     loc_cont_use_fd_boot_sector_params
  4296                              <1> 
  4297                              <1> read_fd_RDT_sector_stc_retn:
  4298 00007EA5 F9                  <1> 	stc
  4299                              <1> read_fd_RDT_sector_retn:
  4300 00007EA6 C3                  <1> 	retn
  4301                              <1> 
  4302                              <1> use_fd_fatfs_boot_sector_params:
  4303 00007EA7 807E2629            <1> 	cmp	byte [esi+BS_BootSig], 29h
  4304 00007EAB 75F8                <1> 	jne	short read_fd_RDT_sector_stc_retn
  4305 00007EAD 807E15F0            <1> 	cmp	byte [esi+BPB_Media], 0F0h
  4306 00007EB1 72F3                <1> 	jb	short read_fd_RDT_sector_retn
  4307 00007EB3 57                  <1> 	push	edi
  4308 00007EB4 83C706              <1> 	add	edi, LD_BPB
  4309                              <1> 	;mov	ecx, 16
  4310 00007EB7 B110                <1> 	mov	cl, 16
  4311 00007EB9 F3A5                <1> 	rep	movsd ; 64 bytes 
  4312 00007EBB 5E                  <1> 	pop	esi
  4313 00007EBC 31C0                <1> 	xor	eax, eax
  4314 00007EBE 89466C              <1> 	mov	[esi+LD_StartSector], eax ; 0
  4315 00007EC1 668B461C            <1> 	mov	ax, [esi+LD_BPB+BPB_FATSz16]
  4316 00007EC5 8A4E16              <1> 	mov	cl, [esi+LD_BPB+BPB_NumFATs] 
  4317 00007EC8 F7E1                <1>   	mul	ecx
  4318                              <1> 	; edx = 0 !
  4319 00007ECA 668B5614            <1> 	mov	dx, [esi+LD_BPB+BPB_RsvdSecCnt]
  4320 00007ECE 66895660            <1> 	mov	[esi+LD_FATBegin], dx
  4321                              <1> 	;add	eax, edx
  4322 00007ED2 6601D0              <1> 	add	ax, dx
  4323 00007ED5 894664              <1> 	mov	[esi+LD_ROOTBegin], eax
  4324 00007ED8 894668              <1> 	mov	[esi+LD_DATABegin], eax 
  4325 00007EDB 668B5617            <1> 	mov	dx, [esi+LD_BPB+BPB_RootEntCnt]
  4326                              <1> 	;;shl	edx, 5 ; * 32 (Size of a directory entry)
  4327                              <1> 	;shl	dx, 5
  4328                              <1> 	;;add	edx, 511
  4329                              <1> 	;add	dx, 511
  4330                              <1> 	;;shr	edx, 9 ; edx = ((edx*32)+511) / 512
  4331                              <1> 	;shr	dx, 9
  4332 00007EDF 6683C20F            <1> 	add	dx, 15 ; 06/07/2016 (+(512/32)-1)
  4333 00007EE3 66C1EA04            <1> 	shr	dx, 4 ; / 16 (==16 entries per sector)
  4334 00007EE7 015668              <1> 	add 	[esi+LD_DATABegin], edx ; + rd sectors
  4335                              <1> 	;movzx	eax, word [esi+LD_BPB+BPB_TotalSec16]
  4336 00007EEA 668B4619            <1> 	mov	ax, [esi+LD_BPB+BPB_TotalSec16]
  4337 00007EEE 894670              <1> 	mov	[esi+LD_TotalSectors], eax
  4338 00007EF1 2B4668              <1> 	sub	eax, [esi+LD_DATABegin]
  4339                              <1>   	;movzx	ecx, byte [esi+LD_BPB+BPB_SecPerClust]
  4340 00007EF4 8A4E13              <1> 	mov	cl, [esi+LD_BPB+BPB_SecPerClust]  
  4341 00007EF7 80F901              <1> 	cmp	cl, 1
  4342 00007EFA 7605                <1> 	jna	short save_fd_fatfs_cluster_count
  4343                              <1> 	;sub	edx, edx
  4344 00007EFC 6629D2              <1> 	sub	dx, dx ; 0
  4345                              <1> 	;sub	dl, dl ; 06/07/2016
  4346 00007EFF F7F1                <1> 	div	ecx
  4347                              <1> save_fd_fatfs_cluster_count:
  4348 00007F01 894678              <1> 	mov	[esi+LD_Clusters], eax
  4349                              <1> 
  4350                              <1>       ; Maximum Valid Cluster Number = EAX +1
  4351                              <1>       ; with 2 reserved clusters= EAX +2
  4352                              <1>  
  4353                              <1> reset_FAT_buffer_decriptors:
  4354 00007F04 29C0                <1> 	sub	eax, eax ; 0  
  4355 00007F06 A2[0A920100]        <1> 	mov	[FAT_BuffValidData], al ; 0
  4356 00007F0B A2[0B920100]        <1> 	mov	[FAT_BuffDrvName], al ; 0
  4357 00007F10 A3[0E920100]        <1> 	mov	[FAT_BuffSector], eax ; 0
  4358                              <1> 
  4359                              <1> read_fd_FAT_sectors:
  4360 00007F15 BB001C0900          <1>   	mov	ebx, FAT_Buffer
  4361 00007F1A 668B4614            <1> 	mov	ax, [esi+LD_BPB+BPB_RsvdSecCnt]
  4362                              <1> 	;mov	ecx, 3
  4363 00007F1E B103                <1> 	mov	cl, 3 ; 3 sectors
  4364 00007F20 E89EAC0000          <1> 	call	chs_read
  4365 00007F25 7240                <1> 	jc	short read_fd_FAT_sectors_retn
  4366                              <1> use_fd_FAT_sectors:
  4367 00007F27 8A4602              <1> 	mov	al, [esi+LD_PhyDrvNo]
  4368 00007F2A 0441                <1> 	add	al, 'A' 
  4369 00007F2C A2[0B920100]        <1> 	mov	[FAT_BuffDrvName], al 
  4370 00007F31 C605[0A920100]01    <1>  	mov	byte [FAT_BuffValidData], 1
  4371 00007F38 E82B000000          <1> 	call	fd_init_calculate_free_clusters
  4372 00007F3D 7228                <1> 	jc	short read_fd_FAT_sectors_retn
  4373                              <1>   
  4374                              <1> loc_use_fd_boot_sector_params_FAT:
  4375 00007F3F C6460301            <1> 	mov	byte [esi+LD_FATType], 1 ; FAT 12
  4376 00007F43 C6460401            <1> 	mov	byte [esi+LD_FSType], 1
  4377 00007F47 8B462D              <1>         mov     eax, [esi+LD_BPB+VolumeID]
  4378                              <1> loc_cont_use_fd_boot_sector_params:
  4379 00007F4A 8A7E02              <1> 	mov	bh, [esi+LD_PhyDrvNo]
  4380 00007F4D 887E7D              <1> 	mov	[esi+LD_DParamEntry], bh
  4381 00007F50 88FB                <1> 	mov	bl, bh
  4382 00007F52 80C341              <1> 	add	bl, 'A'
  4383 00007F55 881E                <1> 	mov	byte [esi+LD_Name], bl
  4384 00007F57 C6460101            <1> 	mov	byte [esi+LD_DiskType], 1
  4385 00007F5B C6460500            <1> 	mov	byte [esi+LD_LBAYes], 0
  4386 00007F5F C6467C00            <1> 	mov	byte [esi+LD_PartitionEntry], 0
  4387 00007F63 C6467E06            <1> 	mov	byte [esi+LD_MediaChanged], 6 ; Volume Name Reset
  4388                              <1> 
  4389                              <1> read_fd_FAT_sectors_retn:
  4390 00007F67 C3                  <1> 	retn   
  4391                              <1> 
  4392                              <1> fd_init_calculate_free_clusters:
  4393                              <1> 	; 09/12/2017
  4394                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
  4395                              <1> 	; 04/07/2009
  4396                              <1> 	; INPUT ->
  4397                              <1> 	;     ESI = Logical DOS drive description table address
  4398                              <1> 	; OUTPUT ->
  4399                              <1> 	;    [ESI+LD_FreeSectors] will be set
  4400                              <1> 	
  4401 00007F68 29C0                <1> 	sub	eax, eax
  4402 00007F6A 894674              <1> 	mov	[esi+LD_FreeSectors], eax ; 0
  4403 00007F6D B002                <1> 	mov	al, 2 ; eax = 2
  4404                              <1> 
  4405                              <1> fd_init_loop_get_next_cluster:
  4406 00007F6F E830000000          <1> 	call	fd_init_get_next_cluster
  4407 00007F74 722D                <1> 	jc	short fd_init_calculate_free_clusters_retn
  4408                              <1> 
  4409                              <1> fd_init_free_fat_clusters:
  4410                              <1> 	;cmp 	eax, 0
  4411                              <1> 	;ja	short fd_init_pass_inc_free_cluster_count
  4412                              <1> 	;and	eax, eax
  4413                              <1> 	;jnz	short fd_init_pass_inc_free_cluster_count
  4414 00007F76 6621C0              <1> 	and	ax, ax
  4415 00007F79 7504                <1> 	jnz	short fd_init_pass_inc_free_cluster_count
  4416                              <1> 	;inc	dword [esi+LD_FreeSectors]
  4417 00007F7B 66FF4674            <1>         inc	word [esi+LD_FreeSectors]
  4418                              <1>     
  4419                              <1> fd_init_pass_inc_free_cluster_count:
  4420                              <1>   	;mov	eax, [FAT_CurrentCluster]
  4421 00007F7F 66A1[06920100]      <1> 	mov	ax, [FAT_CurrentCluster]
  4422                              <1> 	;cmp	eax, [esi+LD_Clusters]
  4423 00007F85 663B4678            <1> 	cmp	ax, [esi+LD_Clusters]
  4424 00007F89 7704                <1> 	ja	short short retn_from_fd_init_calculate_free_clusters
  4425                              <1> 	;inc	eax
  4426 00007F8B 6640                <1> 	inc	ax
  4427 00007F8D EBE0                <1> 	jmp	short fd_init_loop_get_next_cluster
  4428                              <1> 
  4429                              <1> retn_from_fd_init_calculate_free_clusters:
  4430 00007F8F 8A4613              <1>   	mov	al, [esi+LD_BPB+BPB_SecPerClust]
  4431 00007F92 3C01                <1>   	cmp	al, 1
  4432 00007F94 760D                <1> 	jna	short fd_init_calculate_free_clusters_retn
  4433                              <1> 	;movzx	eax, al
  4434 00007F96 30E4                <1> 	xor	ah, ah ; 09/12/2017
  4435                              <1> 	;mov	ecx, [esi+LD_FreeSectors]
  4436 00007F98 668B4E74            <1> 	mov	cx, [esi+LD_FreeSectors] ; Count of free clusters
  4437                              <1>   	;mul	ecx
  4438 00007F9C 66F7E1              <1> 	mul	cx
  4439                              <1> 	;mov	[esi+LD_FreeSectors], eax
  4440 00007F9F 66894674            <1> 	mov	[esi+LD_FreeSectors], ax
  4441                              <1> fd_init_calculate_free_clusters_retn:
  4442 00007FA3 C3                  <1> 	retn
  4443                              <1> 
  4444                              <1> fd_init_get_next_cluster:
  4445                              <1> 	; 04/02/2016
  4446                              <1> 	; 02/02/2016
  4447                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
  4448                              <1> 	; 04/07/2009
  4449                              <1> 	; INPUT ->
  4450                              <1> 	;    EAX = Current cluster
  4451                              <1> 	;    ESI = Logical DOS drive description table address
  4452                              <1> 	;    EDX = 0
  4453                              <1> 	; OUTPUT ->
  4454                              <1> 	;    EAX = Next cluster
  4455                              <1> 
  4456 00007FA4 A3[06920100]        <1> 	mov	[FAT_CurrentCluster], eax
  4457                              <1> fd_init_get_next_cluster_readnext:
  4458 00007FA9 29D2                <1> 	sub	edx, edx ; 0
  4459 00007FAB BB00040000          <1>   	mov	ebx, 1024 ; 400h
  4460 00007FB0 F7F3                <1>   	div	ebx
  4461                              <1>   	; EAX = Count of 3 FAT sectors
  4462                              <1>   	; EDX = Buffer entry index
  4463 00007FB2 89C1                <1> 	mov	ecx, eax
  4464                              <1> 	;mov	eax, 3
  4465 00007FB4 B003                <1> 	mov	al, 3
  4466 00007FB6 F7E2                <1> 	mul	edx ; Multiply by 3
  4467 00007FB8 66D1E8              <1> 	shr	ax, 1 ; Divide by 2
  4468 00007FBB 89C3                <1> 	mov	ebx, eax ; Buffer byte offset
  4469 00007FBD 81C3001C0900        <1> 	add	ebx, FAT_Buffer
  4470 00007FC3 89C8                <1> 	mov	eax, ecx
  4471                              <1> 	;mov	edx, 3
  4472 00007FC5 66BA0300            <1> 	mov	dx, 3
  4473 00007FC9 F7E2                <1> 	mul	edx 
  4474                              <1>   	; EAX = FAT Beginning Sector
  4475                              <1> 	; EDX = 0
  4476 00007FCB 8A0E                <1> 	mov	cl, [esi+LD_Name]
  4477                              <1> 	;cmp	byte [FAT_BuffValidData], 0
  4478                              <1> 	;jna	short fd_init_load_FAT_sectors0
  4479 00007FCD 3A0D[0B920100]      <1> 	cmp	cl, [FAT_BuffDrvName]
  4480 00007FD3 751E                <1> 	jne	short fd_init_load_FAT_sectors0
  4481 00007FD5 3B05[0E920100]      <1> 	cmp	eax, [FAT_BuffSector]
  4482 00007FDB 751C                <1> 	jne	short fd_init_load_FAT_sectors1
  4483                              <1> 	;mov	eax, [FAT_CurrentCluster]
  4484 00007FDD A0[06920100]        <1> 	mov	al, [FAT_CurrentCluster]
  4485                              <1> 	;shr	eax, 1
  4486 00007FE2 D0E8                <1> 	shr	al, 1
  4487 00007FE4 668B03              <1> 	mov	ax, [ebx]
  4488 00007FE7 7306                <1>   	jnc	short fd_init_gnc_even
  4489 00007FE9 66C1E804            <1> 	shr	ax, 4
  4490                              <1> fd_init_gnc_clc_retn:
  4491 00007FED F8                  <1> 	clc
  4492 00007FEE C3                  <1> 	retn
  4493                              <1> 
  4494                              <1> fd_init_gnc_even:
  4495 00007FEF 80E40F              <1> 	and	ah, 0Fh
  4496 00007FF2 C3                  <1> 	retn
  4497                              <1> 
  4498                              <1> fd_init_load_FAT_sectors0:
  4499 00007FF3 880D[0B920100]      <1> 	mov 	[FAT_BuffDrvName], cl
  4500                              <1> fd_init_load_FAT_sectors1:
  4501 00007FF9 C605[0A920100]00    <1> 	mov	byte [FAT_BuffValidData], 0
  4502 00008000 A3[0E920100]        <1> 	mov	[FAT_BuffSector], eax
  4503 00008005 034660              <1> 	add	eax, [esi+LD_FATBegin]
  4504 00008008 BB001C0900          <1>  	mov	ebx, FAT_Buffer
  4505                              <1> 	;movzx	ecx, word [esi+LD_BPB+BPB_FATSz16]
  4506 0000800D 668B4E1C            <1> 	mov	cx, [esi+LD_BPB+BPB_FATSz16]
  4507 00008011 662B0D[0E920100]    <1> 	sub	cx, [FAT_BuffSector]
  4508                              <1>         ;cmp	ecx, 3
  4509 00008018 6683F903            <1> 	cmp	cx, 3
  4510 0000801C 7605                <1> 	jna	short fdinit_pass_fix_sector_count_3
  4511                              <1> 	;mov	ecx, 3
  4512 0000801E B903000000          <1> 	mov	ecx, 3
  4513                              <1> fdinit_pass_fix_sector_count_3:  
  4514 00008023 E89BAB0000          <1> 	call	chs_read
  4515 00008028 730D                <1> 	jnc	short fd_init_FAT_sectors_no_load_error
  4516 0000802A C605[0A920100]00    <1> 	mov	byte [FAT_BuffValidData], 0
  4517                              <1> 		; Drv not ready or read Error !
  4518 00008031 B80F000000          <1> 	mov	eax, ERR_DRV_NOT_RDY ; 15
  4519                              <1> 	;xor	edx, edx
  4520 00008036 C3                  <1> 	retn
  4521                              <1> 
  4522                              <1> fd_init_FAT_sectors_no_load_error:
  4523 00008037 C605[0A920100]01    <1> 	mov	byte [FAT_BuffValidData], 1
  4524 0000803E A1[06920100]        <1> 	mov	eax, [FAT_CurrentCluster]
  4525 00008043 E961FFFFFF          <1>         jmp     fd_init_get_next_cluster_readnext
  4526                              <1> 
  4527                              <1> get_FAT_volume_name:
  4528                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
  4529                              <1> 	; 12/09/2009
  4530                              <1> 	; INPUT ->
  4531                              <1> 	;	BH = Logical DOS drive number (0,1,2,3,4 ...)
  4532                              <1> 	;       BL = 0
  4533                              <1> 	; OUTPUT ->
  4534                              <1> 	;	CF = 0 -> ESI = Volume name address
  4535                              <1> 	; 	CF = 1 -> Root volume name not found
  4536                              <1> 
  4537                              <1> 	;mov 	ah, 0FFh
  4538                              <1> 	;mov 	al, [Last_Dos_DiskNo]
  4539                              <1> 	;cmp 	al, bh
  4540                              <1> 	;jb     short loc_gfvn_dir_load_err
  4541                              <1> 
  4542 00008048 89DE                <1> 	mov	esi, ebx
  4543 0000804A 81E600FF0000        <1> 	and	esi, 0FF00h ; esi = bh
  4544 00008050 81C600010900        <1> 	add	esi, Logical_DOSDisks
  4545 00008056 8A06                <1> 	mov     al, [esi+LD_Name]
  4546 00008058 8A6603              <1> 	mov     ah, [esi+LD_FATType]
  4547 0000805B 80FC01              <1> 	cmp     ah, 1
  4548 0000805E 7210                <1> 	jb    	short loc_gfvn_dir_load_err
  4549 00008060 3C41                <1> 	cmp 	al, 'A'
  4550 00008062 720C                <1> 	jb      short loc_gfvn_dir_load_err
  4551 00008064 80FC02              <1> 	cmp 	ah, 2 
  4552 00008067 7708                <1> 	ja      short get_FAT32_root_cluster
  4553                              <1> 	
  4554 00008069 E8634E0000          <1> 	call    load_FAT_root_directory
  4555 0000806E 730B                <1> 	jnc     short loc_get_volume_name
  4556                              <1> 
  4557                              <1> loc_gfvn_dir_load_err:
  4558 00008070 C3                  <1> 	retn
  4559                              <1> 
  4560                              <1> get_FAT32_root_cluster:
  4561 00008071 8B4632              <1> 	mov	eax, [esi+LD_BPB+BPB_RootClus]
  4562 00008074 E8E34E0000          <1> 	call    load_FAT_sub_directory
  4563 00008079 7224                <1> 	jc	short loc_get_volume_name_retn
  4564                              <1> 
  4565                              <1> loc_get_volume_name:
  4566 0000807B BE00000800          <1>         mov     esi, Directory_Buffer
  4567 00008080 6631C9              <1> 	xor	cx, cx ; 0
  4568                              <1> check_root_volume_name:
  4569 00008083 8A06                <1> 	mov	al, [esi]
  4570 00008085 08C0                <1> 	or      al, al
  4571 00008087 7416                <1> 	jz      short loc_get_volume_name_retn
  4572 00008089 807E0B08            <1> 	cmp     byte [esi+0Bh], 08h
  4573 0000808D 7410                <1> 	je      short loc_get_volume_name_retn
  4574 0000808F 663B0D[1F920100]    <1> 	cmp     cx, [DirBuff_LastEntry]
  4575 00008096 7308                <1> 	jnb     short pass_check_root_volume_name
  4576 00008098 6641                <1> 	inc     cx
  4577 0000809A 83C620              <1> 	add     esi, 32
  4578 0000809D EBE4                <1> 	jmp     short check_root_volume_name
  4579                              <1> 
  4580                              <1> loc_get_volume_name_retn:
  4581 0000809F C3                  <1> 	retn
  4582                              <1>     
  4583                              <1> pass_check_root_volume_name:
  4584 000080A0 803D[1B920100]03    <1> 	cmp	byte [DirBuff_FATType], 3
  4585 000080A7 7230                <1> 	jb	short loc_get_volume_name_retn_xor
  4586                              <1> 
  4587 000080A9 BB001C0900          <1> 	mov	ebx, FAT_Buffer
  4588 000080AE BE00010900          <1> 	mov	esi, Logical_DOSDisks
  4589 000080B3 31C0                <1> 	xor	eax, eax
  4590 000080B5 8A25[1A920100]      <1> 	mov	ah, [DirBuff_DRV]
  4591 000080BB 80EC41              <1> 	sub	ah, 'A' 
  4592 000080BE 01C6                <1> 	add	esi, eax
  4593 000080C0 A1[21920100]        <1> 	mov	eax, [DirBuff_Cluster]
  4594 000080C5 E8AC4C0000          <1> 	call	get_next_cluster
  4595 000080CA 7305                <1> 	jnc 	short loc_gfvn_load_FAT32_dir_cluster
  4596                              <1>   	
  4597 000080CC 83F801              <1> 	cmp     eax, 1
  4598 000080CF F5                  <1> 	cmc
  4599 000080D0 C3                  <1> 	retn
  4600                              <1>   
  4601                              <1> loc_gfvn_load_FAT32_dir_cluster:
  4602 000080D1 E8864E0000          <1> 	call	load_FAT_sub_directory
  4603 000080D6 73A3                <1> 	jnc	short loc_get_volume_name
  4604 000080D8 C3                  <1> 	retn
  4605                              <1> 
  4606                              <1> loc_get_volume_name_retn_xor:
  4607 000080D9 31C0                <1> 	xor 	eax, eax
  4608 000080DB C3                  <1> 	retn
  4609                              <1> 
  4610                              <1> get_media_change_status:
  4611                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
  4612                              <1> 	; 09/09/2009
  4613                              <1> 	; INPUT:
  4614                              <1> 	;     DL = Drive number (physical)
  4615                              <1> 	; OUTPUT: clc & AH = 6 media changed
  4616                              <1> 	;     clc & AH = 0 media not changed         
  4617                              <1> 	;     stc -> Drive not ready or an error 
  4618                              <1>   
  4619 000080DC B416                <1> 	mov	ah, 16h
  4620 000080DE E84ED1FFFF          <1>   	call	int13h
  4621 000080E3 80FC06              <1> 	cmp	ah, 06h
  4622 000080E6 7405                <1> 	je	short loc_gmc_status_retn
  4623 000080E8 08E4                <1> 	or	ah, ah
  4624 000080EA 7401                <1> 	jz	short loc_gmc_status_retn
  4625                              <1> loc_gmc_status_stc_retn:    
  4626 000080EC F9                  <1> 	stc
  4627                              <1> loc_gmc_status_retn:
  4628 000080ED C3                  <1> 	retn
  3089                                  %include 'trdosk3.s' ; 06/01/2016
  3090                              <1> ; ****************************************************************************
  3091                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - MAIN PROGRAM : trdosk3.s
  3092                              <1> ; ----------------------------------------------------------------------------
  3093                              <1> ; Last Update: 31/12/2017
  3094                              <1> ; ----------------------------------------------------------------------------
  3095                              <1> ; Beginning: 06/01/2016
  3096                              <1> ; ----------------------------------------------------------------------------
  3097                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
  3098                              <1> ; ----------------------------------------------------------------------------
  3099                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
  3100                              <1> ; MAINPROG.ASM (09/11/2011)
  3101                              <1> ; ****************************************************************************
  3102                              <1> ; MAINPROG.ASM [ TRDOS KERNEL - COMMAND EXECUTER SECTION - MAIN PROGRAM ]
  3103                              <1> ; (c) 2004-2011  Erdogan TAN  [ 17/01/2004 ]  Last Update: 09/11/2011
  3104                              <1> ; CMD_INTR.ASM [ TRDOS Command Interpreter Procedure ] Last Update: 09/11/2011
  3105                              <1> ; DIR.ASM [ DIRECTORY FUNCTIONS ] Last Update: 09/10/2011
  3106                              <1> ; FILE.ASM [ FILE FUNCTIONS ] Last Update: 09/10/2011
  3107                              <1> 
  3108                              <1> change_current_drive:
  3109                              <1> 	; 16/10/2016
  3110                              <1> 	; 02/02/2016
  3111                              <1> 	; 15/01/2016 (TRDOS 386 = TRDOS v2.0)
  3112                              <1> 	; 18/08/2011
  3113                              <1> 	; 09/09/2009
  3114                              <1> 	; INPUT:
  3115                              <1> 	;   DL = Logical DOS Drive Number
  3116                              <1> 	; OUTPUT:
  3117                              <1> 	;  cf=1 -> Not successful
  3118                              <1> 	;   EAX = Error code
  3119                              <1> 	;  cf=0 ->
  3120                              <1> 	;   EAX = 0 (successful)
  3121                              <1> 
  3122 000080EE 31DB                <1> 	xor	ebx, ebx
  3123 000080F0 88D7                <1> 	mov	bh, dl
  3124                              <1> 
  3125                              <1> 	;cmp	dl, 1
  3126                              <1> 	;jna	short loc_ccdrv_initial_media_change_check
  3127                              <1> 	;cmp	bh, [Last_Dos_DiskNo]
  3128                              <1> 	;ja	short loc_ccdrv_drive_not_ready_err
  3129                              <1> 
  3130                              <1> loc_ccdrv_initial_media_change_check:
  3131 000080F2 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  3132 000080F7 01DE                <1> 	add	esi, ebx
  3133                              <1> loc_ccdrv_dos_drive_name_check:
  3134 000080F9 80FA02              <1> 	cmp	dl, 2
  3135 000080FC 720F                <1> 	jb	short loc_ccdrv_dos_drive_name_check_ok
  3136                              <1> 
  3137 000080FE 8A06                <1> 	mov	al, [esi+LD_Name]
  3138 00008100 2C41                <1> 	sub	al, 'A'
  3139 00008102 38D0                <1> 	cmp	al, dl
  3140 00008104 7407                <1> 	je	short loc_ccdrv_dos_drive_name_check_ok
  3141                              <1> 
  3142                              <1> loc_ccdrv_drive_not_ready_err:
  3143                              <1> 	; 16/10/2016 (15h -> 15)
  3144 00008106 B80F000000          <1> 	mov	eax, 15 ; Drive not ready
  3145                              <1> loc_change_current_drive_stc_retn:
  3146 0000810B F9                  <1> 	stc
  3147 0000810C C3                  <1> 	retn  
  3148                              <1> 
  3149                              <1> loc_ccdrv_dos_drive_name_check_ok:
  3150 0000810D 8A667E              <1> 	mov	ah, [esi+LD_MediaChanged]
  3151 00008110 80FC06              <1> 	cmp	ah, 6  ; VOLUME NAME CHECK/MOVE SIGN
  3152 00008113 7455                <1> 	je	short loc_ccdrv_get_FAT_volume_name_0
  3153                              <1> 
  3154 00008115 80FA01              <1> 	cmp	dl, 1
  3155 00008118 777D                <1> 	ja	short loc_gmcs_init_drv_hd
  3156                              <1> 
  3157                              <1> loc_gmcs_init_drv_fd:
  3158 0000811A 08E4                <1> 	or	ah, ah 
  3159                              <1> 	; AH = 1 is initialization sign (invalid_fd_parameter)
  3160 0000811C 7517                <1> 	jnz	short loc_ccdrv_call_fd_init
  3161                              <1> 
  3162 0000811E E8B9FFFFFF          <1> 	call	get_media_change_status
  3163 00008123 72E1                <1> 	jc	short loc_ccdrv_drive_not_ready_err
  3164                              <1> 
  3165 00008125 20E4                <1> 	and	ah, ah
  3166 00008127 7476                <1> 	jz	short loc_change_current_drv3
  3167                              <1> 
  3168 00008129 80F406              <1> 	xor	ah, 6
  3169 0000812C 75D8                <1> 	jnz	short loc_ccdrv_drive_not_ready_err
  3170                              <1> 
  3171                              <1> loc_ccdrv_call_fd_init_check_vol_id:
  3172 0000812E E8440A0000          <1> 	call	get_volume_serial_number
  3173 00008133 730D                <1> 	jnc	short loc_ccdrv_check_vol_serial
  3174                              <1> 
  3175                              <1> loc_ccdrv_call_fd_init:
  3176 00008135 E872FCFFFF          <1> 	call	floppy_drv_init
  3177 0000813A 731A                <1> 	jnc	short loc_reset_drv_fd_current_dir
  3178                              <1> 
  3179                              <1> loc_ccdrv_fdinit_fail_retn:
  3180                              <1> 	; 16/10/2016
  3181 0000813C B80F000000          <1> 	mov	eax, 15 ; Drive not ready
  3182 00008141 C3                  <1> 	retn
  3183                              <1> 
  3184                              <1> loc_ccdrv_check_vol_serial:
  3185 00008142 A3[EC8A0100]        <1> 	mov	[Current_VolSerial], eax
  3186                              <1> 	;mov	dl, bh
  3187 00008147 E860FCFFFF          <1> 	call	floppy_drv_init
  3188 0000814C 72EE                <1> 	jc	short loc_ccdrv_fdinit_fail_retn
  3189                              <1> 
  3190 0000814E 3B05[EC8A0100]      <1> 	cmp	eax, [Current_VolSerial]
  3191 00008154 7445                <1> 	je	short loc_change_current_drv2
  3192                              <1> 
  3193                              <1> loc_reset_drv_fd_current_dir:
  3194 00008156 31C0                <1> 	xor	eax, eax              
  3195 00008158 88467F              <1>         mov	[esi+LD_CDirLevel], al
  3196 0000815B 89F7                <1> 	mov	edi, esi
  3197 0000815D 81C780000000        <1> 	add	edi, LD_CurrentDirectory
  3198 00008163 B920000000          <1> 	mov	ecx, 32
  3199 00008168 F3AB                <1> 	rep	stosd   
  3200                              <1>  
  3201                              <1> loc_ccdrv_get_FAT_volume_name_0:
  3202 0000816A 8A4603              <1> 	mov	al, [esi+LD_FATType]
  3203 0000816D 08C0                <1> 	or	al, al
  3204 0000816F 742A                <1> 	jz	short loc_change_current_drv2
  3205                              <1> 
  3206 00008171 56                  <1> 	push	esi 
  3207 00008172 3C02                <1> 	cmp	al, 2
  3208 00008174 7705                <1> 	ja	short loc_ccdrv_get_FAT32_vol_name
  3209                              <1>              
  3210                              <1> loc_ccdrv_get_FAT2_16_vol_name:
  3211 00008176 83C631              <1> 	add	esi, LD_BPB + VolumeLabel
  3212 00008179 EB03                <1> 	jmp	short loc_ccdrv_get_FAT_volume_name_1
  3213                              <1> 
  3214                              <1> loc_ccdrv_get_FAT32_vol_name:
  3215 0000817B 83C64D              <1> 	add	esi, LD_BPB + FAT32_VolLab
  3216                              <1> loc_ccdrv_get_FAT_volume_name_1:
  3217 0000817E 53                  <1> 	push	ebx
  3218 0000817F 56                  <1> 	push	esi
  3219 00008180 E8C3FEFFFF          <1> 	call	get_FAT_volume_name
  3220 00008185 5F                  <1> 	pop	edi
  3221 00008186 5B                  <1> 	pop	ebx
  3222                              <1> 	; BL = 0
  3223 00008187 720B                <1> 	jc	short loc_change_current_drv1
  3224 00008189 20C0                <1> 	and	al, al
  3225 0000818B 7407                <1> 	jz	short loc_change_current_drv1
  3226                              <1> 
  3227                              <1> loc_ccdrv_move_FAT_volume_name:
  3228 0000818D B90B000000          <1> 	mov	ecx, 11
  3229 00008192 F3A4                <1> 	rep	movsb
  3230                              <1> 
  3231                              <1> loc_change_current_drv1:
  3232 00008194 5E                  <1> 	pop	esi
  3233 00008195 EB04                <1> 	jmp	short loc_change_current_drv2
  3234                              <1> 
  3235                              <1> loc_gmcs_init_drv_hd:
  3236 00008197 08E4                <1> 	or	ah, ah
  3237 00008199 7404                <1> 	jz	short loc_change_current_drv3
  3238                              <1> 	; BL = 0, BH = Logical DOS drive number
  3239                              <1> loc_change_current_drv2:
  3240 0000819B C6467E00            <1> 	mov	byte [esi+LD_MediaChanged], 0
  3241                              <1> loc_change_current_drv3:
  3242 0000819F 883D[F68A0100]      <1> 	mov	[Current_Drv], bh
  3243                              <1> 
  3244                              <1> 	;call	restore_current_directory
  3245                              <1> 	;retn
  3246                              <1> 
  3247                              <1> restore_current_directory:
  3248                              <1> 	; 11/02/2016
  3249                              <1> 	; 15/01/2016 (TRDOS 386 = TRDOS v2.0)
  3250                              <1> 	; 25/01/2010
  3251                              <1> 	; 12/10/2009
  3252                              <1> 	;
  3253                              <1> 	; INPUT:
  3254                              <1> 	;   ESI = Logical DOS Drive Description Table
  3255                              <1> 	;
  3256                              <1> 	; OUTPUT:
  3257                              <1> 	;   ESI = Logical DOS Drive Description Table
  3258                              <1> 	;   EDI = offset Current_Dir_Drv 
  3259                              <1> 
  3260 000081A5 8A4603              <1> 	mov	al, [esi+LD_FATType]
  3261 000081A8 A2[F58A0100]        <1> 	mov	[Current_FATType], al
  3262                              <1> 
  3263 000081AD 8A26                <1> 	mov	ah, [esi+LD_Name] 
  3264 000081AF 8825[F78A0100]      <1> 	mov	[Current_Dir_Drv], ah
  3265                              <1> 
  3266 000081B5 20C0                <1> 	and	al, al
  3267 000081B7 741D                <1> 	jz	short loc_restore_FS_current_directory
  3268                              <1> 
  3269                              <1> loc_restore_FAT_current_directory:
  3270 000081B9 8A667F              <1> 	mov	ah, [esi+LD_CDirLevel]
  3271 000081BC 8825[F48A0100]      <1> 	mov	[Current_Dir_Level], ah
  3272 000081C2 08E4                <1> 	or	ah, ah
  3273 000081C4 7416                <1>         jz	short loc_ccdrv_reset_cdir_FAT_12_16_32_fcluster
  3274                              <1> 
  3275 000081C6 0FB6D4              <1> 	movzx	edx, ah
  3276 000081C9 C0E204              <1> 	shl	dl, 4 ; * 16
  3277 000081CC 01F2                <1>         add	edx, esi
  3278 000081CE 8B828C000000        <1> 	mov	eax, [edx+LD_CurrentDirectory+12]
  3279 000081D4 EB2C                <1> 	jmp	short loc_ccdrv_reset_cdir_FAT_fcluster
  3280                              <1> 
  3281                              <1> loc_restore_FS_current_directory:
  3282 000081D6 E8BC4D0000          <1> 	call	load_current_FS_directory 
  3283 000081DB C3                  <1> 	retn 
  3284                              <1> 
  3285                              <1> loc_ccdrv_reset_cdir_FAT_12_16_32_fcluster:
  3286 000081DC 3C03                <1> 	cmp	al, 3
  3287 000081DE 7205                <1> 	jb	short loc_ccdrv_reset_cdir_FAT_12_16_fcluster
  3288                              <1> loc_ccdrv_reset_cdir_FAT32_fcluster:
  3289 000081E0 8B4632              <1> 	mov	eax, [esi+LD_BPB+FAT32_RootFClust]
  3290 000081E3 EB04                <1> 	jmp	short loc_ccdrv_check_rootdir_sign
  3291                              <1> loc_ccdrv_reset_cdir_FAT_12_16_fcluster:   
  3292 000081E5 30C0                <1> 	xor	al, al  ; xor eax, eax
  3293 000081E7 31D2                <1> 	xor	edx, edx
  3294                              <1> loc_ccdrv_check_rootdir_sign:
  3295 000081E9 80BE8000000000      <1> 	cmp	byte [esi+LD_CurrentDirectory], 0
  3296 000081F0 7510                <1> 	jne	short loc_ccdrv_reset_cdir_FAT_fcluster
  3297                              <1> loc_ccdrv_set_rootdir_FAT_fcluster:
  3298 000081F2 89868C000000        <1>         mov     [esi+LD_CurrentDirectory+12], eax
  3299 000081F8 C78680000000524F4F- <1> 	mov	dword [esi+LD_CurrentDirectory], 'ROOT'
  3299 00008201 54                  <1>
  3300                              <1> 
  3301                              <1> loc_ccdrv_reset_cdir_FAT_fcluster:
  3302 00008202 A3[F08A0100]        <1> 	mov	[Current_Dir_FCluster], eax
  3303                              <1> 
  3304 00008207 BF[53920100]        <1> 	mov	edi, PATH_Array
  3305 0000820C 89F2                <1> 	mov	edx, esi
  3306 0000820E 81C680000000        <1> 	add	esi, LD_CurrentDirectory
  3307 00008214 B920000000          <1> 	mov	ecx, 32
  3308 00008219 F3A5                <1> 	rep	movsd
  3309                              <1> 
  3310 0000821B E84C2D0000          <1> 	call	change_prompt_dir_string
  3311                              <1> 	
  3312 00008220 89D6                <1> 	mov	esi, edx
  3313                              <1> 	
  3314 00008222 29C0                <1>         sub	eax, eax
  3315                              <1>        ;sub	edx, edx
  3316 00008224 BF[F78A0100]        <1> 	mov	edi, Current_Dir_Drv
  3317                              <1> 
  3318 00008229 A2[C3400100]        <1> 	mov	[Restore_CDIR], al ; 0
  3319 0000822E C3                  <1> 	retn
  3320                              <1> 
  3321                              <1> dos_prompt:
  3322                              <1> 	; 06/05/2016
  3323                              <1> 	; 30/01/2016
  3324                              <1> 	; 29/01/2016
  3325                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  3326                              <1> 	; 15/09/2011
  3327                              <1> 	; 13/09/2009
  3328                              <1> 	; 2004-2005
  3329                              <1> 
  3330                              <1> 	; 06/05/2016
  3331 0000822F C705[B0960100]-     <1> 	mov	dword [mainprog_return_addr], return_from_cmd_interpreter
  3331 00008235 [E3820000]          <1>
  3332                              <1> 
  3333                              <1> loc_TRDOS_prompt:
  3334 00008239 BF[F68B0100]        <1> 	mov	edi, TextBuffer
  3335 0000823E C6075B              <1> 	mov	byte [edi], "["
  3336 00008241 47                  <1> 	inc	edi
  3337 00008242 BE[16410100]        <1> 	mov	esi, TRDOSPromptLabel
  3338                              <1> get_next_prompt_label_char:
  3339 00008247 803E20              <1> 	cmp	byte [esi], 20h
  3340 0000824A 7203                <1> 	jb	short pass_prompt_label
  3341 0000824C A4                  <1> 	movsb
  3342 0000824D EBF8                <1> 	jmp	short get_next_prompt_label_char
  3343                              <1> pass_prompt_label:
  3344 0000824F C6075D              <1> 	mov	byte [edi], "]"
  3345 00008252 47                  <1> 	inc	edi
  3346 00008253 C60720              <1> 	mov	byte [edi], 20h
  3347 00008256 47                  <1> 	inc	edi
  3348 00008257 BE[F78A0100]        <1> 	mov	esi, Current_Dir_Drv
  3349 0000825C 66A5                <1> 	movsw
  3350 0000825E A4                  <1> 	movsb 
  3351                              <1> loc_prompt_current_directory:
  3352 0000825F 803E20              <1> 	cmp	byte [esi], 20h
  3353 00008262 7203                <1> 	jb	short pass_prompt_current_directory
  3354 00008264 A4                  <1> 	movsb
  3355 00008265 EBF8                <1> 	jmp	short loc_prompt_current_directory  
  3356                              <1> pass_prompt_current_directory:
  3357 00008267 C6073E              <1> 	mov	byte [edi], '>'
  3358 0000826A 47                  <1> 	inc	edi
  3359 0000826B C60700              <1> 	mov	byte [edi], 0  
  3360 0000826E BE[F68B0100]        <1> 	mov	esi, TextBuffer
  3361 00008273 E8EDF2FFFF          <1> 	call	print_msg
  3362                              <1>         
  3363                              <1> 	;sub	bh, bh ; video page = 0
  3364                              <1> 	;call	get_cpos ; get cursor position
  3365 00008278 668B15[4E8A0100]    <1> 	mov	dx, [CURSOR_POSN] ; video page 0
  3366 0000827F 8815[568B0100]      <1> 	mov	[CursorColumn], dl
  3367                              <1> 
  3368                              <1> 	; 30/01/2016 (to show cursor on the row, again)
  3369                              <1> 	; (Initial color attributes of video page 0 is 0)
  3370                              <1> 	; (see: 'StartPMP' in trdos386.s)
  3371                              <1> 	; 
  3372                              <1> 	;mov	edi, 0B8000h ; start of video page 0
  3373                              <1> 	;movzx	ecx, dl ; column	 
  3374                              <1> 	;mov	al, 80
  3375                              <1> 	;mul	dh
  3376                              <1> 	;add	ax, cx
  3377                              <1> 	;shl	ax, 1 ; character + attribute
  3378                              <1> 	;add	di, ax ; (2*80*row) + (2*column)
  3379                              <1> 	;neg	cl
  3380                              <1> 	;add	cl, 80
  3381                              <1> 	;mov	ax, 700h ;  ah = 7 (color attribute)
  3382                              <1> 	;rep	stosw	
  3383                              <1> 
  3384                              <1> loc_rw_char:
  3385 00008285 E899000000          <1> 	call	rw_char
  3386                              <1> loc_move_command:
  3387 0000828A BE[A68B0100]        <1> 	mov	esi, CommandBuffer
  3388 0000828F 89F7                <1> 	mov	edi, esi
  3389 00008291 31C9                <1> 	xor	ecx, ecx
  3390                              <1> first_command_char:
  3391 00008293 AC                  <1> 	lodsb
  3392 00008294 3C20                <1> 	cmp	al, 20h
  3393 00008296 772E                <1> 	ja	short pass_space_control
  3394 00008298 7241                <1> 	jb	short loc_move_cmd_arguments_ok
  3395 0000829A 81FE[F58B0100]      <1> 	cmp	esi, CommandBuffer + 79
  3396 000082A0 72F1                <1> 	jb	short first_command_char
  3397 000082A2 EB37                <1> 	jmp	short loc_move_cmd_arguments_ok
  3398                              <1> 
  3399                              <1> next_command_char:
  3400 000082A4 AC                  <1> 	lodsb
  3401 000082A5 3C20                <1> 	cmp	al, 20h
  3402 000082A7 771D                <1> 	ja	short pass_space_control
  3403 000082A9 7230                <1> 	jb	short loc_move_cmd_arguments_ok
  3404                              <1> 
  3405                              <1> loc_1st_cmd_arg: ; 30/01/2016
  3406 000082AB AC                  <1> 	lodsb
  3407 000082AC 3C20                <1> 	cmp	al, 20h
  3408 000082AE 74FB                <1> 	je	short loc_1st_cmd_arg
  3409 000082B0 7229                <1> 	jb	short loc_move_cmd_arguments_ok
  3410                              <1> 	
  3411 000082B2 C60700              <1>         mov     byte [edi], 0
  3412 000082B5 47                  <1> 	inc	edi
  3413                              <1> 
  3414                              <1> loc_move_cmd_arguments:
  3415 000082B6 AA                  <1> 	stosb
  3416 000082B7 81FE[F58B0100]      <1> 	cmp	esi, CommandBuffer + 79
  3417 000082BD 731C                <1> 	jnb	short loc_move_cmd_arguments_ok
  3418 000082BF AC                  <1>         lodsb
  3419 000082C0 3C20                <1> 	cmp	al, 20h
  3420 000082C2 73F2                <1> 	jnb	short loc_move_cmd_arguments
  3421 000082C4 EB15                <1> 	jmp	short loc_move_cmd_arguments_ok
  3422                              <1> 
  3423                              <1> pass_space_control:
  3424 000082C6 3C61                <1> 	cmp	al, 61h
  3425 000082C8 7206                <1> 	jb	short pass_capitalize
  3426 000082CA 3C7A                <1> 	cmp	al, 7Ah
  3427 000082CC 7702                <1> 	ja	short pass_capitalize
  3428 000082CE 24DF                <1> 	and	al, 0DFh
  3429                              <1> pass_capitalize:
  3430 000082D0 AA                  <1> 	stosb   
  3431 000082D1 FEC1                <1> 	inc     cl
  3432 000082D3 81FE[F58B0100]      <1>         cmp     esi, CommandBuffer + 79
  3433 000082D9 72C9                <1> 	jb      short next_command_char 
  3434                              <1> 
  3435                              <1> loc_move_cmd_arguments_ok:
  3436 000082DB C60700              <1>         mov     byte [edi], 0
  3437                              <1> 
  3438                              <1> call_command_interpreter:
  3439 000082DE E8CF080000          <1> 	call    command_interpreter
  3440                              <1> 
  3441                              <1> return_from_cmd_interpreter:
  3442 000082E3 B950000000          <1>         mov	ecx, 80
  3443                              <1> 	;mov	cx, 80
  3444 000082E8 BF[A68B0100]        <1> 	mov	edi, CommandBuffer
  3445 000082ED 30C0                <1> 	xor	al, al
  3446 000082EF F3AA                <1> 	rep	stosb
  3447                              <1> 	;cmp	byte [Program_Exit], 0
  3448                              <1> 	;ja	short loc_terminate_trdos
  3449                              <1>         
  3450                              <1> 	; 16/01/2016
  3451 000082F1 803D[DA6F0000]03    <1> 	cmp	byte [CRT_MODE], 3 ; 80*25 color
  3452 000082F8 741D                <1> 	je	short pass_set_txt_mode
  3453                              <1> 
  3454 000082FA E86F98FFFF          <1> 	call	set_txt_mode ; set vide mode to 03h
  3455                              <1> 	; 07/01/2017
  3456 000082FF 30C0                <1> 	xor	al, al
  3457                              <1> 
  3458                              <1> loc_check_active_page:
  3459                              <1> 	;xor	al, al
  3460 00008301 3805[5E8A0100]      <1> 	cmp	[ACTIVE_PAGE], al ; 0
  3461 00008307 0F842CFFFFFF        <1>         je      loc_TRDOS_prompt 
  3462                              <1> 	; AL = 0 = video page 0
  3463 0000830D E8A59CFFFF          <1> 	call	set_active_page
  3464 00008312 E922FFFFFF          <1>         jmp     loc_TRDOS_prompt ; infinitive loop
  3465                              <1> 
  3466                              <1> pass_set_txt_mode: 
  3467 00008317 BE[5F4D0100]        <1> 	mov	esi, nextline
  3468 0000831C E844F2FFFF          <1> 	call	print_msg
  3469 00008321 EBDE                <1> 	jmp     short loc_check_active_page
  3470                              <1> 
  3471                              <1> rw_char:
  3472                              <1> 	; 13/05/2016
  3473                              <1> 	; 30/01/2016
  3474                              <1> 	; 29/01/2016
  3475                              <1> 	; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
  3476                              <1> 	; 2004-2005
  3477                              <1> 	
  3478                              <1> 	; DH = cursor row, DL = cursor column
  3479                              <1> 	; BH = 0 = video page number (active page)
  3480                              <1> 
  3481                              <1> 	;xor	bh, bh ; 0 = video page 0
  3482                              <1> 
  3483                              <1> readnextchar:
  3484 00008323 30E4                <1> 	xor     ah, ah
  3485 00008325 E8C38BFFFF          <1> 	call	int16h
  3486 0000832A 20C0                <1> 	and	al, al
  3487 0000832C 7432                <1> 	jz	short loc_arrow    
  3488 0000832E 3CE0                <1> 	cmp	al, 0E0h          
  3489 00008330 742E                <1> 	je	short loc_arrow
  3490 00008332 3C08                <1> 	cmp	al, 08h             
  3491 00008334 7542                <1> 	jne	short char_return
  3492                              <1> loc_back:
  3493 00008336 3A15[568B0100]      <1> 	cmp	dl, [CursorColumn]
  3494 0000833C 76E5                <1> 	jna     short readnextchar
  3495                              <1> prev_column:
  3496 0000833E FECA                <1> 	dec	dl
  3497                              <1> set_cursor_pos:
  3498                              <1> 	;push	dx
  3499 00008340 52                  <1> 	push	edx ; 29/12/2017
  3500                              <1> 	;xor	bh, bh ; 0 = video page 0
  3501                              <1> 	; DH = Row, DL = Column
  3502 00008341 E859A0FFFF          <1> 	call	_set_cpos ; 17/01/2016
  3503 00008346 5A                  <1>         pop	edx ; 29/12/2017
  3504                              <1> 	;pop	dx
  3505                              <1> 	;movzx	ebx, dl
  3506 00008347 88D3                <1> 	mov	bl, dl
  3507 00008349 2A1D[568B0100]      <1> 	sub	bl, [CursorColumn] 
  3508 0000834F B020                <1> 	mov	al, 20h
  3509 00008351 8883[A68B0100]      <1> 	mov	[CommandBuffer+ebx], al
  3510                              <1> 	;sub	bh, bh ; video page 0
  3511                              <1> 	;mov	cx, 1
  3512 00008357 B307                <1> 	mov	bl, 7 ; color attribute
  3513 00008359 E8209FFFFF          <1> 	call	_write_c_current ; 17/01/2016
  3514                              <1> 	;mov	dx, [CURSOR_POSN]
  3515 0000835E EBC3                <1> 	jmp	short readnextchar
  3516                              <1> loc_arrow:    
  3517 00008360 80FC4B              <1> 	cmp	ah, 4Bh
  3518 00008363 74D1                <1> 	je	short loc_back
  3519 00008365 80FC53              <1> 	cmp	ah, 53h
  3520 00008368 74CC                <1> 	je      short loc_back
  3521 0000836A 80FC4D              <1> 	cmp	ah, 4Dh
  3522 0000836D 75B4                <1> 	jne	short readnextchar
  3523 0000836F 80FA4F              <1> 	cmp	dl, 79
  3524 00008372 73AF                <1> 	jnb	short readnextchar
  3525 00008374 FEC2                <1> 	inc	dl
  3526 00008376 EBC8                <1> 	jmp	short set_cursor_pos
  3527                              <1> char_return:
  3528 00008378 0FB6DA              <1> 	movzx	ebx, dl
  3529 0000837B 2A1D[568B0100]      <1> 	sub	bl, [CursorColumn] 
  3530 00008381 3C20                <1> 	cmp	al, 20h
  3531 00008383 721D                <1> 	jb	short loc_escape
  3532 00008385 8883[A68B0100]      <1> 	mov	[CommandBuffer+ebx], al
  3533 0000838B 80FA4F              <1> 	cmp	dl, 79
  3534 0000838E 7393                <1> 	jnb	short readnextchar
  3535 00008390 66BB0700            <1> 	mov	bx, 7 ; color attribute
  3536 00008394 E86C9FFFFF          <1> 	call	_write_tty
  3537 00008399 668B15[4E8A0100]    <1> 	mov	dx, [CURSOR_POSN] ; video page 0
  3538 000083A0 EB81                <1>         jmp     readnextchar
  3539                              <1> loc_escape:
  3540 000083A2 3C1B                <1> 	cmp	al, 1Bh
  3541 000083A4 7418                <1> 	je	short rw_char_retn
  3542                              <1> 	;
  3543 000083A6 3C0D                <1> 	cmp	al, 0Dh ; CR
  3544 000083A8 0F8575FFFFFF        <1>         jne     readnextchar
  3545                              <1> 	; 13/05/2016
  3546 000083AE 66BB0700            <1> 	mov	bx, 7 ; attribute/color (bl)
  3547                              <1> 		      ; video page 0 (bh=0)	
  3548 000083B2 E84E9FFFFF          <1> 	call	_write_tty
  3549                              <1> 	;mov	bx, 7  ; attribute/color
  3550                              <1> 		      ; video page 0 (bh=0)
  3551 000083B7 B00A                <1> 	mov	al, 0Ah ; LF
  3552 000083B9 E8479FFFFF          <1> 	call	_write_tty
  3553                              <1> rw_char_retn:
  3554 000083BE C3                  <1> 	retn
  3555                              <1> 
  3556                              <1> show_date:
  3557                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
  3558                              <1>         ; 2004-2005
  3559                              <1> 
  3560                              <1> 	;mov	ah, 04h
  3561                              <1> 	;call	int1Ah
  3562 000083BF E85FE7FFFF          <1> 	call	RTC_40	; GET RTC DATE
  3563                              <1> 
  3564 000083C4 88D0                <1> 	mov	al, dl
  3565 000083C6 E8158BFFFF          <1>   	call	bcd_to_ascii
  3566 000083CB 66A3[02420100]      <1> 	mov	[Day], ax
  3567                              <1> 
  3568 000083D1 88F0                <1> 	mov	al, dh
  3569 000083D3 E8088BFFFF          <1>   	call	bcd_to_ascii
  3570 000083D8 66A3[05420100]      <1> 	mov	[Month], ax
  3571                              <1> 
  3572 000083DE 88E8                <1> 	mov	al, ch
  3573 000083E0 E8FB8AFFFF          <1>   	call	bcd_to_ascii
  3574 000083E5 66A3[08420100]      <1> 	mov	[Century], ax
  3575                              <1> 
  3576 000083EB 88C8                <1> 	mov	al, cl
  3577 000083ED E8EE8AFFFF          <1>   	call	bcd_to_ascii
  3578 000083F2 66A3[0A420100]      <1> 	mov	word [Year], ax
  3579                              <1> 
  3580 000083F8 BE[F2410100]        <1> 	mov	esi, Msg_Show_Date
  3581 000083FD E863F1FFFF          <1> 	call	print_msg
  3582                              <1> 
  3583 00008402 C3                  <1> 	retn
  3584                              <1> 
  3585                              <1> set_date:
  3586                              <1> 	; 13/05/2016
  3587                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
  3588                              <1>         ; 2004-2005
  3589                              <1> 
  3590 00008403 BE[D6410100]        <1> 	mov	esi, Msg_Enter_Date
  3591 00008408 E858F1FFFF          <1> 	call	print_msg
  3592                              <1> 
  3593                              <1> loc_enter_day_1:
  3594 0000840D 30E4                <1> 	xor     ah, ah
  3595 0000840F E8D98AFFFF          <1> 	call	int16h
  3596                              <1> 	; AL = ASCII Code of the Character
  3597 00008414 3C0D                <1> 	cmp	al, 13
  3598 00008416 0F84B7010000        <1> 	je	loc_set_date_retn
  3599 0000841C 3C1B                <1> 	cmp	al, 27
  3600 0000841E 0F84AF010000        <1> 	je	loc_set_date_retn
  3601 00008424 A2[02420100]        <1> 	mov	[Day], al
  3602 00008429 3C30                <1> 	cmp	al, '0'
  3603 0000842B 0F82AD010000        <1> 	jb	loc_set_date_stc_0
  3604 00008431 3C33                <1> 	cmp	al, '3'
  3605 00008433 0F87A5010000        <1> 	ja	loc_set_date_stc_0
  3606                              <1> 	; 13/05/2016
  3607                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  3608                              <1> 		      ; video page 0 (bh)	
  3609 00008439 B307                <1> 	mov	bl, 7
  3610 0000843B E8C59EFFFF          <1> 	call	_write_tty
  3611                              <1> loc_enter_day_2:
  3612 00008440 30E4                <1> 	xor     ah, ah
  3613 00008442 E8A68AFFFF          <1> 	call	int16h
  3614                              <1> 	; AL = ASCII Code of the Character
  3615 00008447 3C1B                <1> 	cmp	al, 27
  3616 00008449 0F8484010000        <1>         je      loc_set_date_retn
  3617 0000844F A2[03420100]        <1> 	mov	[Day+1], al
  3618 00008454 3C30                <1> 	cmp	al, '0'
  3619 00008456 0F828C010000        <1>         jb      loc_set_date_stc_1
  3620 0000845C 3C39                <1> 	cmp	al, '9'
  3621 0000845E 0F8784010000        <1>         ja      loc_set_date_stc_1
  3622 00008464 803D[02420100]33    <1> 	cmp	byte [Day], '3'
  3623 0000846B 7208                <1> 	jb	short pass_set_day_31
  3624 0000846D 3C31                <1> 	cmp	al, '1'
  3625 0000846F 0F8773010000        <1>         ja      loc_set_date_stc_1
  3626                              <1> pass_set_day_31:
  3627                              <1> 	; 13/05/2016
  3628                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  3629                              <1> 		      ; video page 0 (bh)	
  3630 00008475 B307                <1> 	mov	bl, 7
  3631 00008477 E8899EFFFF          <1> 	call	_write_tty
  3632                              <1> loc_enter_separator_1:
  3633 0000847C 28E4                <1> 	sub     ah, ah ; 0
  3634 0000847E E86A8AFFFF          <1> 	call	int16h
  3635                              <1> 	; AL = ASCII Code of the Character
  3636 00008483 3C1B                <1> 	cmp	al, 27
  3637 00008485 0F8448010000        <1>         je      loc_set_date_retn
  3638 0000848B 3C2D                <1> 	cmp	al, '-'
  3639 0000848D 7408                <1> 	je	short pass_set_date_separator_1
  3640 0000848F 3C2F                <1> 	cmp	al, '/'
  3641 00008491 0F856C010000        <1>         jne     loc_set_date_stc_2
  3642                              <1> pass_set_date_separator_1:
  3643                              <1> 	; 13/05/2016
  3644                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  3645                              <1> 		      ; video page 0 (bh)
  3646 00008497 B307                <1> 	mov	bl, 7	
  3647 00008499 E8679EFFFF          <1> 	call	_write_tty
  3648                              <1> loc_enter_month_1:
  3649 0000849E 30E4                <1> 	xor     ah, ah ; 0
  3650 000084A0 E8488AFFFF          <1> 	call	int16h
  3651                              <1> 	; AL = ASCII Code of the Character
  3652 000084A5 3C1B                <1> 	cmp	al, 27
  3653 000084A7 0F8426010000        <1>         je      loc_set_date_retn
  3654 000084AD A2[05420100]        <1> 	mov	[Month], al
  3655 000084B2 3C30                <1> 	cmp	al, '0'
  3656 000084B4 0F8264010000        <1>         jb      loc_set_date_stc_3
  3657 000084BA 3C31                <1> 	cmp	al, '1'
  3658 000084BC 0F875C010000        <1>         ja      loc_set_date_stc_3
  3659                              <1> 	; 13/05/2016
  3660                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  3661                              <1> 		      ; video page 0 (bh)	
  3662 000084C2 B307                <1> 	mov	bl, 7
  3663 000084C4 E83C9EFFFF          <1> 	call	_write_tty
  3664                              <1> loc_enter_month_2:
  3665 000084C9 30E4                <1> 	xor     ah, ah
  3666 000084CB E81D8AFFFF          <1> 	call	int16h
  3667                              <1> 	; AL = ASCII Code of the Character
  3668 000084D0 3C1B                <1> 	cmp	al, 27
  3669 000084D2 0F84FB000000        <1>         je      loc_set_date_retn
  3670 000084D8 A2[06420100]        <1> 	mov	[Month+1], al
  3671 000084DD 3C30                <1> 	cmp	al, '0'
  3672 000084DF 0F8254010000        <1>         jb      loc_set_date_stc_4
  3673 000084E5 3C39                <1> 	cmp	al, '9'
  3674 000084E7 0F874C010000        <1>         ja      loc_set_date_stc_4
  3675 000084ED 803D[05420100]31    <1> 	cmp	byte [Month], '1'
  3676 000084F4 7208                <1> 	jb	short pass_set_month_12
  3677 000084F6 3C32                <1> 	cmp	al, '2'
  3678 000084F8 0F873B010000        <1>         ja      loc_set_date_stc_4
  3679                              <1> pass_set_month_12:
  3680                              <1> 	; 13/05/2016
  3681                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  3682                              <1> 		      ; video page 0 (bh)
  3683 000084FE B307                <1> 	mov	bl, 7	
  3684 00008500 E8009EFFFF          <1> 	call	_write_tty
  3685                              <1> loc_enter_separator_2:
  3686 00008505 28E4                <1> 	sub     ah, ah
  3687 00008507 E8E189FFFF          <1> 	call	int16h
  3688                              <1> 	; AL = ASCII Code of the Character
  3689 0000850C 3C1B                <1> 	cmp	al, 27
  3690 0000850E 0F84BF000000        <1>         je      loc_set_date_retn
  3691 00008514 3C2D                <1> 	cmp	al, '-'
  3692 00008516 7408                <1> 	je	short pass_set_date_separator_2
  3693 00008518 3C2F                <1> 	cmp	al, '/'
  3694 0000851A 0F8534010000        <1>         jne     loc_set_date_stc_5
  3695                              <1> pass_set_date_separator_2:
  3696                              <1> 	; 13/05/2016
  3697                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  3698                              <1> 		      ; video page 0 (bh)	
  3699 00008520 B307                <1> 	mov	bl, 7
  3700 00008522 E8DE9DFFFF          <1> 	call	_write_tty
  3701                              <1> loc_enter_year_1:
  3702 00008527 30E4                <1> 	xor    ah, ah
  3703 00008529 E8BF89FFFF          <1> 	call	int16h
  3704                              <1> 	; AL = ASCII Code of the Character
  3705 0000852E 3C1B                <1> 	cmp	al, 27
  3706 00008530 0F849D000000        <1>         je      loc_set_date_retn
  3707 00008536 A2[0A420100]        <1> 	mov	[Year], al
  3708 0000853B 3C30                <1> 	cmp	al, '0'
  3709 0000853D 0F822C010000        <1>         jb      loc_set_date_stc_6
  3710 00008543 3C39                <1> 	cmp	al, '9'
  3711 00008545 0F8724010000        <1>         ja      loc_set_date_stc_6
  3712                              <1> 	; 13/05/2016
  3713                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  3714                              <1> 		      ; video page 0 (bh)
  3715 0000854B B307                <1> 	mov	bl, 7	
  3716 0000854D E8B39DFFFF          <1> 	call	_write_tty
  3717                              <1> loc_enter_year_2:
  3718 00008552 30E4                <1> 	xor	ah, ah
  3719 00008554 E89489FFFF          <1> 	call	int16h
  3720                              <1> 	; AL = ASCII Code of the Character
  3721 00008559 3C1B                <1> 	cmp	al, 27
  3722 0000855B 7476                <1> 	je	short loc_set_date_retn
  3723 0000855D A2[0B420100]        <1> 	mov	byte [Year+1], al
  3724 00008562 3C30                <1> 	cmp	al, '0'
  3725 00008564 0F8220010000        <1>         jb      loc_set_date_stc_7
  3726 0000856A 3C39                <1> 	cmp	al, '9'
  3727 0000856C 0F8718010000        <1>         ja      loc_set_date_stc_7
  3728                              <1> 	; 13/05/2016
  3729                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  3730                              <1> 		      ; video page 0 (bh)
  3731 00008572 B307                <1> 	mov	bl, 7	
  3732 00008574 E88C9DFFFF          <1> 	call	_write_tty
  3733                              <1> loc_set_date_get_lchar_again:
  3734 00008579 28E4                <1> 	sub	ah, ah ; 0
  3735 0000857B E86D89FFFF          <1> 	call	int16h
  3736                              <1> 	; AL = ASCII Code of the Character
  3737 00008580 3C0D                <1> 	cmp	al, 13 ; ENTER key
  3738 00008582 7412                <1> 	je	short loc_set_date_progress
  3739 00008584 3C1B                <1> 	cmp	al, 27 ; ESC key
  3740 00008586 744B                <1> 	je	short loc_set_date_retn
  3741                              <1> 	;
  3742 00008588 E82A010000          <1> 	call	check_for_backspace
  3743 0000858D 75EA                <1> 	jne	short loc_set_date_get_lchar_again
  3744                              <1> 
  3745                              <1> loc_set_date_bs_8:
  3746 0000858F E811010000          <1> 	call	write_backspace
  3747 00008594 EBBC                <1> 	jmp	short loc_enter_year_2
  3748                              <1> 
  3749                              <1> loc_set_date_progress:
  3750                              <1> 	; Get Current Date
  3751                              <1> 	;mov	ah, 04h
  3752                              <1> 	;call	int1Ah
  3753 00008596 E888E5FFFF          <1> 	call	RTC_40	; GET RTC DATE
  3754                              <1> 	; CH = century (in BCD)
  3755                              <1> 
  3756 0000859B 66A1[0A420100]      <1> 	mov	ax, [Year]
  3757 000085A1 662D3030            <1> 	sub	ax, '00'
  3758 000085A5 C0E004              <1> 	shl	al, 4 ; * 16
  3759 000085A8 88C1                <1> 	mov	cl, al
  3760 000085AA 00E1                <1> 	add	cl, ah
  3761 000085AC 66A1[05420100]      <1> 	mov	ax, [Month]
  3762 000085B2 662D3030            <1> 	sub	ax, '00'
  3763 000085B6 C0E004              <1> 	shl	al, 4 ; * 16
  3764 000085B9 88C6                <1> 	mov	dh, al
  3765 000085BB 00E6                <1> 	add	dh, ah
  3766 000085BD 66A1[02420100]      <1> 	mov	ax, [Day]
  3767 000085C3 662D3030            <1> 	sub	ax, '00'
  3768 000085C7 C0E004              <1> 	shl	al, 4 ; * 16
  3769 000085CA 88C2                <1> 	mov	dl, al
  3770 000085CC 00E2                <1> 	add	dl, ah
  3771                              <1> 
  3772                              <1> 	;mov	ah, 05h
  3773                              <1> 	;call	int1Ah
  3774 000085CE E87DE5FFFF          <1> 	call	RTC_50	; SET RTC DATE
  3775                              <1> 
  3776                              <1> loc_set_date_retn:
  3777 000085D3 BE[5F4D0100]        <1> 	mov	esi, nextline
  3778 000085D8 E888EFFFFF          <1> 	call	print_msg
  3779 000085DD C3                  <1> 	retn
  3780                              <1> 
  3781                              <1> loc_set_date_stc_0:
  3782                              <1> 	;xor	bh, bh ; video page 0
  3783 000085DE E80E9EFFFF          <1> 	call	beeper ; BEEP !
  3784 000085E3 E925FEFFFF          <1>         jmp     loc_enter_day_1
  3785                              <1> loc_set_date_stc_1:
  3786 000085E8 E8CA000000          <1> 	call	check_for_backspace
  3787 000085ED 740A                <1> 	je	short loc_set_date_bs_1
  3788                              <1> 	;xor	bh, bh ; video page 0
  3789 000085EF E8FD9DFFFF          <1> 	call	beeper ; BEEP !
  3790 000085F4 E947FEFFFF          <1>         jmp     loc_enter_day_2
  3791                              <1> loc_set_date_bs_1:
  3792 000085F9 E8A7000000          <1> 	call	write_backspace
  3793 000085FE E90AFEFFFF          <1>         jmp     loc_enter_day_1
  3794                              <1> loc_set_date_stc_2:
  3795 00008603 E8AF000000          <1> 	call	check_for_backspace
  3796 00008608 740A                <1> 	je	short loc_set_date_bs_2
  3797                              <1> 	;xor	bh, bh ; video page 0
  3798 0000860A E8E29DFFFF          <1> 	call	beeper ; BEEP !
  3799 0000860F E968FEFFFF          <1>         jmp     loc_enter_separator_1
  3800                              <1> loc_set_date_bs_2:
  3801 00008614 E88C000000          <1> 	call	write_backspace
  3802 00008619 E922FEFFFF          <1>         jmp     loc_enter_day_2
  3803                              <1> loc_set_date_stc_3:
  3804 0000861E E894000000          <1> 	call	check_for_backspace	
  3805 00008623 740A                <1> 	je short loc_set_date_bs_3
  3806                              <1> 	;xor	bh, bh ; video page 0
  3807 00008625 E8C79DFFFF          <1> 	call	beeper ; BEEP !
  3808 0000862A E96FFEFFFF          <1>         jmp     loc_enter_month_1
  3809                              <1> loc_set_date_bs_3:
  3810 0000862F E871000000          <1> 	call	write_backspace
  3811 00008634 E943FEFFFF          <1>         jmp     loc_enter_separator_1
  3812                              <1> loc_set_date_stc_4:
  3813 00008639 E879000000          <1> 	call	check_for_backspace	
  3814 0000863E 740A                <1> 	je	short loc_set_date_bs_4
  3815                              <1> 	;xor	bh, bh ; video page 0
  3816 00008640 E8AC9DFFFF          <1> 	call	beeper ; BEEP !
  3817 00008645 E97FFEFFFF          <1>         jmp     loc_enter_month_2
  3818                              <1> loc_set_date_bs_4:
  3819 0000864A E856000000          <1> 	call	write_backspace
  3820 0000864F E94AFEFFFF          <1>         jmp     loc_enter_month_1
  3821                              <1> loc_set_date_stc_5:
  3822 00008654 E85E000000          <1> 	call	check_for_backspace
  3823 00008659 740A                <1> 	je	short loc_set_date_bs_5
  3824                              <1> 	;xor	bh, bh ; video page 0
  3825 0000865B E8919DFFFF          <1> 	call	beeper ; BEEP !
  3826 00008660 E9A0FEFFFF          <1>         jmp     loc_enter_separator_2
  3827                              <1> loc_set_date_bs_5:
  3828 00008665 E83B000000          <1> 	call	write_backspace
  3829 0000866A E95AFEFFFF          <1>         jmp     loc_enter_month_2
  3830                              <1> loc_set_date_stc_6:
  3831 0000866F E843000000          <1> 	call	check_for_backspace
  3832 00008674 740A                <1>         je      short  loc_set_date_bs_6
  3833                              <1> 	;xor	bh, bh ; video page 0
  3834 00008676 E8769DFFFF          <1> 	call	beeper ; BEEP !
  3835 0000867B E9A7FEFFFF          <1>         jmp     loc_enter_year_1
  3836                              <1> loc_set_date_bs_6:
  3837 00008680 E820000000          <1> 	call	write_backspace
  3838 00008685 E97BFEFFFF          <1>         jmp     loc_enter_separator_2
  3839                              <1> loc_set_date_stc_7:
  3840 0000868A E828000000          <1> 	call	check_for_backspace
  3841 0000868F 740A                <1> 	je	short loc_set_date_bs_7
  3842                              <1> 	;xor	bh, bh ; video page 0
  3843 00008691 E85B9DFFFF          <1> 	call	beeper ; BEEP !
  3844 00008696 E9B7FEFFFF          <1>         jmp     loc_enter_year_2
  3845                              <1> loc_set_date_bs_7:
  3846 0000869B E805000000          <1> 	call	write_backspace
  3847 000086A0 E982FEFFFF          <1>         jmp     loc_enter_year_1
  3848                              <1> 
  3849                              <1> write_backspace:
  3850                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
  3851 000086A5 B008                <1> 	mov	al, 08h ; BACKSPACE
  3852                              <1> 	; 13/05/2016
  3853 000086A7 66BB0700            <1> 	mov	bx, 7 ; bl = attribute/color
  3854                              <1> 		      ; bh = video page = 0	
  3855 000086AB E8559CFFFF          <1> 	call	_write_tty
  3856 000086B0 B020                <1> 	mov	al, 20h ; BLANK/SPACE char 
  3857                              <1> 	;mov	bx, 7 ; attribute/color
  3858                              <1> 	;call	_write_c_current
  3859                              <1> 	;retn
  3860 000086B2 E9C79BFFFF          <1> 	jmp	_write_c_current
  3861                              <1> 
  3862                              <1> check_for_backspace:
  3863                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
  3864 000086B7 663D080E            <1> 	cmp	ax, 0E08h
  3865 000086BB 7410                <1> 	je	short cfbs_retn
  3866 000086BD 663DE04B            <1> 	cmp	ax, 4BE0h
  3867 000086C1 740A                <1> 	je	short cfbs_retn
  3868 000086C3 663D004B            <1> 	cmp	ax, 4B00h
  3869 000086C7 7404                <1> 	je	short cfbs_retn
  3870 000086C9 663DE053            <1> 	cmp	ax, 53E0h
  3871                              <1> cfbs_retn:
  3872 000086CD C3                  <1> 	retn
  3873                              <1> 
  3874                              <1> show_time:
  3875                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
  3876                              <1>         ; 2004-2005
  3877                              <1> 
  3878                              <1> 	;mov	ah, 02h
  3879                              <1> 	;call	int1Ah
  3880 000086CE E8DFE3FFFF          <1> 	call	RTC_20	; GET RTC TIME
  3881                              <1> 	
  3882 000086D3 88E8                <1> 	mov	al, ch
  3883 000086D5 E80688FFFF          <1> 	call	bcd_to_ascii
  3884 000086DA 66A3[30420100]      <1> 	mov	[Hour], ax
  3885                              <1> 
  3886 000086E0 88C8                <1> 	mov	al, cl
  3887 000086E2 E8F987FFFF          <1> 	call	bcd_to_ascii
  3888 000086E7 66A3[33420100]      <1> 	mov	[Minute], ax
  3889                              <1> 
  3890 000086ED 88F0                <1> 	mov	al, dh
  3891 000086EF E8EC87FFFF          <1> 	call	bcd_to_ascii
  3892 000086F4 66A3[36420100]      <1> 	mov	[Second], ax
  3893                              <1> 
  3894 000086FA BE[20420100]        <1> 	mov	esi, Msg_Show_Time
  3895 000086FF E861EEFFFF          <1> 	call	print_msg
  3896 00008704 C3                  <1> 	retn
  3897                              <1> 
  3898                              <1> set_time:
  3899                              <1> 	; 13/05/2016
  3900                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
  3901                              <1>         ; 2004-2005
  3902                              <1> 
  3903 00008705 BE[0F420100]        <1> 	mov 	esi, Msg_Enter_Time
  3904 0000870A E856EEFFFF          <1> 	call	print_msg
  3905                              <1> 
  3906                              <1> loc_enter_hour_1:
  3907 0000870F 30E4                <1> 	xor     ah, ah
  3908 00008711 E8D787FFFF          <1> 	call	int16h
  3909                              <1> 	; AL = ASCII Code of the Character
  3910 00008716 3C0D                <1> 	cmp	al, 13 ; ENTER key
  3911 00008718 0F84AE010000        <1>         je      loc_set_time_retn
  3912 0000871E 3C1B                <1> 	cmp	al, 27 ; ESC key
  3913 00008720 0F84A6010000        <1>         je      loc_set_time_retn
  3914 00008726 A2[30420100]        <1> 	mov	[Hour], al
  3915 0000872B 3C30                <1> 	cmp	al, '0'
  3916 0000872D 0F82A4010000        <1>         jb      loc_set_time_stc_0
  3917 00008733 3C32                <1> 	cmp	al, '2'
  3918 00008735 0F879C010000        <1>         ja      loc_set_time_stc_0
  3919                              <1> 	; 13/05/2016
  3920                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  3921                              <1> 		      ; video page 0 (bh)
  3922 0000873B B307                <1> 	mov	bl, 7	
  3923 0000873D E8C39BFFFF          <1> 	call	_write_tty
  3924                              <1> loc_enter_hour_2:
  3925 00008742 30E4                <1> 	xor     ah, ah
  3926 00008744 E8A487FFFF          <1> 	call	int16h
  3927                              <1> 	; AL = ASCII Code of the Character
  3928 00008749 3C1B                <1> 	cmp	al, 27
  3929 0000874B 0F847B010000        <1>         je      loc_set_time_retn
  3930 00008751 A2[31420100]        <1> 	mov	[Hour+1], al
  3931 00008756 3C30                <1> 	cmp	al, '0'
  3932 00008758 0F8283010000        <1>         jb      loc_set_time_stc_1
  3933 0000875E 3C39                <1> 	cmp	al, '9'
  3934 00008760 0F877B010000        <1> 	ja	loc_set_time_stc_1
  3935 00008766 803D[30420100]32    <1>         cmp     byte [Hour], '2'
  3936 0000876D 7208                <1> 	jb	short pass_set_time_24
  3937 0000876F 3C34                <1> 	cmp	al, '4'
  3938 00008771 0F876A010000        <1>         ja      loc_set_time_stc_1
  3939                              <1> pass_set_time_24:
  3940                              <1> 	; 13/05/2016
  3941                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  3942                              <1> 		      ; video page 0 (bh)
  3943 00008777 B307                <1> 	mov	bl, 7	
  3944 00008779 E8879BFFFF          <1> 	call	_write_tty
  3945                              <1> loc_enter_time_separator_1:
  3946 0000877E 28E4                <1> 	sub    ah, ah ; 0
  3947 00008780 E86887FFFF          <1> 	call	int16h
  3948                              <1> 	; AL = ASCII Code of the Character
  3949 00008785 3C1B                <1> 	cmp	al, 27
  3950 00008787 0F843F010000        <1>         je      loc_set_time_retn
  3951 0000878D 3C3A                <1> 	cmp	al, ':'
  3952 0000878F 0F8567010000        <1>         jne     loc_set_time_stc_2
  3953                              <1> 	; 13/05/2016
  3954                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  3955                              <1> 		      ; video page 0 (bh)
  3956 00008795 B307                <1> 	mov	bl, 7	
  3957 00008797 E8699BFFFF          <1> 	call	_write_tty
  3958                              <1> loc_enter_minute_1:
  3959 0000879C 30E4                <1> 	xor     ah, ah
  3960 0000879E E84A87FFFF          <1> 	call	int16h
  3961                              <1> 	; AL = ASCII Code of the Character
  3962 000087A3 3C1B                <1> 	cmp	al, 27
  3963 000087A5 0F8421010000        <1>         je      loc_set_time_retn
  3964 000087AB A2[33420100]        <1> 	mov	[Minute], al
  3965 000087B0 3C30                <1> 	cmp	al, '0'
  3966 000087B2 0F825F010000        <1>         jb      loc_set_time_stc_3
  3967 000087B8 3C35                <1> 	cmp	al, '5'
  3968 000087BA 0F8757010000        <1>         ja      loc_set_time_stc_3
  3969                              <1> 	; 13/05/2016
  3970                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  3971                              <1> 		      ; video page 0 (bh)
  3972 000087C0 B307                <1> 	mov	bl, 7	
  3973 000087C2 E83E9BFFFF          <1> 	call	_write_tty
  3974                              <1> loc_enter_minute_2:
  3975 000087C7 30E4                <1> 	xor     ah, ah
  3976 000087C9 E81F87FFFF          <1> 	call	int16h
  3977                              <1> 	; AL = ASCII Code of the Character
  3978 000087CE 3C1B                <1> 	cmp	al, 27
  3979 000087D0 0F84F6000000        <1>         je      loc_set_time_retn
  3980 000087D6 A2[34420100]        <1> 	mov	[Minute+1], al
  3981 000087DB 3C30                <1> 	cmp	al, '0'
  3982 000087DD 0F824F010000        <1>         jb      loc_set_time_stc_4
  3983 000087E3 3C39                <1> 	cmp	al, '9'
  3984 000087E5 0F8747010000        <1>         ja      loc_set_time_stc_4
  3985                              <1> 	; 13/05/2016
  3986                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  3987                              <1> 		      ; video page 0 (bh)
  3988 000087EB B307                <1> 	mov	bl, 7	
  3989 000087ED E8139BFFFF          <1> 	call	_write_tty
  3990                              <1> loc_enter_time_separator_2:
  3991 000087F2 66C705[36420100]30- <1> 	mov	word [Second], 3030h
  3991 000087FA 30                  <1>
  3992 000087FB 28E4                <1> 	sub     ah, ah
  3993 000087FD E8EB86FFFF          <1> 	call	int16h
  3994                              <1> 	; AL = ASCII Code of the Character
  3995 00008802 3C0D                <1> 	cmp	al, 13
  3996 00008804 0F8485000000        <1>         je      loc_set_time_progress
  3997 0000880A 3C1B                <1> 	cmp	al, 27
  3998 0000880C 0F84BA000000        <1>         je      loc_set_time_retn
  3999 00008812 3C3A                <1> 	cmp	al, ':'
  4000 00008814 0F8533010000        <1>         jne     loc_set_time_stc_5
  4001                              <1> 	; 13/05/2016
  4002                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  4003                              <1> 		      ; video page 0 (bh)
  4004 0000881A B307                <1> 	mov	bl, 7	
  4005 0000881C E8E49AFFFF          <1> 	call	_write_tty
  4006                              <1> loc_enter_second_1:
  4007 00008821 30E4                <1> 	xor     ah, ah
  4008 00008823 E8C586FFFF          <1> 	call	int16h
  4009                              <1> 	; AL = ASCII Code of the Character
  4010 00008828 3C0D                <1> 	cmp	al, 13
  4011 0000882A 7463                <1> 	je	short loc_set_time_progress
  4012 0000882C 3C1B                <1> 	cmp	al, 27
  4013 0000882E 0F8498000000        <1>         je      loc_set_time_retn
  4014 00008834 A2[36420100]        <1> 	mov	[Second], al
  4015 00008839 3C30                <1> 	cmp	al, '0'
  4016 0000883B 0F8227010000        <1>         jb      loc_set_time_stc_6
  4017 00008841 3C35                <1> 	cmp	al, '5'
  4018 00008843 0F871F010000        <1>         ja      loc_set_time_stc_6
  4019                              <1> 	; 13/05/2016
  4020                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  4021                              <1> 		      ; video page 0 (bh)
  4022 00008849 B307                <1> 	mov	bl, 7	
  4023 0000884B E8B59AFFFF          <1> 	call	_write_tty
  4024                              <1> loc_enter_second_2:
  4025 00008850 30E4                <1> 	xor     ah, ah
  4026 00008852 E89686FFFF          <1> 	call	int16h
  4027                              <1> 	; AL = ASCII Code of the Character
  4028 00008857 3C1B                <1> 	cmp	al, 27
  4029 00008859 7471                <1> 	je	short loc_set_time_retn
  4030 0000885B 3C30                <1> 	cmp	al, '0'
  4031 0000885D 0F8229010000        <1>         jb      loc_set_time_stc_7
  4032 00008863 3C39                <1> 	cmp	al, '9'
  4033 00008865 0F8721010000        <1>         ja      loc_set_time_stc_7
  4034                              <1> 	; 13/05/2016
  4035                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  4036                              <1> 		      ; video page 0 (bh)
  4037 0000886B B307                <1> 	mov	bl, 7	
  4038 0000886D E8939AFFFF          <1> 	call	_write_tty
  4039                              <1> loc_set_time_get_lchar_again:
  4040 00008872 28E4                <1> 	sub	ah, ah ; 0
  4041 00008874 E87486FFFF          <1> 	call	int16h
  4042                              <1> 	; AL = ASCII Code of the Character
  4043 00008879 3C0D                <1> 	cmp	al, 13
  4044 0000887B 7412                <1> 	je	short loc_set_time_progress
  4045 0000887D 3C1B                <1> 	cmp	al, 27
  4046 0000887F 744B                <1> 	je	short loc_set_time_retn
  4047                              <1> 	;
  4048 00008881 E831FEFFFF          <1> 	call	check_for_backspace
  4049 00008886 75EA                <1> 	jne	short loc_set_time_get_lchar_again
  4050                              <1> 
  4051                              <1> loc_set_time_bs_8:
  4052 00008888 E818FEFFFF          <1> 	call	write_backspace
  4053 0000888D EBC1                <1> 	jmp	short loc_enter_second_2
  4054                              <1> 
  4055                              <1> loc_set_time_progress:
  4056                              <1> 	; Get Current Time
  4057                              <1> 	;mov 	ah, 02h
  4058                              <1> 	;call	int1Ah
  4059 0000888F E81EE2FFFF          <1> 	call	RTC_20	; GET RTC TIME
  4060                              <1> 	;DL = Daylight Savings Enable option (0-1)	
  4061                              <1> 
  4062 00008894 66A1[30420100]      <1> 	mov	ax, [Hour]
  4063 0000889A 662D3030            <1> 	sub	ax, '00'
  4064 0000889E C0E004              <1> 	shl	al, 4 ; * 16
  4065 000088A1 88C5                <1> 	mov	ch, al
  4066 000088A3 00E5                <1> 	add	ch, ah
  4067 000088A5 66A1[33420100]      <1> 	mov	ax, [Minute]
  4068 000088AB 662D3030            <1> 	sub	ax, '00'
  4069 000088AF C0E004              <1> 	shl	al, 4 ; * 16
  4070 000088B2 88C1                <1> 	mov	cl, al
  4071 000088B4 00E1                <1> 	add	cl, ah
  4072 000088B6 66A1[36420100]      <1> 	mov	ax, [Second]
  4073 000088BC 662D3030            <1> 	sub	ax, '00'
  4074 000088C0 C0E004              <1> 	shl	al, 4 ; * 16
  4075 000088C3 88C6                <1> 	mov	dh, al
  4076 000088C5 00E6                <1> 	add	dh, ah
  4077                              <1> 	
  4078                              <1> 	;mov	ah, 03h
  4079                              <1> 	;call	int1Ah
  4080 000088C7 E815E2FFFF          <1> 	call	RTC_30	; SET RTC TIME
  4081                              <1> 
  4082                              <1> loc_set_time_retn:
  4083 000088CC BE[5F4D0100]        <1> 	mov 	esi, nextline
  4084 000088D1 E88FECFFFF          <1> 	call	print_msg
  4085 000088D6 C3                  <1> 	retn
  4086                              <1> 
  4087                              <1> loc_set_time_stc_0:
  4088                              <1> 	;xor	bh, bh ; video page 0
  4089 000088D7 E8159BFFFF          <1> 	call	beeper ; BEEP !
  4090 000088DC E92EFEFFFF          <1>         jmp     loc_enter_hour_1
  4091                              <1> loc_set_time_stc_1:
  4092 000088E1 E8D1FDFFFF          <1> 	call	check_for_backspace
  4093 000088E6 740A                <1> 	je	short loc_set_time_bs_1
  4094                              <1> 	;xor	bh, bh ; video page 0
  4095 000088E8 E8049BFFFF          <1> 	call	beeper ; BEEP !
  4096 000088ED E950FEFFFF          <1>         jmp     loc_enter_hour_2
  4097                              <1> loc_set_time_bs_1:
  4098 000088F2 E8AEFDFFFF          <1> 	call	write_backspace
  4099 000088F7 E913FEFFFF          <1>         jmp     loc_enter_hour_1
  4100                              <1> loc_set_time_stc_2:
  4101 000088FC E8B6FDFFFF          <1> 	call	check_for_backspace
  4102 00008901 740A                <1> 	je	short loc_set_time_bs_2
  4103                              <1> 	;xor	bh, bh ; video page 0
  4104 00008903 E8E99AFFFF          <1> 	call	beeper ; BEEP !
  4105 00008908 E971FEFFFF          <1>         jmp     loc_enter_time_separator_1
  4106                              <1> loc_set_time_bs_2:
  4107 0000890D E893FDFFFF          <1> 	call	write_backspace
  4108 00008912 E92BFEFFFF          <1>         jmp     loc_enter_hour_2
  4109                              <1> loc_set_time_stc_3:
  4110 00008917 E89BFDFFFF          <1> 	call	check_for_backspace
  4111 0000891C 740A                <1> 	je	short loc_set_time_bs_3
  4112                              <1> 	;xor	bh, bh ; video page 0
  4113 0000891E E8CE9AFFFF          <1> 	call	beeper ; BEEP !6
  4114 00008923 E974FEFFFF          <1>         jmp     loc_enter_minute_1
  4115                              <1> loc_set_time_bs_3:
  4116 00008928 E878FDFFFF          <1> 	call	write_backspace
  4117 0000892D E94CFEFFFF          <1>         jmp     loc_enter_time_separator_1
  4118                              <1> loc_set_time_stc_4:
  4119 00008932 E880FDFFFF          <1> 	call	check_for_backspace
  4120 00008937 740A                <1> 	je	short loc_set_time_bs_4
  4121                              <1> 	;xor	bh, bh ; video page 0
  4122 00008939 E8B39AFFFF          <1> 	call	beeper ; BEEP !
  4123 0000893E E984FEFFFF          <1>         jmp     loc_enter_minute_2
  4124                              <1> loc_set_time_bs_4:
  4125 00008943 E85DFDFFFF          <1> 	call	write_backspace
  4126 00008948 E94FFEFFFF          <1>         jmp     loc_enter_minute_1
  4127                              <1> loc_set_time_stc_5:
  4128 0000894D E865FDFFFF          <1> 	call	check_for_backspace
  4129 00008952 740A                <1> 	je	short loc_set_time_bs_5
  4130                              <1> 	;xor	bh, bh ; video page 0
  4131 00008954 E8989AFFFF          <1> 	call	beeper ; BEEP !
  4132 00008959 E994FEFFFF          <1>         jmp     loc_enter_time_separator_2
  4133                              <1> loc_set_time_bs_5:
  4134 0000895E E842FDFFFF          <1> 	call	write_backspace
  4135 00008963 E95FFEFFFF          <1>         jmp     loc_enter_minute_2
  4136                              <1> loc_set_time_stc_6:
  4137 00008968 E84AFDFFFF          <1> 	call	check_for_backspace
  4138 0000896D 7413                <1> 	je	short loc_set_time_bs_6
  4139                              <1> 	;xor	bh, bh ; video page 0
  4140 0000896F E87D9AFFFF          <1> 	call	beeper ; BEEP !
  4141 00008974 66C705[36420100]30- <1> 	mov	word [Second], 3030h
  4141 0000897C 30                  <1>
  4142 0000897D E99FFEFFFF          <1>         jmp     loc_enter_second_1
  4143                              <1> loc_set_time_bs_6:
  4144 00008982 E81EFDFFFF          <1> 	call	write_backspace
  4145 00008987 E966FEFFFF          <1>         jmp     loc_enter_time_separator_2
  4146                              <1> loc_set_time_stc_7:
  4147 0000898C E826FDFFFF          <1> 	call	check_for_backspace
  4148 00008991 740A                <1> 	je	short loc_set_time_bs_7
  4149                              <1> 	;xor	bh, bh ; video page 0
  4150 00008993 E8599AFFFF          <1> 	call	beeper ; BEEP !
  4151 00008998 E9B3FEFFFF          <1>         jmp     loc_enter_second_2
  4152                              <1> loc_set_time_bs_7:
  4153 0000899D E803FDFFFF          <1> 	call	write_backspace
  4154 000089A2 E97AFEFFFF          <1>         jmp     loc_enter_second_1
  4155                              <1> 
  4156                              <1> print_volume_info:
  4157                              <1> 	; 01/03/2016
  4158                              <1> 	; 08/02/2016
  4159                              <1> 	; 06/02/2016
  4160                              <1> 	; 04/02/2016
  4161                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
  4162                              <1> 	; 25/10/2009
  4163                              <1> 	;
  4164                              <1> 	; "Volume Serial No: "
  4165                              <1>  	;
  4166                              <1> 	; INPUT  : AL = DOS Drive Number
  4167                              <1> 	; OUTPUT : AH = FS Type
  4168                              <1> 	;          AL = DOS Drive Name
  4169                              <1> 	; CF = 0 -> OK
  4170                              <1> 	; CF = 1 -> Drive not ready 
  4171                              <1> 
  4172 000089A7 88C4                <1> 	mov	ah, al
  4173 000089A9 28C0                <1> 	sub	al, al
  4174 000089AB 0FB7F0              <1> 	movzx	esi, ax	
  4175 000089AE 81C600010900        <1> 	add	esi, Logical_DOSDisks
  4176 000089B4 8A06                <1> 	mov	al, [esi]
  4177 000089B6 3C41                <1> 	cmp	al, 'A'  
  4178 000089B8 7304                <1> 	jnb	short loc_pvi_set_vol_name
  4179 000089BA 8A6604              <1> 	mov	ah, [esi+LD_FSType]
  4180 000089BD C3                  <1> 	retn
  4181                              <1> 
  4182                              <1> loc_pvi_set_vol_name:
  4183 000089BE A2[6A420100]        <1> 	mov	[Vol_Drv_Name], al
  4184 000089C3 56                  <1> 	push	esi
  4185 000089C4 E858010000          <1> 	call	move_volume_name_and_serial_no ;;;
  4186 000089C9 7302                <1> 	jnc	short loc_pvi_mvn_ok
  4187 000089CB 5E                  <1> 	pop	esi
  4188 000089CC C3                  <1> 	retn
  4189                              <1> 
  4190                              <1> loc_pvi_mvn_ok:
  4191 000089CD 8B3424              <1> 	mov	esi, [esp]
  4192 000089D0 807E04A1            <1> 	cmp	byte [esi+LD_FSType], 0A1h
  4193 000089D4 7509                <1> 	jne	short loc_pvi_fat_vol_size
  4194 000089D6 8B4670              <1> 	mov	eax, [esi+LD_FS_VolumeSize]
  4195 000089D9 0FB75E11            <1> 	movzx	ebx, word [esi+LD_FS_BytesPerSec]
  4196 000089DD EB07                <1> 	jmp	short loc_vol_size_mul32
  4197                              <1> loc_pvi_fat_vol_size:
  4198 000089DF 8B4670              <1> 	mov	eax, [esi+LD_TotalSectors]
  4199 000089E2 0FB75E11            <1> 	movzx	ebx, word [esi+LD_BPB+BPB_BytsPerSec]
  4200                              <1> loc_vol_size_mul32:
  4201 000089E6 F7E3                <1> 	mul	ebx
  4202 000089E8 09D2                <1> 	or	edx, edx
  4203 000089EA 7507                <1> 	jnz	short loc_vol_size_in_kbytes
  4204                              <1> loc_vol_size_in_bytes:
  4205 000089EC B9[48420100]        <1> 	mov	ecx, VolSize_Bytes
  4206 000089F1 EB0D                <1> 	jmp	short loc_write_vol_size_str
  4207                              <1> loc_vol_size_in_kbytes:
  4208 000089F3 66BB0004            <1> 	mov	bx, 1024
  4209 000089F7 F7F3                <1> 	div	ebx
  4210 000089F9 B9[3B420100]        <1> 	mov 	ecx, VolSize_KiloBytes
  4211 000089FE 31D2                <1> 	xor	edx, edx ; 0
  4212                              <1> loc_write_vol_size_str:
  4213 00008A00 890D[2B920100]      <1> 	mov	[VolSize_Unit1], ecx
  4214                              <1> 	; 
  4215 00008A06 BF[41920100]        <1> 	mov	edi, Vol_Tot_Sec_Str_End
  4216                              <1>         ;mov	byte [edi], 0
  4217 00008A0B B90A000000          <1> 	mov	ecx, 10
  4218                              <1> loc_write_vol_size_chr:
  4219 00008A10 F7F1                <1> 	div	ecx
  4220 00008A12 80C230              <1> 	add	dl, '0'
  4221 00008A15 4F                  <1> 	dec	edi	
  4222 00008A16 8817                <1> 	mov	[edi], dl
  4223 00008A18 85C0                <1> 	test	eax, eax
  4224 00008A1A 7404                <1> 	jz	short loc_write_vol_size_str_ok
  4225 00008A1C 28D2                <1> 	sub	dl, dl ; 0
  4226 00008A1E EBF0                <1> 	jmp	short loc_write_vol_size_chr
  4227                              <1> 
  4228                              <1> loc_write_vol_size_str_ok:
  4229 00008A20 893D[33920100]      <1> 	mov	[Vol_Tot_Sec_Str_Start], edi
  4230                              <1> 	;
  4231 00008A26 BF[53420100]        <1> 	mov	edi, Vol_FS_Name
  4232 00008A2B 8A4E03              <1> 	mov	cl, [esi+LD_FATType]
  4233 00008A2E 20C9                <1> 	and	cl, cl ; 0 ?
  4234 00008A30 7515                <1> 	jnz	short loc_write_vol_FAT_str_1
  4235 00008A32 66C7075452          <1> 	mov	word [edi], 'TR'
  4236 00008A37 C7470420465331      <1> 	mov	dword [edi+4], ' FS1'
  4237                              <1> 	;movzx	ebx, word [esi+LD_FS_BytesPerSec]
  4238 00008A3E 668B5E11            <1> 	mov	bx, [esi+LD_FS_BytesPerSec]
  4239 00008A42 8B4674              <1> 	mov	eax, [esi+LD_FS_FreeSectors]
  4240 00008A45 EB36                <1> 	jmp	short loc_vol_freespace_mul32
  4241                              <1> 
  4242                              <1> loc_write_vol_FAT_str_1:
  4243 00008A47 66B83332            <1> 	mov	ax, '32' ; FAT32
  4244 00008A4B 80F902              <1> 	cmp	cl, 2 ; [esi+LD_FATType]
  4245 00008A4E 7708                <1> 	ja	short loc_write_vol_FAT_str_2
  4246 00008A50 66B83132            <1> 	mov	ax, '12' ; FAT12
  4247 00008A54 7202                <1> 	jb	short loc_write_vol_FAT_str_2
  4248 00008A56 B436                <1> 	mov	ah, '6'  ; FAT16
  4249                              <1> loc_write_vol_FAT_str_2:
  4250 00008A58 C70746415420        <1> 	mov	dword [edi], 'FAT '
  4251 00008A5E 66894704            <1> 	mov	word [edi+4], ax
  4252                              <1> 	;
  4253                              <1> 	;movzx	ebx, word [esi+LD_BPB+BPB_BytsPerSec]
  4254 00008A62 668B5E11            <1> 	mov	bx, [esi+LD_BPB+BPB_BytsPerSec]
  4255 00008A66 8B4674              <1> 	mov	eax, [esi+LD_FreeSectors]
  4256                              <1> 
  4257                              <1> loc_vol_freespace_recalc0:
  4258                              <1> 	; 01/03/2016
  4259 00008A69 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh
  4260 00008A6C 720F                <1> 	jb	short loc_vol_freespace_mul32
  4261                              <1> 	;inc	eax ; 0
  4262 00008A6E 20C9                <1> 	and	cl, cl ; byte [esi+LD_FATType]
  4263 00008A70 740B                <1> 	jz	short loc_vol_freespace_mul32 	
  4264 00008A72 53                  <1> 	push	ebx
  4265 00008A73 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate free sectors
  4266 00008A77 E876490000          <1> 	call	calculate_fat_freespace
  4267 00008A7C 5B                  <1> 	pop	ebx
  4268                              <1> 
  4269                              <1> loc_vol_freespace_mul32:
  4270 00008A7D F7E3                <1> 	mul	ebx
  4271 00008A7F 09D2                <1> 	or	edx, edx
  4272 00008A81 7507                <1> 	jnz	short loc_vol_fspace_in_kbytes
  4273                              <1> loc_vol_fspace_in_bytes:
  4274 00008A83 B9[48420100]        <1> 	mov	ecx, VolSize_Bytes
  4275 00008A88 EB0D                <1> 	jmp	short loc_write_vol_fspace_str
  4276                              <1> loc_vol_fspace_in_kbytes:
  4277 00008A8A 66BB0004            <1> 	mov	bx, 1024
  4278 00008A8E F7F3                <1> 	div	ebx
  4279 00008A90 B9[3B420100]        <1> 	mov 	ecx, VolSize_KiloBytes
  4280 00008A95 31D2                <1> 	xor	edx, edx ; 0
  4281                              <1> loc_write_vol_fspace_str:
  4282 00008A97 890D[2F920100]      <1> 	mov	[VolSize_Unit2], ecx
  4283                              <1> 	;	
  4284 00008A9D BF[51920100]        <1> 	mov	edi, Vol_Free_Sectors_Str_End
  4285                              <1>         ;mov	byte [edi], 0
  4286 00008AA2 B90A000000          <1> 	mov	ecx, 10
  4287                              <1> loc_write_vol_fspace_chr:
  4288 00008AA7 F7F1                <1> 	div	ecx
  4289 00008AA9 80C230              <1> 	add	dl, '0'
  4290 00008AAC 4F                  <1> 	dec	edi	
  4291 00008AAD 8817                <1> 	mov	[edi], dl
  4292 00008AAF 85C0                <1> 	test	eax, eax
  4293 00008AB1 7404                <1> 	jz	short loc_write_vol_fspace_str_ok
  4294 00008AB3 28D2                <1> 	sub	dl, dl ; 0
  4295 00008AB5 EBF0                <1> 	jmp	short loc_write_vol_fspace_chr
  4296                              <1> 
  4297                              <1> loc_write_vol_fspace_str_ok:
  4298 00008AB7 893D[43920100]      <1> 	mov	[Vol_Free_Sectors_Str_Start], edi
  4299                              <1> 	;
  4300 00008ABD BE[51420100]        <1> 	mov	esi, Volume_in_drive
  4301 00008AC2 E89EEAFFFF          <1> 	call	print_msg
  4302 00008AC7 BE[91420100]        <1> 	mov	esi, Vol_Name
  4303 00008ACC E894EAFFFF          <1> 	call	print_msg
  4304 00008AD1 BE[5F4D0100]        <1> 	mov	esi, nextline
  4305 00008AD6 E88AEAFFFF          <1> 	call	print_msg
  4306                              <1> 	;
  4307 00008ADB BE[F2420100]        <1> 	mov	esi, Vol_Total_Sector_Header
  4308 00008AE0 E880EAFFFF          <1> 	call	print_msg
  4309 00008AE5 8B35[33920100]      <1> 	mov	esi, [Vol_Tot_Sec_Str_Start]
  4310 00008AEB E875EAFFFF          <1> 	call	print_msg
  4311 00008AF0 8B35[2B920100]      <1> 	mov	esi, [VolSize_Unit1]
  4312 00008AF6 E86AEAFFFF          <1> 	call	print_msg
  4313                              <1> 	;
  4314 00008AFB BE[03430100]        <1> 	mov	esi, Vol_Free_Sectors_Header
  4315 00008B00 E860EAFFFF          <1> 	call	print_msg
  4316 00008B05 8B35[43920100]      <1> 	mov	esi, [Vol_Free_Sectors_Str_Start]
  4317 00008B0B E855EAFFFF          <1> 	call	print_msg
  4318 00008B10 8B35[2F920100]      <1> 	mov	esi, [VolSize_Unit2]
  4319 00008B16 E84AEAFFFF          <1> 	call	print_msg
  4320                              <1> 	;
  4321 00008B1B 5E                  <1> 	pop	esi
  4322                              <1> 	
  4323                              <1> 	;mov	ah, [esi+LD_FSType]
  4324                              <1> 	;mov	al, [esi+LD_FATType]
  4325 00008B1C 668B4603            <1> 	mov	ax, [esi+LD_FATType]
  4326                              <1> 
  4327 00008B20 C3                  <1> 	retn
  4328                              <1> 
  4329                              <1> move_volume_name_and_serial_no:
  4330                              <1> 	; 08/02/2016  (TRDOS 386 = TRDOS v2.0)
  4331                              <1> 	; this routine will be called by
  4332                              <1> 	; "print_volume_info" and "print_directory"
  4333                              <1> 	; INPUT ->
  4334                              <1> 	;	ESI = Logical DOS drv descripton table address
  4335                              <1> 	; OUTPUT ->
  4336                              <1> 	;	*Volume name will be moved to text area
  4337                              <1> 	;	*Volume serial number will be converted to
  4338                              <1> 	;	 text and will be moved to text area
  4339                              <1> 	;   cf = 1 -> invalid/unknown dos drive
  4340                              <1> 	;   cf = 0 -> ecx = 0
  4341                              <1> 	;
  4342                              <1> 	; (eax, edx, ecx, esi, edi will be changed)
  4343                              <1> 
  4344 00008B21 BF[91420100]        <1> 	mov 	edi, Vol_Name
  4345                              <1> 
  4346                              <1> 	;mov	ah, [esi+LD_FSType]
  4347                              <1> 	;mov	al, [esi+LD_FATType]
  4348 00008B26 668B4603            <1> 	mov	ax, [esi+LD_FATType]
  4349 00008B2A 80FCA1              <1> 	cmp	ah, 0A1h
  4350 00008B2D 7418                <1> 	je	short mvn_2
  4351 00008B2F 08E4                <1> 	or	ah, ah
  4352 00008B31 7404                <1> 	jz	short mvn_0
  4353 00008B33 08C0                <1> 	or	al, al
  4354 00008B35 7504                <1> 	jnz	short mvn_1
  4355                              <1> mvn_0:
  4356 00008B37 8A06                <1> 	mov	al, [esi]
  4357 00008B39 F9                  <1> 	stc
  4358 00008B3A C3                  <1> 	retn
  4359                              <1> mvn_1:
  4360 00008B3B 3C02                <1> 	cmp	al, 2
  4361 00008B3D 7717                <1> 	ja	short mvn_3 
  4362                              <1> 	;or	al, al
  4363                              <1> 	;jz	short mvn_2
  4364 00008B3F 8B462D              <1> 	mov	eax, [esi+LD_BPB+VolumeID]
  4365 00008B42 83C631              <1> 	add	esi, LD_BPB+VolumeLabel
  4366 00008B45 EB15                <1> 	jmp	short mvn_4
  4367                              <1> mvn_2:
  4368 00008B47 8B4628              <1> 	mov	eax, [esi+LD_FS_VolumeSerial]
  4369 00008B4A 83C62C              <1> 	add	esi, LD_FS_VolumeName
  4370 00008B4D B910000000          <1> 	mov	ecx, 16
  4371 00008B52 F3A5                <1> 	rep	movsd
  4372 00008B54 EB10                <1> 	jmp	short mvn_5
  4373                              <1> mvn_3:
  4374 00008B56 8B4649              <1> 	mov	eax, [esi+LD_BPB+FAT32_VolID]
  4375 00008B59 83C64D              <1> 	add	esi, LD_BPB+FAT32_VolLab
  4376                              <1> mvn_4:
  4377 00008B5C B90B000000          <1> 	mov	ecx, 11
  4378 00008B61 F3A4                <1> 	rep	movsb
  4379 00008B63 C60700              <1> 	mov	byte [edi], 0
  4380                              <1> mvn_5:
  4381                              <1> 	;mov	[Current_VolSerial], eax  
  4382 00008B66 E8AAB7FFFF          <1> 	call	dwordtohex
  4383 00008B6B 8915[E6420100]      <1> 	mov	[Vol_Serial1], edx
  4384 00008B71 A3[EB420100]        <1> 	mov	[Vol_Serial2], eax
  4385                              <1> 	; ecx = 0
  4386 00008B76 C3                  <1> 	retn
  4387                              <1> 
  4388                              <1> get_volume_serial_number:
  4389                              <1> 	; 19/01/2016 (TRDOS 386 = TRDOS v2.0)
  4390                              <1> 	; 08/08/2010
  4391                              <1> 	;
  4392                              <1> 	; INPUT -> DL = Logical DOS Drive number
  4393                              <1> 	; OUTPUT -> EAX = Volume serial number
  4394                              <1> 	;          BL= FAT Type	    
  4395                              <1> 	;          BH = Logical DOS drv Number (DL input)
  4396                              <1> 	; cf = 1 -> Drive not ready
  4397                              <1> 
  4398 00008B77 31DB                <1> 	xor	ebx, ebx
  4399 00008B79 88D7                <1> 	mov	bh, dl
  4400 00008B7B 3815[C2400100]      <1> 	cmp	[Last_DOS_DiskNo], dl
  4401 00008B81 7304                <1> 	jnb	short loc_gvsn_start
  4402                              <1> loc_gvsn_stc_retn:
  4403 00008B83 31C0                <1> 	xor	eax, eax
  4404 00008B85 F9                  <1> 	stc 
  4405 00008B86 C3                  <1>         retn 
  4406                              <1> loc_gvsn_start:
  4407 00008B87 56                  <1> 	push	esi
  4408 00008B88 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  4409 00008B8D 01DE                <1> 	add	esi, ebx
  4410 00008B8F 8A5E03              <1> 	mov	bl, [esi+LD_FATType]
  4411 00008B92 20DB                <1> 	and	bl, bl
  4412 00008B94 740F                <1> 	jz	short loc_gvsn_fs
  4413 00008B96 80FB02              <1> 	cmp	bl, 2
  4414 00008B99 7705                <1> 	ja	short loc_gvsn_fat32
  4415                              <1> loc_gvsn_fat:
  4416 00008B9B 83C62D              <1> 	add	esi, LD_BPB + VolumeID
  4417 00008B9E EB0E                <1> 	jmp	short loc_gvsn_return
  4418                              <1> loc_gvsn_fat32: 
  4419 00008BA0 83C649              <1> 	add	esi, LD_BPB + FAT32_VolID
  4420 00008BA3 EB09                <1> 	jmp	short loc_gvsn_return 
  4421                              <1> loc_gvsn_fs:
  4422 00008BA5 807E04A1            <1> 	cmp	byte [esi+LD_FSType], 0A1h
  4423 00008BA9 75D8                <1> 	jne	short loc_gvsn_stc_retn 
  4424 00008BAB 83C628              <1> 	add	esi, LD_FS_VolumeSerial
  4425                              <1> loc_gvsn_return:
  4426 00008BAE 8B06                <1> 	mov	eax, [esi]
  4427 00008BB0 5E                  <1> 	pop	esi
  4428 00008BB1 C3                  <1> 	retn
  4429                              <1> 
  4430                              <1> ; CMD_INTR.ASM [ TRDOS Command Interpreter Procedure ]
  4431                              <1> ; 09/11/2011
  4432                              <1> ; 29/01/2005
  4433                              <1> 
  4434                              <1> command_interpreter:
  4435                              <1> 	; 16/10/2016
  4436                              <1> 	; 12/10/2016
  4437                              <1> 	; 13/05/2016
  4438                              <1> 	; 07/05/2016
  4439                              <1> 	; 04/03/2016
  4440                              <1> 	; 04/02/2016
  4441                              <1> 	; 03/02/2016
  4442                              <1> 	; 30/01/2016
  4443                              <1> 	; 29/01/2016 (TRDOS 386 = TRDOS 2.0)
  4444                              <1> 	; 15/09/2011         
  4445                              <1> 	; 29/01/2005
  4446                              <1>         
  4447                              <1> 	; Input: ecx = command word length (CL)
  4448                              <1> 	;	 CommandBuffer = Command string offset
  4449                              <1>  
  4450 00008BB2 C605[E4920100]00    <1> 	mov	byte [Program_Exit],0
  4451 00008BB9 80F904              <1> 	cmp	cl, 4
  4452 00008BBC 0F87B5020000        <1>         ja      c_6
  4453 00008BC2 0F8237010000        <1>         jb      c_2
  4454                              <1> c_4:
  4455                              <1> 
  4456                              <1> cmp_cmd_exit:
  4457 00008BC8 BF[30410100]        <1> 	mov	edi, Cmd_Exit
  4458 00008BCD E8C2030000          <1> 	call	cmp_cmd	
  4459 00008BD2 7208                <1> 	jc	short cmp_cmd_date
  4460                              <1> 
  4461 00008BD4 C605[E4920100]01    <1>         mov     byte [Program_Exit], 1
  4462 00008BDB C3                  <1>         retn
  4463                              <1> 
  4464                              <1> cmp_cmd_date:
  4465 00008BDC B104                <1> 	mov	cl, 4
  4466 00008BDE BF[4C410100]        <1> 	mov	edi, Cmd_Date
  4467 00008BE3 E8AC030000          <1> 	call	cmp_cmd	
  4468 00008BE8 720B                <1>         jc	short cmp_cmd_time
  4469                              <1> 	
  4470 00008BEA E8D0F7FFFF          <1> 	call	show_date
  4471 00008BEF E80FF8FFFF          <1> 	call	set_date
  4472 00008BF4 C3                  <1> 	retn
  4473                              <1> 
  4474                              <1> cmp_cmd_time:
  4475 00008BF5 B104                <1> 	mov	cl, 4
  4476 00008BF7 BF[51410100]        <1> 	mov	edi, Cmd_Time
  4477 00008BFC E893030000          <1>    	call	cmp_cmd	
  4478 00008C01 720B                <1> 	jc	short cmp_cmd_show
  4479                              <1> 
  4480 00008C03 E8C6FAFFFF          <1> 	call	show_time
  4481 00008C08 E8F8FAFFFF          <1> 	call	set_time
  4482 00008C0D C3                  <1> 	retn
  4483                              <1> 
  4484                              <1> cmp_cmd_show:
  4485 00008C0E B104                <1> 	mov	cl, 4
  4486 00008C10 BF[62410100]        <1> 	mov	edi, Cmd_Show
  4487 00008C15 E87A030000          <1>    	call	cmp_cmd	
  4488 00008C1A 0F83050A0000        <1>         jnc     show_file
  4489                              <1> 
  4490                              <1> cmp_cmd_echo:
  4491 00008C20 B104                <1> 	mov	cl, 4
  4492 00008C22 BF[9E410100]        <1> 	mov	edi, Cmd_Echo
  4493 00008C27 E868030000          <1>    	call	cmp_cmd	
  4494 00008C2C 7224                <1> 	jc	short cmp_cmd_copy
  4495                              <1> 	
  4496                              <1> 	; 22/11/2017
  4497                              <1> 	; AL = 0
  4498 00008C2E 803E20              <1> 	cmp	byte [esi], 20h
  4499 00008C31 7215                <1> 	jb	short cmd_echo_nextline
  4500                              <1> 	; 14/04/2016
  4501 00008C33 56                  <1> 	push	esi
  4502                              <1> cmd_echo_asciiz:
  4503                              <1> 	;inc	esi
  4504                              <1> 	;mov	al, [esi]
  4505                              <1> 	; 22/11/2017
  4506 00008C34 AC                  <1> 	lodsb
  4507 00008C35 3C20                <1> 	cmp	al, 20h
  4508 00008C37 73FB                <1> 	jnb	short cmd_echo_asciiz
  4509 00008C39 4E                  <1> 	dec	esi
  4510 00008C3A C60600              <1> 	mov	byte [esi], 0
  4511 00008C3D 5E                  <1> 	pop	esi
  4512 00008C3E 89F7                <1> 	mov	edi, esi
  4513 00008C40 E820E9FFFF          <1> 	call	print_msg
  4514 00008C45 C60700              <1> 	mov	byte [edi], 0	
  4515                              <1> cmd_echo_nextline:
  4516 00008C48 BE[CD4D0100]        <1> 	mov	esi, NextLine
  4517                              <1> 	;call	print_msg   
  4518                              <1> 	;retn
  4519 00008C4D E913E9FFFF          <1> 	jmp	print_msg
  4520                              <1> 
  4521                              <1> cmp_cmd_copy:
  4522 00008C52 B104                <1> 	mov	cl, 4
  4523 00008C54 BF[85410100]        <1> 	mov	edi, Cmd_Copy
  4524 00008C59 E836030000          <1>    	call	cmp_cmd	
  4525 00008C5E 0F83CC170000        <1> 	jnc	copy_file
  4526                              <1> 
  4527                              <1> cmp_cmd_move:
  4528 00008C64 B104                <1> 	mov	cl, 4
  4529 00008C66 BF[8A410100]        <1> 	mov	edi, Cmd_Move
  4530 00008C6B E824030000          <1>    	call	cmp_cmd	
  4531 00008C70 0F836E160000        <1> 	jnc	move_file
  4532                              <1> 
  4533                              <1> cmp_cmd_path:
  4534 00008C76 B104                <1> 	mov	cl, 4
  4535 00008C78 BF[8F410100]        <1> 	mov	edi, Cmd_Path
  4536 00008C7D E812030000          <1>    	call	cmp_cmd	
  4537 00008C82 0F83F0190000        <1> 	jnc	set_get_path
  4538                              <1> 
  4539                              <1> cmp_cmd_beep:
  4540 00008C88 B104                <1> 	mov	cl, 4
  4541 00008C8A BF[BC410100]        <1> 	mov	edi, Cmd_Beep
  4542 00008C8F E800030000          <1>    	call	cmp_cmd	
  4543 00008C94 720B                <1> 	jc	short cmp_cmd_find
  4544                              <1> 	; 13/05/2016
  4545 00008C96 8A3D[5E8A0100]      <1> 	mov	bh, [ptty] ; [ACTIVE_PAGE]
  4546 00008C9C E95097FFFF          <1> 	jmp	beeper
  4547                              <1> 
  4548                              <1> cmp_cmd_find:
  4549 00008CA1 B104                <1> 	mov	cl, 4
  4550 00008CA3 BF[99410100]        <1> 	mov	edi, Cmd_Find
  4551 00008CA8 E8E7020000          <1>    	call	cmp_cmd	
  4552 00008CAD 0F82C4020000        <1>         jc      cmp_cmd_external
  4553                              <1> 
  4554                              <1> 	;call	find_and_list_files
  4555 00008CB3 E9AF220000          <1> 	jmp	find_and_list_files
  4556                              <1> 	;retn
  4557                              <1> 
  4558                              <1> c_1:
  4559 00008CB8 AD                  <1> 	lodsd
  4560                              <1> cmp_cmd_help:
  4561 00008CB9 3C3F                <1> 	cmp	al, '?'
  4562 00008CBB 751D                <1>         jne     short cmp_cmd_remark
  4563                              <1> 
  4564 00008CBD BE[22410100]        <1> 	mov	esi, Command_List
  4565                              <1> cmd_help_next_w:
  4566 00008CC2 E89EE8FFFF          <1> 	call	print_msg
  4567                              <1> 
  4568 00008CC7 803E20              <1> 	cmp	byte [esi], 20h ; 0
  4569 00008CCA 7232                <1> 	jb	short cmd_help_retn
  4570                              <1> 	
  4571 00008CCC 56                  <1> 	push	esi
  4572 00008CCD BE[5F4D0100]        <1> 	mov	esi, nextline
  4573 00008CD2 E88EE8FFFF          <1> 	call	print_msg
  4574 00008CD7 5E                  <1> 	pop	esi
  4575 00008CD8 EBE8                <1> 	jmp	short cmd_help_next_w	
  4576                              <1> 
  4577                              <1> cmp_cmd_remark:
  4578 00008CDA 3C2A                <1> 	cmp	al, '*'
  4579 00008CDC 0F8595020000        <1>         jne     cmp_cmd_external
  4580 00008CE2 46                  <1> 	inc	esi
  4581 00008CE3 BF[588B0100]        <1> 	mov	edi, Remark
  4582 00008CE8 8A06                <1> 	mov	al, [esi]
  4583 00008CEA 3C20                <1> 	cmp	al, 20h
  4584 00008CEC 7707                <1> 	ja	short cmd_remark_write
  4585 00008CEE 89FE                <1> 	mov	esi, edi ; Remark
  4586 00008CF0 E970E8FFFF          <1> 	jmp	print_msg
  4587                              <1> 
  4588                              <1> cmd_remark_write:
  4589 00008CF5 AA                  <1> 	stosb
  4590 00008CF6 AC                  <1> 	lodsb
  4591 00008CF7 3C20                <1> 	cmp	al, 20h
  4592 00008CF9 73FA                <1> 	jnb	short cmd_remark_write
  4593 00008CFB C60700              <1> 	mov	byte [edi], 0
  4594                              <1> 
  4595                              <1> cmd_help_retn:
  4596                              <1> cmd_remark_retn:
  4597                              <1> cd_retn:
  4598 00008CFE C3                  <1> 	retn
  4599                              <1> 
  4600                              <1> c_2:
  4601 00008CFF 80F902              <1> 	cmp	cl, 2
  4602 00008D02 0F87AF000000        <1>         ja      c_3
  4603 00008D08 BE[A68B0100]        <1> 	mov	esi, CommandBuffer
  4604 00008D0D 72A9                <1> 	jb	short c_1
  4605                              <1> 
  4606                              <1> cmp_cmd_cd:
  4607 00008D0F 66AD                <1> 	lodsw
  4608 00008D11 663D4344            <1> 	cmp	ax, 'CD'
  4609 00008D15 7551                <1> 	jne	short cmp_cmd_drive
  4610 00008D17 46                  <1>         inc	esi
  4611                              <1> cd_0:
  4612 00008D18 668B06              <1> 	mov	ax, [esi]	
  4613 00008D1B 3C20                <1> 	cmp	al, 20h
  4614 00008D1D 76DF                <1> 	jna	short cd_retn
  4615                              <1> 	; 10/02/2016
  4616 00008D1F 80FC3A              <1> 	cmp	ah, ':'
  4617 00008D22 7504                <1> 	jne	short cd_1
  4618 00008D24 46                  <1> 	inc	esi
  4619 00008D25 46                  <1> 	inc	esi
  4620 00008D26 EB49                <1> 	jmp	short cd_2
  4621                              <1> 
  4622                              <1> cd_1:	; change current directory
  4623                              <1> 	; 29/11/2009
  4624                              <1> 	; AH = CDh	; to separate 'CD' command from others
  4625                              <1> 			; for restoring current directory
  4626                              <1> 			; 0CDh sign is for saving cdir into 
  4627                              <1> 			; DOS drv description table cdir area
  4628                              <1> 	
  4629 00008D28 B4CD                <1> 	mov	ah, 0CDh ; mov byte [CD_COMMAND], 0CDh 
  4630                              <1> 
  4631 00008D2A E81D230000          <1> 	call	change_current_directory
  4632 00008D2F 0F8337220000        <1>         jnc     change_prompt_dir_string
  4633                              <1> 
  4634                              <1> cd_error_messages:
  4635 00008D35 3C03                <1> 	cmp	al, 3
  4636 00008D37 740C                <1> 	je	short cd_path_not_found
  4637                              <1> 	; 16/10/2016 (15h -> 15)
  4638 00008D39 3C0F                <1> 	cmp	al, 15 ; drive not ready error 
  4639 00008D3B 7459                <1> 	je	short cd_drive_not_ready
  4640 00008D3D 3C11                <1> 	cmp	al, 17 ; read error
  4641 00008D3F 7455                <1> 	je	short cd_drive_not_ready	
  4642 00008D41 3C13                <1> 	cmp	al, 19 ; ; Bad directory/path name 
  4643 00008D43 7466                <1> 	je	short cd_command_failed
  4644                              <1> 
  4645                              <1> cd_path_not_found:
  4646 00008D45 50                  <1> 	push	eax ; 29/12/2017
  4647                              <1> 	;push	ax	
  4648 00008D46 BE[C5430100]        <1> 	mov	esi, Msg_Dir_Not_Found
  4649 00008D4B E815E8FFFF          <1> 	call	print_msg
  4650                              <1> 	;pop	ax
  4651 00008D50 58                  <1> 	pop	eax ; 29/12/2017
  4652 00008D51 3A25[F48A0100]      <1> 	cmp	ah, [Current_Dir_Level]
  4653 00008D57 0F830F220000        <1>         jnb     change_prompt_dir_string
  4654 00008D5D 8825[F48A0100]      <1> 	mov	[Current_Dir_Level], ah
  4655 00008D63 E904220000          <1>         jmp     change_prompt_dir_string   
  4656                              <1> 
  4657                              <1> cmp_cmd_drive: ; change current drive
  4658                              <1> 	; C:, D:, E: etc.
  4659 00008D68 80FC3A              <1> 	cmp	ah, ':'
  4660 00008D6B 0F8506020000        <1>         jne     cmp_cmd_external
  4661                              <1> 
  4662                              <1> cd_2:	; 'CD C:', 'CD D:' ...
  4663 00008D71 803E20              <1> 	cmp	byte [esi], 20h
  4664 00008D74 0F8707020000        <1>         ja      loc_cmd_failed
  4665                              <1> 
  4666 00008D7A 24DF                <1> 	and	al, 0DFh
  4667 00008D7C 2C41                <1> 	sub	al, 'A'
  4668 00008D7E 0F82FD010000        <1>         jc      loc_cmd_failed
  4669                              <1> 
  4670 00008D84 3A05[C2400100]      <1>         cmp     al, [Last_DOS_DiskNo]
  4671 00008D8A 770A                <1>         ja	short cd_drive_not_ready
  4672                              <1> 	
  4673 00008D8C 88C2                <1> 	mov	dl, al
  4674 00008D8E E85BF3FFFF          <1> 	call 	change_current_drive
  4675 00008D93 7201                <1> 	jc	short cd_drive_not_ready	
  4676 00008D95 C3                  <1> 	retn
  4677                              <1> 
  4678                              <1> cd_drive_not_ready:
  4679 00008D96 BE[82430100]        <1> 	mov	esi, Msg_Not_Ready_Read_Err
  4680 00008D9B E8C5E7FFFF          <1> 	call	print_msg
  4681                              <1> 
  4682                              <1> cd_fail_drive_restart:
  4683 00008DA0 8A15[F68A0100]      <1> 	mov	dl, [Current_Drv]
  4684                              <1> 	;call 	change_current_drive
  4685 00008DA6 E943F3FFFF          <1>         jmp     change_current_drive
  4686                              <1> 	;retn
  4687                              <1> 
  4688                              <1> cd_command_failed:
  4689 00008DAB BE[63430100]        <1> 	mov	esi, Msg_Bad_Command
  4690 00008DB0 E8B0E7FFFF          <1> 	call	print_msg
  4691 00008DB5 EBE9                <1> 	jmp	short cd_fail_drive_restart
  4692                              <1> 
  4693                              <1> c_3:
  4694                              <1> cmp_cmd_dir:
  4695 00008DB7 BF[22410100]        <1> 	mov	edi, Cmd_Dir
  4696 00008DBC E8D3010000          <1> 	call	cmp_cmd	
  4697 00008DC1 0F8380020000        <1> 	jnc	print_directory_list
  4698                              <1> 
  4699                              <1> cmp_cmd_cls:
  4700 00008DC7 B103                <1> 	mov	cl, 3
  4701 00008DC9 BF[5E410100]        <1> 	mov	edi, Cmd_Cls
  4702 00008DCE E8C1010000          <1> 	call	cmp_cmd	
  4703 00008DD3 0F83A2E7FFFF        <1>         jnc	clear_screen
  4704                              <1> 
  4705                              <1> cmp_cmd_ver:
  4706 00008DD9 B103                <1> 	mov	cl, 3
  4707 00008DDB BF[2C410100]        <1> 	mov	edi, Cmd_Ver
  4708 00008DE0 E8AF010000          <1> 	call	cmp_cmd	
  4709 00008DE5 720A                <1> 	jc	short cmp_cmd_mem
  4710                              <1> 
  4711 00008DE7 BE[CA400100]        <1> 	mov	esi, mainprog_Version
  4712                              <1> 	;call	print_msg
  4713 00008DEC E974E7FFFF          <1> 	jmp	print_msg
  4714                              <1> 	;retn
  4715                              <1> 
  4716                              <1> cmp_cmd_mem:
  4717 00008DF1 B103                <1> 	mov	cl, 3
  4718 00008DF3 BF[94410100]        <1> 	mov	edi, Cmd_Mem
  4719 00008DF8 E897010000          <1> 	call	cmp_cmd	
  4720 00008DFD 0F8344B4FFFF        <1> 	jnc	memory_info
  4721                              <1> 
  4722                              <1> cmp_cmd_del:
  4723 00008E03 B103                <1> 	mov	cl, 3
  4724 00008E05 BF[67410100]        <1> 	mov	edi, Cmd_Del
  4725 00008E0A E885010000          <1> 	call	cmp_cmd	
  4726 00008E0F 0F83280F0000        <1>         jnc     delete_file
  4727                              <1> 
  4728                              <1> cmp_cmd_set:
  4729 00008E15 B103                <1> 	mov	cl, 3
  4730 00008E17 BF[5A410100]        <1> 	mov	edi, Cmd_Set
  4731 00008E1C E873010000          <1> 	call	cmp_cmd	
  4732 00008E21 0F83C9170000        <1>         jnc     set_get_env
  4733                              <1> 
  4734                              <1> cmp_cmd_run:
  4735 00008E27 B103                <1> 	mov	cl, 3
  4736 00008E29 BF[56410100]        <1> 	mov	edi, Cmd_Run
  4737 00008E2E E861010000          <1> 	call	cmp_cmd	
  4738                              <1> 	; 07/05/2016
  4739 00008E33 0F823E010000        <1>         jc      cmp_cmd_external
  4740 00008E39 E90F1E0000          <1> 	jmp	load_and_execute_file
  4741                              <1> c_5:
  4742                              <1> cmp_cmd_mkdir:
  4743 00008E3E BF[7F410100]        <1> 	mov	edi, Cmd_Mkdir
  4744 00008E43 E84C010000          <1> 	call	cmp_cmd	
  4745 00008E48 0F83990A0000        <1>         jnc     make_directory
  4746                              <1> 
  4747                              <1> cmp_cmd_rmdir:
  4748 00008E4E B105                <1> 	mov	cl, 5
  4749 00008E50 BF[79410100]        <1> 	mov	edi, Cmd_Rmdir
  4750 00008E55 E83A010000          <1> 	call	cmp_cmd	
  4751 00008E5A 0F83AA0B0000        <1>         jnc     delete_directory
  4752                              <1> 
  4753                              <1> cmp_cmd_chdir:
  4754 00008E60 B105                <1> 	mov	cl, 5
  4755 00008E62 BF[B6410100]        <1> 	mov	edi, Cmd_Chdir
  4756 00008E67 E828010000          <1> 	call	cmp_cmd	
  4757 00008E6C 0F8205010000        <1>         jc      cmp_cmd_external
  4758                              <1> 
  4759 00008E72 E9A1FEFFFF          <1> 	jmp	cd_0
  4760                              <1> 
  4761                              <1> c_6:
  4762 00008E77 80F906              <1> 	cmp	cl, 6
  4763 00008E7A 0F87E0000000        <1>         ja      c_8
  4764 00008E80 72BC                <1> 	jb	short c_5
  4765                              <1> cmp_cmd_prompt:
  4766 00008E82 BF[35410100]        <1> 	mov	edi, Cmd_Prompt
  4767 00008E87 E808010000          <1> 	call	cmp_cmd	
  4768 00008E8C 722F                <1>         jc	short cmp_cmd_volume
  4769                              <1> get_prompt_name_fchar:
  4770 00008E8E AC                  <1> 	lodsb
  4771 00008E8F 3C20                <1> 	cmp	al, 20h
  4772 00008E91 74FB                <1> 	je	short get_prompt_name_fchar
  4773 00008E93 7713                <1> 	ja	short loc_change_prompt_label
  4774                              <1> default_command_prompt: ; 31/12/2017 ('sysprompt')
  4775 00008E95 BE[16410100]        <1> 	mov	esi, TRDOSPromptLabel
  4776 00008E9A C7065452444F        <1> 	mov	dword [esi], "TRDO"
  4777 00008EA0 66C746045300        <1>        	mov	word [esi+4], "S" 
  4778                              <1> loc_cmd_prompt_return:
  4779 00008EA6 C3                  <1> 	retn
  4780                              <1> 
  4781                              <1> set_command_prompt: ; 31/12/2017 ('sysprompt')
  4782 00008EA7 AC                  <1> 	lodsb
  4783                              <1> loc_change_prompt_label:
  4784 00008EA8 66B90B00            <1> 	mov	cx, 11
  4785 00008EAC BF[16410100]        <1> 	mov	edi, TRDOSPromptLabel
  4786                              <1> put_char_new_prompt_label:
  4787 00008EB1 AA                  <1> 	stosb
  4788 00008EB2 AC                  <1> 	lodsb
  4789 00008EB3 3C20                <1> 	cmp	al, 20h
  4790 00008EB5 7202                <1> 	jb	short pass_put_new_prompt_label
  4791 00008EB7 E2F8                <1> 	loop	put_char_new_prompt_label
  4792                              <1> pass_put_new_prompt_label:
  4793 00008EB9 C60700              <1> 	mov	byte [edi], 0
  4794 00008EBC C3                  <1> 	retn
  4795                              <1> 
  4796                              <1> cmp_cmd_volume:
  4797 00008EBD B106                <1> 	mov	cl, 6
  4798 00008EBF BF[3C410100]        <1> 	mov	edi, Cmd_Volume
  4799 00008EC4 E8CB000000          <1> 	call	cmp_cmd	
  4800 00008EC9 7255                <1>         jc	short cmp_cmd_attrib
  4801                              <1> 
  4802                              <1> cmd_vol1:
  4803 00008ECB AC                  <1> 	lodsb
  4804 00008ECC 3C20                <1> 	cmp	al, 20h
  4805 00008ECE 7707                <1> 	ja	short cmd_vol2
  4806 00008ED0 A0[F68A0100]        <1> 	mov	al, [Current_Drv]
  4807 00008ED5 EB3D                <1> 	jmp	short cmd_vol4
  4808                              <1> cmd_vol2:
  4809 00008ED7 3C41                <1> 	cmp	al, 'A'
  4810 00008ED9 0F82A2000000        <1>         jb      loc_cmd_failed
  4811 00008EDF 3C7A                <1> 	cmp	al, 'z'
  4812 00008EE1 0F879A000000        <1>         ja      loc_cmd_failed
  4813 00008EE7 3C5A                <1> 	cmp	al, 'Z'
  4814 00008EE9 760A                <1> 	jna	short cmd_vol3
  4815 00008EEB 3C61                <1> 	cmp	al, 'a'
  4816 00008EED 0F828E000000        <1>         jb      loc_cmd_failed
  4817 00008EF3 24DF                <1> 	and	al, 0DFh
  4818                              <1> cmd_vol3:
  4819 00008EF5 8A26                <1> 	mov	ah, [esi]
  4820 00008EF7 80FC3A              <1> 	cmp	ah, ':'
  4821 00008EFA 0F8581000000        <1>         jne     loc_cmd_failed
  4822 00008F00 2C41                <1> 	sub	al, 'A'
  4823 00008F02 3A05[C2400100]      <1>         cmp     al, [Last_DOS_DiskNo]
  4824 00008F08 760A                <1> 	jna	short cmd_vol4
  4825                              <1> 
  4826 00008F0A BE[82430100]        <1> 	mov	esi, Msg_Not_Ready_Read_Err
  4827 00008F0F E951E6FFFF          <1> 	jmp	print_msg
  4828                              <1> 	
  4829                              <1> cmd_vol4:
  4830 00008F14 E88EFAFFFF          <1> 	call	print_volume_info
  4831 00008F19 0F8277FEFFFF        <1>         jc      cd_drive_not_ready
  4832 00008F1F C3                  <1> 	retn
  4833                              <1> 
  4834                              <1> cmp_cmd_attrib:
  4835 00008F20 B106                <1> 	mov	cl, 6
  4836 00008F22 BF[6B410100]        <1> 	mov	edi, Cmd_Attrib
  4837 00008F27 E868000000          <1> 	call	cmp_cmd	
  4838 00008F2C 0F831D0F0000        <1>         jnc     set_file_attributes
  4839                              <1> 
  4840                              <1> cmp_cmd_rename:
  4841 00008F32 B106                <1> 	mov	cl, 6
  4842 00008F34 BF[72410100]        <1> 	mov	edi, Cmd_Rename
  4843 00008F39 E856000000          <1> 	call	cmp_cmd	
  4844 00008F3E 0F8353110000        <1>         jnc     rename_file
  4845                              <1> 
  4846                              <1> cmp_cmd_device:
  4847 00008F44 B106                <1> 	mov	cl, 6
  4848 00008F46 BF[A7410100]        <1> 	mov	edi, Cmd_Device
  4849 00008F4B E844000000          <1> 	call	cmp_cmd	
  4850 00008F50 7225                <1>         jc	short cmp_cmd_external
  4851                              <1> 
  4852 00008F52 C3                  <1> 	retn
  4853                              <1> 
  4854                              <1> c_7:
  4855                              <1> cmp_cmd_devlist:
  4856 00008F53 BF[AE410100]        <1> 	mov	edi, Cmd_DevList
  4857 00008F58 E837000000          <1> 	call	cmp_cmd	
  4858 00008F5D 7218                <1>         jc	short cmp_cmd_external
  4859                              <1> 
  4860                              <1> loc_cmd_return:
  4861 00008F5F C3                  <1> 	retn
  4862                              <1> 
  4863                              <1> c_8:
  4864 00008F60 80F908              <1>         cmp	cl, 8
  4865 00008F63 7712                <1> 	ja	short cmp_cmd_external
  4866 00008F65 72EC                <1> 	jb	short c_7
  4867                              <1> 
  4868                              <1> cmp_cmd_longname:
  4869 00008F67 BF[43410100]        <1> 	mov	edi, Cmd_LongName
  4870 00008F6C E823000000          <1> 	call	cmp_cmd	
  4871 00008F71 0F8350060000        <1>         jnc     get_and_print_longname
  4872                              <1> 
  4873                              <1> cmp_cmd_external:
  4874                              <1> 	; 07/05/2016
  4875                              <1> 	; 22/04/2016
  4876 00008F77 BE[A68B0100]        <1> 	mov	esi, CommandBuffer
  4877 00008F7C E9CC1C0000          <1> 	jmp	loc_run_check_filename 
  4878                              <1> 
  4879                              <1> loc_cmd_failed:
  4880 00008F81 803D[A68B0100]20    <1> 	cmp	byte [CommandBuffer], 20h
  4881 00008F88 76D5                <1> 	jna	short loc_cmd_return
  4882 00008F8A BE[63430100]        <1> 	mov	esi, Msg_Bad_Command
  4883                              <1> ;	call	print_msg
  4884                              <1> ;loc_cmd_return:
  4885                              <1> ;	retn
  4886 00008F8F E9D1E5FFFF          <1> 	jmp	print_msg
  4887                              <1> 
  4888                              <1> cmp_cmd:
  4889                              <1> 	 ; 29/01/2016 (TRDOS 386 = TRDOS v2.0)
  4890 00008F94 BE[A68B0100]        <1>          mov	esi, CommandBuffer
  4891                              <1>          ; edi = internal command word (ASCIIZ)
  4892                              <1> 	 ; ecx = command length (<=8)
  4893                              <1> cmp_cmd_1:
  4894 00008F99 AC                  <1> 	lodsb
  4895 00008F9A AE                  <1> 	scasb
  4896 00008F9B 750D                <1> 	jne	short cmp_cmd_3
  4897 00008F9D E2FA                <1> 	loop	cmp_cmd_1
  4898 00008F9F AC                  <1>  	lodsb
  4899 00008FA0 3C20                <1> 	cmp	al, 20h
  4900 00008FA2 7703                <1> 	ja	short cmp_cmd_2
  4901 00008FA4 30C0                <1> 	xor	al, al
  4902                              <1> 	; ZF = 1 -> internal command word matches
  4903 00008FA6 C3                  <1> 	retn
  4904                              <1> cmp_cmd_2:
  4905                              <1> 	; ZF = 0 (CF = 0) -> external command word 	
  4906 00008FA7 58                  <1> 	pop	eax ; no return to the caller from here 
  4907 00008FA8 EBCD                <1> 	jmp	cmp_cmd_external	
  4908                              <1> cmp_cmd_3:
  4909 00008FAA F9                  <1> 	stc
  4910                              <1> 	; CF = 1 -> internal command word does not match
  4911 00008FAB C3                  <1> 	retn
  4912                              <1> 
  4913                              <1> loc_run_cmd_failed:
  4914                              <1> 	; 15/03/2016
  4915                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
  4916                              <1> 	; 07/12/2009 (CMD_INTR.ASM)	
  4917                              <1> 	; 29/11/2009
  4918                              <1> 
  4919 00008FAC E863000000          <1> 	call	restore_cdir_after_cmd_fail
  4920                              <1> 
  4921                              <1> loc_run_cmd_failed_cmp_al:
  4922                              <1> 	; End of Restore_CDIR code (29/11/2009)
  4923                              <1> 
  4924 00008FB1 3C01                <1> 	cmp	al, 1 ; Bad command or file name
  4925 00008FB3 74CC                <1> 	je	loc_cmd_failed
  4926                              <1> loc_run_dir_not_found:
  4927 00008FB5 3C03                <1> 	cmp	al, 3
  4928 00008FB7 750A                <1> 	jne	short loc_run_file_notfound_msg
  4929                              <1> 	; Path not found (MS-DOS Error Code = 3)
  4930 00008FB9 BE[C5430100]        <1> 	mov	esi, Msg_Dir_Not_Found
  4931 00008FBE E9A2E5FFFF          <1> 	jmp	print_msg
  4932                              <1> 
  4933                              <1> loc_run_file_notfound_msg:
  4934 00008FC3 3C02                <1> 	cmp	al, 2 ; File not found
  4935 00008FC5 750A                <1> 	jne	short loc_run_file_drv_read_err
  4936                              <1> 
  4937                              <1> loc_print_file_notfound_msg: 
  4938 00008FC7 BE[DC430100]        <1>         mov     esi, Msg_File_Not_Found
  4939                              <1> 	;call	proc_printmsg
  4940                              <1> 	;retn
  4941 00008FCC E994E5FFFF          <1> 	jmp	print_msg
  4942                              <1> 
  4943                              <1> loc_run_file_drv_read_err:
  4944                              <1> 	; Err: 17 (Read fault)
  4945 00008FD1 3C11                <1> 	cmp	al, 17 ; Drive not ready or read error
  4946 00008FD3 7404                <1> 	je	short loc_run_file_print_drv_read_err
  4947                              <1> 	;
  4948 00008FD5 3C0F                <1> 	cmp	al, 15 ; Drive not ready (or read error)
  4949 00008FD7 750A                <1> 	jne	short loc_run_file_toobig
  4950                              <1> 
  4951                              <1> loc_run_file_print_drv_read_err:
  4952 00008FD9 BE[82430100]        <1> 	mov	esi, Msg_Not_Ready_Read_Err
  4953 00008FDE E982E5FFFF          <1> 	jmp	print_msg
  4954                              <1> 
  4955                              <1> loc_run_file_toobig:
  4956 00008FE3 3C08                <1> 	cmp	al, 8 ; Not enough free memory to load&run file
  4957 00008FE5 750A                <1> 	jne	short loc_run_file_perm_denied
  4958 00008FE7 BE[27440100]        <1> 	mov	esi, Msg_Insufficient_Memory
  4959 00008FEC E974E5FFFF          <1> 	jmp	print_msg
  4960                              <1> 
  4961                              <1> loc_run_file_perm_denied:
  4962                              <1> 	; 29/12/2017
  4963 00008FF1 3C0B                <1> 	cmp	al, ERR_PERM_DENIED ; 11 ; Permission denied
  4964 00008FF3 750A                <1> 	jne	short loc_run_misc_error
  4965 00008FF5 BE[BC450100]        <1> 	mov	esi, Msg_Permission_Denied
  4966 00008FFA E966E5FFFF          <1> 	jmp	print_msg	
  4967                              <1> 
  4968                              <1> 	; 15/03/2016
  4969                              <1> print_misc_error_msg:
  4970                              <1> loc_run_misc_error:
  4971                              <1> 	; AL = Error code
  4972 00008FFF E8D1B2FFFF          <1> 	call	bytetohex
  4973 00009004 66A3[5B440100]      <1>         mov     [error_code_hex], ax
  4974                              <1> 	
  4975 0000900A BE[3E440100]        <1> 	mov	esi, Msg_Error_Code 
  4976                              <1> 	;call	print_msg 
  4977                              <1> 	;retn
  4978                              <1> 
  4979 0000900F E951E5FFFF          <1> 	jmp	print_msg
  4980                              <1> 
  4981                              <1> restore_cdir_after_cmd_fail:
  4982                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
  4983 00009014 50                  <1> 	push	eax
  4984 00009015 8A3D[52920100]      <1> 	mov	bh, [RUN_CDRV] ; it is set at the beginning
  4985                              <1> 				; of the 'run' command.
  4986 0000901B 3A3D[F68A0100]      <1> 	cmp	bh, [Current_Drv]
  4987 00009021 7409                <1> 	je	short loc_run_restore_cdir
  4988 00009023 88FA                <1> 	mov	dl, bh
  4989 00009025 E8C4F0FFFF          <1> 	call	change_current_drive 
  4990 0000902A EB19                <1> 	jmp	short loc_run_err_pass_restore_cdir
  4991                              <1> 
  4992                              <1> loc_run_restore_cdir:
  4993 0000902C 803D[C3400100]00    <1> 	cmp	byte [Restore_CDIR], 0
  4994 00009033 7610                <1> 	jna	short loc_run_err_pass_restore_cdir
  4995 00009035 30DB                <1> 	xor	bl, bl
  4996 00009037 0FB7F3              <1> 	movzx	esi, bx
  4997 0000903A 81C600010900        <1> 	add	esi, Logical_DOSDisks
  4998 00009040 E860F1FFFF          <1> 	call	restore_current_directory
  4999                              <1> 
  5000                              <1> loc_run_err_pass_restore_cdir:
  5001 00009045 58                  <1> 	pop	eax
  5002 00009046 C3                  <1> 	retn
  5003                              <1> 
  5004                              <1> print_directory_list:
  5005                              <1> 	; 10/02/2016
  5006                              <1> 	; 08/02/2016 (TRDOS 386 = TRDOS v2.0)
  5007                              <1> 	; 06/12/2009 ('cmp_cmd_dir')	
  5008                              <1> 	;
  5009 00009047 66C705[94930100]00- <1> 	mov	word [AttributesMask], 0800h ; ..except volume names..
  5009 0000904F 08                  <1>
  5010 00009050 A0[F68A0100]        <1> 	mov	al, [Current_Drv]
  5011 00009055 A2[52920100]        <1> 	mov	[RUN_CDRV], al
  5012                              <1> get_dfname_fchar:
  5013 0000905A AC                  <1> 	lodsb
  5014 0000905B 3C20                <1> 	cmp	al, 20h
  5015 0000905D 74FB                <1> 	je	short get_dfname_fchar
  5016 0000905F 0F82A4000000        <1>         jb      loc_print_dir_call_all
  5017 00009065 3C2D                <1> 	cmp	al, '-'
  5018 00009067 7542                <1> 	jne	short loc_print_dir_call_flt
  5019                              <1> get_next_attr_char:
  5020 00009069 AC                  <1> 	lodsb
  5021 0000906A 3C20                <1> 	cmp	al, 20h
  5022 0000906C 74FB                <1> 	je	short get_next_attr_char
  5023 0000906E 0F820DFFFFFF        <1>         jb      loc_cmd_failed
  5024 00009074 24DF                <1> 	and	al, 0DFh
  5025 00009076 3C44                <1> 	cmp	al, 'D' ; directories only ?
  5026 00009078 7512                <1> 	jne	short pass_only_directories
  5027 0000907A AC                  <1> 	lodsb
  5028 0000907B 3C20                <1> 	cmp	al, 20h
  5029 0000907D 0F87FEFEFFFF        <1>         ja      loc_cmd_failed
  5030 00009083 800D[94930100]10    <1> 	or	byte [AttributesMask], 10h ; ..directory..
  5031 0000908A EB18                <1> 	jmp	short get_dfname_fchar_attr
  5032                              <1> pass_only_directories:
  5033 0000908C 3C46                <1> 	cmp	al, 'F'	; files only ?
  5034 0000908E 0F85B0000000        <1>         jne     check_attr_s
  5035 00009094 AC                  <1> 	lodsb
  5036 00009095 3C20                <1> 	cmp	al, 20h
  5037 00009097 0F87E4FEFFFF        <1>         ja      loc_cmd_failed
  5038 0000909D 800D[95930100]10    <1> 	or	byte [AttributesMask+1], 10h ; ..except directories..
  5039                              <1> get_dfname_fchar_attr:
  5040 000090A4 AC                  <1> 	lodsb
  5041 000090A5 3C20                <1> 	cmp	al, 20h
  5042 000090A7 74FB                <1> 	je	short get_dfname_fchar_attr
  5043 000090A9 725E                <1> 	jb	short loc_print_dir_call_all
  5044                              <1> 
  5045                              <1> loc_print_dir_call_flt:
  5046 000090AB 4E                  <1> 	dec	esi
  5047 000090AC BF[96930100]        <1> 	mov	edi, FindFile_Drv
  5048 000090B1 E8AC250000          <1> 	call	parse_path_name
  5049 000090B6 7308                <1>  	jnc	short loc_print_dir_change_drv_1
  5050 000090B8 3C01                <1> 	cmp	al, 1
  5051 000090BA 0F87ECFEFFFF        <1>         ja      loc_run_cmd_failed
  5052                              <1> 
  5053                              <1> loc_print_dir_change_drv_1:
  5054 000090C0 8A15[96930100]      <1> 	mov	dl, [FindFile_Drv]
  5055                              <1> loc_print_dir_change_drv_2:
  5056 000090C6 3A15[52920100]      <1> 	cmp	dl, [RUN_CDRV]
  5057 000090CC 740B                <1> 	je	short loc_print_dir_change_directory 
  5058 000090CE E81BF0FFFF          <1> 	call	change_current_drive
  5059 000090D3 0F82D3FEFFFF        <1>         jc      loc_run_cmd_failed
  5060                              <1> loc_print_dir_change_directory:
  5061 000090D9 803D[97930100]20    <1> 	cmp	byte [FindFile_Directory], 20h ; 0 or 20h ?
  5062 000090E0 761D                <1> 	jna	short pass_print_dir_change_directory
  5063                              <1> 
  5064 000090E2 FE05[C3400100]      <1> 	inc	byte [Restore_CDIR]
  5065 000090E8 BE[97930100]        <1> 	mov	esi, FindFile_Directory
  5066 000090ED 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  5067 000090EF E8581F0000          <1> 	call	change_current_directory
  5068 000090F4 0F82B2FEFFFF        <1>         jc      loc_run_cmd_failed
  5069                              <1> 
  5070                              <1> loc_print_dir_change_prompt_dir_string:
  5071 000090FA E86D1E0000          <1> 	call	change_prompt_dir_string
  5072                              <1> 
  5073                              <1> pass_print_dir_change_directory:
  5074 000090FF BE[D8930100]        <1> 	mov	esi, FindFile_Name
  5075 00009104 803E20              <1> 	cmp	byte [esi], 20h ; ; 0 or 20h ?
  5076 00009107 7706                <1> 	ja	short loc_print_dir_call
  5077                              <1> 
  5078                              <1> loc_print_dir_call_all:
  5079 00009109 C7062A2E2A00        <1> 	mov	dword [esi], '*.*'
  5080                              <1> loc_print_dir_call:
  5081 0000910F E87E000000          <1> 	call	print_directory
  5082                              <1> 
  5083 00009114 8A15[52920100]      <1> 	mov	dl, [RUN_CDRV]  ; it is set at the beginning
  5084 0000911A 3A15[F68A0100]      <1> 	cmp	dl, [Current_Drv]
  5085 00009120 7406                <1> 	je	short loc_print_dir_call_restore_cdir_retn
  5086 00009122 E8C7EFFFFF          <1> 	call	change_current_drive 
  5087 00009127 C3                  <1> 	retn
  5088                              <1> 
  5089                              <1> loc_print_dir_call_restore_cdir_retn:
  5090 00009128 803D[C3400100]00    <1> 	cmp	byte [Restore_CDIR], 0
  5091 0000912F 7610                <1> 	jna	short pass_print_dir_call_restore_cdir_retn
  5092                              <1> 
  5093 00009131 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  5094 00009136 31C0                <1> 	xor	eax, eax
  5095 00009138 88D4                <1> 	mov	ah, dl
  5096 0000913A 01C6                <1> 	add	esi, eax
  5097                              <1> 
  5098 0000913C E864F0FFFF          <1> 	call	restore_current_directory
  5099                              <1> 
  5100                              <1> pass_print_dir_call_restore_cdir_retn:
  5101 00009141 C3                  <1> 	retn
  5102                              <1> 
  5103                              <1> check_attr_s_cap:
  5104 00009142 24DF                <1> 	and	al, 0DFh
  5105                              <1> check_attr_s:
  5106 00009144 3C53                <1> 	cmp	al, 'S'
  5107 00009146 7514                <1> 	jne	short pass_attr_s
  5108 00009148 800D[94930100]04    <1> 	or	byte [AttributesMask], 4 ; system
  5109 0000914F AC                  <1> 	lodsb
  5110 00009150 3C20                <1> 	cmp	al, 20h
  5111 00009152 0F844CFFFFFF        <1>         je      get_dfname_fchar_attr
  5112 00009158 72AF                <1> 	jb	short loc_print_dir_call_all
  5113 0000915A 24DF                <1> 	and	al, 0DFh
  5114                              <1> pass_attr_s:
  5115 0000915C 3C48                <1> 	cmp	al, 'H'
  5116 0000915E 7514                <1> 	jne	short pass_attr_h
  5117 00009160 800D[94930100]02    <1> 	or	byte [AttributesMask], 2 ; hidden
  5118                              <1> pass_attr_shr:
  5119 00009167 AC                  <1> 	lodsb
  5120 00009168 3C20                <1> 	cmp	al, 20h
  5121 0000916A 0F8434FFFFFF        <1>         je      get_dfname_fchar_attr
  5122 00009170 7297                <1> 	jb	short loc_print_dir_call_all
  5123 00009172 EBCE                <1> 	jmp	short check_attr_s_cap
  5124                              <1> 
  5125                              <1> pass_attr_h:
  5126 00009174 3C52                <1> 	cmp	al, 'R'
  5127 00009176 7509                <1> 	jne	short pass_attr_r
  5128 00009178 800D[94930100]01    <1> 	or	byte [AttributesMask], 1 ; read only
  5129 0000917F EBE6                <1> 	jmp	short pass_attr_shr
  5130                              <1> 
  5131                              <1> pass_attr_r:
  5132 00009181 3C41                <1> 	cmp	al, 'A'
  5133 00009183 0F85F8FDFFFF        <1>         jne     loc_cmd_failed
  5134 00009189 800D[94930100]20    <1> 	or	byte [AttributesMask], 20h ; archive
  5135 00009190 EBD5                <1> 	jmp	short pass_attr_shr
  5136                              <1> 
  5137                              <1> print_directory:
  5138                              <1> 	; 13/05/2016
  5139                              <1> 	; 11/02/2016
  5140                              <1> 	; 10/02/2016
  5141                              <1> 	; 08/02/2016 (TRDOS 386 = TRDOS v2.0)
  5142                              <1> 	; 30/10/2010 ('proc_print_directory')	
  5143                              <1> 	; 19/09/2009
  5144                              <1> 	; 2005 
  5145                              <1> 	; INPUT ->
  5146                              <1> 	;	ESI = Asciiz File/Dir Name Address
  5147                              <1> 
  5148 00009192 56                  <1> 	push	esi
  5149                              <1> 
  5150 00009193 29C0                <1> 	sub	eax, eax
  5151                              <1> 
  5152 00009195 66A3[20940100]      <1> 	mov	word [Dir_Count], ax ; 0
  5153 0000919B 66A3[1E940100]      <1> 	mov 	word [File_Count], ax ; 0
  5154 000091A1 A3[22940100]        <1> 	mov 	dword [Total_FSize], eax ; 0
  5155                              <1> 
  5156 000091A6 E8D0E3FFFF          <1> 	call    clear_screen
  5157                              <1> 	
  5158 000091AB 31C9                <1> 	xor	ecx, ecx	
  5159 000091AD 8A2D[F68A0100]      <1> 	mov     ch, [Current_Drv] ; DirBuff_Drv - 'A'
  5160 000091B3 A0[F78A0100]        <1> 	mov     al, [Current_Dir_Drv] 
  5161 000091B8 A2[80420100]        <1> 	mov     [Dir_Drive_Name], al
  5162 000091BD BE00010900          <1> 	mov	esi, Logical_DOSDisks
  5163 000091C2 01CE                <1> 	add	esi, ecx
  5164                              <1> 
  5165 000091C4 E858F9FFFF          <1> 	call	move_volume_name_and_serial_no
  5166 000091C9 730C                <1> 	jnc	short print_dir_strlen_check
  5167                              <1> 
  5168 000091CB 5E                  <1> 	pop	esi
  5169 000091CC 8A3D[5E8A0100]      <1> 	mov	bh, [ptty] ; [ACTIVE_PAGE]
  5170                              <1> 	;call	beeper
  5171                              <1> 	;retn
  5172 000091D2 E91A92FFFF          <1> 	jmp	beeper  ; beep ! and return
  5173                              <1> 
  5174                              <1> print_dir_strlen_check:
  5175 000091D7 BE[F98A0100]        <1> 	mov	esi, Current_Dir_Root
  5176 000091DC BF[1D430100]        <1> 	mov	edi, Dir_Str_Root
  5177                              <1> 	
  5178                              <1> 	;xor	ecx, ecx
  5179 000091E1 8A0D[558B0100]      <1>         mov     cl, [Current_Dir_StrLen]
  5180 000091E7 FEC1                <1> 	inc	cl
  5181 000091E9 80F940              <1> 	cmp	cl, 64
  5182 000091EC 760D                <1> 	jna	short pass_print_dir_strlen_shorting
  5183 000091EE 46                  <1> 	inc	esi
  5184 000091EF 01CE                <1> 	add	esi, ecx
  5185 000091F1 83EE40              <1> 	sub	esi, 64 
  5186 000091F4 47                  <1> 	inc	edi
  5187 000091F5 B82E2E2E20          <1> 	mov	eax, '... ' 
  5188 000091FA AB                  <1> 	stosd
  5189                              <1>  
  5190                              <1> pass_print_dir_strlen_shorting:
  5191 000091FB F3A4                <1> 	rep	movsb
  5192                              <1> 
  5193 000091FD BE[73420100]        <1> 	mov	esi, Dir_Drive_Str
  5194 00009202 E85EE3FFFF          <1> 	call	print_msg
  5195                              <1> 
  5196 00009207 BE[D2420100]        <1> 	mov	esi, Vol_Serial_Header
  5197 0000920C E854E3FFFF          <1> 	call	print_msg
  5198                              <1> 
  5199 00009211 BE[12430100]        <1> 	mov	esi, Dir_Str_Header
  5200 00009216 E84AE3FFFF          <1> 	call	print_msg
  5201                              <1> 	
  5202 0000921B BE[5D4D0100]        <1> 	mov	esi, next2line
  5203 00009220 E840E3FFFF          <1> 	call	print_msg
  5204                              <1> 
  5205                              <1> loc_print_dir_first_file:
  5206 00009225 C605[35940100]10    <1> 	mov	byte [PrintDir_RowCounter], 16
  5207 0000922C 66A1[94930100]      <1> 	mov	ax, [AttributesMask]
  5208 00009232 5E                  <1> 	pop	esi
  5209                              <1> 
  5210 00009233 E859020000          <1> 	call	find_first_file
  5211 00009238 0F826F010000        <1>         jc      loc_dir_ok
  5212                              <1> 	 
  5213                              <1> loc_dfname_use_this:
  5214                              <1> 	; bl =	File Attributes (bh = Long Name Entry Length)
  5215 0000923E F6C310              <1> 	test	bl, 10h  ; Is it a directory?
  5216 00009241 741B                <1> 	jz	short loc_not_dir
  5217                              <1> 
  5218 00009243 66FF05[20940100]    <1> 	inc	word [Dir_Count]
  5219 0000924A 89F2                <1> 	mov	edx, esi 	; FindFile_DirEntry address
  5220 0000924C BE[62440100]        <1>  	mov	esi, Type_Dir	; '<DIR>     '
  5221 00009251 BF[79440100]        <1> 	mov	edi, Dir_Or_FileSize
  5222                              <1> 	; move 10 bytes
  5223 00009256 A5                  <1> 	movsd
  5224 00009257 A5                  <1> 	movsd
  5225 00009258 66A5                <1> 	movsw	    	
  5226 0000925A 89D6                <1> 	mov	esi, edx
  5227 0000925C EB36                <1> 	jmp     short loc_dir_attribute
  5228                              <1> 
  5229                              <1> loc_not_dir:
  5230 0000925E 66FF05[1E940100]    <1> 	inc	word [File_Count]
  5231 00009265 0105[22940100]      <1> 	add	[Total_FSize], eax
  5232                              <1> 
  5233 0000926B B90A000000          <1> 	mov	ecx, 10  ; 32 bit divisor
  5234 00009270 89CF                <1> 	mov	edi, ecx
  5235 00009272 81C7[79440100]      <1> 	add	edi, Dir_Or_FileSize
  5236                              <1> loc_dir_rdivide:
  5237 00009278 29D2                <1> 	sub	edx, edx
  5238 0000927A F7F1                <1> 	div	ecx 	 ; remainder in dl (< 10)
  5239 0000927C 80C230              <1> 	add     dl, '0'	 ; to make visible (ascii)
  5240 0000927F 4F                  <1> 	dec	edi
  5241 00009280 8817                <1> 	mov     [edi], dl
  5242 00009282 21C0                <1> 	and	eax, eax
  5243 00009284 75F2                <1> 	jnz	short loc_dir_rdivide
  5244                              <1> 
  5245                              <1> loc_dir_fill_space:
  5246 00009286 81FF[79440100]      <1> 	cmp     edi, Dir_Or_FileSize
  5247 0000928C 7606                <1> 	jna     short loc_dir_attribute
  5248 0000928E 4F                  <1> 	dec     edi
  5249 0000928F C60720              <1> 	mov     byte [edi], 20h
  5250 00009292 EBF2                <1> 	jmp     short loc_dir_fill_space
  5251                              <1> 
  5252                              <1> loc_dir_attribute:
  5253 00009294 C705[84440100]2020- <1> 	mov	dword [File_Attribute], 20202020h
  5253 0000929C 2020                <1>
  5254                              <1> 
  5255 0000929E 80FB20              <1> 	cmp	bl, 20h  ; Is it an archive file?
  5256 000092A1 7207                <1> 	jb	short loc_dir_pass_arch
  5257 000092A3 C605[87440100]41    <1> 	mov	byte [File_Attribute+3], 'A'
  5258                              <1> 
  5259                              <1> loc_dir_pass_arch:
  5260 000092AA 80E307              <1> 	and	bl, 7
  5261 000092AD 7428                <1> 	jz	short loc_dir_file_name
  5262 000092AF 88DF                <1> 	mov	bh, bl
  5263 000092B1 80E303              <1> 	and	bl, 3
  5264 000092B4 38DF                <1> 	cmp	bh, bl
  5265 000092B6 7607                <1> 	jna	short loc_dir_pass_s
  5266 000092B8 C605[84440100]53    <1> 	mov	byte [File_Attribute], 'S'
  5267                              <1> 
  5268                              <1> loc_dir_pass_s:
  5269 000092BF 80E302              <1> 	and     bl,2
  5270 000092C2 7407                <1> 	jz      short loc_dir_pass_h
  5271 000092C4 C605[85440100]48    <1> 	mov     byte [File_Attribute+1], 'H'
  5272                              <1> loc_dir_pass_h:
  5273 000092CB 80E701              <1> 	and     bh,1
  5274 000092CE 7407                <1> 	jz      short loc_dir_file_name
  5275 000092D0 C605[86440100]52    <1> 	mov     byte [File_Attribute+2], 'R'
  5276                              <1> loc_dir_file_name:
  5277                              <1> 	;mov     bx, [esi+18h] ; Date
  5278                              <1> 	;mov     dx, [esi+16h] ; Time
  5279 000092D7 8B5E16              <1> 	mov	ebx, [esi+16h]
  5280 000092DA 89F1                <1> 	mov	ecx, esi ; FindFile_DirEntry address
  5281 000092DC BF[6C440100]        <1> 	mov     edi, File_Name
  5282                              <1> 	; move 8 bytes
  5283 000092E1 A5                  <1> 	movsd
  5284 000092E2 A5                  <1> 	movsd
  5285 000092E3 C60720              <1> 	mov	byte [edi], 20h
  5286 000092E6 47                  <1> 	inc	edi
  5287                              <1> 	; move 3 bytes
  5288 000092E7 66A5                <1> 	movsw
  5289 000092E9 A4                  <1> 	movsb
  5290 000092EA 89CE                <1> 	mov	esi, ecx
  5291                              <1> 
  5292                              <1> Dir_Time_start:
  5293                              <1> 	;mov	ax, dx		; Time
  5294 000092EC 6689D8              <1> 	mov	ax, bx
  5295 000092EF 66C1E805            <1> 	shr	ax, 5		; shift right 5 times
  5296 000092F3 6683E03F            <1> 	and	ax, 0000111111b	; Minute Mask
  5297 000092F7 D40A                <1> 	aam			; Q([AL]/10)->AH
  5298                              <1> 				; R([AL]/10)->AL
  5299                              <1> 				; [AL]+[AH]= Minute as BCD
  5300 000092F9 660D3030            <1> 	or	ax, '00'	; Convert to ASCII
  5301 000092FD 86E0                <1> 	xchg	ah, al
  5302 000092FF 66A3[97440100]      <1> 	mov	[File_Minute], ax
  5303                              <1> 
  5304                              <1> 	;mov	al, dh
  5305 00009305 88F8                <1> 	mov	al, bh
  5306 00009307 C0E803              <1> 	shr	al, 3		; shift right 3 times
  5307 0000930A D40A                <1> 	aam			; [AL]+[AH]= Hours as BCD
  5308 0000930C 660D3030            <1> 	or	ax, '00'
  5309 00009310 86E0                <1> 	xchg	ah, al
  5310 00009312 66A3[94440100]      <1> 	mov     [File_Hour], ax
  5311                              <1> 
  5312 00009318 C1EB10              <1> 	shr	ebx, 16		; BX = Date
  5313                              <1> 	
  5314                              <1> Dir_Date_start:
  5315 0000931B 6689D8              <1> 	mov	ax, bx		; Date
  5316 0000931E 6683E01F            <1> 	and	ax, 00011111b	; Day Mask
  5317 00009322 D40A                <1> 	aam			; Q([AL]/10)->AH
  5318                              <1> 				; R([AL]/10)->AL
  5319                              <1> 				; [AL]+[AH]= Day as BCD
  5320 00009324 660D3030            <1> 	or	ax, '00'	; Convert to ASCII
  5321 00009328 86C4                <1> 	xchg	al, ah
  5322                              <1> 
  5323 0000932A 66A3[89440100]      <1> 	mov	[File_Day], ax
  5324                              <1> 
  5325 00009330 6689D8              <1> 	mov	ax, bx
  5326 00009333 66C1E805            <1> 	shr	ax, 5		; shift right 5 times
  5327 00009337 6683E00F            <1> 	and	ax, 00001111b	; Month Mask
  5328 0000933B D40A                <1> 	aam
  5329 0000933D 660D3030            <1> 	or	ax, '00'
  5330 00009341 86E0                <1> 	xchg	ah, al
  5331 00009343 66A3[8C440100]      <1> 	mov	[File_Month], ax
  5332                              <1> 
  5333 00009349 6689D8              <1> 	mov	ax, bx
  5334 0000934C 66C1E809            <1> 	shr     ax, 9
  5335 00009350 6683E07F            <1> 	and	ax, 01111111b	; Result = Year - 1980
  5336 00009354 6605BC07            <1> 	add	ax, 1980
  5337                              <1> 
  5338 00009358 B10A                <1> 	mov	cl, 10
  5339 0000935A F6F1                <1> 	div	cl		; Q -> AL, R -> AH 
  5340 0000935C 80CC30              <1> 	or	ah, '0'
  5341 0000935F 8825[92440100]      <1> 	mov	[File_Year+3], ah
  5342 00009365 D40A                <1> 	aam
  5343 00009367 86E0                <1> 	xchg	ah, al
  5344 00009369 80CC30              <1> 	or	ah, '0'	  ; Convert to ASCII
  5345 0000936C 8825[91440100]      <1> 	mov	[File_Year+2], ah
  5346 00009372 D40A                <1> 	aam
  5347 00009374 86C4                <1> 	xchg	al, ah
  5348 00009376 660D3030            <1> 	or	ax, '00'
  5349 0000937A 66A3[8F440100]      <1> 	mov	[File_Year], ax
  5350                              <1> 
  5351                              <1> loc_show_line:
  5352 00009380 56                  <1> 	push	esi
  5353 00009381 BE[6C440100]        <1> 	mov     esi, File_Name
  5354 00009386 E8DAE1FFFF          <1> 	call	print_msg
  5355 0000938B BE[5F4D0100]        <1> 	mov	esi, nextline
  5356 00009390 E8D0E1FFFF          <1> 	call	print_msg
  5357 00009395 5E                  <1> 	pop	esi
  5358                              <1> 
  5359 00009396 FE0D[35940100]      <1> 	dec	byte [PrintDir_RowCounter]
  5360 0000939C 0F84D4000000        <1>         jz      pause_dir_scroll
  5361                              <1> 
  5362                              <1> loc_next_entry:
  5363 000093A2 E899010000          <1> 	call	find_next_file
  5364 000093A7 0F8391FEFFFF        <1>         jnc     loc_dfname_use_this
  5365                              <1> 
  5366                              <1> loc_dir_ok:
  5367 000093AD B90A000000          <1> 	mov     ecx, 10
  5368 000093B2 66A1[20940100]      <1> 	mov	ax, [Dir_Count]
  5369 000093B8 BF[AD440100]        <1> 	mov	edi, Decimal_Dir_Count
  5370 000093BD 6639C8              <1> 	cmp	ax, cx ; 10
  5371 000093C0 7216                <1> 	jb	short pass_ddc
  5372 000093C2 47                  <1> 	inc	edi
  5373 000093C3 6683F864            <1> 	cmp	ax, 100
  5374 000093C7 720F                <1> 	jb	short pass_ddc
  5375 000093C9 47                  <1> 	inc	edi
  5376 000093CA 663DE803            <1> 	cmp	ax, 1000
  5377 000093CE 7208                <1> 	jb	short pass_ddc
  5378 000093D0 47                  <1> 	inc	edi
  5379 000093D1 663D1027            <1> 	cmp	ax, 10000
  5380 000093D5 7201                <1> 	jb	short pass_ddc
  5381 000093D7 47                  <1> 	inc	edi
  5382                              <1> pass_ddc:
  5383 000093D8 886F01              <1> 	mov     [edi+1], ch ; 0
  5384                              <1> loc_ddc_rediv:
  5385 000093DB 31D2                <1> 	xor     edx, edx
  5386 000093DD 66F7F1              <1> 	div     cx	; 10
  5387 000093E0 80C230              <1> 	add     dl, '0'
  5388 000093E3 8817                <1> 	mov     [edi], dl
  5389 000093E5 4F                  <1> 	dec     edi
  5390 000093E6 6609C0              <1> 	or	ax, ax
  5391 000093E9 75F0                <1> 	jnz	short loc_ddc_rediv
  5392                              <1> 
  5393 000093EB 66A1[1E940100]      <1> 	mov     ax, [File_Count]
  5394 000093F1 BF[9C440100]        <1> 	mov     edi, Decimal_File_Count
  5395 000093F6 6639C8              <1> 	cmp     ax, cx ; 10
  5396 000093F9 7216                <1> 	jb      short pass_dfc
  5397 000093FB 47                  <1> 	inc     edi
  5398 000093FC 6683F864            <1> 	cmp     ax, 100
  5399 00009400 720F                <1> 	jb      short pass_dfc
  5400 00009402 47                  <1> 	inc     edi
  5401 00009403 663DE803            <1> 	cmp     ax, 1000
  5402 00009407 7208                <1> 	jb      short pass_dfc
  5403 00009409 47                  <1> 	inc     edi
  5404 0000940A 663D1027            <1> 	cmp     ax, 10000
  5405 0000940E 7201                <1> 	jb      short pass_dfc
  5406 00009410 47                  <1> 	inc     edi
  5407                              <1> pass_dfc:
  5408                              <1> 	;mov    cx, 10
  5409 00009411 886F01              <1> 	mov     [edi+1], ch ; 00
  5410                              <1> loc_dfc_rediv:
  5411                              <1> 	;xor	dx, dx
  5412 00009414 30D2                <1> 	xor	dl, dl
  5413 00009416 66F7F1              <1> 	div	cx
  5414 00009419 80C230              <1> 	add	dl, '0'
  5415 0000941C 8817                <1> 	mov	[edi], dl
  5416 0000941E 4F                  <1> 	dec	edi
  5417 0000941F 6609C0              <1> 	or	ax, ax
  5418 00009422 75F0                <1> 	jnz	short loc_dfc_rediv
  5419                              <1> 
  5420 00009424 BF[34940100]        <1> 	mov     edi, TFS_Dec_End
  5421                              <1>         ;mov    byte [edi], 0
  5422 00009429 A1[22940100]        <1> 	mov     eax, [Total_FSize]
  5423                              <1> 	;mov    ecx, 10
  5424                              <1> rediv_tfs_hex:
  5425                              <1> 	;sub	edx, edx
  5426 0000942E 28D2                <1> 	sub	dl, dl
  5427 00009430 F7F1                <1> 	div	ecx
  5428 00009432 80C230              <1> 	add	dl, '0'
  5429 00009435 4F                  <1> 	dec     edi
  5430 00009436 8817                <1> 	mov     [edi], dl
  5431 00009438 21C0                <1> 	and	eax, eax
  5432 0000943A 75F2                <1> 	jnz	short rediv_tfs_hex
  5433                              <1> 	
  5434 0000943C 893D[26940100]      <1> 	mov	[TFS_Dec_Begin], edi
  5435 00009442 BE[9A440100]        <1> 	mov	esi, Decimal_File_Count_Header
  5436 00009447 E819E1FFFF          <1> 	call	print_msg
  5437 0000944C BE[A2440100]        <1> 	mov	esi, str_files
  5438 00009451 E80FE1FFFF          <1> 	call	print_msg
  5439 00009456 BE[B3440100]        <1> 	mov	esi, str_dirs
  5440 0000945B E805E1FFFF          <1> 	call	print_msg
  5441 00009460 8B35[26940100]      <1> 	mov	esi, [TFS_Dec_Begin]
  5442 00009466 E8FAE0FFFF          <1> 	call	print_msg
  5443 0000946B BE[C4440100]        <1> 	mov	esi, str_bytes
  5444 00009470 E8F0E0FFFF          <1> 	call	print_msg
  5445                              <1> 
  5446 00009475 C3                  <1> 	retn
  5447                              <1> 
  5448                              <1> pause_dir_scroll:
  5449 00009476 28E4                <1> 	sub	ah, ah           
  5450 00009478 E8707AFFFF          <1> 	call	int16h
  5451 0000947D 3C1B                <1> 	cmp	al, 1Bh
  5452 0000947F 0F8428FFFFFF        <1>         je      loc_dir_ok
  5453 00009485 C605[35940100]10    <1> 	mov	byte [PrintDir_RowCounter], 16 ; Reset counter
  5454 0000948C E911FFFFFF          <1>         jmp     loc_next_entry
  5455                              <1> 
  5456                              <1> find_first_file:
  5457                              <1> 	; 11/02/2016
  5458                              <1> 	; 10/02/2016
  5459                              <1> 	; 08/02/2016 (TRDOS 386 = TRDOS v2.0)
  5460                              <1> 	; 09/10/2011
  5461                              <1> 	; 17/09/2009
  5462                              <1> 	; 2005
  5463                              <1> 	; INPUT ->
  5464                              <1> 	;	ESI = ASCIIZ File/Dir Name Address (in Current Directory)
  5465                              <1> 	;	AL = Attributes AND mask (The AND result must be equal to AL)
  5466                              <1> 	;	      bit 0 = Read Only
  5467                              <1> 	;	      bir 1 = Hidden
  5468                              <1> 	;	      bit 2 = System
  5469                              <1> 	;	      bit 3 = Volume Label
  5470                              <1> 	;	      bit 4 = Directory
  5471                              <1> 	;	      bit 5 = Archive
  5472                              <1> 	;	      bit 6 = Reserved, must be 0
  5473                              <1> 	;	      bit 7 = Reserved, must be 0
  5474                              <1> 	;       AH = Attributes Negative AND mask (The AND result must be ZERO)
  5475                              <1> 	;
  5476                              <1> 	; OUTPUT ->
  5477                              <1> 	;	CF = 1 -> Error, Error Code in EAX (AL)
  5478                              <1> 	;	CF = 0 ->
  5479                              <1> 	;	     ESI = Directory Entry (FindFile_DirEntry) Location
  5480                              <1> 	;	     EDI = Directory Buffer Directory Entry Location
  5481                              <1> 	;	     EAX = File Size
  5482                              <1> 	;	      BL = Attributes of The File/Directory
  5483                              <1> 	;	      BH = Long Name Yes/No Status (>0 is YES)
  5484                              <1> 	;             DX > 0 : Ambiguous filename chars are used
  5485                              <1> 	;
  5486                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI will be changed)
  5487                              <1> 
  5488 00009491 66A3[E6930100]      <1> 	mov	[FindFile_AttributesMask], ax
  5489 00009497 BF[E8930100]        <1> 	mov	edi, FindFile_DirEntry ; TR-DOS Fullfilename formatted buffer
  5490 0000949C 31C0                <1> 	xor	eax, eax
  5491 0000949E B90B000000          <1> 	mov	ecx, 11
  5492 000094A3 F3AB                <1> 	rep	stosd	; 44 bytes
  5493                              <1> 	;stosw		; +2 bytes 
  5494                              <1> 	    
  5495 000094A5 BF[D8930100]        <1> 	mov	edi, FindFile_Name ; FFF structure, offset 66
  5496 000094AA 39FE                <1> 	cmp	esi, edi
  5497 000094AC 7408                <1> 	je	short loc_fff_mfn_ok
  5498 000094AE 89FA                <1> 	mov	edx, edi 
  5499                              <1> 	 ; move 13 bytes
  5500 000094B0 A5                  <1> 	movsd
  5501 000094B1 A5                  <1> 	movsd
  5502 000094B2 A5                  <1> 	movsd
  5503 000094B3 AA                  <1> 	stosb
  5504 000094B4 89D6                <1> 	mov	esi, edx
  5505                              <1> loc_fff_mfn_ok:
  5506 000094B6 BF[87930100]        <1> 	mov	edi, Dir_Entry_Name ; Dir Entry Format File Name
  5507 000094BB E8D7200000          <1> 	call	convert_file_name
  5508 000094C0 89FE                <1> 	mov	esi, edi ; offset Dir_Entry_Name
  5509                              <1> 
  5510 000094C2 66A1[E6930100]      <1> 	mov	ax, [FindFile_AttributesMask]
  5511                              <1> 	;xor	ecx, ecx
  5512 000094C8 30C9                <1> 	xor	cl, cl  
  5513 000094CA E8D01D0000          <1> 	call	locate_current_dir_file
  5514 000094CF 726E                <1> 	jc	short loc_fff_retn
  5515                              <1> 	; EDI = Directory Entry
  5516                              <1> 	; EBX = Directory Buffer Entry Index/Number
  5517                              <1> 
  5518                              <1> loc_fff_fnf_ln_check:
  5519 000094D1 30ED                <1> 	xor	ch, ch 
  5520 000094D3 80F60F              <1> 	xor	dh, 0Fh
  5521 000094D6 7408                <1> 	jz	short loc_fff_longname_yes
  5522 000094D8 882D[E5930100]      <1> 	mov	[FindFile_LongNameYes], ch ; 0
  5523 000094DE EB0C                <1> 	jmp	short loc_fff_longname_no
  5524                              <1> 
  5525                              <1> loc_fff_longname_yes:
  5526                              <1> 	;inc	byte [FindFile_LongNameYes]
  5527 000094E0 8A0D[F2920100]      <1> 	mov	cl, [LFN_EntryLength]  
  5528 000094E6 880D[E5930100]      <1> 	mov	[FindFile_LongNameEntryLength], cl ; FindFile_LongNameYes
  5529                              <1> 
  5530                              <1> loc_fff_longname_no:
  5531                              <1> 	;mov	bx, [DirBuff_CurrentEntry]
  5532 000094EC 66891D[10940100]    <1> 	mov	[FindFile_DirEntryNumber], bx
  5533 000094F3 6689C2              <1> 	mov	dx, ax ; Ambiguous Filename chars used sign > 0
  5534                              <1> 
  5535 000094F6 A0[F68A0100]        <1> 	mov	al, [Current_Drv]
  5536 000094FB A2[96930100]        <1> 	mov	[FindFile_Drv], al 
  5537                              <1> 
  5538 00009500 A1[F08A0100]        <1> 	mov	eax, [Current_Dir_FCluster]
  5539 00009505 A3[08940100]        <1> 	mov	[FindFile_DirFirstCluster], eax
  5540                              <1> 
  5541 0000950A A1[21920100]        <1> 	mov	eax, [DirBuff_Cluster]
  5542 0000950F A3[0C940100]        <1> 	mov	[FindFile_DirCluster], eax
  5543                              <1> 
  5544 00009514 66FF05[12940100]    <1> 	inc	word [FindFile_MatchCounter]
  5545                              <1> 
  5546 0000951B 89FB                <1> 	mov	ebx, edi
  5547 0000951D 89FE                <1> 	mov	esi, edi
  5548 0000951F BF[E8930100]        <1> 	mov	edi, FindFile_DirEntry
  5549 00009524 89F8                <1> 	mov	eax, edi
  5550 00009526 B108                <1> 	mov	cl, 8
  5551 00009528 F3A5                <1> 	rep	movsd
  5552 0000952A 89C6                <1> 	mov	esi, eax
  5553 0000952C 89DF                <1> 	mov	edi, ebx
  5554                              <1> 
  5555 0000952E A1[04940100]        <1> 	mov	eax, [FindFile_DirEntry+28] ; File Size
  5556                              <1> 
  5557 00009533 8A1D[F3930100]      <1> 	mov	bl, [FindFile_DirEntry+11] ; File Attributes 
  5558 00009539 8A3D[E5930100]      <1> 	mov	bh, [FindFile_LongNameYes]
  5559                              <1> 
  5560                              <1> 	;mov	cx, [DirBuff_EntryCounter]
  5561                              <1> 	;mov	[FindFile_DirEntryNumber], cx
  5562                              <1> 	;mov	cx, [FindFile_DirEntryNumber]
  5563                              <1> 	; ecx = 0
  5564                              <1> 
  5565                              <1> loc_fff_retn:
  5566 0000953F C3                  <1> 	retn
  5567                              <1> 
  5568                              <1> find_next_file:
  5569                              <1> 	; 15/10/2016
  5570                              <1> 	; 10/02/2016
  5571                              <1> 	; 08/02/2016 (TRDOS 386 = TRDOS v2.0)
  5572                              <1> 	; 06/02/2011
  5573                              <1> 	; 17/09/2009
  5574                              <1> 	; 2005
  5575                              <1> 	; INPUT ->
  5576                              <1> 	;	NONE, Find First File Parameters
  5577                              <1> 	; OUTPUT ->
  5578                              <1> 	;	CF = 1 -> Error, Error Code in EAX (AL)
  5579                              <1> 	;	CF = 0 -> 
  5580                              <1> 	;	    ESI = Directory Entry (FindFile_DirEntry) Location
  5581                              <1> 	;	    EDI = Directory Buffer Directory Entry Location
  5582                              <1> 	;	    EAX = File Size
  5583                              <1> 	;	      BL = Attributes of The File/Directory
  5584                              <1> 	;	      BH = Long Name Yes/No Status (>0 is YES)
  5585                              <1> 	;             DX > 0 : Ambiguous filename chars are used 
  5586                              <1> 	;
  5587                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI will be changed)
  5588                              <1> 
  5589 00009540 66833D[12940100]00  <1> 	cmp	word [FindFile_MatchCounter], 0
  5590 00009548 7707                <1> 	ja	short loc_start_search_next_file
  5591                              <1> 
  5592                              <1> loc_fnf_stc_retn:
  5593 0000954A F9                  <1> 	stc
  5594                              <1> loc_fnf_ax12h_retn:
  5595 0000954B B80C000000          <1> 	mov	eax, 12 ; No More files
  5596                              <1> ;loc_fnf_retn:
  5597 00009550 C3                  <1> 	retn
  5598                              <1> 
  5599                              <1> loc_start_search_next_file:
  5600 00009551 668B1D[10940100]    <1> 	mov	bx, [FindFile_DirEntryNumber]
  5601 00009558 6643                <1> 	inc	bx
  5602 0000955A 663B1D[1F920100]    <1> 	cmp	bx, [DirBuff_LastEntry]
  5603 00009561 7719                <1> 	ja	short loc_cont_search_next_file
  5604                              <1> 
  5605                              <1> loc_fnf_search:
  5606 00009563 BE[87930100]        <1> 	mov	esi, Dir_Entry_Name
  5607 00009568 66A1[E6930100]      <1> 	mov	ax, [FindFile_AttributesMask]
  5608 0000956E 6631C9              <1> 	xor	cx, cx
  5609 00009571 E82D1E0000          <1> 	call	find_directory_entry
  5610 00009576 0F8355FFFFFF        <1>         jnc     loc_fff_fnf_ln_check
  5611                              <1> 
  5612                              <1> loc_cont_search_next_file:
  5613 0000957C 31DB                <1> 	xor	ebx, ebx
  5614 0000957E 8A3D[F68A0100]      <1> 	mov	bh, [Current_Drv]
  5615 00009584 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  5616 00009589 01DE                <1> 	add	esi, ebx
  5617                              <1> 
  5618 0000958B 803D[F48A0100]00    <1> 	cmp	byte [Current_Dir_Level], 0
  5619 00009592 7608                <1> 	jna	short loc_fnf_check_FAT_type
  5620 00009594 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
  5621 00009598 72B1                <1> 	jb	short loc_fnf_ax12h_retn
  5622 0000959A EB06                <1> 	jmp	short loc_fnf_check_next_cluster
  5623                              <1>  
  5624                              <1> loc_fnf_check_FAT_type:
  5625 0000959C 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3
  5626 000095A0 72A9                <1> 	jb	short loc_fnf_ax12h_retn
  5627                              <1> 
  5628                              <1> loc_fnf_check_next_cluster:
  5629 000095A2 A1[21920100]        <1> 	mov	eax, [DirBuff_Cluster]
  5630 000095A7 E8CA370000          <1> 	call	get_next_cluster
  5631 000095AC 7306                <1> 	jnc	short loc_fnf_load_next_dir_cluster
  5632 000095AE 09C0                <1> 	or	eax, eax
  5633 000095B0 7498                <1> 	jz	short loc_fnf_stc_retn
  5634                              <1> 	;mov	eax, 17 ;Drive not ready or read error
  5635 000095B2 F5                  <1>  	cmc	;stc
  5636                              <1> loc_fnf_retn:
  5637 000095B3 C3                  <1> 	retn
  5638                              <1> 
  5639                              <1> loc_fnf_load_next_dir_cluster:
  5640 000095B4 E8A3390000          <1> 	call	load_FAT_sub_directory
  5641 000095B9 72F8                <1> 	jc	short loc_fnf_retn
  5642 000095BB 6631DB              <1> 	xor	bx, bx
  5643 000095BE 66891D[10940100]    <1> 	mov	[FindFile_DirEntryNumber], bx
  5644 000095C5 EB9C                <1> 	jmp	short loc_fnf_search
  5645                              <1> 
  5646                              <1> get_and_print_longname:
  5647                              <1> 	; 16/10/2016
  5648                              <1> 	; 13/02/2016 (TRDOS 386 = TRDOS v2.0)
  5649                              <1> 	; 24/01/2010
  5650                              <1> 	; 17/10/2009 (CMD_INTR.ASM, 'cmp_cmd_longname')
  5651                              <1> get_longname_fchar:
  5652 000095C7 803E20              <1> 	cmp	byte [esi], 20h
  5653 000095CA 7701                <1> 	ja	short loc_find_longname
  5654                              <1> 	;jb	short loc_longname_retn
  5655                              <1> 	;inc	esi
  5656                              <1> 	;je	short get_longname_fchar
  5657                              <1> ;loc_longname_retn:
  5658 000095CC C3                  <1> 	retn
  5659                              <1> loc_find_longname:
  5660 000095CD E839210000          <1> 	call	find_longname
  5661 000095D2 7328                <1> 	jnc	short loc_print_longname
  5662                              <1> 	
  5663 000095D4 08C0                <1> 	or	al, al
  5664 000095D6 741A                <1> 	jz	short loc_longname_not_found
  5665                              <1> 	  
  5666                              <1> 	; 16/10/2016 (15h -> 15, 17)
  5667 000095D8 3C0F                <1> 	cmp	al, 15
  5668 000095DA 0F84B6F7FFFF        <1> 	je	cd_drive_not_ready ; drive not ready
  5669                              <1> 				   ; or
  5670 000095E0 3C11                <1> 	cmp	al, 17		   ; read error	
  5671 000095E2 0F84AEF7FFFF        <1> 	je	cd_drive_not_ready 
  5672                              <1> 
  5673                              <1> loc_ln_file_dir_not_found:
  5674 000095E8 BE[EE430100]        <1> 	mov	esi, Msg_File_Directory_Not_Found
  5675                              <1> 	;call	print_msg	
  5676                              <1>         ;retn
  5677 000095ED E973DFFFFF          <1> 	jmp	print_msg
  5678                              <1> 
  5679                              <1> loc_longname_not_found:
  5680 000095F2 BE[0D440100]        <1>         mov     esi, Msg_LongName_Not_Found
  5681                              <1> 	;call	print_msg	
  5682                              <1>         ;retn
  5683 000095F7 E969DFFFFF          <1> 	jmp	print_msg
  5684                              <1> 
  5685                              <1> loc_print_longname:
  5686                              <1> 	;mov	esi, LongFileName
  5687 000095FC BF[F68B0100]        <1> 	mov	edi, TextBuffer
  5688 00009601 57                  <1> 	push	edi 
  5689 00009602 3C00                <1> 	cmp	al, 0
  5690 00009604 7708                <1> 	ja	short loc_print_longname_1
  5691                              <1> loc_print_FS_longname: ; Singlix FS (64 byte ASCIIZ file name)
  5692 00009606 AC                  <1> 	lodsb
  5693 00009607 AA                  <1> 	stosb  
  5694 00009608 08C0                <1> 	or	al, al
  5695 0000960A 75FA                <1> 	jnz	short loc_print_FS_longname
  5696 0000960C EB07                <1> 	jmp	short loc_print_longname_2
  5697                              <1> 	;
  5698                              <1> loc_print_longname_1: ; MS Windows long name (UNICODE chars)
  5699 0000960E 66AD                <1> 	lodsw
  5700 00009610 AA                  <1> 	stosb  
  5701 00009611 08C0                <1> 	or	al, al
  5702 00009613 75F9                <1> 	jnz	short loc_print_longname_1
  5703                              <1> 	;
  5704                              <1> loc_print_longname_2:	
  5705 00009615 5E                  <1> 	pop	esi
  5706 00009616 E84ADFFFFF          <1> 	call	print_msg
  5707 0000961B BE[5F4D0100]        <1>   	mov	esi, nextline
  5708                              <1> 	;call	print_msg
  5709                              <1> 	;retn
  5710 00009620 E940DFFFFF          <1> 	jmp	print_msg	
  5711                              <1> 
  5712                              <1> show_file:
  5713                              <1> 	; 18/02/2016
  5714                              <1> 	; 17/02/2016
  5715                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
  5716                              <1> 	; 13/09/2011 (CMD_INTR.ASM, 'cmp_cmd_show')
  5717                              <1> 	; 08/11/2009
  5718                              <1> 
  5719                              <1> loc_show_parse_path_name:
  5720 00009625 BF[96930100]        <1> 	mov	edi, FindFile_Drv
  5721 0000962A E833200000          <1> 	call	parse_path_name
  5722 0000962F 0F824CF9FFFF        <1> 	jc	loc_cmd_failed
  5723                              <1> 
  5724                              <1> loc_show_check_filename_exists:
  5725 00009635 BE[D8930100]        <1> 	mov	esi, FindFile_Name
  5726 0000963A 803E20              <1> 	cmp	byte [esi], 20h
  5727 0000963D 0F863EF9FFFF        <1> 	jna	loc_cmd_failed
  5728                              <1> 
  5729                              <1> 	; 15/02/2016 (invalid file name check)
  5730 00009643 E807020000          <1> 	call	check_filename 	
  5731 00009648 730A                <1> 	jnc	short loc_show_change_drv
  5732                              <1> 
  5733 0000964A BE[DA440100]        <1> 	mov	esi, Msg_invalid_name_chars
  5734 0000964F E911DFFFFF          <1> 	jmp	print_msg
  5735                              <1>    
  5736                              <1> loc_show_change_drv:
  5737 00009654 8A35[F68A0100]      <1> 	mov	dh, [Current_Drv]
  5738 0000965A 8835[52920100]      <1> 	mov	[RUN_CDRV], dh
  5739 00009660 8A15[96930100]      <1> 	mov	dl, [FindFile_Drv]
  5740 00009666 38F2                <1> 	cmp	dl, dh
  5741 00009668 740B                <1> 	je	short loc_show_change_directory
  5742 0000966A E87FEAFFFF          <1> 	call	change_current_drive
  5743                              <1> 	;jc	loc_file_rw_cmd_failed
  5744 0000966F 0F8237F9FFFF        <1> 	jc	loc_run_cmd_failed
  5745                              <1> 
  5746                              <1> loc_show_change_directory:
  5747 00009675 803D[97930100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  5748 0000967C 7618                <1> 	jna	short loc_findload_showfile
  5749                              <1> 
  5750 0000967E FE05[C3400100]      <1> 	inc	byte [Restore_CDIR]
  5751 00009684 BE[97930100]        <1> 	mov	esi, FindFile_Directory
  5752 00009689 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  5753 0000968B E8BC190000          <1> 	call	change_current_directory
  5754                              <1> 	;jc	loc_file_rw_cmd_failed
  5755 00009690 0F8216F9FFFF        <1> 	jc	loc_run_cmd_failed
  5756                              <1> 
  5757                              <1> ;loc_show_change_prompt_dir_string:
  5758                              <1> 	;call	change_prompt_dir_string
  5759                              <1> 
  5760                              <1> loc_findload_showfile:
  5761                              <1> 	; 15/02/2016
  5762 00009696 BE[D8930100]        <1> 	mov	esi, FindFile_Name
  5763 0000969B BF[87930100]        <1> 	mov	edi, Dir_Entry_Name ; Dir Entry Format File Name
  5764 000096A0 E8F21E0000          <1> 	call	convert_file_name
  5765 000096A5 89FE                <1> 	mov	esi, edi ; offset Dir_Entry_Name
  5766                              <1> 
  5767 000096A7 28C0                <1> 	sub	al, al	; Attrib AND mask = 0
  5768                              <1> 	; Directory attribute : 10h
  5769                              <1> 	; Volume name attribute: 8h
  5770 000096A9 B418                <1> 	mov	ah, 00011000b ; 18h (Attrib NAND, AND --> zero mask)
  5771                              <1> 	;
  5772 000096AB 6631C9              <1> 	xor	cx, cx  
  5773 000096AE E8EC1B0000          <1> 	call	locate_current_dir_file
  5774                              <1> 	;jc	loc_file_rw_cmd_failed
  5775 000096B3 0F82F3F8FFFF        <1> 	jc	loc_run_cmd_failed
  5776                              <1> 
  5777                              <1> loc_show_load_file:
  5778                              <1> 	; EDI = Directory Entry
  5779 000096B9 668B4714            <1> 	mov	ax, [edi+DirEntry_FstClusHI] ; First Cluster High Word
  5780 000096BD C1E010              <1> 	shl	eax, 16
  5781 000096C0 668B471A            <1> 	mov	ax, [edi+DirEntry_FstClusLO] ; First Cluster Low Word
  5782 000096C4 A3[40940100]        <1> 	mov	[Show_Cluster], eax
  5783 000096C9 8B471C              <1> 	mov	eax, [edi+DirEntry_FileSize] ; File Size
  5784 000096CC 21C0                <1> 	and	eax, eax ; Empty file !
  5785 000096CE 0F8491000000        <1>         jz      end_of_show_file 
  5786 000096D4 A3[44940100]        <1> 	mov	[Show_FileSize], eax
  5787 000096D9 31C0                <1> 	xor	eax, eax
  5788 000096DB A3[48940100]        <1> 	mov	[Show_FilePointer], eax ; 0
  5789 000096E0 66A3[4C940100]      <1> 	mov	[Show_ClusterPointer], ax ; 0
  5790 000096E6 29DB                <1> 	sub	ebx, ebx
  5791 000096E8 8A3D[F68A0100]      <1> 	mov	bh, [Current_Drv]
  5792 000096EE BE00010900          <1> 	mov	esi, Logical_DOSDisks
  5793 000096F3 01DE                <1> 	add	esi, ebx
  5794 000096F5 8935[3C940100]      <1> 	mov	[Show_LDDDT], esi ; Logical DOS Drv Description Table addr
  5795                              <1> 
  5796 000096FB 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0	
  5797 000096FF 7713                <1> 	ja	short loc_show_calculate_cluster_size
  5798                              <1> 	; Singlix FS
  5799                              <1> 	; First Cluster Number is FDT number (in compatibility buffer)
  5800 00009701 8B15[40940100]      <1> 	mov	edx, [Show_Cluster] ; Compatibility dir. buffer value (FDT)	
  5801 00009707 8915[38940100]      <1> 	mov	[Show_FDT], edx
  5802 0000970D 31C0                <1> 	xor	eax, eax
  5803 0000970F A3[40940100]        <1> 	mov	[Show_Cluster], eax ; Sector index  = 0
  5804                              <1> 				    ; (next time it will be 1)			
  5805                              <1> loc_show_calculate_cluster_size:
  5806 00009714 668B5E11            <1> 	mov	bx, [esi+LD_BPB+BPB_BytsPerSec] ; FAT 12-16-32 (512)
  5807                              <1> 	; BX = 512 = [esi+LD_FS_BytesPerSec] ; Singlix FS	
  5808 00009718 8A4613              <1> 	mov	al, [esi+LD_BPB+BPB_SecPerClust] ; FAT 12-16-32 (<= 128)
  5809                              <1> 	; AL = 1 = [esi+LD_FS_Reserved2] ; SectPerClust for Singlix FS
  5810 0000971B F7E3                <1> 	mul	ebx	
  5811                              <1> 
  5812                              <1> 	;cmp	eax, 65536 ; non-compatible (very big) cluster size
  5813                              <1> 	;ja	short end_of_show_file	
  5814 0000971D 66A3[4E940100]      <1> 	mov	[Show_ClusterSize], ax
  5815                              <1> 
  5816                              <1> loc_start_show_file:
  5817 00009723 BE[5F4D0100]        <1> 	mov	esi, nextline
  5818 00009728 E838DEFFFF          <1> 	call	print_msg
  5819                              <1> 
  5820 0000972D A1[40940100]        <1> 	mov	eax, [Show_Cluster]
  5821 00009732 C605[50940100]17    <1> 	mov	byte [Show_RowCount], 23
  5822                              <1> 
  5823                              <1> 	; 17/02/2016
  5824 00009739 8B35[3C940100]      <1> 	mov	esi, [Show_LDDDT]
  5825                              <1> 
  5826                              <1> loc_show_next_cluster:
  5827                              <1> 	; 15/02/2016
  5828 0000973F BB00000700          <1> 	mov	ebx, Cluster_Buffer ; 70000h (for current TRDOS 386 version)
  5829                              <1> 	; ESI = Logical DOS drv description table address
  5830 00009744 E851380000          <1> 	call	read_cluster
  5831                              <1> 	;jc	loc_file_rw_cmd_failed
  5832 00009749 0F825DF8FFFF        <1> 	jc	loc_run_cmd_failed
  5833                              <1> 
  5834 0000974F 31DB                <1> 	xor 	ebx, ebx
  5835                              <1> loc_show_next_byte:
  5836 00009751 803D[50940100]00    <1> 	cmp	byte [Show_RowCount], 0
  5837 00009758 7521                <1> 	jne	short pass_show_wait_for_key
  5838 0000975A 30E4                <1> 	xor	ah, ah
  5839 0000975C E88C77FFFF          <1> 	call	int16h
  5840 00009761 3C1B                <1> 	cmp	al, 1Bh
  5841 00009763 750F                <1> 	jne	short pass_exit_show
  5842                              <1> end_of_show_file:
  5843                              <1> pass_show_file:
  5844 00009765 BE[5F4D0100]        <1> 	mov	esi, nextline
  5845 0000976A E8F6DDFFFF          <1> 	call	print_msg
  5846 0000976F E94B010000          <1> 	jmp	loc_file_rw_restore_retn
  5847                              <1> 
  5848                              <1> pass_exit_show:
  5849 00009774 C605[50940100]14    <1> 	mov	byte [Show_RowCount], 20
  5850                              <1> pass_show_wait_for_key:
  5851 0000977B 81C300000700        <1> 	add	ebx, Cluster_Buffer
  5852 00009781 8A03                <1> 	mov	al, [ebx]
  5853 00009783 3C0D                <1> 	cmp	al, 0Dh
  5854 00009785 0F8590000000        <1>         jne     loc_show_check_tab_space
  5855 0000978B FE0D[50940100]      <1> 	dec	byte [Show_RowCount]
  5856                              <1> pass_show_dec_rowcount:
  5857 00009791 B307                <1> 	mov	bl, 7 ; (light gray character color, black background)
  5858 00009793 8A3D[5E8A0100]      <1> 	mov	bh, [ACTIVE_PAGE] ; [ptty]
  5859 00009799 E8678BFFFF          <1> 	call	_write_tty
  5860                              <1> loc_show_check_eof:
  5861 0000979E FF05[48940100]      <1> 	inc	dword [Show_FilePointer]
  5862 000097A4 A1[48940100]        <1> 	mov	eax, [Show_FilePointer]
  5863 000097A9 3B05[44940100]      <1> 	cmp	eax, [Show_FileSize]
  5864 000097AF 73B4                <1> 	jnb	short end_of_show_file
  5865 000097B1 66FF05[4C940100]    <1> 	inc	word [Show_ClusterPointer]
  5866 000097B8 0FB71D[4C940100]    <1> 	movzx	ebx, word [Show_ClusterPointer]
  5867                              <1> 
  5868                              <1> 	; 17/02/2016
  5869                              <1> 	; (sector boundary -9 bits- check, 512 = 0)
  5870 000097BF 66F7C3FF01          <1>         test    bx, 1FFh ;  1 to 511
  5871 000097C4 758B                <1> 	jnz	short loc_show_next_byte
  5872                              <1> 
  5873                              <1> 	; 16/02/2016
  5874 000097C6 8B35[3C940100]      <1> 	mov	esi, [Show_LDDDT]
  5875                              <1> 	;
  5876 000097CC 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  5877 000097D0 7719                <1> 	ja	short loc_show_check_fat_cluster_size
  5878                              <1> 
  5879                              <1> 	; Singlix FS
  5880                              <1> 	; 1 sector, more... (cluster size = 1 sector)
  5881 000097D2 A1[40940100]        <1> 	mov	eax, [Show_Cluster]
  5882 000097D7 40                  <1> 	inc	eax
  5883 000097D8 A3[40940100]        <1> 	mov	[Show_Cluster], eax
  5884                              <1> 
  5885 000097DD 6621DB              <1> 	and	bx, bx ; 65536 -> 0
  5886 000097E0 0F856BFFFFFF        <1>         jnz	loc_show_next_byte
  5887 000097E6 E954FFFFFF          <1> 	jmp     loc_show_next_cluster
  5888                              <1> 	 
  5889                              <1> loc_show_check_fat_cluster_size:
  5890                              <1> 	; 17/02/2016
  5891 000097EB 663B1D[4E940100]    <1> 	cmp	bx, [Show_ClusterSize] ; cluster size in bytes
  5892 000097F2 0F8259FFFFFF        <1>         jb	loc_show_next_byte
  5893 000097F8 66C705[4C940100]00- <1> 	mov	word [Show_ClusterPointer], 0
  5893 00009800 00                  <1>
  5894                              <1> 
  5895 00009801 A1[40940100]        <1> 	mov	eax, [Show_Cluster]
  5896                              <1> 	;mov	esi, [Show_LDDDT]
  5897                              <1> loc_show_get_next_cluster:
  5898 00009806 E86B350000          <1> 	call	get_next_cluster
  5899                              <1> 	;jc	loc_file_rw_cmd_failed
  5900 0000980B 0F829BF7FFFF        <1> 	jc	loc_run_cmd_failed
  5901                              <1> loc_show_update_ccluster:
  5902 00009811 A3[40940100]        <1> 	mov	[Show_Cluster], eax			
  5903 00009816 E924FFFFFF          <1>         jmp     loc_show_next_cluster
  5904                              <1> 
  5905                              <1> loc_show_check_tab_space:
  5906 0000981B 3C09                <1> 	cmp	al, 09h
  5907 0000981D 0F856EFFFFFF        <1>         jne     pass_show_dec_rowcount
  5908                              <1> loc_show_put_tab_space:
  5909 00009823 8A3D[5E8A0100]      <1> 	mov	bh, [ACTIVE_PAGE] ; [ptty]
  5910 00009829 E85387FFFF          <1> 	call	get_cpos
  5911                              <1> 	; dl = cursor column
  5912 0000982E 80E207              <1> 	and	dl, 7 ; 18/02/2016
  5913                              <1> 	;shr	bh, 1 ; [ACTIVE_PAGE]
  5914 00009831 8A3D[5E8A0100]      <1> 	mov	bh, [ACTIVE_PAGE]
  5915 00009837 B307                <1> 	mov	bl, 7 ; color attribute
  5916                              <1> loc_show_put_space_chars:
  5917 00009839 B020                <1> 	mov	al, 20h ; space
  5918                              <1> 	;mov	bh, [ACTIVE_PAGE] ; [ptty]
  5919                              <1> 	;mov	bl, 7 ; color attribute
  5920                              <1> 	;push	dx
  5921 0000983B 52                  <1> 	push	edx ; 29/12/2017
  5922 0000983C E8C48AFFFF          <1> 	call	_write_tty
  5923 00009841 5A                  <1> 	pop	edx ; 29/12/2017
  5924                              <1> 	;pop	dx
  5925                              <1> 	; 18/02/2016
  5926 00009842 80FA07              <1> 	cmp	dl, 7
  5927 00009845 0F8353FFFFFF        <1> 	jnb	loc_show_check_eof
  5928 0000984B FEC2                <1> 	inc	dl
  5929 0000984D EBEA                <1> 	jmp	short loc_show_put_space_chars
  5930                              <1> 
  5931                              <1> check_filename:
  5932                              <1> 	; 10/10/2016
  5933                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
  5934                              <1> 	; 07/08/2010 (FILE.ASM, 'proc_check_filename')
  5935                              <1> 	; 10/07/2010
  5936                              <1> 	; Derived from 'proc_check_filename'
  5937                              <1> 	; in the old TRDOS.ASM (09/02/2005).
  5938                              <1> 	;
  5939                              <1> 	; INPUT -> 
  5940                              <1> 	;	ESI = Dot File Name Location
  5941                              <1> 	; OUTPUT ->
  5942                              <1> 	;	cf = 1 -> error code in AL
  5943                              <1> 	;	     AL = ERR_INV_FILE_NAME (=26)
  5944                              <1> 	;		  Invalid file name chars   
  5945                              <1> 	;	cf = 0 -> valid file name
  5946                              <1> 	; 
  5947                              <1> 	;(EAX, ECX, EDI will be changed)
  5948                              <1> 
  5949                              <1> check_invalid_filename_chars:
  5950                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
  5951                              <1> 	; 10/07/2010 (FILE.ASM, 'proc_check_invalid_filename_chars')
  5952                              <1> 	; 10/02/2010
  5953                              <1> 	; Derived from 'proc_check_invalid_filename_chars'
  5954                              <1> 	; in the old TRDOS.ASM (09/02/2005).
  5955                              <1> 	;
  5956                              <1> 	; INPUT -> 
  5957                              <1> 	;	ESI = ASCIIZ FileName
  5958                              <1> 	; OUTPUT ->
  5959                              <1> 	;	cf = 1 -> invalid
  5960                              <1> 	;	cf = 0 -> valid
  5961                              <1> 	; 
  5962                              <1> 	;(EAX, ECX, EDI will be changed)
  5963                              <1>   
  5964 0000984F 56                  <1> 	push	esi
  5965                              <1> 
  5966 00009850 BF[C2410100]        <1>         mov     edi, invalid_fname_chars
  5967 00009855 AC                  <1> 	lodsb
  5968                              <1> check_filename_next_char:
  5969 00009856 B914000000          <1> 	mov	ecx, sizeInvFnChars
  5970 0000985B BF[C2410100]        <1> 	mov	edi, invalid_fname_chars
  5971                              <1> loc_scan_invalid_filename_char:
  5972 00009860 AE                  <1> 	scasb 
  5973 00009861 741F                <1> 	je	short loc_invalid_filename_stc 
  5974 00009863 E2FB                <1> 	loop	loc_scan_invalid_filename_char
  5975 00009865 AC                  <1> 	lodsb
  5976 00009866 3C1F                <1> 	cmp	al, 1Fh  ; 20h and above 
  5977 00009868 77EC                <1> 	ja	short check_filename_next_char
  5978                              <1> 
  5979                              <1> check_filename_dot:
  5980 0000986A 8B3424              <1> 	mov	esi, [esp]
  5981                              <1> 
  5982 0000986D B421                <1> 	mov	ah, 21h
  5983 0000986F B908000000          <1> 	mov	ecx, 8
  5984                              <1> loc_check_filename_next_char:
  5985 00009874 AC                  <1> 	lodsb
  5986 00009875 3C2E                <1> 	cmp	al, 2Eh
  5987 00009877 7511                <1> 	jne	short pass_check_fn_dot_check
  5988                              <1> loc_check_filename_ext_0:
  5989 00009879 AC                  <1> 	lodsb
  5990 0000987A 38E0                <1> 	cmp	al, ah ; 21h
  5991 0000987C 7205                <1> 	jb	short loc_invalid_filename
  5992 0000987E 3C2E                <1> 	cmp	al, 2Eh
  5993 00009880 7519                <1> 	jne	short loc_check_filename_ext_1
  5994                              <1> 
  5995                              <1> loc_invalid_filename_stc:
  5996                              <1> loc_check_fn_stc_rtn:
  5997 00009882 F9                  <1> 	stc
  5998                              <1> loc_invalid_filename:
  5999                              <1> 	; 10/10/2016 (0Bh -> 26)
  6000 00009883 B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME ; (=26)
  6001                              <1> 	; Invalid file name chars
  6002                              <1> loc_check_fn_rtn:
  6003 00009888 5E                  <1> 	pop	esi
  6004 00009889 C3                  <1> 	retn
  6005                              <1> 
  6006                              <1> pass_check_fn_dot_check:
  6007 0000988A 38E0                <1> 	cmp	al, ah ; 21h
  6008 0000988C 7224                <1> 	jb	short loc_check_fn_clc_rtn
  6009 0000988E E2E4                <1> 	loop	loc_check_filename_next_char
  6010 00009890 AC                  <1> 	lodsb
  6011 00009891 38E0                <1> 	cmp	al, ah ; 21h
  6012 00009893 721D                <1> 	jb	short loc_check_fn_clc_rtn
  6013 00009895 3C2E                <1> 	cmp	al, 2Eh
  6014 00009897 75E9                <1> 	jne	short loc_check_fn_stc_rtn
  6015 00009899 EBDE                <1> 	jmp	short loc_check_filename_ext_0
  6016                              <1> 
  6017                              <1> loc_check_filename_ext_1:
  6018 0000989B AC                  <1> 	lodsb
  6019 0000989C 38E0                <1> 	cmp	al, ah ; 21h
  6020 0000989E 7212                <1> 	jb	short loc_check_fn_clc_rtn
  6021 000098A0 3C2E                <1> 	cmp	al, 2Eh
  6022 000098A2 74DE                <1> 	je	short loc_check_fn_stc_rtn
  6023 000098A4 AC                  <1> 	lodsb
  6024 000098A5 38E0                <1> 	cmp	al, ah ; 21h
  6025 000098A7 7209                <1> 	jb	short loc_check_fn_clc_rtn
  6026 000098A9 3C2E                <1> 	cmp	al, 2Eh
  6027 000098AB 74D5                <1> 	je	short loc_check_fn_stc_rtn
  6028 000098AD AC                  <1> 	lodsb
  6029 000098AE 38E0                <1> 	cmp	al, ah ; 21h
  6030 000098B0 73D0                <1> 	jnb	short loc_check_fn_stc_rtn
  6031                              <1> 
  6032                              <1> loc_check_fn_clc_rtn:
  6033 000098B2 5E                  <1> 	pop	esi
  6034 000098B3 F8                  <1> 	clc
  6035 000098B4 C3                  <1> 	retn
  6036                              <1> 
  6037                              <1> loc_print_deleted_message:
  6038 000098B5 BE[AF450100]        <1> 	mov	esi, Msg_Deleted
  6039 000098BA E8A6DCFFFF          <1> 	call	print_msg
  6040                              <1> 
  6041                              <1> 	;clc
  6042                              <1> 
  6043                              <1> loc_file_rw_restore_retn:
  6044                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
  6045                              <1> 	; 28/02/2010 (CMD_INTR.ASM)
  6046                              <1> loc_file_rw_cmd_failed:
  6047 000098BF 9C                  <1> 	pushf 
  6048 000098C0 E84FF7FFFF          <1> 	call	restore_cdir_after_cmd_fail	
  6049 000098C5 9D                  <1> 	popf
  6050 000098C6 720D                <1> 	jc	short loc_file_rw_check_write_fault
  6051 000098C8 C3                  <1> 	retn
  6052                              <1> 
  6053                              <1> loc_permission_denied:
  6054                              <1> 	; 27/02/2016
  6055 000098C9 BE[BC450100]        <1> 	mov	esi, Msg_Permission_Denied
  6056 000098CE E892DCFFFF          <1> 	call	print_msg
  6057 000098D3 EBEA                <1> 	jmp	short loc_file_rw_restore_retn
  6058                              <1> 
  6059                              <1> loc_file_rw_check_write_fault:
  6060                              <1> 	;cmp	al, 1Dh ; Write Fault
  6061 000098D5 3C12                <1>         cmp	al, 18 ; 05/11/2016
  6062 000098D7 0F85D4F6FFFF        <1> 	jne     loc_run_cmd_failed_cmp_al
  6063 000098DD BE[A3430100]        <1> 	mov	esi, Msg_Not_Ready_Write_Err
  6064                              <1> 	;call	print_msg
  6065                              <1> 	;retn
  6066 000098E2 E97EDCFFFF          <1> 	jmp	print_msg
  6067                              <1> 
  6068                              <1> make_directory:
  6069                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
  6070                              <1> 	; 12/03/2011 (CMD_INTR.ASM, 'cmp_cmd_mkdir')
  6071                              <1> 	; 14/08/2010
  6072                              <1> 	; 10/07/2010
  6073                              <1> 	; 29/11/2009
  6074                              <1> 	;
  6075                              <1> get_mkdir_fchar:
  6076                              <1> 	; esi = directory name
  6077 000098E7 803E20              <1> 	cmp	byte [esi], 20h
  6078 000098EA 7701                <1>         ja	short loc_mkdir_parse_path_name
  6079                              <1> 
  6080                              <1> loc_mkdir_nodirname_retn:
  6081 000098EC C3                  <1> 	retn
  6082                              <1> 
  6083                              <1> loc_mkdir_parse_path_name:
  6084 000098ED BF[96930100]        <1> 	mov	edi, FindFile_Drv
  6085 000098F2 E86B1D0000          <1>         call    parse_path_name
  6086 000098F7 0F8284F6FFFF        <1> 	jc	loc_cmd_failed
  6087                              <1> 
  6088                              <1> loc_mkdir_check_dirname_exists:
  6089 000098FD BE[D8930100]        <1> 	mov	esi, FindFile_Name
  6090 00009902 803E20              <1> 	cmp	byte [esi], 20h
  6091 00009905 0F8676F6FFFF        <1> 	jna	loc_cmd_failed
  6092 0000990B 8935[54940100]      <1> 	mov	[DelFile_FNPointer], esi
  6093 00009911 E839FFFFFF          <1> 	call	check_filename
  6094 00009916 7259                <1> 	jc	short loc_mkdir_invalid_dir_name_chars
  6095                              <1> 
  6096                              <1> loc_mkdir_drv:
  6097 00009918 8A35[F68A0100]      <1> 	mov	dh, [Current_Drv]
  6098 0000991E 8835[52920100]      <1> 	mov	[RUN_CDRV], dh
  6099                              <1> 	
  6100 00009924 8A15[96930100]      <1> 	mov	dl, [FindFile_Drv]
  6101 0000992A 38F2                <1> 	cmp	dl, dh
  6102 0000992C 7407                <1> 	je	short loc_mkdir_change_directory
  6103                              <1> 
  6104 0000992E E8BBE7FFFF          <1> 	call	change_current_drive
  6105 00009933 728A                <1> 	jc	loc_file_rw_cmd_failed
  6106                              <1> 
  6107                              <1> loc_mkdir_change_directory:
  6108 00009935 803D[97930100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  6109 0000993C 7614                <1> 	jna	short loc_mkdir_find_directory
  6110                              <1> 
  6111 0000993E FE05[C3400100]      <1> 	inc	byte [Restore_CDIR]
  6112 00009944 BE[97930100]        <1> 	mov	esi, FindFile_Directory
  6113 00009949 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  6114 0000994B E8FC160000          <1> 	call	change_current_directory
  6115 00009950 722E                <1> 	jc	short loc_mkdir_check_error_code
  6116                              <1> 
  6117                              <1> ;loc_mkdir_change_prompt_dir_string:
  6118                              <1> 	;call	change_prompt_dir_string
  6119                              <1> 
  6120                              <1> loc_mkdir_find_directory:
  6121                              <1> 	;mov	esi, FindFile_Name
  6122 00009952 8B35[54940100]      <1> 	mov	esi, [DelFile_FNPointer]
  6123                              <1> 	;xor	eax, eax
  6124 00009958 6631C0              <1> 	xor	ax, ax ; any name (dir, file, volume)
  6125 0000995B E831FBFFFF          <1> 	call	find_first_file
  6126 00009960 721E                <1> 	jc	short loc_mkdir_check_error_code
  6127                              <1> 
  6128                              <1> loc_mkdir_directory_found:
  6129 00009962 BE[07450100]        <1> 	mov	esi, Msg_Name_Exists
  6130 00009967 E8F9DBFFFF          <1> 	call	print_msg
  6131                              <1> 
  6132 0000996C E94EFFFFFF          <1>         jmp     loc_file_rw_restore_retn
  6133                              <1> 
  6134                              <1> loc_mkdir_invalid_dir_name_chars:
  6135 00009971 BE[DA440100]        <1> 	mov	esi, Msg_invalid_name_chars
  6136 00009976 E8EADBFFFF          <1> 	call	print_msg
  6137                              <1> 
  6138 0000997B E93FFFFFFF          <1>         jmp     loc_file_rw_restore_retn
  6139                              <1> 
  6140                              <1> loc_mkdir_check_error_code:
  6141 00009980 3C02                <1> 	cmp	al, 2
  6142                              <1> 	;je	short loc_mkdir_directory_not_found
  6143 00009982 7406                <1> 	je	short loc_mkdir_ask_for_yes_no
  6144 00009984 F9                  <1> 	stc
  6145 00009985 E935FFFFFF          <1>         jmp     loc_file_rw_cmd_failed
  6146                              <1> 
  6147                              <1> loc_mkdir_directory_not_found:
  6148                              <1> loc_mkdir_ask_for_yes_no:
  6149 0000998A BE[28450100]        <1> 	mov	esi, Msg_DoYouWantMkdir
  6150 0000998F E8D1DBFFFF          <1> 	call	print_msg
  6151 00009994 8B35[54940100]      <1> 	mov	esi, [DelFile_FNPointer]
  6152 0000999A E8C6DBFFFF          <1> 	call	print_msg
  6153 0000999F BE[47450100]        <1> 	mov	esi, Msg_YesNo
  6154 000099A4 E8BCDBFFFF          <1> 	call	print_msg
  6155                              <1> 
  6156 000099A9 C605[51450100]20    <1> 	mov	byte [Y_N_nextline], 20h
  6157                              <1> 
  6158                              <1> loc_mkdir_ask_again:
  6159 000099B0 30E4                <1> 	xor	ah, ah
  6160 000099B2 E83675FFFF          <1> 	call	int16h
  6161 000099B7 3C1B                <1> 	cmp	al, 1Bh
  6162                              <1> 	;je	short loc_do_not_make_directory
  6163 000099B9 7439                <1> 	je	short loc_mkdir_y_n_escape
  6164 000099BB 24DF                <1> 	and	al, 0DFh ; y -> Y, n -> N
  6165 000099BD 3C59                <1> 	cmp	al, 'Y' ; 'yes'
  6166 000099BF 7404                <1> 	je	short loc_mkdir_yes_make_directory
  6167 000099C1 3C4E                <1> 	cmp	al, 'N' ; 'no'
  6168 000099C3 75EB                <1> 	jne	short loc_mkdir_ask_again
  6169                              <1> 
  6170                              <1> loc_do_not_make_directory:
  6171                              <1> loc_mkdir_yes_make_directory:
  6172 000099C5 E82E000000          <1> 	call	y_n_answer ; 29/12/2017
  6173                              <1> 	;cmp	al, 'Y' ; 'yes'
  6174                              <1> 	;cmc
  6175                              <1>         ;jnc	loc_file_rw_restore_retn
  6176 000099CA 3C4E                <1> 	cmp	al, 'N' ; 'no'
  6177 000099CC 0F84EDFEFFFF        <1>         je	loc_file_rw_restore_retn  
  6178                              <1> 
  6179                              <1> loc_mkdir_call_make_sub_directory:
  6180 000099D2 8B35[54940100]      <1> 	mov	esi, [DelFile_FNPointer]
  6181 000099D8 B110                <1> 	mov	cl, 10h ; Directory attributes 
  6182 000099DA E8821D0000          <1> 	call	make_sub_directory
  6183                              <1> loc_rename_file_ok: ; 06/03/2016
  6184 000099DF 0F82DAFEFFFF        <1>         jc	loc_file_rw_cmd_failed
  6185                              <1> move_source_file_to_destination_OK:
  6186 000099E5 BE[55450100]        <1> 	mov	esi, Msg_OK
  6187 000099EA E876DBFFFF          <1> 	call	print_msg
  6188 000099EF E9CBFEFFFF          <1> 	jmp	loc_file_rw_restore_retn
  6189                              <1> 
  6190                              <1> loc_mkdir_y_n_escape:
  6191 000099F4 B04E                <1> 	mov	al, 'N' ; 'no'
  6192 000099F6 EBCD                <1> 	jmp	short loc_do_not_make_directory
  6193                              <1> 
  6194                              <1> y_n_answer:
  6195                              <1> 	; 29/12/2017
  6196 000099F8 A2[51450100]        <1> 	mov	[Y_N_nextline], al
  6197                              <1> 	;push	ax
  6198 000099FD 50                  <1> 	push	eax
  6199 000099FE BE[51450100]        <1> 	mov	esi, Y_N_nextline
  6200 00009A03 E85DDBFFFF          <1> 	call	print_msg
  6201 00009A08 58                  <1> 	pop	eax
  6202                              <1> 	;pop	ax
  6203 00009A09 C3                  <1> 	retn
  6204                              <1> 
  6205                              <1> delete_directory:
  6206                              <1> 	; 29/12/2017
  6207                              <1> 	; 15/10/2016
  6208                              <1> 	; 01/03/2016, 06/03/2016
  6209                              <1> 	; 27/02/2016, 28/02/2016, 29/02/2016
  6210                              <1> 	; 26/02/2016 (TRDOS 386 = TRDOS v2.0)
  6211                              <1> 	; 16/10/2010 (CMD_INTR.ASM, 'cmp_cmd_rmdir')
  6212                              <1> 	; 05/06/2010
  6213                              <1> 	;
  6214                              <1> get_fchar:
  6215                              <1> 	; esi = directory name
  6216 00009A0A 803E20              <1> 	cmp	byte [esi], 20h
  6217 00009A0D 7701                <1>         ja	short loc_rmdir_parse_path_name
  6218                              <1> 
  6219                              <1> loc_rmdir_nodirname_retn:
  6220 00009A0F C3                  <1> 	retn
  6221                              <1> 
  6222                              <1> loc_rmdir_parse_path_name:
  6223 00009A10 BF[96930100]        <1> 	mov	edi, FindFile_Drv
  6224 00009A15 E8481C0000          <1> 	call	parse_path_name
  6225 00009A1A 0F8261F5FFFF        <1> 	jc	loc_cmd_failed
  6226                              <1> 
  6227                              <1> loc_rmdir_check_dirname_exists:
  6228 00009A20 BE[D8930100]        <1> 	mov	esi, FindFile_Name
  6229 00009A25 803E20              <1> 	cmp	byte [esi], 20h
  6230 00009A28 0F8653F5FFFF        <1> 	jna	loc_cmd_failed
  6231 00009A2E 8935[54940100]      <1> 	mov	[DelFile_FNPointer], esi 
  6232                              <1> 
  6233                              <1> loc_rmdir_drv:
  6234 00009A34 8A35[F68A0100]      <1> 	mov	dh, [Current_Drv]
  6235 00009A3A 8835[52920100]      <1> 	mov	[RUN_CDRV], dh
  6236                              <1> 
  6237 00009A40 8A15[96930100]      <1> 	mov	dl, [FindFile_Drv]
  6238 00009A46 38F2                <1> 	cmp	dl, dh
  6239 00009A48 740B                <1> 	je	short loc_rmdir_change_directory
  6240                              <1> 
  6241 00009A4A E89FE6FFFF          <1> 	call	change_current_drive
  6242 00009A4F 0F826AFEFFFF        <1> 	jc	loc_file_rw_cmd_failed
  6243                              <1> 
  6244                              <1> loc_rmdir_change_directory:
  6245 00009A55 803D[97930100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  6246 00009A5C 7614                <1> 	jna	short loc_rmdir_find_directory
  6247                              <1> 
  6248 00009A5E FE05[C3400100]      <1> 	inc	byte [Restore_CDIR]
  6249 00009A64 BE[97930100]        <1> 	mov	esi, FindFile_Directory
  6250 00009A69 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  6251 00009A6B E8DC150000          <1> 	call	change_current_directory
  6252 00009A70 7211                <1> 	jc	short loc_rmdir_check_error_code
  6253                              <1> 
  6254                              <1> ;loc_rmdir_change_prompt_dir_string:
  6255                              <1> 	;call	change_prompt_dir_string
  6256                              <1> 
  6257                              <1> loc_rmdir_find_directory:
  6258                              <1> 	;mov	esi, FindFile_Name
  6259 00009A72 8B35[54940100]      <1> 	mov	esi, [DelFile_FNPointer]
  6260 00009A78 66B81008            <1> 	mov	ax, 0810h ; Only directories
  6261 00009A7C E810FAFFFF          <1> 	call	find_first_file
  6262 00009A81 730A                <1> 	jnc	short loc_rmdir_ambgfn_check
  6263                              <1> 
  6264                              <1> loc_rmdir_check_error_code:
  6265 00009A83 3C02                <1> 	cmp	al, 2
  6266 00009A85 740B                <1> 	je	short loc_rmdir_directory_not_found
  6267 00009A87 F9                  <1> 	stc
  6268 00009A88 E932FEFFFF          <1> 	jmp	loc_file_rw_cmd_failed
  6269                              <1> 
  6270                              <1> loc_rmdir_ambgfn_check:
  6271 00009A8D 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
  6272 00009A90 740F                <1> 	jz	short loc_rmdir_directory_found
  6273                              <1> 
  6274                              <1> loc_rmdir_directory_not_found:
  6275 00009A92 BE[C5430100]        <1> 	mov	esi, Msg_Dir_Not_Found
  6276 00009A97 E8C9DAFFFF          <1> 	call	print_msg
  6277                              <1> 
  6278 00009A9C E91EFEFFFF          <1> 	jmp	loc_file_rw_restore_retn
  6279                              <1> 
  6280                              <1> loc_rmdir_directory_found:
  6281 00009AA1 80E307              <1> 	and	bl, 07h ; Attributes
  6282 00009AA4 0F851FFEFFFF        <1> 	jnz	loc_permission_denied
  6283                              <1> 
  6284                              <1> loc_rmdir_save_lnel: ; 28/02/2016
  6285                              <1>        ;mov	bh, [LongName_EntryLength]
  6286 00009AAA 883D[5E940100]      <1> 	mov	[DelFile_LNEL], bh ; Long name entry length (if > 0)
  6287                              <1> 	; edi = Directory Entry Offset (DirBuff)
  6288                              <1> 	; esi = Directory Entry (FFF Structure)
  6289                              <1> 	;mov	[DelFile_DirEntryAddr], edi ; not required
  6290                              <1> 	;mov	ax, [edi+20] ; First Cluster High Word
  6291                              <1>         ;shl	eax, 16
  6292                              <1> 	;mov	ax, [edi+26] ; First Cluster Low Word
  6293                              <1> 	; ROOT Dir First Cluster = 0
  6294                              <1>         ;cmp	eax, 2
  6295                              <1> 	;jb	loc_update_direntry_1
  6296                              <1> 
  6297                              <1> pass_rmdir_fc_check:
  6298 00009AB0 57                  <1> 	push	edi ; * (29/02/2016)
  6299                              <1> 
  6300 00009AB1 BE[5B450100]        <1> 	mov	esi, Msg_DoYouWantRmDir
  6301 00009AB6 E8AADAFFFF          <1> 	call	print_msg
  6302 00009ABB 8B35[54940100]      <1> 	mov	esi, [DelFile_FNPointer]
  6303 00009AC1 E89FDAFFFF          <1> 	call	print_msg
  6304 00009AC6 BE[47450100]        <1> 	mov	esi, Msg_YesNo
  6305 00009ACB E895DAFFFF          <1> 	call	print_msg
  6306                              <1> 
  6307                              <1> loc_rmdir_ask_again:
  6308 00009AD0 30E4                <1> 	xor	ah, ah
  6309 00009AD2 E81674FFFF          <1> 	call	int16h
  6310 00009AD7 3C1B                <1> 	cmp	al, 1Bh
  6311                              <1> 	;je	short loc_do_not_delete_directory
  6312 00009AD9 7433                <1>         je      loc_rmdir_y_n_escape ; 06/03/2016
  6313 00009ADB 24DF                <1> 	and	al, 0DFh
  6314 00009ADD A2[51450100]        <1> 	mov	[Y_N_nextline], al
  6315 00009AE2 3C59                <1> 	cmp	al, 'Y'
  6316 00009AE4 7404                <1> 	je	short loc_rmdir_yes_delete_directory
  6317 00009AE6 3C4E                <1> 	cmp	al, 'N'
  6318 00009AE8 75E6                <1> 	jne	short loc_rmdir_ask_again
  6319                              <1> 
  6320                              <1> loc_do_not_delete_directory:
  6321                              <1> loc_rmdir_yes_delete_directory:
  6322 00009AEA E809FFFFFF          <1> 	call	y_n_answer ; 29/12/2017
  6323 00009AEF 5F                  <1> 	pop	edi ; * (29/02/2016)
  6324                              <1> 	;cmp	al, 'Y' ; 'yes'
  6325                              <1> 	;cmc
  6326                              <1>         ;jnc	loc_file_rw_restore_retn
  6327 00009AF0 3C4E                <1> 	cmp	al, 'N' ; 'no'
  6328 00009AF2 0F84C7FDFFFF        <1>         je	loc_file_rw_restore_retn 
  6329                              <1> 
  6330                              <1> 	; 29/12/2017
  6331 00009AF8 E869000000          <1> 	call	delete_sub_directory
  6332 00009AFD 7213                <1> 	jc	short loc_rmdir_cmd_failed
  6333                              <1> 
  6334                              <1> loc_rmdir_ok:
  6335 00009AFF BE[55450100]        <1> 	mov	esi, Msg_OK
  6336 00009B04 E85CDAFFFF          <1> 	call	print_msg
  6337 00009B09 E9B1FDFFFF          <1> 	jmp	loc_file_rw_restore_retn
  6338                              <1> 
  6339                              <1> loc_rmdir_y_n_escape:
  6340 00009B0E B04E                <1> 	mov	al, 'N' ; 'no'
  6341 00009B10 EBD8                <1>         jmp     loc_do_not_delete_directory
  6342                              <1> 
  6343                              <1> loc_rmdir_cmd_failed:
  6344                              <1> 	; 29/12/2017
  6345 00009B12 09C0                <1> 	or	eax, eax ; EAX = 0 -> Directory not empty!
  6346 00009B14 7426                <1> 	jz	short loc_rmdir_directory_not_empty
  6347                              <1> 
  6348                              <1> 	; EAX > 0 -> Error code in AL (or AX or EAX)
  6349                              <1> 
  6350 00009B16 833D[12920100]01    <1> 	cmp	dword [FAT_ClusterCounter], 1
  6351 00009B1D 0F829CFDFFFF        <1> 	jb	loc_file_rw_cmd_failed	
  6352 00009B23 F9                  <1> 	stc
  6353                              <1> loc_rmdir_cmd_return:
  6354                              <1> 	; 01/03/2016
  6355 00009B24 9C                  <1> 	pushf
  6356                              <1> 	; ESI = Logical DOS Drive Description Table address	
  6357 00009B25 66BB00FF            <1> 	mov	bx, 0FF00h ; BH = FFh -> use ESI for Drive parameters
  6358                              <1> 	           ; BL = 0 -> Recalculate free cluster count
  6359 00009B29 50                  <1> 	push	eax
  6360 00009B2A E8C3380000          <1> 	call	calculate_fat_freespace	
  6361 00009B2F 58                  <1> 	pop	eax
  6362 00009B30 9D                  <1> 	popf
  6363 00009B31 0F8288FDFFFF        <1> 	jc	loc_file_rw_cmd_failed
  6364 00009B37 E983FDFFFF          <1> 	jmp	loc_file_rw_restore_retn
  6365                              <1> 
  6366                              <1> loc_rmdir_directory_not_empty:
  6367 00009B3C BE[7C450100]        <1> 	mov	esi, Msg_Dir_Not_Empty
  6368 00009B41 E81FDAFFFF          <1> 	call	print_msg
  6369                              <1> 	; 01/03/2016
  6370 00009B46 A1[12920100]        <1> 	mov	eax, [FAT_ClusterCounter]
  6371 00009B4B 09C0                <1> 	or	eax, eax ; 0 ?
  6372 00009B4D 0F846CFDFFFF        <1> 	jz	loc_file_rw_restore_retn
  6373                              <1> 	; ESI = Logical DOS Drive Description Table address	
  6374 00009B53 66BB01FF            <1> 	mov	bx, 0FF01h ; BH = FFh -> use ESI for Drive parameters
  6375                              <1> 	           ; BL = 1 -> add free clusters
  6376 00009B57 E896380000          <1> 	call	calculate_fat_freespace
  6377 00009B5C 09C9                <1> 	or	ecx, ecx
  6378 00009B5E 0F845BFDFFFF        <1>         jz      loc_file_rw_restore_retn ; ecx = 0 -> OK
  6379                              <1> 	; ecx > 0 -> Error (Recalculation is needed)
  6380 00009B64 EBBE                <1> 	jmp	short loc_rmdir_cmd_return
  6381                              <1> 
  6382                              <1> 
  6383                              <1> delete_sub_directory:
  6384                              <1> 	; 29/12/2017 
  6385                              <1> 	; (moved here from 'delete_directory' for 'sysrmdir' )
  6386                              <1> 
  6387                              <1> 	; EDI = Directory buffer entry offset/address
  6388                              <1> 
  6389                              <1> loc_rmdir_delete_short_name_check_dir_empty:
  6390 00009B66 668B4714            <1> 	mov	ax, [edi+20] ; First Cluster High Word
  6391 00009B6A C1E010              <1>         shl	eax, 16
  6392 00009B6D 668B471A            <1> 	mov	ax, [edi+26] ; First Cluster Low Word
  6393                              <1> 
  6394                              <1> 	;mov 	[DelFile_FCluster], eax
  6395                              <1> 
  6396                              <1> 	;;mov	bx, [DirBuff_EntryCounter]
  6397                              <1> 	;mov	bx, [FindFile_DirEntryNumber] ; 27/02/2016
  6398                              <1> 	;mov	[DelFile_EntryCounter], bx
  6399                              <1> 
  6400 00009B71 29DB                <1>     	sub	ebx, ebx
  6401                              <1> 	; 29/12/2017
  6402 00009B73 891D[12920100]      <1> 	mov	[FAT_ClusterCounter], ebx ; 0 ; Reset
  6403                              <1> 
  6404 00009B79 8A3D[96930100]      <1> 	mov	bh, [FindFile_Drv]
  6405 00009B7F BE00010900          <1> 	mov	esi, Logical_DOSDisks
  6406 00009B84 01DE                <1> 	add	esi, ebx
  6407                              <1> 
  6408 00009B86 66817F0CA101        <1> 	cmp	word [edi+DirEntry_NTRes], 01A1h
  6409 00009B8C 745A                <1> 	je	short loc_rmdir_check_fs_directory
  6410                              <1> 
  6411                              <1> 	;cmp	byte [esi+LD_FATType], 1
  6412                              <1> 	;jb	short loc_rmdir_get__last_cluster_0
  6413                              <1> 
  6414                              <1> 	; 29/12/2017
  6415 00009B8E 83F802              <1> 	cmp	eax, 2
  6416 00009B91 7306                <1> 	jnb	short loc_rmdir_get_last_cluster_1
  6417                              <1> 	; eax < 2
  6418                              <1> loc_rmdir_get_last_cluster_0:
  6419                              <1> 	;mov	eax, ERR_INV_FORMAT ; invalid format!
  6420 00009B93 B813000000          <1> 	mov	eax, ERR_NOT_DIR ; not a valid directory!
  6421                              <1> 	;stc
  6422 00009B98 C3                  <1> 	retn
  6423                              <1> 
  6424                              <1> loc_rmdir_get_last_cluster_1:
  6425 00009B99 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3 ; FAT32
  6426 00009B9D 750C                <1> 	jne	short loc_rmdir_get_last_cluster_2
  6427                              <1> 
  6428                              <1> 	; is it root directory ?
  6429 00009B9F 3B4632              <1> 	cmp	eax, [esi+LD_BPB+BPB_RootClus]
  6430 00009BA2 7507                <1> 	jne	short loc_rmdir_get_last_cluster_2
  6431                              <1> 
  6432                              <1> 	; root directory can not be deleted !!
  6433                              <1> loc_rmdir_permission_denied:
  6434 00009BA4 B80B000000          <1> 	mov	eax, ERR_PERM_DENIED ; permission denied!
  6435 00009BA9 F9                  <1> 	stc
  6436 00009BAA C3                  <1> 	retn		
  6437                              <1> 
  6438                              <1> loc_rmdir_get_last_cluster_2:
  6439                              <1> 	; 29/12/2017
  6440 00009BAB A3[58940100]        <1> 	mov 	[DelFile_FCluster], eax
  6441                              <1> 	
  6442                              <1> 	;mov	dx, [DirBuff_EntryCounter]
  6443 00009BB0 668B15[10940100]    <1> 	mov	dx, [FindFile_DirEntryNumber] ; 27/02/2016
  6444 00009BB7 668915[5C940100]    <1> 	mov	[DelFile_EntryCounter], dx
  6445                              <1> 	
  6446 00009BBE 8B15[21920100]      <1> 	mov	edx, [DirBuff_Cluster]
  6447 00009BC4 8915[88940100]      <1> 	mov	[RmDir_ParentDirCluster], edx
  6448                              <1> 
  6449 00009BCA 893D[84940100]      <1> 	mov	[RmDir_DirEntryOffset], edi
  6450                              <1> 
  6451                              <1> 	; 01/03/2016
  6452                              <1> 	;mov	dword [FAT_ClusterCounter], 0 ; Reset
  6453                              <1> 
  6454                              <1> loc_rmdir_get_last_cluster_3:
  6455 00009BD0 E89C390000          <1> 	call	get_last_cluster
  6456                              <1>         ;jc	loc_rmdir_cmd_failed
  6457 00009BD5 721E                <1> 	jc	short loc_delete_sub_dir_retn ; 29/12/2017
  6458                              <1> 	
  6459 00009BD7 3B05[58940100]      <1> 	cmp	eax, [DelFile_FCluster]
  6460 00009BDD 7517                <1> 	jne	short loc_rmdir_multi_dir_clusters
  6461                              <1> 
  6462 00009BDF C605[83940100]00    <1> 	mov	byte [RmDir_MultiClusters], 0
  6463 00009BE6 EB15                <1> 	jmp	short pass_rmdir_multi_dir_clusters
  6464                              <1> 
  6465                              <1> loc_rmdir_check_fs_directory:
  6466                              <1> 	; 29/12/2017
  6467 00009BE8 807E04A1            <1> 	cmp	byte [esi+LD_FSType], 0A1h
  6468 00009BEC 75B6                <1> 	jne	short loc_rmdir_permission_denied
  6469                              <1> 
  6470                              <1> loc_rmdir_delete_fs_directory:
  6471 00009BEE E876130000          <1> 	call	delete_fs_directory
  6472                              <1> 	;jnc	loc_print_deleted_message
  6473 00009BF3 7300                <1> 	jnc	short loc_delete_sub_dir_retn ; 29/12/2017
  6474                              <1> 
  6475                              <1> 	; EAX=0 -> Directory not empty !
  6476                              <1> 	; EAX>0 -> Disk r/w error or another (misc) error
  6477                              <1> 	
  6478                              <1> 	;or	eax, eax
  6479                              <1> 	;jz	loc_rmdir_directory_not_empty_2         
  6480                              <1> 	;;stc
  6481                              <1> 	;;jmp	loc_file_rw_cmd_failed
  6482                              <1> 	
  6483                              <1> loc_delete_sub_dir_retn:
  6484 00009BF5 C3                  <1> 	retn
  6485                              <1>  
  6486                              <1> loc_rmdir_multi_dir_clusters:
  6487 00009BF6 C605[83940100]01    <1> 	mov	byte [RmDir_MultiClusters], 1
  6488                              <1> 
  6489                              <1> pass_rmdir_multi_dir_clusters:
  6490 00009BFD A3[8C940100]        <1> 	mov 	[RmDir_DirLastCluster], eax
  6491 00009C02 890D[90940100]      <1> 	mov	[RmDir_PreviousCluster], ecx
  6492                              <1> 
  6493                              <1> loc_rmdir_load_fat_sub_directory:
  6494 00009C08 E84F330000          <1> 	call	load_FAT_sub_directory
  6495                              <1> 	;jc	loc_rmdir_cmd_failed
  6496 00009C0D 72E6                <1> 	jc	short loc_delete_sub_dir_retn
  6497                              <1> 
  6498                              <1> loc_rmdir_find_last_dir_entry:
  6499 00009C0F 56                  <1> 	push	esi
  6500 00009C10 BE[7A930100]        <1> 	mov	esi, Dir_File_Name
  6501 00009C15 C6062A              <1> 	mov	byte [esi], '*'
  6502 00009C18 C646082A            <1> 	mov	byte [esi+8], '*'
  6503 00009C1C 31DB                <1> 	xor	ebx, ebx ; Entry offset  = 0
  6504                              <1> loc_rmdir_find_last_dir_entry_next:
  6505 00009C1E 66B80008            <1> 	mov	ax, 0800h ; Except volume/long names
  6506 00009C22 6631C9              <1> 	xor	cx, cx ; 0 = Find a valid file or dir name
  6507 00009C25 E879170000          <1> 	call	find_directory_entry
  6508 00009C2A 7225                <1> 	jc	short loc_rmdir_empty_dir_cluster
  6509 00009C2C 83FB01              <1> 	cmp	ebx, 1
  6510 00009C2F 771B                <1> 	ja	short loc_rmdir_directory_not_empty_1
  6511                              <1> loc_rmdir_dot_entry_check:
  6512 00009C31 80FD2E              <1> 	cmp	ch, '.' ; The first char of the dir entry
  6513 00009C34 7516                <1> 	jne	short loc_rmdir_directory_not_empty_1
  6514 00009C36 08DB                <1> 	or	bl, bl
  6515 00009C38 7506                <1> 	jnz	short loc_rmdir_dotdot_entry_check
  6516 00009C3A 807F0120            <1> 	cmp	byte [edi+1], 20h
  6517 00009C3E EB06                <1> 	jmp	short pass_rmdir_dot_entry_check
  6518                              <1> 
  6519                              <1> loc_rmdir_dotdot_entry_check:
  6520 00009C40 66817F012E20        <1> 	cmp	word [edi+1], '. '
  6521                              <1> pass_rmdir_dot_entry_check:	
  6522 00009C46 7504                <1> 	jne	short loc_rmdir_directory_not_empty_1 
  6523 00009C48 FEC3                <1> 	inc	bl
  6524 00009C4A EBD2                <1> 	jmp	short loc_rmdir_find_last_dir_entry_next 
  6525                              <1> 
  6526                              <1> loc_rmdir_directory_not_empty_1:
  6527 00009C4C 58                  <1> 	pop	eax ; pushed esi 
  6528 00009C4D 31C0                <1> 	xor	eax, eax ; 0
  6529                              <1> loc_rmdir_directory_not_empty_2:
  6530                              <1> loc_delete_sub_dir_stc_retn:
  6531 00009C4F F9                  <1> 	stc
  6532 00009C50 C3                  <1> 	retn
  6533                              <1> 
  6534                              <1> loc_rmdir_empty_dir_cluster:
  6535 00009C51 5E                  <1> 	pop	esi
  6536                              <1> 
  6537                              <1> loc_rmdir_set_prev_cluster_dir_last_cluster:
  6538 00009C52 803D[83940100]00    <1> 	cmp	byte [RmDir_MultiClusters], 0
  6539 00009C59 7613                <1> 	jna	short loc_rmdir_unlink_dir_last_cluster
  6540                              <1> 
  6541 00009C5B A1[90940100]        <1> 	mov	eax, [RmDir_PreviousCluster]
  6542                              <1> 	;xor	ecx, ecx
  6543 00009C60 49                  <1> 	dec	ecx ; FFFFFFFFh
  6544 00009C61 E83A340000          <1> 	call	update_cluster
  6545 00009C66 7306                <1> 	jnc	short loc_rmdir_unlink_dir_last_cluster
  6546                              <1> 
  6547                              <1> 	; 01/03/2016
  6548                              <1> 	;cmp	eax, 1  ; eax = 0 -> end of cluster chain
  6549                              <1> 	;cmc 
  6550                              <1> 	;jc	short loc_rmdir_cmd_failed
  6551                              <1> 	;jmp	short loc_rmdir_save_fat_buffer
  6552                              <1> 	; 29/12/2017 
  6553 00009C68 21C0                <1> 	and	eax, eax
  6554 00009C6A 75E3                <1> 	jnz	short loc_delete_sub_dir_stc_retn
  6555 00009C6C EB12                <1> 	jmp	short loc_rmdir_save_fat_buffer	
  6556                              <1> 
  6557                              <1> loc_rmdir_unlink_dir_last_cluster:
  6558 00009C6E A1[8C940100]        <1> 	mov	eax, [RmDir_DirLastCluster]
  6559 00009C73 31C9                <1> 	xor	ecx, ecx ; 0
  6560 00009C75 E826340000          <1> 	call	update_cluster
  6561 00009C7A 7327                <1> 	jnc	short loc_rmdir_unlink_stc_retn_0Bh
  6562                              <1> 	; Because of it is the last cluster
  6563                              <1> 	; 'update_cluster' must return with eocc error 
  6564 00009C7C 09C0                <1> 	or	eax, eax
  6565                              <1> 	;jz	short loc_rmdir_save_fat_buffer ; eocc	
  6566                              <1> 	;stc
  6567                              <1>         ;jmp     short loc_rmdir_cmd_failed
  6568                              <1> 	; 29/12/2017
  6569 00009C7E 75CF                <1> 	jnz	short loc_delete_sub_dir_stc_retn
  6570                              <1> 	
  6571                              <1> loc_rmdir_save_fat_buffer:
  6572 00009C80 803D[0A920100]02    <1> 	cmp	byte [FAT_BuffValidData], 2
  6573 00009C87 7528                <1> 	jne	short loc_rmdir_calculate_FAT_freespace
  6574 00009C89 E8CF360000          <1> 	call	save_fat_buffer
  6575                              <1> 	;jc	short loc_rmdir_cmd_failed
  6576                              <1> 	; 29/12/2017
  6577 00009C8E 7219                <1> 	jc	short loc_rmdir_unlink_error_retn
  6578                              <1> 
  6579                              <1> 	; 01/03/2016
  6580 00009C90 803D[83940100]00    <1> 	cmp	byte [RmDir_MultiClusters], 0
  6581 00009C97 7618                <1> 	jna	short loc_rmdir_calculate_FAT_freespace
  6582                              <1> 
  6583 00009C99 A1[58940100]        <1> 	mov	eax, [DelFile_FCluster]
  6584 00009C9E E92DFFFFFF          <1>         jmp     loc_rmdir_get_last_cluster_3
  6585                              <1> 
  6586                              <1> loc_rmdir_unlink_stc_retn_0Bh:
  6587                              <1> 	; 15/10/2016 (0Bh -> 28)
  6588 00009CA3 B81C000000          <1> 	mov	eax, ERR_INV_FORMAT ; 28 = Invalid format
  6589                              <1> loc_rmdir_unlink_stc_retn:
  6590 00009CA8 F9                  <1> 	stc
  6591                              <1> loc_rmdir_unlink_error_retn:
  6592 00009CA9 C3                  <1> 	retn
  6593                              <1> 
  6594                              <1> loc_rmdir_delete_short_name_invalid_data:
  6595 00009CAA B81D000000          <1> 	mov	eax, 29 ; Invalid data (15/10/2016)
  6596                              <1> 	;stc
  6597                              <1>         ;jmp	loc_rmdir_cmd_failed
  6598                              <1> 	; 29/12/2017
  6599 00009CAF EBF7                <1> 	jmp	short loc_rmdir_unlink_stc_retn
  6600                              <1> 
  6601                              <1> loc_rmdir_calculate_FAT_freespace:
  6602                              <1> 	;mov	eax, [FAT_ClusterCounter]
  6603                              <1> 	; 29/12/2017
  6604 00009CB1 29C0                <1> 	sub	eax, eax ; 0
  6605 00009CB3 8705[12920100]      <1> 	xchg	eax, [FAT_ClusterCounter]
  6606                              <1> 	;
  6607 00009CB9 66BB01FF            <1> 	mov	bx, 0FF01h
  6608                              <1> 	; BL = 1 -> Add EAX to free space count
  6609                              <1> 	; BH = FFh ->
  6610                              <1> 	; ESI = Logical DOS Drive Description Table address
  6611 00009CBD E830370000          <1> 	call	calculate_fat_freespace
  6612                              <1> 
  6613 00009CC2 21C9                <1> 	and	ecx, ecx ; ecx = 0 -> valid free sector count
  6614 00009CC4 7409                <1> 	jz 	short loc_rmdir_delete_short_name_continue
  6615                              <1> 
  6616                              <1> loc_rmdir_recalculate_FAT_freespace:
  6617 00009CC6 66BB00FF            <1>         mov     bx, 0FF00h ; BL = 0 -> Recalculate free space
  6618 00009CCA E823370000          <1> 	call	calculate_fat_freespace
  6619                              <1> 	          
  6620                              <1> loc_rmdir_delete_short_name_continue:
  6621 00009CCF A1[88940100]        <1> 	mov	eax, [RmDir_ParentDirCluster]
  6622 00009CD4 83F802              <1> 	cmp	eax, 2
  6623 00009CD7 7309                <1> 	jnb	short loc_rmdir_del_short_name_load_sub_dir
  6624 00009CD9 E8F3310000          <1> 	call	load_FAT_root_directory
  6625                              <1> 	;jc	loc_file_rw_cmd_failed
  6626                              <1> 	; 29/12/2017
  6627 00009CDE 72C9                <1> 	jc	short loc_rmdir_unlink_error_retn
  6628 00009CE0 EB07                <1> 	jmp	short loc_rmdir_del_short_name_ld_chk_fclust
  6629                              <1> 
  6630                              <1> loc_rmdir_del_short_name_load_sub_dir:	
  6631 00009CE2 E875320000          <1> 	call	load_FAT_sub_directory
  6632                              <1> 	;jc	loc_file_rw_cmd_failed
  6633                              <1> 	; 29/12/2017
  6634 00009CE7 72C0                <1> 	jc	short loc_rmdir_unlink_error_retn
  6635                              <1> 
  6636                              <1> loc_rmdir_del_short_name_ld_chk_fclust:
  6637 00009CE9 0FB73D[84940100]    <1> 	movzx	edi, word [RmDir_DirEntryOffset]
  6638 00009CF0 81C700000800        <1> 	add	edi, Directory_Buffer
  6639                              <1> 
  6640 00009CF6 668B4714            <1> 	mov	ax, [edi+20] ; First Cluster High Word
  6641 00009CFA C1E010              <1> 	shl	eax, 16
  6642 00009CFD 668B471A            <1> 	mov	ax, [edi+26] ; First Cluster Low Word
  6643                              <1>         ; Not necessary... 
  6644 00009D01 3B05[58940100]      <1> 	cmp	eax, [DelFile_FCluster]
  6645 00009D07 75A1                <1> 	jne	short loc_rmdir_delete_short_name_invalid_data
  6646                              <1> 	;
  6647 00009D09 C607E5              <1> 	mov	byte [edi], 0E5h ; 'Deleted' sign
  6648                              <1> 	; 27/02/2016
  6649                              <1> 	; TRDOS v1 has a bug here! it does not set
  6650                              <1> 	; 'DirBuff_ValidData' to 2; as result of this bug,
  6651                              <1> 	; 'save_directory_buffer' would not save the change ! 
  6652 00009D0C C605[1C920100]02    <1>   	mov	byte [DirBuff_ValidData], 2 ; change sign
  6653                              <1> 	;
  6654 00009D13 E8AE1D0000          <1> 	call	save_directory_buffer
  6655                              <1> 	;jc	loc_file_rw_cmd_failed
  6656                              <1> 	; 29/12/2017
  6657 00009D18 728F                <1> 	jc	short loc_rmdir_unlink_error_retn
  6658                              <1> 
  6659                              <1> loc_rmdir_del_long_name:
  6660 00009D1A 0FB615[5E940100]    <1> 	movzx	edx, byte [DelFile_LNEL]
  6661 00009D21 08D2                <1> 	or	dl, dl
  6662 00009D23 7410                <1> 	jz	short loc_rmdir_update_parent_dir_lmdt
  6663                              <1>              
  6664 00009D25 0FB705[5C940100]    <1> 	movzx	eax, word [DelFile_EntryCounter]
  6665 00009D2C 29D0                <1> 	sub	eax, edx
  6666                              <1> 	; 29/12/2017
  6667 00009D2E 7205                <1> 	jc	short loc_rmdir_update_parent_dir_lmdt
  6668                              <1>  
  6669                              <1>  	; EAX = Directory Entry Number of the long name last entry
  6670 00009D30 E8EF1E0000          <1> 	call	delete_longname
  6671                              <1> 
  6672                              <1> loc_rmdir_update_parent_dir_lmdt:
  6673 00009D35 E8271E0000          <1> 	call	update_parent_dir_lmdt
  6674                              <1> 	;jc	short loc_file_rw_cmd_failed
  6675                              <1> 	; 29/12/2017
  6676                              <1> 	;jc	short loc_rmdir_unlink_error_retn
  6677                              <1> 
  6678                              <1> loc_delete_sub_directory_ok:
  6679                              <1> 	; 29/12/2017
  6680 00009D3A 31C0                <1> 	xor	eax, eax ;  0 ;  cf = 0
  6681 00009D3C C3                  <1> 	retn
  6682                              <1> 
  6683                              <1> 
  6684                              <1> delete_file:
  6685                              <1> 	; 29/02/2016
  6686                              <1> 	; 28/02/2016 (TRDOS 386 = TRDOS v2.0)
  6687                              <1> 	; 09/08/2010 (CMD_INTR.ASM, 'cmp_cmd_del')
  6688                              <1> 	; 28/02/2010
  6689                              <1> 
  6690                              <1> get_delfile_fchar:
  6691                              <1> 	; esi = file name
  6692 00009D3D 803E20              <1> 	cmp	byte [esi], 20h
  6693 00009D40 7701                <1>         ja	short loc_delfile_parse_path_name
  6694                              <1> 
  6695                              <1> loc_delfile_nofilename_retn:
  6696 00009D42 C3                  <1> 	retn
  6697                              <1> 
  6698                              <1> loc_delfile_parse_path_name:
  6699 00009D43 BF[96930100]        <1> 	mov	edi, FindFile_Drv
  6700 00009D48 E815190000          <1> 	call	parse_path_name
  6701 00009D4D 0F822EF2FFFF        <1> 	jc	loc_cmd_failed
  6702                              <1> 
  6703                              <1> loc_delfile_check_filename_exists:
  6704 00009D53 BE[D8930100]        <1> 	mov	esi, FindFile_Name
  6705 00009D58 803E20              <1> 	cmp	byte [esi], 20h
  6706 00009D5B 0F8620F2FFFF        <1> 	jna	loc_cmd_failed
  6707 00009D61 8935[54940100]      <1> 	mov	[DelFile_FNPointer], esi 
  6708                              <1> 
  6709                              <1> loc_delfile_drv:
  6710 00009D67 8A15[96930100]      <1> 	mov	dl, [FindFile_Drv]
  6711 00009D6D 8A35[F68A0100]      <1> 	mov	dh, [Current_Drv]
  6712 00009D73 8835[52920100]      <1> 	mov	[RUN_CDRV], dh
  6713 00009D79 38F2                <1> 	cmp	dl, dh
  6714 00009D7B 740B                <1> 	je	short loc_delfile_change_directory
  6715                              <1> 
  6716 00009D7D E86CE3FFFF          <1> 	call	change_current_drive
  6717 00009D82 0F8237FBFFFF        <1> 	jc	loc_file_rw_cmd_failed
  6718                              <1> 
  6719                              <1> loc_delfile_change_directory:
  6720 00009D88 803D[97930100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  6721 00009D8F 7618                <1> 	jna	short loc_delfile_find
  6722                              <1> 
  6723 00009D91 FE05[C3400100]      <1> 	inc	byte [Restore_CDIR]
  6724 00009D97 BE[97930100]        <1> 	mov	esi, FindFile_Directory
  6725 00009D9C 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  6726 00009D9E E8A9120000          <1> 	call	change_current_directory
  6727 00009DA3 0F8216FBFFFF        <1> 	jc	loc_file_rw_cmd_failed
  6728                              <1> 
  6729                              <1> ;loc_delfile_change_prompt_dir_string:
  6730                              <1> 	;call	change_prompt_dir_string
  6731                              <1> 
  6732                              <1> loc_delfile_find:
  6733                              <1> 	;mov	esi, FindFile_Name
  6734 00009DA9 8B35[54940100]      <1> 	mov	esi, [DelFile_FNPointer]
  6735 00009DAF 66B80018            <1> 	mov	ax, 1800h ; Except volume label and dirs
  6736 00009DB3 E8D9F6FFFF          <1> 	call	find_first_file
  6737 00009DB8 0F8201FBFFFF        <1> 	jc	loc_file_rw_cmd_failed
  6738                              <1> 
  6739                              <1> loc_delfile_ambgfn_check:
  6740 00009DBE 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
  6741 00009DC1 740B                <1> 	jz	short loc_delfile_found
  6742                              <1> 
  6743                              <1> loc_file_not_found:
  6744 00009DC3 B802000000          <1> 	mov	eax, 2 ; File not found sign
  6745 00009DC8 F9                  <1> 	stc
  6746 00009DC9 E9F1FAFFFF          <1> 	jmp	loc_file_rw_cmd_failed   
  6747                              <1> 
  6748                              <1> loc_delfile_found:
  6749 00009DCE 80E307              <1> 	and	bl, 07h ; Attributes
  6750 00009DD1 0F85F2FAFFFF        <1>         jnz     loc_permission_denied
  6751                              <1> 
  6752                              <1> ;loc_delfile_found_save_lnel:
  6753                              <1> ;	mov	[DelFile_LNEL], bh ; Long name entry length (if > 0)
  6754                              <1> 
  6755                              <1> loc_delfile_ask_for_delete:
  6756 00009DD7 57                  <1> 	push	edi ; * (29/02/2016)
  6757                              <1> 
  6758 00009DD8 BE[93450100]        <1> 	mov	esi, Msg_DoYouWantDelete
  6759 00009DDD E883D7FFFF          <1> 	call	print_msg
  6760 00009DE2 8B35[54940100]      <1> 	mov	esi, [DelFile_FNPointer]
  6761 00009DE8 E878D7FFFF          <1> 	call	print_msg
  6762 00009DED BE[47450100]        <1> 	mov	esi, Msg_YesNo
  6763 00009DF2 E86ED7FFFF          <1> 	call	print_msg
  6764                              <1> 
  6765                              <1> loc_delfile_ask_again:
  6766 00009DF7 30E4                <1> 	xor	ah, ah
  6767 00009DF9 E8EF70FFFF          <1> 	call	int16h
  6768 00009DFE 3C1B                <1> 	cmp	al, 1Bh
  6769                              <1> 	;je	short loc_do_not_delete_file
  6770 00009E00 7449                <1> 	je	short loc_delfile_y_n_escape ; 06/03/2016
  6771 00009E02 24DF                <1> 	and	al, 0DFh
  6772 00009E04 A2[51450100]        <1> 	mov	[Y_N_nextline], al
  6773 00009E09 3C59                <1> 	cmp	al, 'Y'
  6774 00009E0B 7404                <1> 	je	short loc_yes_delete_file
  6775 00009E0D 3C4E                <1> 	cmp	al, 'N'
  6776 00009E0F 75E6                <1> 	jne	short loc_delfile_ask_again
  6777                              <1> 
  6778                              <1> loc_do_not_delete_file:
  6779                              <1> loc_yes_delete_file:
  6780 00009E11 E8E2FBFFFF          <1> 	call	y_n_answer ; 29/12/2017
  6781 00009E16 5F                  <1> 	pop	edi ; * (29/02/2016)
  6782                              <1> 	;cmp	al, 'Y' ; 'yes'
  6783                              <1> 	;cmc
  6784                              <1>         ;jnc	loc_file_rw_restore_retn
  6785 00009E17 3C4E                <1> 	cmp	al, 'N' ; 'no'
  6786 00009E19 0F84A0FAFFFF        <1>         je	loc_file_rw_restore_retn  
  6787                              <1> 
  6788                              <1> loc_delete_file:
  6789 00009E1F 8A3D[96930100]      <1> 	mov	bh, [FindFile_Drv]
  6790                              <1> 	;mov	bl, [DelFile_LNEL]
  6791 00009E25 8A1D[E5930100]      <1> 	mov	bl, [FindFile_LongNameEntryLength]
  6792                              <1> 	;mov	cx, [DirBuff_EntryCounter]
  6793 00009E2B 668B0D[10940100]    <1> 	mov	cx, [FindFile_DirEntryNumber]
  6794                              <1> 	; (*) EDI = Directory buffer entry offset/address 
  6795 00009E32 E8D71F0000          <1> 	call	remove_file ; (FILE.ASM, 'proc_delete_file')
  6796 00009E37 0F8378FAFFFF        <1> 	jnc	loc_print_deleted_message
  6797                              <1> 
  6798                              <1> 	;cmp	al, 05h
  6799 00009E3D 3C0B                <1> 	cmp	al, ERR_PERM_DENIED  ; 29/12/2017 (5 -> 11)
  6800 00009E3F 0F8484FAFFFF        <1> 	je	loc_permission_denied
  6801 00009E45 F9                  <1> 	stc
  6802 00009E46 E974FAFFFF          <1> 	jmp	loc_file_rw_cmd_failed
  6803                              <1> 
  6804                              <1> loc_delfile_y_n_escape:
  6805 00009E4B B04E                <1> 	mov	al, 'N' ; 'no'
  6806 00009E4D EBC2                <1> 	jmp	short loc_do_not_delete_file
  6807                              <1> 
  6808                              <1> set_file_attributes:
  6809                              <1> 	; 06/03/2016
  6810                              <1> 	; 04/03/2016 (TRDOS 386 = TRDOS v2.0)
  6811                              <1> 	; 10/07/2010 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_attrib')
  6812                              <1> 	; 23/05/2010 
  6813                              <1> 	; 17/12/2000 (P2000.ASM)
  6814                              <1> 
  6815                              <1> 	; esi = file or directory name
  6816 00009E4F 6631C0              <1> 	xor	ax, ax
  6817 00009E52 66A3[E4450100]      <1> 	mov	[Attr_Chars], ax
  6818 00009E58 A2[AC940100]        <1> 	mov	[Attributes], al
  6819                              <1> 
  6820                              <1> get_attrib_fchar:
  6821                              <1> 	; esi = file name
  6822 00009E5D 8A06                <1> 	mov	al, [esi]
  6823 00009E5F 3C20                <1> 	cmp	al, 20h
  6824 00009E61 7623                <1> 	jna	short loc_attr_file_nofilename_retn
  6825                              <1> 
  6826                              <1> loc_scan_attrib_params:
  6827 00009E63 3C2D                <1> 	cmp	al, '-'
  6828 00009E65 0F871C010000        <1> 	ja	loc_attr_file_parse_path_name
  6829 00009E6B 7408                <1> 	je	short loc_attr_space
  6830                              <1> 
  6831 00009E6D 3C2B                <1> 	cmp	al, '+'
  6832 00009E6F 0F850CF1FFFF        <1> 	jne	loc_cmd_failed
  6833                              <1> 
  6834                              <1> loc_attr_space:
  6835 00009E75 8A6601              <1> 	mov	ah, [esi+1]
  6836 00009E78 80FC20              <1>  	cmp	ah, 20h
  6837 00009E7B 770A                <1> 	ja	short pass_attr_space
  6838 00009E7D 0F82FEF0FFFF        <1> 	jb	loc_cmd_failed
  6839 00009E83 46                  <1> 	inc	esi
  6840 00009E84 EBEF                <1> 	jmp	short loc_attr_space
  6841                              <1> 
  6842                              <1> loc_attr_file_nofilename_retn:
  6843 00009E86 C3                  <1> 	retn
  6844                              <1> 
  6845                              <1> pass_attr_space:
  6846 00009E87 80E4DF              <1> 	and	ah, 0DFh
  6847 00009E8A 80FC53              <1> 	cmp	ah, 'S'
  6848 00009E8D 0F87EEF0FFFF        <1> 	ja	loc_cmd_failed
  6849 00009E93 7204                <1> 	jb	short pass_attr_system
  6850 00009E95 B404                <1> 	mov	ah, 04h   ; System
  6851 00009E97 EB21                <1> 	jmp	short pass_attr_archive
  6852                              <1> 
  6853                              <1> pass_attr_system:
  6854 00009E99 80FC48              <1> 	cmp	ah, 'H'
  6855 00009E9C 7706                <1> 	ja	short pass_attr_hidden
  6856 00009E9E 7213                <1> 	jb	short pass_attr_read_only
  6857 00009EA0 B402                <1> 	mov	ah, 02h    ; Hidden
  6858 00009EA2 EB16                <1> 	jmp	short pass_attr_archive
  6859                              <1> 
  6860                              <1> pass_attr_hidden:
  6861 00009EA4 80FC52              <1> 	cmp	ah, 'R'
  6862 00009EA7 0F87D4F0FFFF        <1> 	ja	loc_cmd_failed
  6863 00009EAD 7204                <1> 	jb	short pass_attr_read_only ; Read only
  6864 00009EAF B401                <1> 	mov	ah, 01h
  6865 00009EB1 EB07                <1> 	jmp	short pass_attr_archive
  6866                              <1> 
  6867                              <1> pass_attr_read_only:
  6868 00009EB3 80FC41              <1> 	cmp	ah, 'A'
  6869 00009EB6 753B                <1> 	jne	short loc_chk_attr_enter
  6870 00009EB8 B420                <1> 	mov	ah, 20h    ; Archive
  6871                              <1> 
  6872                              <1> pass_attr_archive:
  6873 00009EBA 3C2D                <1> 	cmp	al, '-'
  6874 00009EBC 7508                <1> 	jne	short pass_reducing_attributes
  6875 00009EBE 0825[E4450100]      <1> 	or	[Attr_Chars], ah
  6876 00009EC4 EB06                <1> 	jmp	short loc_change_attributes_inc
  6877                              <1> 
  6878                              <1> pass_reducing_attributes:
  6879 00009EC6 0825[E5450100]      <1> 	or	[Attr_Chars+1], ah
  6880                              <1> 
  6881                              <1> loc_change_attributes_inc:
  6882 00009ECC 46                  <1> 	inc	esi
  6883 00009ECD 8A6601              <1> 	mov	ah, [esi+1]
  6884 00009ED0 80FC20              <1> 	cmp	ah, 20h
  6885 00009ED3 7227                <1> 	jb	short pass_change_attr
  6886 00009ED5 74F5                <1> 	je	short loc_change_attributes_inc
  6887 00009ED7 80FC2D              <1> 	cmp	ah, '-'
  6888 00009EDA 770D                <1> 	ja	short loc_chk_next_attr_char1
  6889 00009EDC 7405                <1> 	je	short loc_chk_next_attr_char0
  6890 00009EDE 80FC2B              <1> 	cmp	ah, '+'
  6891 00009EE1 7506                <1> 	jne	short loc_chk_next_attr_char1
  6892                              <1> 
  6893                              <1> loc_chk_next_attr_char0:
  6894 00009EE3 46                  <1> 	inc	esi
  6895 00009EE4 668B06              <1> 	mov	ax, [esi]
  6896 00009EE7 EB9E                <1> 	jmp	short pass_attr_space
  6897                              <1> 
  6898                              <1> loc_chk_next_attr_char1:
  6899 00009EE9 803E2D              <1> 	cmp	byte [esi], '-'
  6900 00009EEC 7799                <1> 	ja	short pass_attr_space
  6901 00009EEE E988000000          <1>         jmp     loc_attr_file_check_fname_fchar
  6902                              <1> 
  6903                              <1> loc_chk_attr_enter:
  6904 00009EF3 80FC0D              <1> 	cmp	ah, 0Dh
  6905 00009EF6 0F8585F0FFFF        <1> 	jne	loc_cmd_failed
  6906                              <1> 
  6907                              <1> pass_change_attr:
  6908 00009EFC A0[E4450100]        <1> 	mov	al, [Attr_Chars]
  6909 00009F01 F6D0                <1> 	not	al
  6910 00009F03 2005[AC940100]      <1> 	and	[Attributes], al
  6911 00009F09 A0[E5450100]        <1> 	mov	al, [Attr_Chars+1]
  6912 00009F0E 0805[AC940100]      <1> 	or	[Attributes], al
  6913                              <1> 
  6914                              <1> loc_show_attributes:
  6915 00009F14 BE[5F4D0100]        <1> 	mov	esi, nextline
  6916 00009F19 E847D6FFFF          <1> 	call	print_msg
  6917                              <1> 
  6918                              <1> loc_show_attributes_no_nextline:
  6919 00009F1E C705[E4450100]4E4F- <1> 	mov	dword [Attr_Chars], 'NORM'
  6919 00009F26 524D                <1>
  6920 00009F28 66C705[E8450100]41- <1> 	mov	word [Attr_Chars+4], 'AL'
  6920 00009F30 4C                  <1>
  6921 00009F31 BE[E4450100]        <1> 	mov	esi, Attr_Chars
  6922 00009F36 A0[AC940100]        <1> 	mov	al, [Attributes]
  6923 00009F3B A804                <1> 	test	al, 04h
  6924 00009F3D 7406                <1> 	jz	short pass_put_attr_s
  6925 00009F3F 66C7065300          <1> 	mov	word [esi], 0053h     ; S
  6926 00009F44 46                  <1> 	inc	esi
  6927                              <1> 
  6928                              <1> pass_put_attr_s:
  6929 00009F45 A802                <1> 	test	al, 02h
  6930 00009F47 7406                <1> 	jz	short pass_put_attr_h
  6931 00009F49 66C7064800          <1> 	mov	word [esi], 0048h     ; H
  6932 00009F4E 46                  <1> 	inc	esi
  6933                              <1> 
  6934                              <1> pass_put_attr_h:
  6935 00009F4F A801                <1> 	test	al, 01h
  6936 00009F51 7406                <1> 	jz	short pass_put_attr_r
  6937 00009F53 66C7065200          <1> 	mov	word [esi], 0052h     ; R
  6938 00009F58 46                  <1> 	inc	esi
  6939                              <1> 
  6940                              <1> pass_put_attr_r:
  6941 00009F59 3C20                <1> 	cmp	al, 20h
  6942 00009F5B 7205                <1> 	jb	short pass_put_attr_a
  6943 00009F5D 66C7064100          <1> 	mov	word [esi], 0041h     ; A
  6944                              <1> 
  6945                              <1> pass_put_attr_a:
  6946 00009F62 BE[D7450100]        <1> 	mov	esi, Str_Attributes
  6947 00009F67 E8F9D5FFFF          <1> 	call	print_msg
  6948 00009F6C BE[5F4D0100]        <1> 	mov	esi, nextline
  6949 00009F71 E8EFD5FFFF          <1> 	call	print_msg
  6950 00009F76 E944F9FFFF          <1> 	jmp	loc_file_rw_restore_retn 
  6951                              <1> 
  6952                              <1> loc_attr_file_check_fname_fchar:
  6953 00009F7B 46                  <1> 	inc	esi
  6954 00009F7C 803E20              <1> 	cmp	byte [esi], 20h
  6955 00009F7F 74FA                <1> 	je	short loc_attr_file_check_fname_fchar
  6956 00009F81 0F8275FFFFFF        <1>         jb      pass_change_attr
  6957                              <1> 		   
  6958                              <1> loc_attr_file_parse_path_name:
  6959 00009F87 BF[96930100]        <1> 	mov	edi, FindFile_Drv
  6960 00009F8C E8D1160000          <1> 	call	parse_path_name
  6961 00009F91 0F82EAEFFFFF        <1> 	jc	loc_cmd_failed
  6962                              <1> 
  6963                              <1> loc_attr_file_check_filename_exists:
  6964 00009F97 BE[D8930100]        <1> 	mov	esi, FindFile_Name
  6965 00009F9C 803E20              <1> 	cmp	byte [esi], 20h
  6966 00009F9F 0F86DCEFFFFF        <1> 	jna	loc_cmd_failed
  6967 00009FA5 8935[54940100]      <1> 	mov	[DelFile_FNPointer], esi 
  6968                              <1> 
  6969                              <1> loc_attr_file_drv:
  6970 00009FAB 8A35[F68A0100]      <1> 	mov	dh, [Current_Drv]
  6971 00009FB1 8835[52920100]      <1> 	mov	[RUN_CDRV], dh
  6972                              <1> 
  6973 00009FB7 8A15[96930100]      <1> 	mov	dl, [FindFile_Drv]
  6974 00009FBD 38F2                <1> 	cmp	dl, dh
  6975 00009FBF 740B                <1> 	je	short loc_attr_file_change_directory
  6976                              <1> 
  6977 00009FC1 E828E1FFFF          <1> 	call	change_current_drive
  6978 00009FC6 0F82F3F8FFFF        <1> 	jc	loc_file_rw_cmd_failed
  6979                              <1> 
  6980                              <1> loc_attr_file_change_directory:
  6981 00009FCC 803D[97930100]20    <1>         cmp     byte [FindFile_Directory], 20h
  6982 00009FD3 7618                <1> 	jna	short loc_attr_file_find
  6983                              <1> 
  6984 00009FD5 FE05[C3400100]      <1> 	inc	byte [Restore_CDIR]
  6985                              <1> 	
  6986 00009FDB BE[97930100]        <1> 	mov	esi, FindFile_Directory
  6987 00009FE0 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  6988 00009FE2 E865100000          <1> 	call	change_current_directory
  6989 00009FE7 0F82D2F8FFFF        <1> 	jc	loc_file_rw_cmd_failed
  6990                              <1> 
  6991                              <1> ;loc_attr_file_change_prompt_dir_string:
  6992                              <1> 	;call	change_prompt_dir_string
  6993                              <1> 
  6994                              <1> loc_attr_file_find:
  6995                              <1> 	;mov	esi, FindFile_Name
  6996 00009FED 8B35[54940100]      <1> 	mov	esi, [DelFile_FNPointer]
  6997 00009FF3 66B80008            <1> 	mov	ax, 0800h ; Except volume labels
  6998 00009FF7 E895F4FFFF          <1> 	call	find_first_file
  6999 00009FFC 0F82BDF8FFFF        <1> 	jc	loc_file_rw_cmd_failed
  7000                              <1> 
  7001                              <1> loc_attr_file_ambgfn_check:
  7002 0000A002 6609D2              <1> 	or	dx, dx ; Ambiguous filename chars used sign (DX>0)
  7003                              <1> 	;	(Note: It was BX in TRDOS v1)
  7004                              <1> 	;jz	short loc_attr_file_found
  7005 0000A005 0F85B8FDFFFF        <1>         jnz     loc_file_not_found ; 06/03/2016 
  7006                              <1> 
  7007                              <1> 	;mov	eax, 2 ; File not found sign
  7008                              <1> 	;stc
  7009                              <1> 	;jmp	loc_file_rw_cmd_failed   
  7010                              <1> 
  7011                              <1> loc_attr_file_found:
  7012                              <1> 	; EDI = Directory buffer entry offset/address
  7013                              <1> 	; BL = File (or Directory) Attributes 
  7014                              <1> 	;	(Note: It was 'CL' in TRDOS v1)
  7015                              <1> 	; mov	bl, [EDI+0Bh]
  7016                              <1> 	
  7017 0000A00B 66833D[E4450100]00  <1> 	cmp	word [Attr_Chars], 0
  7018 0000A013 770B                <1> 	ja	short loc_attr_file_change_attributes
  7019 0000A015 881D[AC940100]      <1> 	mov	[Attributes], bl
  7020 0000A01B E9F4FEFFFF          <1> 	jmp	loc_show_attributes
  7021                              <1> 
  7022                              <1> loc_attr_file_change_attributes:
  7023 0000A020 A0[E4450100]        <1> 	mov	al, [Attr_Chars]
  7024 0000A025 F6D0                <1> 	not	al
  7025 0000A027 20C3                <1> 	and	bl, al
  7026 0000A029 A0[E5450100]        <1> 	mov	al, [Attr_Chars+1]
  7027 0000A02E 08C3                <1> 	or	bl, al
  7028                              <1> 
  7029 0000A030 66817F0CA101        <1> 	cmp	word [edi+DirEntry_NTRes], 01A1h ; Singlix FS
  7030 0000A036 741D                <1> 	je	short loc_attr_file_fs_check
  7031                              <1> 
  7032 0000A038 881D[AC940100]      <1> 	mov	[Attributes], bl
  7033 0000A03E 885F0B              <1> 	mov	[edi+0Bh], bl    ; Attributes (New!)
  7034                              <1> 
  7035                              <1> 	; 04/03/2016
  7036                              <1> 	; TRDOS v1 has a bug here! it does not set
  7037                              <1> 	; 'DirBuff_ValidData' to 2; as result of this bug,
  7038                              <1> 	; 'save_directory_buffer' would not save the new attributes ! 
  7039                              <1> 	
  7040 0000A041 C605[1C920100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  7041                              <1> 
  7042 0000A048 E8791A0000          <1> 	call 	save_directory_buffer
  7043 0000A04D 0F826CF8FFFF        <1> 	jc	loc_file_rw_cmd_failed
  7044                              <1> 
  7045 0000A053 EB33                <1> 	jmp	short loc_print_attr_changed_message
  7046                              <1> 
  7047                              <1> loc_attr_file_fs_check:
  7048 0000A055 29C0                <1> 	sub	eax, eax
  7049 0000A057 8A25[1A920100]      <1>         mov     ah, [DirBuff_DRV]
  7050 0000A05D BE00010900          <1> 	mov	esi, Logical_DOSDisks
  7051 0000A062 01C6                <1>         add     esi, eax
  7052 0000A064 807E04A1            <1>         cmp     byte [esi+LD_FSType], 0A1h
  7053 0000A068 7309                <1> 	jnc	short loc_attr_file_change_fs_file_attributes
  7054                              <1> 	; 29/12/2017 (0Dh -> 29)	
  7055 0000A06A 66B81D00            <1> 	mov	ax, 29 ; Invalid Data
  7056 0000A06E E94CF8FFFF          <1> 	jmp	loc_file_rw_cmd_failed
  7057                              <1> 
  7058                              <1> loc_attr_file_change_fs_file_attributes:
  7059                              <1> 	; BL = New MS-DOS File Attributes
  7060 0000A073 88D8                <1> 	mov	al, bl ; File/Directory Attributes
  7061 0000A075 30E4                <1> 	xor	ah, ah ; Attributes in MS-DOS format sign	  
  7062 0000A077 E873050000          <1> 	call	change_fs_file_attributes
  7063 0000A07C 0F823DF8FFFF        <1> 	jc	loc_file_rw_cmd_failed
  7064                              <1> 
  7065 0000A082 881D[AC940100]      <1> 	mov	[Attributes], bl 
  7066                              <1> 
  7067                              <1> loc_print_attr_changed_message:
  7068 0000A088 BE[D2450100]        <1> 	mov	esi, Msg_New
  7069 0000A08D E8D3D4FFFF          <1> 	call	print_msg
  7070 0000A092 E987FEFFFF          <1> 	jmp	loc_show_attributes_no_nextline
  7071                              <1> 
  7072                              <1> rename_file:
  7073                              <1> 	; 13/11/2017
  7074                              <1> 	; 06/11/2016
  7075                              <1> 	; 05/11/2016
  7076                              <1> 	; 16/10/2016
  7077                              <1> 	; 08/03/2016
  7078                              <1> 	; 06/03/2016 (TRDOS 386 = TRDOS v2.0)
  7079                              <1> 	; 20/11/2010 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_rename')
  7080                              <1> 	; 16/11/2010 
  7081                              <1> 
  7082                              <1> get_rename_source_fchar:
  7083                              <1> 	; esi = file name
  7084 0000A097 803E20              <1> 	cmp	byte [esi], 20h
  7085 0000A09A 7614                <1>         jna	short loc_rename_nofilename_retn
  7086                              <1> 
  7087 0000A09C 8935[D4940100]      <1> 	mov	[SourceFilePath], esi
  7088                              <1> 
  7089                              <1> rename_scan_source_file:
  7090 0000A0A2 46                  <1> 	inc	esi
  7091 0000A0A3 803E20              <1> 	cmp	byte [esi], 20h
  7092 0000A0A6 7409                <1> 	je	short rename_scan_destination_file_1
  7093                              <1> 	;jb	short loc_rename_nofilename_retn
  7094 0000A0A8 0F82D3EEFFFF        <1> 	jb	loc_cmd_failed
  7095 0000A0AE EBF2                <1> 	jmp	short rename_scan_source_file
  7096                              <1> 
  7097                              <1> loc_rename_nofilename_retn: ; 08/03/2016
  7098 0000A0B0 C3                  <1> 	retn
  7099                              <1> 
  7100                              <1> rename_scan_destination_file_1:
  7101 0000A0B1 C60600              <1> 	mov	byte [esi], 0
  7102                              <1> 
  7103                              <1> rename_scan_destination_file_2:
  7104 0000A0B4 46                  <1> 	inc	esi  
  7105 0000A0B5 803E20              <1> 	cmp	byte [esi], 20h
  7106 0000A0B8 74FA                <1> 	je	short rename_scan_destination_file_2
  7107                              <1> 	;jb	short loc_rename_nofilename_retn
  7108 0000A0BA 0F82C1EEFFFF        <1> 	jb	loc_cmd_failed
  7109                              <1> 
  7110 0000A0C0 8935[D8940100]      <1> 	mov	[DestinationFilePath], esi
  7111                              <1> 
  7112                              <1> rename_scan_destination_file_3:
  7113 0000A0C6 46                  <1> 	inc	esi  
  7114 0000A0C7 803E20              <1> 	cmp	byte [esi], 20h
  7115 0000A0CA 77FA                <1> 	ja	short rename_scan_destination_file_3
  7116                              <1> 
  7117 0000A0CC C60600              <1> 	mov	byte [esi], 0
  7118                              <1> 
  7119                              <1> loc_rename_save_current_drive:
  7120 0000A0CF 8A35[F68A0100]      <1> 	mov	dh, [Current_Drv]
  7121 0000A0D5 8835[52920100]      <1> 	mov	byte [RUN_CDRV], dh
  7122                              <1> 
  7123                              <1> loc_rename_sf_parse_path_name:
  7124 0000A0DB 8B35[D4940100]      <1> 	mov	esi, [SourceFilePath] 
  7125 0000A0E1 BF[96930100]        <1> 	mov	edi, FindFile_Drv
  7126 0000A0E6 E877150000          <1> 	call	parse_path_name
  7127 0000A0EB 0F8290EEFFFF        <1> 	jc	loc_cmd_failed
  7128                              <1> 
  7129                              <1> loc_rename_sf_check_filename_exists:
  7130 0000A0F1 BE[D8930100]        <1> 	mov	esi, FindFile_Name
  7131 0000A0F6 803E20              <1> 	cmp	byte [esi], 20h
  7132 0000A0F9 0F8682EEFFFF        <1> 	jna	loc_cmd_failed
  7133                              <1> 
  7134                              <1> 	;mov	[DelFile_FNPointer], esi 
  7135                              <1> 
  7136                              <1> loc_rename_sf_drv:
  7137                              <1> 	;mov	dh, [Current_Drv]
  7138                              <1> 	;mov	[RUN_CDRV], dh
  7139                              <1> 
  7140 0000A0FF 8A15[96930100]      <1> 	mov	dl, [FindFile_Drv]
  7141 0000A105 38F2                <1> 	cmp	dl, dh ; dh = [Current_Drv]
  7142 0000A107 740B                <1> 	je	short rename_sf_change_directory
  7143                              <1> 
  7144 0000A109 E8E0DFFFFF          <1> 	call	change_current_drive
  7145 0000A10E 0F82ABF7FFFF        <1> 	jc	loc_file_rw_cmd_failed
  7146                              <1> 
  7147                              <1> rename_sf_change_directory:
  7148 0000A114 803D[97930100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  7149 0000A11B 7618                <1> 	jna	short rename_sf_find
  7150                              <1> 
  7151 0000A11D FE05[C3400100]      <1> 	inc	byte [Restore_CDIR]
  7152 0000A123 BE[97930100]        <1> 	mov	esi, FindFile_Directory
  7153 0000A128 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  7154 0000A12A E81D0F0000          <1> 	call	change_current_directory
  7155 0000A12F 0F828AF7FFFF        <1>  	jc	loc_file_rw_cmd_failed
  7156                              <1> 
  7157                              <1> ;rename_sf_change_prompt_dir_string:
  7158                              <1> 	;call	change_prompt_dir_string
  7159                              <1> 
  7160                              <1> rename_sf_find:
  7161                              <1> 	;mov	esi, [DelFile_FNPointer]
  7162 0000A135 BE[D8930100]        <1> 	mov	esi, FindFile_Name
  7163                              <1> 
  7164 0000A13A 66B80008            <1> 	mov	ax, 0800h ; Except volume labels
  7165 0000A13E E84EF3FFFF          <1> 	call	find_first_file
  7166 0000A143 0F8276F7FFFF        <1> 	jc	loc_file_rw_cmd_failed
  7167                              <1> 
  7168                              <1> loc_rename_sf_ambgfn_check:
  7169 0000A149 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
  7170                              <1> 	;	(Note: It was BX in TRDOS v1)
  7171                              <1> 	;jz	short loc_rename_sf_found
  7172 0000A14C 0F8571FCFFFF        <1> 	jnz	loc_file_not_found
  7173                              <1> 
  7174                              <1> 	;mov	eax, 2 ; File not found sign
  7175                              <1> 	;stc
  7176                              <1> 	;jmp	loc_file_rw_cmd_failed   
  7177                              <1> 
  7178                              <1> loc_rename_sf_found:
  7179                              <1> 	; EDI = Directory buffer entry offset/address
  7180                              <1> 	; BL = File (or Directory) Attributes 
  7181                              <1> 	;	(Note: It was 'CL' in TRDOS v1)
  7182                              <1> 	; mov	bl, [EDI+0Bh]
  7183                              <1> 
  7184 0000A152 F6C307              <1> 	test	bl, 07h ; Attributes, S-H-R
  7185 0000A155 0F856EF7FFFF        <1> 	jnz	loc_permission_denied
  7186                              <1> 	
  7187 0000A15B BE[96930100]        <1>         mov     esi, FindFile_Drv
  7188 0000A160 BF[DC940100]        <1>         mov     edi, SourceFile_Drv
  7189 0000A165 B920000000          <1> 	mov	ecx, 32
  7190 0000A16A F3A5                <1> 	rep	movsd
  7191                              <1> 
  7192                              <1> loc_rename_df_parse_path_name:
  7193 0000A16C 8B35[D8940100]      <1> 	mov	esi, [DestinationFilePath]
  7194 0000A172 BF[96930100]        <1> 	mov	edi, FindFile_Drv
  7195 0000A177 E8E6140000          <1> 	call	parse_path_name
  7196 0000A17C 7219                <1> 	jc	short loc_rename_df_cmd_failed
  7197                              <1> 
  7198                              <1> 	;mov	dh, [RUN_CDRV]
  7199 0000A17E 8A35[F68A0100]      <1> 	mov	dh, [Current_Drv]
  7200                              <1> 
  7201                              <1> 	; 'rename' command is valid only for same dos drive and same dir!
  7202                              <1> 	; ('move' command must be used if source file and destination file
  7203                              <1> 	; directories are not same!) 
  7204 0000A184 8A15[96930100]      <1> 	mov	dl, [FindFile_Drv]
  7205 0000A18A 38F2                <1> 	cmp	dl, dh ; are source and destination drives different ?!
  7206 0000A18C 7509                <1> 	jne	short loc_rename_df_cmd_failed ; yes! 
  7207                              <1> 
  7208                              <1> rename_df_check_dirname_exists:
  7209 0000A18E 803D[97930100]00    <1> 	cmp	byte [FindFile_Directory], 0
  7210 0000A195 760B                <1> 	jna	short rename_df_check_filename_exists
  7211                              <1> 
  7212                              <1> 	; different source file and destination file directories !
  7213                              <1> loc_rename_df_cmd_failed:
  7214 0000A197 B801000000          <1> 	mov	eax, 1 ; TRDOS 'Bad command or file name' error
  7215 0000A19C F9                  <1> 	stc
  7216 0000A19D E91DF7FFFF          <1> 	jmp	loc_file_rw_cmd_failed
  7217                              <1> 	  
  7218                              <1> rename_df_check_filename_exists:
  7219 0000A1A2 BE[D8930100]        <1> 	mov	esi, FindFile_Name
  7220 0000A1A7 E8A3F6FFFF          <1> 	call	check_filename
  7221 0000A1AC 0F82BFF7FFFF        <1> 	jc	loc_mkdir_invalid_dir_name_chars
  7222                              <1> 
  7223                              <1> 	;mov	[DelFile_FNPointer], esi 
  7224                              <1> 	;cmp	byte [esi], 20h
  7225                              <1> 	;ja	short loc_rename_df_find
  7226                              <1> 
  7227                              <1> 	;mov	dh, [Current_Drv] ; dh has not been changed
  7228                              <1> 
  7229                              <1> rename_df_drv_check_writable:
  7230 0000A1B2 0FB6F6              <1> 	movzx	esi, dh
  7231                              <1> 	;movzx	esi, byte [Current_Drv]
  7232 0000A1B5 81C600010900        <1> 	add	esi, Logical_DOSDisks
  7233                              <1> 
  7234 0000A1BB 88F2                <1> 	mov	dl, dh ; dl = [Current_Drv]
  7235 0000A1BD 8A7601              <1> 	mov	dh, [esi+LD_DiskType]
  7236                              <1> 
  7237 0000A1C0 80FE01              <1> 	cmp	dh, 1 ; 0 = Invalid
  7238 0000A1C3 7310                <1> 	jnb	short rename_df_compare_sf_df_name
  7239                              <1> 
  7240                              <1> 	; 16/10/2016 (13h -> 30)
  7241 0000A1C5 B81E000000          <1> 	mov	eax, 30 ; 'Disk write-protected' error
  7242 0000A1CA 8B1D[D8940100]      <1> 	mov	ebx, [DestinationFilePath] 
  7243 0000A1D0 E9EAF6FFFF          <1> 	jmp	loc_file_rw_cmd_failed
  7244                              <1> 
  7245                              <1> rename_df_compare_sf_df_name:
  7246 0000A1D5 BE[D8930100]        <1> 	mov	esi, FindFile_Name
  7247 0000A1DA BF[1E950100]        <1> 	mov	edi, SourceFile_Name
  7248 0000A1DF B90C000000          <1> 	mov	ecx, 12
  7249                              <1> rename_df_compare_sf_df_name_next: 
  7250 0000A1E4 AC                  <1> 	lodsb
  7251 0000A1E5 AE                  <1> 	scasb
  7252 0000A1E6 7506                <1> 	jne	short loc_rename_df_find
  7253 0000A1E8 08C0                <1> 	or	al, al
  7254 0000A1EA 74AB                <1> 	jz	short loc_rename_df_cmd_failed
  7255 0000A1EC E2F6                <1> 	loop	rename_df_compare_sf_df_name_next 
  7256                              <1> 
  7257                              <1> loc_rename_df_find:
  7258                              <1> 	;mov	esi, [DelFile_FNPointer]
  7259 0000A1EE BE[D8930100]        <1> 	mov	esi, FindFile_Name
  7260                              <1> 
  7261 0000A1F3 6631C0              <1> 	xor	ax, ax ; Any
  7262 0000A1F6 E896F2FFFF          <1> 	call	find_first_file
  7263                              <1> 	;jnc	short loc_rename_df_found
  7264                              <1> 	; 29/12/2017
  7265 0000A1FB 0F83C8F6FFFF        <1> 	jnc	loc_permission_denied
  7266                              <1> 
  7267                              <1> loc_rename_df_check_error_code:
  7268                              <1> 	;cmp	eax, 2
  7269 0000A201 3C02                <1> 	cmp	al, 2 ; Not found error
  7270 0000A203 7406                <1> 	je	short rename_df_move_find_struct_to_dest
  7271 0000A205 F9                  <1> 	stc
  7272 0000A206 E9B4F6FFFF          <1> 	jmp	loc_file_rw_cmd_failed
  7273                              <1> 
  7274                              <1> ;loc_rename_df_found:
  7275                              <1> 	; 05/11/2016
  7276                              <1> 	; Permission denied error
  7277                              <1> 	;mov	eax, ERR_PERM_DENIED ; 29/12/2017
  7278                              <1> 	;stc
  7279                              <1> 	;jmp	loc_permission_denied  ; 06/11/2016
  7280                              <1> 
  7281                              <1> rename_df_move_find_struct_to_dest:
  7282 0000A20B BE[96930100]        <1>         mov     esi, FindFile_Drv
  7283 0000A210 BF[5C950100]        <1>         mov     edi, DestinationFile_Drv
  7284 0000A215 B920000000          <1> 	mov	ecx, 32
  7285 0000A21A F3A5                <1> 	rep	movsd
  7286                              <1> 
  7287                              <1> loc_rename_df_process_q_sf:
  7288                              <1> 	;mov	ecx, 12
  7289 0000A21C B10C                <1> 	mov	cl, 12
  7290 0000A21E BE[1E950100]        <1>  	mov	esi, SourceFile_Name
  7291 0000A223 BF[13460100]        <1> 	mov	edi, Rename_OldName
  7292                              <1> rename_df_process_q_nml_1_sf:
  7293 0000A228 AC                  <1> 	lodsb
  7294 0000A229 3C20                <1>         cmp	al, 20h
  7295 0000A22B 7603                <1>         jna	short rename_df_process_q_nml_2_sf
  7296 0000A22D AA                  <1> 	stosb
  7297 0000A22E E2F8                <1> 	loop	rename_df_process_q_nml_1_sf
  7298                              <1> 
  7299                              <1> rename_df_process_q_nml_2_sf:
  7300 0000A230 C60700              <1> 	mov	byte [edi], 0
  7301                              <1> 
  7302                              <1> loc_rename_df_process_q_df:
  7303                              <1> 	;mov	ecx, 12
  7304 0000A233 B10C                <1> 	mov	cl, 12
  7305 0000A235 BE[9E950100]        <1> 	mov	esi, DestinationFile_Name
  7306 0000A23A BF[24460100]        <1> 	mov	edi, Rename_NewName
  7307                              <1> rename_df_process_q_nml_1_df:
  7308 0000A23F AC                  <1> 	lodsb
  7309 0000A240 3C20                <1> 	cmp	al, 20h
  7310 0000A242 7603                <1> 	jna	short loc_rename_df_process_q_nml_2_df
  7311 0000A244 AA                  <1> 	stosb
  7312 0000A245 E2F8                <1> 	loop	rename_df_process_q_nml_1_df
  7313                              <1> 
  7314                              <1> loc_rename_df_process_q_nml_2_df:
  7315 0000A247 C60700              <1> 	mov	byte [edi], 0
  7316                              <1> 
  7317                              <1> loc_rename_confirmation_question:
  7318 0000A24A BE[EB450100]        <1> 	mov	esi, Msg_DoYouWantRename
  7319 0000A24F E811D3FFFF          <1> 	call	print_msg
  7320                              <1> 
  7321 0000A254 A0[39950100]        <1> 	mov	al, [SourceFile_DirEntry+11] ; Attributes
  7322 0000A259 2410                <1> 	and	al, 10h
  7323 0000A25B 750C                <1> 	jnz	short rename_confirmation_question_dir
  7324                              <1> 
  7325                              <1> rename_confirmation_question_file:
  7326 0000A25D BE[02460100]        <1> 	mov	esi, Rename_File
  7327 0000A262 E8FED2FFFF          <1> 	call	print_msg 
  7328 0000A267 EB0A                <1> 	jmp	short rename_confirmation_question_as 
  7329                              <1> 
  7330                              <1> rename_confirmation_question_dir:
  7331 0000A269 BE[08460100]        <1> 	mov	esi, Rename_Directory
  7332 0000A26E E8F2D2FFFF          <1> 	call	print_msg
  7333                              <1> 
  7334                              <1> rename_confirmation_question_as:
  7335 0000A273 BE[13460100]        <1> 	mov	esi, Rename_OldName
  7336 0000A278 E8E8D2FFFF          <1> 	call	print_msg
  7337 0000A27D BE[20460100]        <1> 	mov	esi, Msg_File_rename_as
  7338 0000A282 E8DED2FFFF          <1> 	call	print_msg
  7339 0000A287 BE[47450100]        <1> 	mov	esi, Msg_YesNo
  7340 0000A28C E8D4D2FFFF          <1> 	call	print_msg
  7341                              <1> 
  7342                              <1> loc_rename_ask_again:
  7343 0000A291 30E4                <1> 	xor	ah, ah
  7344 0000A293 E8556CFFFF          <1> 	call	int16h
  7345 0000A298 3C1B                <1> 	cmp	al, 1Bh
  7346 0000A29A 740F                <1> 	je	short loc_do_not_rename_file
  7347 0000A29C 24DF                <1> 	and	al, 0DFh
  7348 0000A29E A2[51450100]        <1> 	mov	[Y_N_nextline], al
  7349 0000A2A3 3C59                <1> 	cmp	al, 'Y'
  7350 0000A2A5 7404                <1> 	je	short loc_yes_rename_file
  7351 0000A2A7 3C4E                <1> 	cmp	al, 'N'
  7352 0000A2A9 75E6                <1> 	jne	short loc_rename_ask_again
  7353                              <1> 
  7354                              <1> loc_do_not_rename_file:
  7355                              <1> loc_yes_rename_file:
  7356 0000A2AB E848F7FFFF          <1> 	call	y_n_answer ; 29/12/2017
  7357                              <1> 	;cmp	al, 'Y' ; 'yes'
  7358                              <1> 	;cmc
  7359                              <1>         ;jnc	loc_file_rw_restore_retn
  7360 0000A2B0 3C4E                <1> 	cmp	al, 'N' ; 'no'
  7361 0000A2B2 0F8407F6FFFF        <1>         je	loc_file_rw_restore_retn  
  7362                              <1> 
  7363 0000A2B8 BE[24460100]        <1> 	mov	esi, Rename_NewName
  7364 0000A2BD 668B0D[56950100]    <1> 	mov	cx, [SourceFile_DirEntryNumber] 
  7365 0000A2C4 66A1[42950100]      <1> 	mov	ax, [SourceFile_DirEntry+20] ; First Cluster, HW 
  7366 0000A2CA C1E010              <1> 	shl	eax, 16 ; 13/11/2017
  7367 0000A2CD 66A1[48950100]      <1> 	mov	ax, [SourceFile_DirEntry+26] ; First Cluster, LW 
  7368                              <1> 
  7369 0000A2D3 0FB61D[2B950100]    <1>   	movzx	ebx, byte [SourceFile_LongNameEntryLength]  
  7370 0000A2DA E8CB1B0000          <1>    	call	rename_directory_entry
  7371 0000A2DF E9FBF6FFFF          <1> 	jmp	loc_rename_file_ok	
  7372                              <1> ;loc_rename_file_ok:
  7373                              <1> ;	jc	loc_run_cmd_failed
  7374                              <1> ;	mov	esi, Msg_OK
  7375                              <1> ;	call	proc_printmsg
  7376                              <1> ;	jmp	loc_file_rw_restore_retn
  7377                              <1> 
  7378                              <1> move_file:
  7379                              <1> 	; 11/03/2016
  7380                              <1> 	; 09/03/2016
  7381                              <1> 	; 08/03/2016 (TRDOS 386 = TRDOS v2.0)
  7382                              <1> 	; 21/05/2011 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_move')
  7383                              <1> 	; 23/04/2011
  7384                              <1> 
  7385                              <1> get_move_source_fchar:
  7386                              <1> 	; esi = file name
  7387 0000A2E4 803E20              <1> 	cmp	byte [esi], 20h
  7388 0000A2E7 7614                <1>         jna	short loc_move_nofilename_retn
  7389                              <1> 
  7390 0000A2E9 8935[D4940100]      <1> 	mov	[SourceFilePath], esi
  7391                              <1> 
  7392                              <1> move_scan_source_file:
  7393 0000A2EF 46                  <1> 	inc	esi
  7394 0000A2F0 803E20              <1> 	cmp	byte [esi], 20h
  7395 0000A2F3 7409                <1>         je      short move_scan_destination_1
  7396                              <1> 	;jb	short loc_move_nofilename_retn
  7397 0000A2F5 0F8286ECFFFF        <1> 	jb	loc_cmd_failed
  7398 0000A2FB EBF2                <1> 	jmp	short move_scan_source_file
  7399                              <1> 
  7400                              <1> loc_move_nofilename_retn:
  7401 0000A2FD C3                  <1> 	retn
  7402                              <1> 
  7403                              <1> move_scan_destination_1:
  7404 0000A2FE C60600              <1> 	mov	byte [esi], 0
  7405                              <1> 
  7406                              <1> move_scan_destination_2:
  7407 0000A301 46                  <1> 	inc	esi  
  7408 0000A302 803E20              <1> 	cmp	byte [esi], 20h
  7409 0000A305 74FA                <1> 	je	short move_scan_destination_2
  7410                              <1> 	;jb	short loc_move_nofilename_retn
  7411 0000A307 0F8274ECFFFF        <1> 	jb	loc_cmd_failed
  7412                              <1> 
  7413 0000A30D 8935[D8940100]      <1> 	mov	[DestinationFilePath], esi
  7414                              <1> 
  7415                              <1> move_scan_destination_3:
  7416 0000A313 46                  <1> 	inc	esi  
  7417 0000A314 803E20              <1> 	cmp	byte [esi], 20h
  7418 0000A317 77FA                <1> 	ja	short move_scan_destination_3
  7419 0000A319 C60600              <1> 	mov	byte [esi], 0
  7420                              <1> 
  7421                              <1> loc_move_scan_destination_OK:
  7422 0000A31C 8B35[D4940100]      <1> 	mov	esi, [SourceFilePath]
  7423 0000A322 8B3D[D8940100]      <1> 	mov	edi, [DestinationFilePath]
  7424                              <1> 
  7425 0000A328 B001                <1> 	mov	al, 1  ; move procedure Phase 1
  7426 0000A32A E8F71B0000          <1> 	call	move_source_file_to_destination_file
  7427 0000A32F 7328                <1> 	jnc	short move_source_file_to_destination_question
  7428                              <1> 
  7429                              <1> loc_move_cmd_failed_1:
  7430 0000A331 08C0                <1> 	or	al, al
  7431 0000A333 0F8448ECFFFF        <1> 	jz	loc_cmd_failed 
  7432 0000A339 3C11                <1> 	cmp	al, 11h
  7433 0000A33B 740D                <1> 	je	short loc_msg_not_same_device   
  7434                              <1> 	;cmp	al, 05h
  7435                              <1> 	;cmp	al, ERR_PERM_DENIED ; 29/12/2017
  7436                              <1> 	;jne	loc_run_cmd_failed
  7437                              <1> 	;jmp	loc_permission_denied
  7438 0000A33D 3C0B                <1> 	cmp	al, ERR_PERM_DENIED
  7439 0000A33F 0F8484F5FFFF        <1> 	je	loc_permission_denied
  7440 0000A345 E962ECFFFF          <1> 	jmp	loc_run_cmd_failed
  7441                              <1> 
  7442                              <1> 	;mov	esi, Msg_Permission_denied
  7443                              <1> 	;call	print_msg
  7444                              <1> 	;jmp	loc_file_rw_restore_retn
  7445                              <1> 
  7446                              <1> loc_msg_not_same_device:
  7447 0000A34A BE[31460100]        <1> 	mov	esi, msg_not_same_drv 
  7448 0000A34F E811D2FFFF          <1> 	call	print_msg
  7449 0000A354 E966F5FFFF          <1> 	jmp	loc_file_rw_restore_retn
  7450                              <1> 
  7451                              <1> move_source_file_to_destination_question:
  7452 0000A359 A0[DC940100]        <1>         mov     al, [SourceFile_Drv]
  7453 0000A35E 0441                <1> 	add	al, 'A'
  7454 0000A360 A2[93460100]        <1> 	mov	[msg_source_file_drv], al
  7455 0000A365 A0[5C950100]        <1>         mov     al, [DestinationFile_Drv]
  7456 0000A36A 0441                <1> 	add	al, 'A'
  7457 0000A36C A2[B2460100]        <1> 	mov	[msg_destination_file_drv], al
  7458                              <1> 
  7459 0000A371 57                  <1> 	push	edi ; *
  7460                              <1> 
  7461 0000A372 BE[77460100]        <1> 	mov	esi, msg_source_file
  7462 0000A377 E8E9D1FFFF          <1> 	call	print_msg
  7463 0000A37C BE[DD940100]        <1> 	mov	esi, SourceFile_Directory
  7464 0000A381 803E20              <1> 	cmp	byte [esi], 20h
  7465 0000A384 7605                <1> 	jna	short msftdfq_sfn
  7466 0000A386 E8DAD1FFFF          <1> 	call	print_msg
  7467                              <1> msftdfq_sfn:
  7468 0000A38B BE[1E950100]        <1> 	mov	esi, SourceFile_Name
  7469 0000A390 E8D0D1FFFF          <1> 	call	print_msg
  7470 0000A395 BE[96460100]        <1> 	mov	esi, msg_destination_file
  7471 0000A39A E8C6D1FFFF          <1> 	call	print_msg
  7472 0000A39F BE[5D950100]        <1> 	mov	esi, DestinationFile_Directory
  7473 0000A3A4 803E20              <1> 	cmp	byte [esi], 20h
  7474 0000A3A7 7605                <1> 	jna	short msftdfq_dfn
  7475 0000A3A9 E8B7D1FFFF          <1> 	call	print_msg
  7476                              <1> msftdfq_dfn:
  7477 0000A3AE BE[9E950100]        <1> 	mov	esi, DestinationFile_Name
  7478 0000A3B3 E8ADD1FFFF          <1> 	call	print_msg
  7479 0000A3B8 BE[B5460100]        <1> 	mov	esi, msg_copy_nextline
  7480 0000A3BD E8A3D1FFFF          <1> 	call	print_msg
  7481 0000A3C2 BE[B5460100]        <1> 	mov	esi, msg_copy_nextline
  7482 0000A3C7 E899D1FFFF          <1> 	call	print_msg
  7483                              <1> 
  7484                              <1> loc_move_ask_for_new_file_yes_no:
  7485 0000A3CC BE[43460100]        <1> 	mov	esi, Msg_DoYouWantMoveFile
  7486 0000A3D1 E88FD1FFFF          <1> 	call	print_msg
  7487 0000A3D6 BE[47450100]        <1> 	mov	esi, Msg_YesNo
  7488 0000A3DB E885D1FFFF          <1> 	call	print_msg
  7489                              <1> loc_move_ask_for_new_file_again:
  7490 0000A3E0 30E4                <1> 	xor	ah, ah
  7491 0000A3E2 E8066BFFFF          <1> 	call	int16h
  7492 0000A3E7 3C1B                <1> 	cmp	al, 1Bh
  7493                              <1> 	;je	short loc_do_not_move_file
  7494 0000A3E9 7441                <1> 	je	short loc_move_y_n_escape
  7495 0000A3EB 24DF                <1> 	and	al, 0DFh
  7496 0000A3ED A2[51450100]        <1>         mov     [Y_N_nextline], al
  7497 0000A3F2 3C59                <1> 	cmp	al, 'Y'
  7498 0000A3F4 7404                <1> 	je	short loc_yes_move_file
  7499 0000A3F6 3C4E                <1> 	cmp	al, 'N'
  7500 0000A3F8 75E6                <1> 	jne	short loc_move_ask_for_new_file_again
  7501                              <1> 
  7502                              <1> loc_do_not_move_file:
  7503                              <1> loc_yes_move_file:
  7504 0000A3FA E8F9F5FFFF          <1> 	call	y_n_answer ; 29/12/2017
  7505 0000A3FF 5F                  <1> 	pop	edi ; *
  7506                              <1> 	;cmp	al, 'Y' ; 'yes'
  7507                              <1> 	;cmc
  7508                              <1>         ;jnc	loc_file_rw_restore_retn
  7509 0000A400 3C4E                <1> 	cmp	al, 'N' ; 'no'
  7510 0000A402 0F84B7F4FFFF        <1>         je	loc_file_rw_restore_retn
  7511                              <1> 
  7512                              <1> loc_move_yes_move_file:
  7513 0000A408 B002                <1> 	mov	al, 2 ; move procedure Phase 2
  7514 0000A40A E8171B0000          <1> 	call	move_source_file_to_destination_file
  7515                              <1> 	;jc	short loc_move_cmd_failed_2
  7516 0000A40F 0F83D0F5FFFF        <1>         jnc     move_source_file_to_destination_OK
  7517                              <1> 
  7518                              <1> ;move_source_file_to_destination_OK:
  7519                              <1> ;	mov	esi, Msg_OK
  7520                              <1> ;	call	print_msg
  7521                              <1> ;	jmp	loc_file_rw_restore_retn
  7522                              <1> 
  7523                              <1> loc_move_cmd_failed_2:
  7524 0000A415 3C27                <1> 	cmp	al, 27h
  7525 0000A417 0F858FEBFFFF        <1> 	jne	loc_run_cmd_failed
  7526                              <1> 
  7527 0000A41D BE[5C460100]        <1> 	mov	esi, msg_insufficient_disk_space
  7528 0000A422 E83ED1FFFF          <1> 	call	print_msg
  7529                              <1> 
  7530 0000A427 E993F4FFFF          <1> 	jmp	loc_file_rw_restore_retn
  7531                              <1> 
  7532                              <1> loc_move_y_n_escape:
  7533 0000A42C B04E                <1> 	mov	al, 'N' ; 'no'
  7534 0000A42E EBCA                <1> 	jmp	short loc_do_not_move_file
  7535                              <1> 
  7536                              <1> copy_file:
  7537                              <1> 	; 15/10/2016
  7538                              <1> 	; 24/03/2016
  7539                              <1> 	; 21/03/2016
  7540                              <1> 	; 15/03/2016 (TRDOS 386 = TRDOS v2.0)
  7541                              <1> 	; 21/05/2011 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_copy')
  7542                              <1> 	; 01/08/2010
  7543                              <1> 
  7544                              <1> get_copy_source_fchar:
  7545                              <1> 	; esi = file name
  7546 0000A430 803E20              <1> 	cmp	byte [esi], 20h
  7547 0000A433 7614                <1>         jna     short loc_copy_nofilename_retn
  7548                              <1> 
  7549 0000A435 8935[D4940100]      <1> 	mov	[SourceFilePath], esi
  7550                              <1> 
  7551                              <1> copy_scan_source_file:
  7552 0000A43B 46                  <1> 	inc	esi  
  7553 0000A43C 803E20              <1> 	cmp	byte [esi], 20h
  7554 0000A43F 7409                <1> 	je	short copy_scan_destination_1
  7555                              <1> 	;jb	short loc_copy_nofilename_retn
  7556 0000A441 0F823AEBFFFF        <1> 	jb	loc_cmd_failed
  7557 0000A447 EBF2                <1> 	jmp	short copy_scan_source_file
  7558                              <1> 
  7559                              <1> loc_copy_nofilename_retn:
  7560 0000A449 C3                  <1> 	retn
  7561                              <1> 
  7562                              <1> copy_scan_destination_1:
  7563 0000A44A C60600              <1> 	mov	byte [esi], 0
  7564                              <1> 
  7565                              <1> copy_scan_destination_2:
  7566 0000A44D 46                  <1> 	inc	esi  
  7567 0000A44E 803E20              <1> 	cmp	byte [esi], 20h
  7568 0000A451 74FA                <1> 	je	short copy_scan_destination_2
  7569                              <1> 	;jb	short loc_copy_nofilename_retn
  7570 0000A453 0F8228EBFFFF        <1> 	jb	loc_cmd_failed
  7571                              <1> 
  7572 0000A459 8935[D8940100]      <1> 	mov	[DestinationFilePath], esi
  7573                              <1> 
  7574                              <1> copy_scan_destination_3:
  7575 0000A45F 46                  <1> 	inc	esi  
  7576 0000A460 803E20              <1> 	cmp	byte [esi], 20h
  7577 0000A463 77FA                <1> 	ja	short copy_scan_destination_3
  7578 0000A465 C60600              <1> 	mov	byte [esi], 0
  7579                              <1> 
  7580                              <1> loc_copy_save_current_drive:
  7581 0000A468 8A35[F68A0100]      <1> 	mov	dh, [Current_Drv]
  7582 0000A46E 8835[52920100]      <1> 	mov	[RUN_CDRV], dh
  7583                              <1> 
  7584                              <1> copy_source_file_to_destination_phase_1:
  7585 0000A474 8B35[D4940100]      <1> 	mov	esi, [SourceFilePath]
  7586 0000A47A 8B3D[D8940100]      <1> 	mov	edi, [DestinationFilePath]
  7587                              <1> 
  7588 0000A480 B001                <1> 	mov	al, 1  ; copy procedure Phase 1
  7589 0000A482 E83C1D0000          <1> 	call	copy_source_file_to_destination_file
  7590 0000A487 732B                <1> 	jnc	short copy_source_file_to_destination_question
  7591                              <1> 
  7592                              <1> loc_copy_cmd_failed_1:
  7593                              <1> 	; 18/03/2016 (restore current drive and directory)
  7594 0000A489 08C0                <1> 	or	al, al
  7595 0000A48B 7507                <1> 	jnz	short loc_copy_cmd_failed_2
  7596                              <1> 
  7597 0000A48D FEC0                <1>         inc     al ; mov al, 1 ; Bad command or file name !
  7598 0000A48F E918EBFFFF          <1> 	jmp	loc_run_cmd_failed
  7599                              <1> 
  7600                              <1> loc_copy_cmd_failed_2:
  7601 0000A494 3C27                <1> 	cmp	al, 27h ; Insufficient disk space 
  7602 0000A496 740D                <1> 	je	short loc_file_write_insuff_disk_space_msg
  7603                              <1>  
  7604                              <1> 	; 29/12/2017
  7605                              <1> 	;cmp	al, 05h
  7606 0000A498 3C0B                <1> 	cmp	al, ERR_PERM_DENIED
  7607 0000A49A 0F850CEBFFFF        <1> 	jne	loc_run_cmd_failed
  7608                              <1> 	
  7609 0000A4A0 E924F4FFFF          <1> 	jmp	loc_permission_denied
  7610                              <1> 
  7611                              <1> loc_file_write_insuff_disk_space_msg:
  7612 0000A4A5 BE[5C460100]        <1> 	mov	esi, msg_insufficient_disk_space
  7613 0000A4AA E8B6D0FFFF          <1> 	call	print_msg
  7614 0000A4AF E90BF4FFFF          <1>         jmp     loc_file_rw_restore_retn 
  7615                              <1> 
  7616                              <1> copy_source_file_to_destination_question:
  7617 0000A4B4 57                  <1> 	push	edi ; *
  7618                              <1> 
  7619                              <1> 	; dh = source file attributes
  7620                              <1> 	; dl > 0 -> destination file found
  7621 0000A4B5 20D2                <1> 	and	dl, dl            
  7622 0000A4B7 7449                <1> 	jz	short copy_source_file_to_destination_pass_owrq
  7623                              <1> 
  7624                              <1> loc_copy_ask_for_owr_yes_no:
  7625 0000A4B9 BE[B8460100]        <1> 	mov	esi, Msg_DoYouWantOverWriteFile
  7626 0000A4BE E8A2D0FFFF          <1> 	call	print_msg
  7627 0000A4C3 BE[9E950100]        <1> 	mov	esi, DestinationFile_Name
  7628 0000A4C8 E898D0FFFF          <1> 	call	print_msg
  7629 0000A4CD BE[47450100]        <1> 	mov	esi, Msg_YesNo
  7630 0000A4D2 E88ED0FFFF          <1> 	call	print_msg
  7631                              <1> 
  7632                              <1> loc_copy_ask_for_owr_again:
  7633 0000A4D7 30E4                <1> 	xor	ah, ah
  7634 0000A4D9 E80F6AFFFF          <1> 	call	int16h
  7635 0000A4DE 3C1B                <1> 	cmp	al, 1Bh
  7636                              <1>         ;je     loc_do_not_copy_file
  7637 0000A4E0 7419                <1>         je      short loc_copy_y_n_escape
  7638 0000A4E2 24DF                <1> 	and	al, 0DFh
  7639 0000A4E4 A2[51450100]        <1>         mov     [Y_N_nextline], al
  7640 0000A4E9 3C59                <1> 	cmp	al, 'Y'
  7641 0000A4EB 0F84B1000000        <1>         je      loc_yes_copy_file
  7642 0000A4F1 3C4E                <1> 	cmp	al, 'N'
  7643 0000A4F3 0F84A9000000        <1>         je      loc_do_not_copy_file
  7644 0000A4F9 EBDC                <1> 	jmp	short loc_copy_ask_for_owr_again
  7645                              <1> 
  7646                              <1> loc_copy_y_n_escape:
  7647 0000A4FB B04E                <1> 	mov	al, 'N' ; 'no'
  7648 0000A4FD E9A0000000          <1>         jmp     loc_do_not_copy_file
  7649                              <1> 
  7650                              <1> copy_source_file_to_destination_pass_owrq:
  7651 0000A502 A0[DC940100]        <1> 	mov     al, [SourceFile_Drv]
  7652 0000A507 0441                <1> 	add	al, 'A'
  7653 0000A509 A2[93460100]        <1> 	mov	[msg_source_file_drv], al
  7654 0000A50E A0[5C950100]        <1>         mov     al, [DestinationFile_Drv]
  7655 0000A513 0441                <1> 	add	al, 'A'
  7656 0000A515 A2[B2460100]        <1> 	mov	[msg_destination_file_drv], al
  7657                              <1> 
  7658 0000A51A BE[77460100]        <1> 	mov	esi, msg_source_file
  7659 0000A51F E841D0FFFF          <1> 	call	print_msg
  7660 0000A524 BE[DD940100]        <1> 	mov	esi, SourceFile_Directory
  7661 0000A529 803E20              <1> 	cmp	byte [esi], 20h
  7662 0000A52C 7605                <1> 	jna	short csftdfq_sfn
  7663 0000A52E E832D0FFFF          <1> 	call	print_msg
  7664                              <1> csftdfq_sfn:
  7665 0000A533 BE[1E950100]        <1> 	mov	esi, SourceFile_Name
  7666 0000A538 E828D0FFFF          <1> 	call	print_msg
  7667 0000A53D BE[96460100]        <1> 	mov	esi, msg_destination_file
  7668 0000A542 E81ED0FFFF          <1> 	call	print_msg
  7669 0000A547 BE[5D950100]        <1> 	mov	esi, DestinationFile_Directory
  7670 0000A54C 803E20              <1> 	cmp	byte [esi], 20h
  7671 0000A54F 7605                <1> 	jna	short csftdfq_dfn
  7672 0000A551 E80FD0FFFF          <1> 	call	print_msg
  7673                              <1> csftdfq_dfn:
  7674 0000A556 BE[9E950100]        <1> 	mov	esi, DestinationFile_Name
  7675 0000A55B E805D0FFFF          <1> 	call	print_msg
  7676 0000A560 BE[B5460100]        <1> 	mov	esi, msg_copy_nextline
  7677 0000A565 E8FBCFFFFF          <1> 	call	print_msg
  7678 0000A56A BE[B5460100]        <1> 	mov	esi, msg_copy_nextline
  7679 0000A56F E8F1CFFFFF          <1> 	call	print_msg
  7680                              <1> 
  7681                              <1> loc_copy_ask_for_new_file_yes_no:
  7682 0000A574 BE[D7460100]        <1> 	mov	esi, Msg_DoYouWantCopyFile
  7683 0000A579 E8E7CFFFFF          <1> 	call	print_msg
  7684 0000A57E BE[47450100]        <1> 	mov	esi, Msg_YesNo
  7685 0000A583 E8DDCFFFFF          <1> 	call	print_msg
  7686                              <1> 
  7687                              <1> loc_copy_ask_for_new_file_again:
  7688 0000A588 30E4                <1> 	xor	ah, ah
  7689 0000A58A E85E69FFFF          <1> 	call	int16h
  7690 0000A58F 3C1B                <1> 	cmp	al, 1Bh
  7691 0000A591 740F                <1> 	je	short loc_do_not_copy_file
  7692 0000A593 24DF                <1> 	and	al, 0DFh
  7693 0000A595 A2[51450100]        <1>         mov     [Y_N_nextline], al
  7694 0000A59A 3C59                <1> 	cmp	al, 'Y'
  7695 0000A59C 7404                <1> 	je	short loc_yes_copy_file
  7696 0000A59E 3C4E                <1> 	cmp	al, 'N'
  7697 0000A5A0 75E6                <1> 	jne	short loc_copy_ask_for_new_file_again
  7698                              <1> 
  7699                              <1> loc_do_not_copy_file:
  7700                              <1> loc_yes_copy_file:
  7701 0000A5A2 E851F4FFFF          <1> 	call	y_n_answer ; 29/12/2017
  7702 0000A5A7 5F                  <1> 	pop	edi ; *
  7703                              <1> 	;cmp	al, 'Y' ; 'yes'
  7704                              <1> 	;cmc
  7705                              <1>         ;jnc	loc_file_rw_restore_retn
  7706 0000A5A8 3C4E                <1> 	cmp	al, 'N' ; 'no'
  7707 0000A5AA 0F840FF3FFFF        <1>         je	loc_file_rw_restore_retn
  7708                              <1> 
  7709                              <1> copy_source_file_to_destination_pass_q:
  7710 0000A5B0 B002                <1> 	mov	al, 2  ; copy procedure Phase 2
  7711 0000A5B2 E80C1C0000          <1> 	call	copy_source_file_to_destination_file
  7712                              <1> 	;jc	short loc_file_write_check_disk_space_err
  7713                              <1> 
  7714                              <1> 	; 24/03/2016
  7715                              <1> 	;push	cx
  7716 0000A5B7 51                  <1> 	push	ecx ; 29/12/2017
  7717 0000A5B8 BE[B5460100]        <1> 	mov	esi, msg_copy_nextline
  7718 0000A5BD E8A3CFFFFF          <1> 	call	print_msg
  7719 0000A5C2 58                  <1> 	pop	eax ; 29/12/2017
  7720                              <1> 	;;pop	cx
  7721                              <1> 	;pop	ax
  7722                              <1> 
  7723                              <1> 	;or	cl, cl
  7724 0000A5C3 08C0                <1> 	or	al, al
  7725 0000A5C5 7419                <1> 	jz	short copy_source_file_to_destination_OK
  7726                              <1> 	
  7727                              <1> 	; 15/10/2016 (1Dh -> 18)
  7728                              <1> 	; 18/03/2016 (1Dh)
  7729                              <1> 	;cmp	cl, 18 ; write error
  7730 0000A5C7 3C12                <1> 	cmp	al, 18
  7731 0000A5C9 7506                <1> 	jne	short copy_source_file_to_destination_not_OK
  7732                              <1> 	;
  7733                              <1> 	;mov	al, cl ; error number (write fault!)
  7734 0000A5CB F9                  <1> 	stc
  7735 0000A5CC E9EEF2FFFF          <1> 	jmp	loc_file_rw_cmd_failed
  7736                              <1> 
  7737                              <1> copy_source_file_to_destination_not_OK:
  7738 0000A5D1 BE[F0460100]        <1> 	mov	esi, Msg_read_file_error_before_EOF
  7739 0000A5D6 E88ACFFFFF          <1> 	call	print_msg
  7740 0000A5DB E9DFF2FFFF          <1> 	jmp	loc_file_rw_restore_retn	      
  7741                              <1>  
  7742                              <1> copy_source_file_to_destination_OK:
  7743 0000A5E0 BE[55450100]        <1> 	mov	esi, Msg_OK
  7744 0000A5E5 E87BCFFFFF          <1> 	call	print_msg
  7745                              <1> 
  7746 0000A5EA E9D0F2FFFF          <1> 	jmp	loc_file_rw_restore_retn
  7747                              <1> 
  7748                              <1> ;loc_file_write_check_disk_space_err:
  7749                              <1> 	;cmp	al, 27h ; Insufficient disk space 
  7750                              <1> 	;je	loc_file_write_insuff_disk_space_msg
  7751                              <1>         ;jb	loc_file_rw_cmd_failed
  7752                              <1> 
  7753                              <1> 	;call	print_misc_error_msg ; 15/03/2016
  7754                              <1>         ;jmp	loc_file_rw_restore_retn 
  7755                              <1> 
  7756                              <1> change_fs_file_attributes:
  7757                              <1> 	; 04/03/2016 ; Temporary
  7758                              <1> 	; AL = File or directory attributes
  7759                              <1> 	; AH = 0 -> Attributes are in MS-DOS format
  7760                              <1> 	; AH > 0 -> Attributes are in SINGLIX format
  7761                              <1> 	;push	ebx
  7762                              <1> 	; ... do somethings here ...
  7763                              <1> 	;pop	ebx
  7764                              <1> 	; BL = File or directory attributes
  7765 0000A5EF C3                  <1> 	retn
  7766                              <1> 
  7767                              <1> set_get_env:
  7768                              <1> 	; 11/04/2016 (TRDOS 386 = TRDOS v2.0)
  7769                              <1> 	; 02/09/2011 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_set')
  7770                              <1> 	; 2005 - 28/08/2011 
  7771                              <1> get_setenv_fchar:
  7772                              <1> 	; esi = environment variable/string
  7773 0000A5F0 8A06                <1> 	mov	al, [esi]
  7774 0000A5F2 3C20                <1> 	cmp	al, 20h
  7775 0000A5F4 771E                <1> 	ja	short loc_find_env
  7776                              <1> 
  7777 0000A5F6 BE00300900          <1> 	mov	esi, Env_Page
  7778                              <1> loc_print_setline:
  7779 0000A5FB 803E00              <1> 	cmp	byte [esi], 0
  7780 0000A5FE 7613                <1> 	jna	short loc_setenv_retn
  7781 0000A600 E860CFFFFF          <1> 	call	print_msg
  7782 0000A605 56                  <1> 	push	esi
  7783 0000A606 BE[5F4D0100]        <1> 	mov	esi, nextline
  7784 0000A60B E855CFFFFF          <1> 	call	print_msg 
  7785 0000A610 5E                  <1> 	pop	esi
  7786 0000A611 EBE8                <1> 	jmp	short loc_print_setline   
  7787                              <1> 
  7788                              <1> loc_setenv_retn: 
  7789 0000A613 C3                  <1> 	retn
  7790                              <1> 
  7791                              <1> loc_find_env:
  7792 0000A614 3C3D                <1> 	cmp	al, '='
  7793 0000A616 0F8465E9FFFF        <1> 	je	loc_cmd_failed
  7794                              <1> 
  7795 0000A61C 56                  <1> 	push	esi
  7796                              <1> loc_repeat_env_equal_check:
  7797 0000A61D 46                  <1> 	inc	esi
  7798 0000A61E 803E3D              <1> 	cmp	byte [esi], '='
  7799 0000A621 7431                <1> 	je	short pass_env_equal_check
  7800 0000A623 803E20              <1> 	cmp	byte [esi], 20h
  7801 0000A626 73F5                <1> 	jnb	short loc_repeat_env_equal_check
  7802 0000A628 C60600              <1> 	mov	byte [esi], 0 
  7803 0000A62B 5E                  <1> 	pop	esi
  7804 0000A62C BF[F68B0100]        <1> 	mov	edi, TextBuffer ; out buffer
  7805 0000A631 B9FF000000          <1> 	mov	ecx, 255 ; maximum size (limit)
  7806 0000A636 30C0                <1> 	xor	al, al ; 0 -> use [ESI]
  7807 0000A638 E89E000000          <1> 	call	get_environment_string
  7808 0000A63D 72D4                <1> 	jc	short loc_setenv_retn
  7809                              <1> 
  7810 0000A63F BE[F68B0100]        <1> 	mov	esi, TextBuffer
  7811 0000A644 E81CCFFFFF          <1> 	call	print_msg
  7812 0000A649 BE[5F4D0100]        <1> 	mov	esi, nextline
  7813 0000A64E E812CFFFFF          <1> 	call	print_msg
  7814                              <1> 
  7815 0000A653 C3                  <1> 	retn 
  7816                              <1>               
  7817                              <1> pass_env_equal_check:
  7818 0000A654 46                  <1> 	inc	esi
  7819 0000A655 803E20              <1> 	cmp	byte [esi], 20h
  7820 0000A658 73FA                <1> 	jnb	short pass_env_equal_check
  7821 0000A65A C60600              <1> 	mov	byte [esi], 0	
  7822                              <1> 
  7823                              <1> loc_call_set_env_string:
  7824 0000A65D 5E                  <1> 	pop	esi
  7825 0000A65E E83B010000          <1> 	call	set_environment_string
  7826 0000A663 73AE                <1> 	jnc	short loc_setenv_retn
  7827                              <1> 
  7828                              <1> loc_set_cmd_failed:
  7829 0000A665 3C08                <1> 	cmp	al, 08h
  7830 0000A667 0F8514E9FFFF        <1> 	jne	loc_cmd_failed
  7831                              <1> 
  7832 0000A66D BE[30470100]        <1> 	mov	esi, Msg_No_Set_Space
  7833 0000A672 E8EECEFFFF          <1> 	call	print_msg
  7834                              <1> 
  7835 0000A677 C3                  <1> 	retn
  7836                              <1> 
  7837                              <1> set_get_path:
  7838                              <1> 	; 11/04/2016 (TRDOS 386 = TRDOS v2.0)
  7839                              <1> 	; 03/09/2011 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_path')
  7840                              <1> 	; 2005
  7841                              <1> get_path_fchar:
  7842                              <1>  	; esi = path
  7843 0000A678 803E20              <1> 	cmp	byte [esi], 20h
  7844 0000A67B 7737                <1> 	ja	short loc_set_path
  7845                              <1> 
  7846 0000A67D BE00300900          <1> 	mov	esi, Env_Page
  7847                              <1> loc_print_path:
  7848 0000A682 803E00              <1> 	cmp	byte [esi], 0
  7849 0000A685 762C                <1> 	jna	short loc_path_retn
  7850                              <1> 
  7851 0000A687 BE[8F410100]        <1> 	mov	esi, Cmd_Path ; 'PATH' address
  7852 0000A68C BF[F68B0100]        <1> 	mov	edi, TextBuffer ; out buffer
  7853 0000A691 30C0                <1> 	xor	al, al  ; use [ESI]
  7854 0000A693 B9FF000000          <1> 	mov	ecx, 255 ; maximum size (limit)
  7855 0000A698 E83E000000          <1> 	call	get_environment_string
  7856 0000A69D 7214                <1> 	jc	short loc_path_retn
  7857                              <1> 
  7858 0000A69F BE[F68B0100]        <1> 	mov	esi, TextBuffer
  7859 0000A6A4 E8BCCEFFFF          <1> 	call	print_msg
  7860 0000A6A9 BE[5F4D0100]        <1> 	mov	esi, nextline
  7861 0000A6AE E8B2CEFFFF          <1> 	call	print_msg   
  7862                              <1> 
  7863                              <1> loc_path_retn: 
  7864 0000A6B3 C3                  <1> 	retn
  7865                              <1> 
  7866                              <1> loc_set_path:
  7867 0000A6B4 56                  <1> 	push	esi 
  7868                              <1> loc_set_path_find_end:
  7869 0000A6B5 46                  <1> 	inc	esi
  7870 0000A6B6 803E20              <1> 	cmp	byte [esi], 20h
  7871 0000A6B9 73FA                <1> 	jnb	short loc_set_path_find_end
  7872 0000A6BB C60600              <1> 	mov	byte [esi], 0 
  7873                              <1> loc_set_path_header: 
  7874 0000A6BE 5E                  <1> 	pop	esi
  7875                              <1> set_path_x: ; 31/12/2017 ('syspath')	  
  7876 0000A6BF 4E                  <1> 	dec	esi
  7877 0000A6C0 C6063D              <1> 	mov	byte [esi], '='
  7878 0000A6C3 4E                  <1> 	dec	esi
  7879 0000A6C4 C60648              <1> 	mov	byte [esi], 'H'
  7880 0000A6C7 4E                  <1> 	dec	esi
  7881 0000A6C8 C60654              <1> 	mov	byte [esi], 'T'
  7882 0000A6CB 4E                  <1> 	dec	esi
  7883 0000A6CC C60641              <1> 	mov	byte [esi], 'A'
  7884 0000A6CF 4E                  <1> 	dec	esi
  7885 0000A6D0 C60650              <1> 	mov	byte [esi], 'P'   
  7886                              <1> 
  7887                              <1> loc_path_call_set_env_string:
  7888 0000A6D3 E8C6000000          <1> 	call	set_environment_string
  7889 0000A6D8 728B                <1>         jc	short loc_set_cmd_failed
  7890                              <1> 
  7891 0000A6DA C3                  <1> 	retn              
  7892                              <1> 
  7893                              <1> get_environment_string:
  7894                              <1> 	; 12/04/2016
  7895                              <1> 	; 11/04/2016
  7896                              <1> 	; 05/04/2016 (TRDOS 386 = TRDOS v2.0)
  7897                              <1> 	; 02/09/2011 (TRDOS v1, MAINPROG.ASM)
  7898                              <1> 	; 28/08/2011
  7899                              <1> 	; INPUT->
  7900                              <1> 	;	EDI = Output buffer
  7901                              <1> 	;	CX = Buffer length (<= ENV_PAGE_SIZE)
  7902                              <1> 	;
  7903                              <1> 	;	AL > 0 = AL = String sequence number
  7904                              <1> 	;	AL = 0 -> ESI = ASCIIZ Set word 
  7905                              <1> 	;		(environment variable)
  7906                              <1> 	; OUTPUT ->
  7907                              <1> 	;	ESI is not changed
  7908                              <1> 	;	EDI is not changed
  7909                              <1> 	;	EAX = String length (with zero tail)
  7910                              <1> 	;	EDX = Environment variables page address
  7911                              <1> 	;	CF = 1 -> Not found (EAX not valid)
  7912                              <1> 	;
  7913                              <1> 	; (Modified registers: EAX, EDX) 
  7914                              <1> 
  7915 0000A6DB BA00300900          <1> 	mov	edx, Env_Page
  7916 0000A6E0 803A00              <1> 	cmp	byte [edx], 0
  7917 0000A6E3 7474                <1> 	jz	short get_env_string_with_word_stc_retn
  7918                              <1> 
  7919 0000A6E5 66890D[60960100]    <1> 	mov	[env_var_length], cx
  7920                              <1> 
  7921 0000A6EC 51                  <1> 	push	ecx ; *
  7922 0000A6ED 56                  <1> 	push	esi ; **
  7923                              <1> 
  7924 0000A6EE 08C0                <1> 	or	al, al
  7925 0000A6F0 7449                <1> 	jz	short get_env_string_with_word
  7926                              <1> 
  7927                              <1> get_env_string_with_seq_number:
  7928 0000A6F2 B101                <1> 	mov	cl, 1
  7929 0000A6F4 88C5                <1> 	mov	ch, al
  7930 0000A6F6 31C0                <1> 	xor	eax, eax
  7931 0000A6F8 89D6                <1> 	mov	esi, edx ; Env_Page
  7932                              <1> 
  7933                              <1> get_env_string_seq_number_check:
  7934 0000A6FA 38CD                <1> 	cmp	ch, cl
  7935 0000A6FC 7726                <1> 	ja	short get_env_string_seq_number_next
  7936                              <1> 
  7937                              <1> get_env_string_move_to_buff:
  7938 0000A6FE 57                  <1> 	push	edi ; ***
  7939                              <1> 
  7940 0000A6FF 29D2                <1> 	sub	edx, edx
  7941                              <1> 
  7942                              <1> get_env_string_seq_number_repeat1:
  7943 0000A701 42                  <1> 	inc	edx
  7944 0000A702 AC                  <1> 	lodsb
  7945 0000A703 AA                  <1> 	stosb
  7946                              <1> 
  7947 0000A704 66FF0D[60960100]    <1> 	dec	word [env_var_length]
  7948 0000A70B 7508                <1> 	jnz	short get_env_string_seq_number_repeat3
  7949                              <1> 
  7950                              <1> get_env_string_seq_number_repeat2:
  7951 0000A70D 20C0                <1> 	and	al, al
  7952 0000A70F 7408                <1> 	jz	short get_env_string_seq_number_ok
  7953 0000A711 42                  <1> 	inc	edx
  7954 0000A712 AC                  <1> 	lodsb
  7955 0000A713 EBF8                <1> 	jmp	short get_env_string_seq_number_repeat2
  7956                              <1> 
  7957                              <1> get_env_string_seq_number_repeat3:
  7958 0000A715 08C0                <1> 	or	al, al
  7959 0000A717 75E8                <1> 	jnz	short get_env_string_seq_number_repeat1
  7960                              <1> 
  7961                              <1> get_env_string_seq_number_ok:
  7962 0000A719 5F                  <1> 	pop	edi ; ***
  7963 0000A71A 89D0                <1> 	mov	eax, edx ; Length of the environment string
  7964                              <1> 			 ; (ASCIIZ, includes ZERO tail)
  7965 0000A71C BA00300900          <1> 	mov	edx, Env_Page
  7966                              <1> 
  7967                              <1> get_env_string_stc_retn:
  7968 0000A721 5E                  <1> 	pop	esi ; **
  7969 0000A722 59                  <1> 	pop	ecx ; *
  7970 0000A723 C3                  <1> 	retn   
  7971                              <1> 	
  7972                              <1> get_env_string_seq_number_next:
  7973 0000A724 AC                  <1> 	lodsb
  7974 0000A725 08C0                <1> 	or	al, al
  7975 0000A727 75FB                <1> 	jnz	short get_env_string_seq_number_next
  7976                              <1> 
  7977 0000A729 81FE00320900        <1> 	cmp	esi, Env_Page + Env_Page_Size ; +512 (+4096)
  7978 0000A72F F5                  <1> 	cmc
  7979 0000A730 72EF                <1> 	jc	short get_env_string_stc_retn
  7980                              <1> 
  7981 0000A732 AC                  <1> 	lodsb
  7982 0000A733 3C01                <1> 	cmp	al, 1
  7983 0000A735 72EA                <1> 	jb	short get_env_string_stc_retn
  7984 0000A737 FEC1                <1> 	inc	cl
  7985 0000A739 EBBF                <1> 	jmp	short get_env_string_seq_number_check
  7986                              <1> 
  7987                              <1> get_env_string_with_word:
  7988 0000A73B 31C9                <1> 	xor	ecx, ecx
  7989                              <1> 
  7990                              <1> get_env_string_calc_word_length:
  7991 0000A73D AC                  <1> 	lodsb 
  7992 0000A73E 3C20                <1> 	cmp	al, 20h
  7993 0000A740 7211                <1> 	jb	short get_env_string_calc_word_length_ok
  7994                              <1> 	;inc	cx
  7995 0000A742 FEC1                <1> 	inc	cl
  7996                              <1> 
  7997 0000A744 3C61                <1> 	cmp	al, 'a'
  7998 0000A746 72F5                <1> 	jb	short get_env_string_calc_word_length
  7999 0000A748 3C7A                <1> 	cmp	al, 'z'
  8000 0000A74A 77F1                <1> 	ja	short get_env_string_calc_word_length
  8001 0000A74C 24DF                <1> 	and	al, 0DFh
  8002 0000A74E 8846FF              <1> 	mov	[esi-1], al
  8003 0000A751 EBEA                <1> 	jmp	short get_env_string_calc_word_length
  8004                              <1> 	
  8005                              <1> get_env_string_calc_word_length_ok:
  8006 0000A753 08C9                <1> 	or	cl, cl
  8007 0000A755 7506                <1> 	jnz	short get_env_string_calc_word_length_save
  8008                              <1>      
  8009 0000A757 5E                  <1> 	pop	esi ; **
  8010                              <1> 
  8011                              <1> get_env_string_stc_retn1:
  8012 0000A758 59                  <1> 	pop	ecx ; *
  8013                              <1>         
  8014                              <1> get_env_string_with_word_stc_retn:
  8015 0000A759 31C0                <1> 	xor	eax, eax  
  8016 0000A75B F9                  <1> 	stc
  8017 0000A75C C3                  <1> 	retn
  8018                              <1>   
  8019                              <1> get_env_string_calc_word_length_save:
  8020 0000A75D 871C24              <1> 	xchg	ebx, [esp] ; **
  8021 0000A760 89DE                <1> 	mov	esi, ebx 
  8022                              <1> 		; Start of the env string (to be searched)
  8023                              <1> 
  8024 0000A762 57                  <1> 	push	edi ; ***
  8025 0000A763 89D7                <1> 	mov	edi, edx ; Env_Page
  8026                              <1> 
  8027                              <1> get_env_string_compare:
  8028 0000A765 57                  <1> 	push	edi ; ****
  8029 0000A766 51                  <1> 	push	ecx ; ***** ; Variable name length
  8030                              <1> 
  8031                              <1> get_env_string_compare_rep:
  8032 0000A767 AC                  <1> 	lodsb
  8033 0000A768 AE                  <1> 	scasb
  8034 0000A769 7511                <1> 	jne	short get_env_string_compare_next1
  8035 0000A76B E2FA                <1> 	loop	get_env_string_compare_rep
  8036                              <1> 	
  8037 0000A76D 803F3D              <1> 	cmp	byte [edi], '='
  8038 0000A770 750A                <1> 	jne	short get_env_string_compare_next1
  8039                              <1>  
  8040 0000A772 59                  <1> 	pop	ecx ; *****
  8041 0000A773 5F                  <1> 	pop	edi ; ****
  8042 0000A774 89FE                <1> 	mov	esi, edi
  8043 0000A776 5F                  <1> 	pop	edi ; ***
  8044 0000A777 871C24              <1> 	xchg	ebx, [esp] ; **
  8045 0000A77A EB82                <1> 	jmp	short get_env_string_move_to_buff
  8046                              <1> 
  8047                              <1> get_env_string_compare_next1:
  8048 0000A77C 89FE                <1> 	mov	esi, edi
  8049 0000A77E 59                  <1> 	pop	ecx ; *****
  8050 0000A77F 5F                  <1> 	pop	edi ; ****
  8051                              <1> get_env_string_compare_next2:
  8052 0000A780 81FEFF310900        <1> 	cmp	esi, Env_Page + Env_Page_Size - 1 ; +511 (+4095)
  8053 0000A786 7310                <1> 	jnb	short get_env_string_compare_not_ok
  8054 0000A788 20C0                <1> 	and	al, al
  8055 0000A78A AC                  <1> 	lodsb
  8056 0000A78B 75F3                <1> 	jnz	short get_env_string_compare_next2
  8057 0000A78D 08C0                <1> 	or	al, al
  8058 0000A78F 7407                <1> 	jz	short get_env_string_compare_not_ok
  8059 0000A791 4E                  <1> 	dec	esi ; 12/04/2016
  8060 0000A792 89F7                <1> 	mov	edi, esi
  8061 0000A794 89DE                <1> 	mov	esi, ebx
  8062 0000A796 EBCD                <1> 	jmp	short get_env_string_compare
  8063                              <1> 
  8064                              <1> get_env_string_compare_not_ok:
  8065 0000A798 5F                  <1> 	pop	edi ; ***
  8066 0000A799 89DE                <1> 	mov	esi, ebx
  8067 0000A79B 5B                  <1> 	pop	ebx ; **
  8068 0000A79C EBBA                <1> 	jmp	short get_env_string_stc_retn1
  8069                              <1> 
  8070                              <1> set_environment_string:
  8071                              <1> 	; 13/04/2016
  8072                              <1> 	; 12/04/2016
  8073                              <1> 	; 11/04/2016
  8074                              <1> 	; 06/04/2016
  8075                              <1> 	; 05/04/2016 (TRDOS 386 = TRDOS v2.0)
  8076                              <1> 	; 02/09/2011 (TRDOS v1, MAINPROG.ASM)
  8077                              <1> 	; 29/08/2011
  8078                              <1> 	; 29/08/2011
  8079                              <1> 	; INPUT->
  8080                              <1> 	;	ESI = ASCIIZ environment string
  8081                              <1> 	; OUTPUT ->
  8082                              <1> 	;	ESI is not changed
  8083                              <1> 	;	CF = 1 -> Could not set, 
  8084                              <1> 	;	     insufficient environment space
  8085                              <1> 	;
  8086                              <1> 	; (EAX, EDX will be changed) 
  8087                              <1> 	;
  8088                              <1> 	;    (EAX = Start address of the env string if > 0)	
  8089                              <1> 	;    (EDX = Environment string length)	
  8090                              <1> 
  8091 0000A79E 56                  <1> 	push 	esi ; *
  8092                              <1> 
  8093 0000A79F 31C0                <1> 	xor	eax, eax
  8094                              <1> 
  8095                              <1> set_env_chk_validation1:
  8096 0000A7A1 FEC4                <1> 	inc	ah ; variable (string) length
  8097 0000A7A3 AC                  <1> 	lodsb
  8098 0000A7A4 3C3D                <1> 	cmp	al, '='
  8099 0000A7A6 7415                <1> 	je	short set_env_chk_validation2
  8100 0000A7A8 3C20                <1> 	cmp	al, 20h
  8101 0000A7AA 720F                <1> 	jb	short set_env_string_stc
  8102                              <1> 
  8103                              <1> 	; 06/04/2016
  8104 0000A7AC 3C61                <1> 	cmp	al, 'a'
  8105 0000A7AE 72F1                <1> 	jb	short set_env_chk_validation1
  8106 0000A7B0 3C7A                <1> 	cmp	al, 'z'
  8107 0000A7B2 77ED                <1> 	ja	short set_env_chk_validation1
  8108 0000A7B4 2C20                <1> 	sub	al, 'a'-'A'
  8109 0000A7B6 8846FF              <1> 	mov	[esi-1], al
  8110 0000A7B9 EBE6                <1> 	jmp	short set_env_chk_validation1
  8111                              <1> 
  8112                              <1> set_env_string_stc:
  8113 0000A7BB 5E                  <1> 	pop	esi ; *
  8114                              <1> 	;stc
  8115 0000A7BC C3                  <1> 	retn 
  8116                              <1> 	   
  8117                              <1> set_env_chk_validation2:
  8118 0000A7BD 51                  <1> 	push	ecx ; **
  8119 0000A7BE 53                  <1> 	push	ebx ; *** 
  8120 0000A7BF 57                  <1> 	push	edi ; ****
  8121                              <1> 
  8122                              <1> 	; 12/04/2016
  8123 0000A7C0 8B5C240C            <1> 	mov	ebx, [esp+12]
  8124                              <1> 
  8125                              <1> set_env_chk_validation2w:
  8126 0000A7C4 89F7                <1> 	mov	edi, esi
  8127 0000A7C6 4F                  <1> 	dec	edi
  8128                              <1> 
  8129 0000A7C7 807FFF20            <1> 	cmp	byte [edi-1], 20h
  8130 0000A7CB 771A                <1> 	ja	short set_env_chk_validation2z
  8131                              <1> 	
  8132 0000A7CD 56                  <1> 	push	esi
  8133 0000A7CE 89FE                <1> 	mov	esi, edi
  8134 0000A7D0 4E                  <1> 	dec	esi
  8135                              <1> 
  8136                              <1> set_env_chk_validation2x:
  8137 0000A7D1 4E                  <1> 	dec	esi
  8138                              <1> 
  8139 0000A7D2 39DE                <1> 	cmp	esi, ebx
  8140 0000A7D4 7207                <1> 	jb	short set_env_chk_validation2y
  8141                              <1> 
  8142 0000A7D6 4F                  <1> 	dec	edi
  8143                              <1> 
  8144 0000A7D7 8A06                <1> 	mov	al, [esi]
  8145 0000A7D9 8807                <1> 	mov	[edi], al
  8146                              <1> 
  8147 0000A7DB EBF4                <1> 	jmp	short set_env_chk_validation2x
  8148                              <1> 
  8149                              <1> set_env_chk_validation2y:
  8150 0000A7DD 5E                  <1> 	pop	esi
  8151                              <1> 
  8152                              <1> 	;mov	byte [ebx], 20h
  8153                              <1> 	
  8154 0000A7DE 43                  <1> 	inc 	ebx
  8155 0000A7DF 895C240C            <1> 	mov	[esp+12], ebx
  8156                              <1> 
  8157 0000A7E3 FECC                <1> 	dec 	ah ; 13/04/2016
  8158                              <1> 
  8159 0000A7E5 EBDD                <1> 	jmp	short set_env_chk_validation2w
  8160                              <1> 	
  8161                              <1> set_env_chk_validation2z:	
  8162 0000A7E7 BA00300900          <1> 	mov	edx, Env_Page
  8163 0000A7EC 89D7                <1> 	mov	edi, edx
  8164                              <1> 
  8165                              <1> set_env_chk_validation3:
  8166 0000A7EE AC                  <1> 	lodsb
  8167 0000A7EF 3C20                <1> 	cmp	al, 20h
  8168 0000A7F1 74FB                <1> 	je	short set_env_chk_validation3
  8169                              <1> 
  8170 0000A7F3 9C                  <1> 	pushf
  8171                              <1> 
  8172                              <1> 	; 12/04/2016
  8173                              <1> set_env_chk_validation3n:
  8174 0000A7F4 3C61                <1> 	cmp	al, 'a'
  8175 0000A7F6 720C                <1> 	jb	short set_env_chk_validation3c
  8176 0000A7F8 3C7A                <1> 	cmp	al, 'z'
  8177 0000A7FA 7705                <1> 	ja	short set_env_chk_validation3x
  8178 0000A7FC 2C20                <1> 	sub	al, 'a'-'A'
  8179 0000A7FE 8846FF              <1> 	mov	[esi-1], al
  8180                              <1> 
  8181                              <1> set_env_chk_validation3x:
  8182 0000A801 AC                  <1> 	lodsb
  8183 0000A802 EBF0                <1> 	jmp	short set_env_chk_validation3n
  8184                              <1> 
  8185                              <1> set_env_chk_validation3c:
  8186 0000A804 3C20                <1> 	cmp	al, 20h
  8187 0000A806 73F9                <1> 	jnb	short set_env_chk_validation3x
  8188                              <1> 		
  8189 0000A808 803F00              <1> 	cmp	byte [edi], 0
  8190 0000A80B 7731                <1> 	ja	short set_env_chk_validation4
  8191                              <1> 
  8192 0000A80D 9D                  <1> 	popf
  8193 0000A80E 7228                <1> 	jb	short set_env_string_nothing
  8194                              <1> 
  8195 0000A810 B900020000          <1> 	mov	ecx, Env_Page_Size ; 512 (4096)
  8196                              <1> 
  8197 0000A815 89DE                <1> 	mov	esi, ebx ; 12/04/2016
  8198                              <1> 
  8199                              <1> set_env_string_copy_to_envb:
  8200 0000A817 AC                  <1> 	lodsb
  8201 0000A818 3C20                <1> 	cmp	al, 20h
  8202 0000A81A 720A                <1> 	jb	short set_env_string_copy_to_envb_z
  8203 0000A81C AA                  <1> 	stosb
  8204 0000A81D E2F8                <1> 	loop	set_env_string_copy_to_envb
  8205                              <1> 
  8206                              <1> 	; 11/04/2016
  8207 0000A81F 89D7                <1> 	mov	edi, edx ; Env_Page
  8208 0000A821 B900020000          <1> 	mov	ecx, Env_Page_Size 
  8209                              <1> 
  8210                              <1> set_env_string_copy_to_envb_z:
  8211 0000A826 52                  <1> 	push	edx  ; Start address of the variable
  8212 0000A827 BA00020000          <1> 	mov	edx, Env_Page_Size
  8213 0000A82C 29CA                <1> 	sub	edx, ecx ; variable (string) length
  8214                              <1> 
  8215 0000A82E 28C0                <1> 	sub	al, al ; 0
  8216 0000A830 F3AA                <1>  	rep	stosb ; clear remain bytes of the env page
  8217                              <1> 
  8218 0000A832 58                  <1> 	pop	eax  ; Start address of the variable
  8219                              <1> 
  8220                              <1> set_env_string_allocate_envb_retn:  ; stc or clc return
  8221 0000A833 5F                  <1> 	pop	edi ; ****
  8222 0000A834 5B                  <1> 	pop	ebx ; ***
  8223 0000A835 59                  <1> 	pop	ecx ; **
  8224 0000A836 5E                  <1> 	pop	esi ; *	
  8225 0000A837 C3                  <1> 	retn
  8226                              <1> 
  8227                              <1> set_env_string_nothing:
  8228 0000A838 31C0                <1> 	xor	eax, eax
  8229 0000A83A 31D2                <1> 	xor	edx, edx ; 11/04/2016
  8230 0000A83C EBF5                <1> 	jmp	short set_env_string_allocate_envb_retn
  8231                              <1> 
  8232                              <1> set_env_chk_validation4:
  8233                              <1> 	; 11/04/2016
  8234 0000A83E 9D                  <1> 	popf
  8235                              <1> 
  8236 0000A83F 89D6                <1> 	mov	esi, edx  ; Env_Page
  8237                              <1> 
  8238                              <1> set_env_chk_validation5:	
  8239 0000A841 89DF                <1> 	mov	edi, ebx  ; ASCIIZ environment string address	
  8240 0000A843 0FB6CC              <1> 	movzx	ecx, ah ; Variable (string) length (with '=')
  8241                              <1> 
  8242                              <1> set_env_chk_validation5_loop:
  8243 0000A846 AC                  <1> 	lodsb
  8244 0000A847 AE                  <1> 	scasb
  8245 0000A848 750A                <1> 	jne	short set_env_chk_validation6
  8246 0000A84A E2FA                <1> 	loop	set_env_chk_validation5_loop
  8247                              <1> 
  8248 0000A84C 3C3D                <1> 	cmp	al, '='
  8249 0000A84E 0F8483000000        <1>         je      set_env_change_variable
  8250                              <1> 
  8251                              <1> set_env_chk_validation6:
  8252 0000A854 08C0                <1> 	or	al, al ; 0
  8253 0000A856 7403                <1> 	jz	short set_env_chk_validation7
  8254                              <1> 
  8255 0000A858 AC                  <1> 	lodsb
  8256 0000A859 EBF9                <1> 	jmp	short set_env_chk_validation6
  8257                              <1> 
  8258                              <1> set_env_chk_validation7:
  8259 0000A85B 88E1                <1> 	mov	cl, ah
  8260 0000A85D 01F1                <1> 	add	ecx, esi
  8261 0000A85F 81F9FF310900        <1> 	cmp	ecx, Env_Page + Env_Page_Size - 1 
  8262                              <1> 		; 511 (4095) 
  8263                              <1> 		; strlen + '=' + 0
  8264 0000A865 72DA                <1> 	jb	short set_env_chk_validation5
  8265                              <1> 
  8266                              <1> set_env_chk_validation8: ; variable not found
  8267 0000A867 0FB6F4              <1> 	movzx	esi, ah  ; variable name length (with '=') 
  8268 0000A86A 01DE                <1> 	add	esi, ebx ; position just after of the '='
  8269                              <1> 
  8270                              <1> set_env_chk_validation8_loop:
  8271 0000A86C AC                  <1> 	lodsb
  8272 0000A86D 3C20                <1> 	cmp	al, 20h
  8273 0000A86F 74FB                <1> 	je	short set_env_chk_validation8_loop	
  8274 0000A871 72C5                <1> 	jb	short set_env_string_nothing
  8275                              <1> 
  8276                              <1> set_env_chk_validation9:
  8277 0000A873 AC                  <1> 	lodsb
  8278 0000A874 3C20                <1> 	cmp	al, 20h
  8279 0000A876 73FB                <1> 	jnb	short set_env_chk_validation9
  8280                              <1> 
  8281                              <1> 	; End of ASCIIZ environment string
  8282                              <1> 
  8283                              <1> set_env_add_variable:
  8284 0000A878 29DE                <1> 	sub	esi, ebx ; variable+definition length
  8285                              <1> 	
  8286 0000A87A 56                  <1> 	push	esi ; *****
  8287                              <1> 
  8288 0000A87B 89D6                <1> 	mov	esi, edx ; Environment page address
  8289                              <1> 
  8290 0000A87D B900020000          <1> 	mov	ecx, Env_Page_Size ; 512 (4096)	
  8291                              <1> 
  8292                              <1> set_env_add_variable_loop:
  8293 0000A882 AC                  <1> 	lodsb
  8294 0000A883 20C0                <1> 	and	al, al		
  8295 0000A885 7406                <1> 	jz	short set_env_add_variable_chk1 ; 0
  8296 0000A887 E2F9                <1> 	loop	set_env_add_variable_loop
  8297                              <1> 
  8298                              <1> 	; 11/04/2016
  8299 0000A889 884EFF              <1> 	mov	[esi-1], cl ; 0
  8300 0000A88C 41                  <1> 	inc	ecx
  8301                              <1> 	
  8302                              <1> set_env_add_variable_chk1: 
  8303 0000A88D 49                  <1> 	dec	ecx
  8304 0000A88E 7408                <1> 	jz	short set_env_add_variable_nspc
  8305 0000A890 AC                  <1> 	lodsb
  8306 0000A891 08C0                <1> 	or 	al, al
  8307 0000A893 740C                <1> 	jz	short set_env_add_variable_chk2 ; 00
  8308 0000A895 49                  <1> 	dec	ecx
  8309 0000A896 75EA                <1> 	jnz	short set_env_add_variable_loop
  8310                              <1> 
  8311                              <1> set_env_add_variable_nspc: ; no space on environment page
  8312 0000A898 58                  <1> 	pop	eax ; *****
  8313 0000A899 B808000000          <1> 	mov	eax, 8 ; No space for new environment string
  8314 0000A89E F9                  <1> 	stc
  8315 0000A89F EB92                <1>         jmp     short set_env_string_allocate_envb_retn
  8316                              <1> 
  8317                              <1> set_env_add_variable_chk2:
  8318 0000A8A1 8B0C24              <1> 	mov	ecx, [esp] ; *****
  8319 0000A8A4 4E                  <1> 	dec	esi ; beginning address of the new variable
  8320 0000A8A5 89F0                <1> 	mov	eax, esi
  8321 0000A8A7 01C8                <1> 	add	eax, ecx ; string length (with CR)
  8322 0000A8A9 81C200020000        <1> 	add	edx, Env_Page_Size ; 512 (4096)
  8323 0000A8AF 39D0                <1> 	cmp	eax, edx 
  8324 0000A8B1 77E5                <1> 	ja	short set_env_add_variable_nspc
  8325 0000A8B3 49                  <1> 	dec	ecx ; except CR at the end
  8326 0000A8B4 89CA                <1> 	mov	edx, ecx ; 12/04/2016
  8327 0000A8B6 89F7                <1> 	mov	edi, esi
  8328 0000A8B8 893C24              <1> 	mov	[esp], edi ; ***** ; Start address of new variable
  8329 0000A8BB 89DE                <1> 	mov	esi, ebx ; ASCIIZ environment string address
  8330 0000A8BD F3A4                <1> 	rep	movsb
  8331 0000A8BF 28C0                <1> 	sub	al, al
  8332 0000A8C1 AA                  <1> 	stosb
  8333 0000A8C2 58                  <1> 	pop	eax ; ***** ; Beginning address of new variable			
  8334 0000A8C3 81FF00320900        <1>         cmp     edi, Env_Page + Env_Page_Size ; 12/04/2016
  8335 0000A8C9 0F8364FFFFFF        <1>         jnb     set_env_string_allocate_envb_retn ; OK !
  8336 0000A8CF 880F                <1> 	mov	[edi], cl ; 0
  8337 0000A8D1 F8                  <1> 	clc	; 13/04/2016
  8338 0000A8D2 E95CFFFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
  8339                              <1> 
  8340                              <1> set_env_change_variable:
  8341                              <1> 	; 06/04/2016
  8342                              <1> 	; esi = Variable's address in environment page (after '=')
  8343                              <1> 	; edi = ASCIIZ environment string address (after '=')
  8344                              <1> 
  8345                              <1> 	; ah = variable length from start to the '='
  8346 0000A8D7 8825[60960100]      <1> 	mov	[env_var_length], ah
  8347                              <1> 
  8348 0000A8DD 28C9                <1> 	sub	cl, cl ; ecx = 0
  8349                              <1> 
  8350 0000A8DF 57                  <1> 	push	edi ; *****
  8351                              <1> 
  8352 0000A8E0 89F7                <1> 	mov	edi, esi ; 11/04/2016
  8353                              <1> 
  8354                              <1> set_env_change_variable_calc1:
  8355 0000A8E2 AC                  <1> 	lodsb
  8356 0000A8E3 08C0                <1> 	or	al, al
  8357 0000A8E5 7403                <1> 	jz	short set_env_change_variable_calc2
  8358                              <1> 
  8359 0000A8E7 41                  <1> 	inc	ecx ; length of environment string (after the '=')
  8360                              <1> 
  8361 0000A8E8 EBF8                <1> 	jmp	short set_env_change_variable_calc1	
  8362                              <1> 
  8363                              <1> set_env_change_variable_calc2:
  8364 0000A8EA 8B3424              <1> 	mov	esi, [esp] ; ASCIIZ environment string address
  8365                              <1> 	
  8366 0000A8ED 29D2                <1> 	sub	edx, edx
  8367                              <1> 
  8368                              <1> set_env_change_variable_calc3:
  8369 0000A8EF AC                  <1> 	lodsb
  8370 0000A8F0 3C20                <1> 	cmp	al, 20h
  8371 0000A8F2 7203                <1> 	jb	short set_env_change_variable_calc4
  8372                              <1> 
  8373 0000A8F4 42                  <1> 	inc	edx ; length of ASCIIZ string (after the '=')
  8374                              <1> 	
  8375 0000A8F5 EBF8                <1> 	jmp	short set_env_change_variable_calc3
  8376                              <1> 	
  8377                              <1> set_env_change_variable_calc4:
  8378 0000A8F7 C646FF00            <1> 	mov	byte [esi-1], 0  ; put ZERO instead of CR
  8379                              <1> 	
  8380 0000A8FB 5E                  <1> 	pop	esi ; ***** ; ASCIIZ string address (after '=')
  8381                              <1> 
  8382                              <1> 	; EDI = Old variable's address (after '=')
  8383                              <1> 	
  8384                              <1> 	; compare the new string with the old string
  8385 0000A8FC 39CA                <1> 	cmp	edx, ecx
  8386 0000A8FE 7717                <1> 	ja	short set_env_change_variable_calc5 ; longer
  8387 0000A900 0F828F000000        <1>         jb      set_env_change_variable_calc9 ; shorter
  8388                              <1> 	
  8389                              <1> 	;same length (simple copy)
  8390 0000A906 0FB6C4              <1> 	movzx	eax, ah
  8391 0000A909 01C2                <1> 	add	edx, eax
  8392 0000A90B F7D8                <1> 	neg	eax
  8393 0000A90D 01F8                <1> 	add	eax, edi
  8394                              <1> 	; EAX = Start address of the variable
  8395                              <1> 	; EDX = Variable length (without ZERO at the end of variable)
  8396                              <1> 
  8397 0000A90F F3A4                <1> 	rep	movsb
  8398 0000A911 F8                  <1> 	clc	; 13/04/2016
  8399 0000A912 E91CFFFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
  8400                              <1> 
  8401                              <1> set_env_change_variable_calc5:
  8402                              <1> 	; 11/04/2016
  8403 0000A917 52                  <1> 	push	edx ; *****
  8404 0000A918 29CA                <1> 	sub	edx, ecx ; difference ; (the new string is longer)
  8405 0000A91A 89F3                <1> 	mov 	ebx, esi
  8406 0000A91C 89FE                <1> 	mov	esi, edi
  8407                              <1> 
  8408                              <1> set_env_change_variable_calc6:
  8409 0000A91E AC                  <1> 	lodsb 
  8410 0000A91F 20C0                <1> 	and	al, al
  8411 0000A921 75FB                <1> 	jnz	short set_env_change_variable_calc6
  8412                              <1> 
  8413 0000A923 81FE00320900        <1> 	cmp	esi, Env_Page + Env_Page_Size ; 512 (4096)
  8414 0000A929 0F8369FFFFFF        <1>         jnb     set_env_add_variable_nspc
  8415                              <1> 
  8416 0000A92F 89F9                <1> 	mov	ecx, edi  ; current (old) variable's address
  8417 0000A931 89F7                <1> 	mov	edi, esi  ; next variable's address 
  8418                              <1> 
  8419 0000A933 AC                  <1> 	lodsb
  8420 0000A934 08C0                <1> 	or	al, al
  8421 0000A936 7416                <1> 	jz	short set_env_change_variable_calc8 ; 00
  8422                              <1> 
  8423                              <1> set_env_change_variable_calc7:
  8424 0000A938 AC                  <1> 	lodsb
  8425 0000A939 20C0                <1> 	and	al, al
  8426 0000A93B 75FB                <1> 	jnz	short set_env_change_variable_calc7
  8427                              <1> 
  8428 0000A93D 81FE00320900        <1> 	cmp	esi, Env_Page + Env_Page_Size ; 512 (4096)
  8429 0000A943 0F834FFFFFFF        <1>         jnb     set_env_add_variable_nspc
  8430                              <1> 
  8431 0000A949 AC                  <1> 	lodsb
  8432 0000A94A 08C0                <1> 	or	al, al
  8433 0000A94C 75EA                <1> 	jnz	short set_env_change_variable_calc7
  8434                              <1> 
  8435                              <1> set_env_change_variable_calc8:
  8436 0000A94E 4E                  <1> 	dec	esi ; address of the second (last) 0 of the 00
  8437                              <1> 
  8438 0000A94F 01F2                <1> 	add	edx, esi ; final position of the last 0
  8439                              <1> 
  8440 0000A951 81FA00320900        <1> 	cmp	edx, Env_Page + Env_Page_Size ; 512 (4096)
  8441 0000A957 0F833BFFFFFF        <1>         jnb     set_env_add_variable_nspc
  8442                              <1> 
  8443 0000A95D 89C8                <1> 	mov	eax, ecx ; old variable's address (after '=')
  8444                              <1> 
  8445 0000A95F 89F1                <1> 	mov	ecx, esi 
  8446 0000A961 29F9                <1> 	sub	ecx, edi ; count of bytes to move forward
  8447                              <1> 
  8448                              <1> 	; 13/04/2016
  8449 0000A963 C60200              <1> 	mov	byte [edx], 0
  8450 0000A966 89D7                <1> 	mov	edi, edx
  8451 0000A968 29F2                <1> 	sub	edx, esi ; difference (additional byte count)
  8452 0000A96A 4F                  <1> 	dec	edi ; the last zero address (first byte of the 00)
  8453 0000A96B 89FE                <1> 	mov	esi, edi
  8454 0000A96D 29D6                <1> 	sub	esi, edx ; - displacement
  8455                              <1> 	
  8456 0000A96F FA                  <1> 	cli	; disable interrupts
  8457 0000A970 FD                  <1> 	std	; backward
  8458                              <1> 
  8459 0000A971 F3A4                <1> 	rep	movsb ; move ECX bytes from DS:ESI to ES:EDI
  8460                              <1> 
  8461 0000A973 FC                  <1> 	cld	; forward (default)
  8462 0000A974 FB                  <1> 	sti	; enable interrupts
  8463                              <1> 	
  8464 0000A975 89C7                <1> 	mov	edi, eax
  8465 0000A977 59                  <1> 	pop	ecx ; ***** ; byte count (after '=')
  8466 0000A978 89CA                <1> 	mov	edx, ecx
  8467 0000A97A 89DE                <1> 	mov	esi, ebx ; ASCIIZ string address (after '=')
  8468 0000A97C 89FB                <1> 	mov	ebx, edi
  8469                              <1> 
  8470 0000A97E F3A4                <1> 	rep	movsb
  8471                              <1> 
  8472 0000A980 880F                <1> 	mov	[edi], cl ; 0 ; end of variable
  8473                              <1> 
  8474 0000A982 0FB605[60960100]    <1> 	movzx	eax, byte [env_var_length]
  8475 0000A989 01C2                <1> 	add	edx, eax ; variable length (total)
  8476 0000A98B F7D8                <1> 	neg	eax
  8477 0000A98D 01D8                <1> 	add	eax, ebx ; start address of the variable
  8478 0000A98F F8                  <1> 	clc	; 13/04/2016
  8479 0000A990 E99EFEFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
  8480                              <1> 
  8481                              <1> set_env_change_variable_calc9:
  8482                              <1> 	; 11/04/2016
  8483 0000A995 21D2                <1> 	and	edx, edx ; is empty ?
  8484 0000A997 753B                <1> 	jnz	short set_env_change_variable_calc15
  8485                              <1> 	
  8486 0000A999 0FB6DC              <1> 	movzx	ebx, ah
  8487 0000A99C F7DB                <1> 	neg	ebx
  8488 0000A99E 01FB                <1> 	add	ebx, edi
  8489                              <1> 
  8490                              <1> 	; EBX = Start address of the variable (in env page)
  8491                              <1> 	; EDX = Variable length = 0
  8492                              <1> 	
  8493 0000A9A0 89FE                <1> 	mov	esi, edi
  8494                              <1> 
  8495                              <1> set_env_change_variable_calc10:
  8496 0000A9A2 AC                  <1> 	lodsb
  8497 0000A9A3 08C0                <1> 	or	al, al
  8498 0000A9A5 75FB                <1> 	jnz	short set_env_change_variable_calc10
  8499                              <1> 
  8500 0000A9A7 B9FF310900          <1> 	mov	ecx, Env_Page + Env_Page_Size - 1
  8501                              <1> 
  8502 0000A9AC 39CE                <1> 	cmp	esi, ecx ; +511 (+4095)
  8503 0000A9AE 7604                <1> 	jna	short set_env_change_variable_calc11
  8504                              <1> 
  8505 0000A9B0 89CE                <1> 	mov	esi, ecx
  8506 0000A9B2 8806                <1> 	mov	[esi], al ; 0
  8507                              <1> 
  8508                              <1> set_env_change_variable_calc11:
  8509 0000A9B4 89DF                <1> 	mov	edi, ebx ; old variable's start address
  8510                              <1> 
  8511                              <1> set_env_change_variable_calc12:
  8512 0000A9B6 AC                  <1> 	lodsb
  8513 0000A9B7 AA                  <1> 	stosb
  8514 0000A9B8 20C0                <1> 	and	al, al
  8515 0000A9BA 75FA                <1> 	jnz	short set_env_change_variable_calc12
  8516 0000A9BC 39CE                <1> 	cmp	esi, ecx
  8517 0000A9BE 7706                <1> 	ja	short set_env_change_variable_calc13
  8518 0000A9C0 AC                  <1> 	lodsb
  8519 0000A9C1 AA                  <1> 	stosb
  8520 0000A9C2 20C0                <1> 	and	al, al
  8521 0000A9C4 75F0                <1> 	jnz	short set_env_change_variable_calc12	
  8522                              <1> 
  8523                              <1> set_env_change_variable_calc13:
  8524 0000A9C6 29F9                <1> 	sub	ecx, edi
  8525 0000A9C8 7203                <1> 	jb	short set_env_change_variable_calc14
  8526 0000A9CA 41                  <1> 	inc	ecx ; 1-512 (1-4096)
  8527 0000A9CB F3AA                <1> 	rep	stosb ; al = 0	
  8528                              <1> 
  8529                              <1> set_env_change_variable_calc14:
  8530 0000A9CD 29C0                <1> 	sub	eax, eax ; Start address of the variable
  8531                              <1> 	; EAX = 0 -> Variable is removed
  8532                              <1> 	; EDX = Variable length = 0	
  8533                              <1> 
  8534 0000A9CF E95FFEFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
  8535                              <1> 	    
  8536                              <1> set_env_change_variable_calc15:	
  8537 0000A9D4 52                  <1> 	push	edx ; *****
  8538 0000A9D5 F7DA                <1> 	neg	edx
  8539 0000A9D7 01CA                <1> 	add	edx, ecx ; difference (the old string is longer)
  8540 0000A9D9 89F3                <1> 	mov 	ebx, esi
  8541 0000A9DB 89FE                <1> 	mov	esi, edi
  8542                              <1> 
  8543                              <1> set_env_change_variable_calc16:
  8544 0000A9DD AC                  <1> 	lodsb 
  8545 0000A9DE 20C0                <1> 	and	al, al
  8546 0000A9E0 75FB                <1> 	jnz	short set_env_change_variable_calc16
  8547                              <1> 
  8548 0000A9E2 B900320900          <1> 	mov	ecx, Env_Page + Env_Page_Size
  8549                              <1> 
  8550 0000A9E7 39CE                <1> 	cmp	esi, ecx ; +512 (+4096)
  8551 0000A9E9 7605                <1> 	jna	short set_env_change_variable_calc17
  8552                              <1> 
  8553 0000A9EB 89CE                <1> 	mov	esi, ecx
  8554 0000A9ED 8846FF              <1> 	mov	[esi-1], al ; 0
  8555                              <1> 
  8556                              <1> set_env_change_variable_calc17:
  8557 0000A9F0 89F9                <1> 	mov	ecx, edi  ; current (old) variable's address
  8558 0000A9F2 89F7                <1> 	mov	edi, esi  ; next variable's address 
  8559                              <1> 
  8560 0000A9F4 AC                  <1> 	lodsb
  8561 0000A9F5 08C0                <1> 	or	al, al
  8562 0000A9F7 741D                <1> 	jz	short set_env_change_variable_calc20
  8563                              <1> 
  8564                              <1> set_env_change_variable_calc18:
  8565 0000A9F9 AC                  <1> 	lodsb
  8566 0000A9FA 20C0                <1> 	and	al, al
  8567 0000A9FC 75FB                <1> 	jnz	short set_env_change_variable_calc18
  8568                              <1> 
  8569 0000A9FE 81FE00320900        <1> 	cmp	esi, Env_Page + Env_Page_Size
  8570 0000AA04 720B                <1> 	jb	short set_env_change_variable_calc19
  8571 0000AA06 740E                <1> 	je	short set_env_change_variable_calc20
  8572                              <1> 
  8573 0000AA08 BEFF310900          <1> 	mov	esi, Env_Page + Env_Page_Size - 1
  8574 0000AA0D 8806                <1> 	mov	[esi], al ; 0
  8575 0000AA0F EB06                <1> 	jmp	short set_env_change_variable_calc21
  8576                              <1> 
  8577                              <1> set_env_change_variable_calc19:
  8578 0000AA11 AC                  <1> 	lodsb
  8579 0000AA12 08C0                <1> 	or	al, al
  8580 0000AA14 75E3                <1> 	jnz	short set_env_change_variable_calc18
  8581                              <1> 
  8582                              <1> set_env_change_variable_calc20:
  8583 0000AA16 4E                  <1> 	dec	esi ; address of the second (last) 0 of the 00
  8584                              <1> 
  8585                              <1> set_env_change_variable_calc21:
  8586                              <1> 	; edx = difference (byte count)
  8587                              <1> 	
  8588 0000AA17 89C8                <1> 	mov	eax, ecx ; old variable's address (after '=')
  8589                              <1> 
  8590 0000AA19 89F1                <1> 	mov	ecx, esi 
  8591 0000AA1B 29F9                <1> 	sub	ecx, edi ; count of bytes to move backward
  8592                              <1> 
  8593 0000AA1D 89FE                <1> 	mov	esi, edi ; next variable's address
  8594 0000AA1F 29D7                <1> 	sub	edi, edx ; (displacement)
  8595                              <1> 	
  8596 0000AA21 F3A4                <1> 	rep	movsb
  8597                              <1> 
  8598 0000AA23 880F                <1> 	mov	[edi], cl ; 0 ; 00 ; end of environment variables
  8599                              <1> 
  8600 0000AA25 89C7                <1> 	mov	edi, eax
  8601 0000AA27 5A                  <1> 	pop	edx ; ***** ; byte count (after '=')
  8602 0000AA28 89D1                <1> 	mov	ecx, edx
  8603 0000AA2A 89DE                <1> 	mov	esi, ebx ; ASCIIZ string address (after '=')
  8604 0000AA2C 89FB                <1> 	mov	ebx, edi
  8605                              <1> 	
  8606 0000AA2E F3A4                <1> 	rep	movsb
  8607                              <1> 
  8608 0000AA30 880F                <1> 	mov	[edi], cl ; 0 ; end of variable
  8609                              <1> 
  8610 0000AA32 0FB605[60960100]    <1> 	movzx	eax, byte [env_var_length]
  8611 0000AA39 01C2                <1> 	add	edx, eax ; variable length (total)
  8612 0000AA3B F7D8                <1> 	neg	eax
  8613 0000AA3D 01D8                <1> 	add	eax, ebx ; start address of the variable
  8614 0000AA3F F8                  <1> 	clc	; 13/04/2016
  8615 0000AA40 E9EEFDFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
  8616                              <1> 
  8617                              <1> mainprog_startup_configuration:
  8618                              <1> 	; 22/11/2017
  8619                              <1> 	; 06/05/2016
  8620                              <1> 	; 14/04/2016 (TRDOS 386 = TRDOS v2.0)
  8621                              <1> 	; 17/09/2011 (TRDOS v1, MAINPROG.ASM)
  8622                              <1> 	;
  8623                              <1> loc_load_mainprog_cfg_file:
  8624 0000AA45 BE[09410100]        <1> 	mov	esi, MainProgCfgFile
  8625 0000AA4A 66B80018            <1> 	mov	ax, 1800h ; Except volume label and dirs
  8626 0000AA4E E83EEAFFFF          <1> 	call	find_first_file
  8627 0000AA53 7256                <1> 	jc	short loc_load_mainprog_cfg_exit
  8628                              <1> 
  8629                              <1> 	;or	eax, eax
  8630                              <1> 	;jz	short loc_load_mainprog_cfg_exit
  8631                              <1> 
  8632                              <1> loc_start_mainprog_configuration:
  8633                              <1> 	; ESI = FindFile_DirEntry Location
  8634                              <1> 	; EAX = File Size
  8635                              <1> 
  8636 0000AA55 A3[E48A0100]        <1> 	mov	[MainProgCfg_FileSize], eax
  8637                              <1> 
  8638 0000AA5A 668B5614            <1> 	mov	dx, [esi+DirEntry_FstClusHI]
  8639 0000AA5E C1E210              <1> 	shl	edx, 16
  8640 0000AA61 668B561A            <1> 	mov	dx, [esi+DirEntry_FstClusLO]
  8641 0000AA65 8915[14960100]      <1> 	mov	[csftdf_sf_cluster], edx
  8642                              <1> 
  8643 0000AA6B 89C1                <1> 	mov	ecx, eax
  8644 0000AA6D 29C0                <1> 	sub	eax, eax
  8645                              <1> 
  8646                              <1> 	; TRDOS 386 (TRDOS v2.0)
  8647                              <1> 	; Allocate contiguous memory block for loading the file
  8648                              <1> 	
  8649                              <1> 	; eax = 0 (Allocate memory from the beginning)
  8650                              <1> 	; ecx = File (Allocation) size in bytes
  8651                              <1> 	
  8652 0000AA6F E811BAFFFF          <1> 	call	allocate_memory_block
  8653 0000AA74 7235                <1> 	jc	short loc_load_mainprog_cfg_exit
  8654                              <1> 
  8655 0000AA76 A3[0C960100]        <1> 	mov	[csftdf_sf_mem_addr], eax ; loading address
  8656 0000AA7B 890D[10960100]      <1> 	mov	[csftdf_sf_mem_bsize], ecx ; block size
  8657                              <1> 
  8658 0000AA81 31DB                <1> 	xor	ebx, ebx
  8659                              <1> 	;mov	[csftdf_sf_rbytes], ebx ; 0, reset
  8660                              <1> 
  8661 0000AA83 8A3D[F68A0100]      <1> 	mov	bh, [Current_Drv] ; [FindFile_Drv]
  8662 0000AA89 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  8663 0000AA8E 01DE                <1> 	add	esi, ebx
  8664                              <1> 
  8665 0000AA90 8B1D[0C960100]      <1> 	mov	ebx, [csftdf_sf_mem_addr] ; memory block address
  8666                              <1> 
  8667 0000AA96 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  8668 0000AA9A 7710                <1>         ja	short loc_mcfg_load_fat_file
  8669                              <1> 
  8670 0000AA9C C705[1C960100]0000- <1> 	mov	dword [csftdf_r_size], 65536
  8670 0000AAA4 0100                <1>
  8671 0000AAA6 E9A1010000          <1>         jmp     loc_mcfg_load_fs_file
  8672                              <1> 
  8673                              <1> loc_load_mainprog_cfg_exit:
  8674 0000AAAB C3                  <1> 	retn 
  8675                              <1> 
  8676                              <1> loc_mcfg_load_fat_file:
  8677 0000AAAC 0FB74611            <1> 	movzx	eax, word [esi+LD_BPB+BytesPerSec]
  8678 0000AAB0 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
  8679 0000AAB4 F7E1                <1> 	mul	ecx
  8680 0000AAB6 A3[1C960100]        <1> 	mov	[csftdf_r_size], eax
  8681                              <1> 
  8682                              <1> loc_mcfg_load_fat_file_next:
  8683 0000AABB E822010000          <1> 	call	mcfg_read_fat_file_sectors
  8684 0000AAC0 0F8206010000        <1>         jc      mcfg_deallocate_mem
  8685                              <1> 
  8686 0000AAC6 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
  8687 0000AAC8 74F1                <1> 	jz	short loc_mcfg_load_fat_file_next
  8688                              <1> 
  8689                              <1> loc_mcfg_load_fat_file_ok:
  8690                              <1> 	; 06/05/2016
  8691 0000AACA C705[B0960100]-     <1> 	mov	dword [mainprog_return_addr], loc_mcfg_ci_return_addr 
  8691 0000AAD0 [8DAB0000]          <1>
  8692                              <1> 	;
  8693 0000AAD4 8B35[0C960100]      <1> 	mov	esi, [csftdf_sf_mem_addr]
  8694 0000AADA 8935[E88A0100]      <1> 	mov	[MainProgCfg_LineOffset], esi
  8695                              <1> 	
  8696 0000AAE0 A1[E48A0100]        <1> 	mov	eax, [MainProgCfg_FileSize]
  8697 0000AAE5 89C2                <1> 	mov	edx, eax
  8698 0000AAE7 01F2                <1> 	add	edx, esi
  8699                              <1> 
  8700                              <1> loc_mcfg_process_next_line_check:
  8701 0000AAE9 89C1                <1> 	mov	ecx, eax
  8702                              <1> 
  8703 0000AAEB 803E2A              <1> 	cmp	byte [esi], "*" ; Remark sign
  8704 0000AAEE 7503                <1> 	jne	short loc_mcfg_process_next_line
  8705 0000AAF0 46                  <1> 	inc	esi
  8706 0000AAF1 EB17                <1> 	jmp	short loc_move_mainprog_cfg_nl1
  8707                              <1> 
  8708                              <1> loc_mcfg_process_next_line:
  8709 0000AAF3 83F94F              <1> 	cmp	ecx, 79
  8710 0000AAF6 7605                <1> 	jna	short loc_start_mainprog_cfg_process
  8711                              <1> 	
  8712 0000AAF8 B94F000000          <1> 	mov	ecx, 79 
  8713                              <1> 
  8714                              <1> loc_start_mainprog_cfg_process:
  8715 0000AAFD BF[A68B0100]        <1> 	mov	edi, CommandBuffer
  8716                              <1> 
  8717                              <1> loc_move_mainprog_cfg_line:
  8718 0000AB02 AC                  <1> 	lodsb
  8719 0000AB03 3C20                <1> 	cmp	al, 20h
  8720 0000AB05 720C                <1> 	jb	short loc_move_mainprog_cfg_nl2
  8721 0000AB07 AA                  <1> 	stosb
  8722 0000AB08 E2F8                <1> 	loop	loc_move_mainprog_cfg_line
  8723                              <1> 
  8724                              <1> loc_move_mainprog_cfg_nl1:
  8725 0000AB0A 39D6                <1> 	cmp	esi, edx ; + configuration file size
  8726 0000AB0C 7312                <1> 	jnb	short loc_end_of_mainprog_cfg_line
  8727 0000AB0E AC                  <1> 	lodsb
  8728 0000AB0F 3C20                <1> 	cmp	al, 20h
  8729 0000AB11 73F7                <1> 	jnb	short loc_move_mainprog_cfg_nl1
  8730                              <1> 
  8731                              <1> loc_move_mainprog_cfg_nl2:
  8732 0000AB13 39D6                <1> 	cmp	esi, edx
  8733 0000AB15 7309                <1> 	jnb	short loc_end_of_mainprog_cfg_line
  8734 0000AB17 8A06                <1> 	mov	al, [esi]
  8735 0000AB19 3C20                <1> 	cmp	al, 20h
  8736 0000AB1B 7703                <1>  	ja	short loc_end_of_mainprog_cfg_line
  8737 0000AB1D 46                  <1> 	inc	esi
  8738 0000AB1E EBF3                <1> 	jmp	short loc_move_mainprog_cfg_nl2	               
  8739                              <1> 
  8740                              <1> loc_end_of_mainprog_cfg_line:
  8741 0000AB20 C60700              <1> 	mov	byte [edi], 0
  8742                              <1> 
  8743 0000AB23 8935[E88A0100]      <1> 	mov	[MainProgCfg_LineOffset], esi
  8744                              <1> 
  8745                              <1> 	; 22/11/2017
  8746 0000AB29 BE[AE8B0100]        <1> 	mov	esi, CommandBuffer + 8
  8747 0000AB2E 29FE                <1> 	sub	esi, edi
  8748 0000AB30 7606                <1> 	jna	short loc_move_mainprog_cfg_command
  8749 0000AB32 30C0                <1> 	xor	al, al
  8750                              <1> loc_mainprog_cfg_clear_chrs:
  8751 0000AB34 AA                  <1> 	stosb
  8752 0000AB35 4E                  <1> 	dec	esi
  8753 0000AB36 75FC                <1> 	jnz	short loc_mainprog_cfg_clear_chrs	
  8754                              <1> 
  8755                              <1> loc_move_mainprog_cfg_command:
  8756 0000AB38 BE[A68B0100]        <1> 	mov	esi, CommandBuffer
  8757 0000AB3D 89F7                <1> 	mov	edi, esi
  8758 0000AB3F 31DB                <1> 	xor	ebx, ebx
  8759                              <1> 	;xor	ecx, ecx
  8760 0000AB41 30C9                <1> 	xor	cl, cl
  8761                              <1> 
  8762                              <1> loc_move_mcfg_first_cmd_char:
  8763 0000AB43 8A041E              <1> 	mov	al, [esi+ebx]
  8764 0000AB46 FEC3                <1> 	inc	bl 
  8765 0000AB48 3C20                <1> 	cmp	al, 20h
  8766 0000AB4A 7712                <1> 	ja	short loc_move_mcfg_cmd_capitalizing
  8767 0000AB4C 7237                <1> 	jb	short loc_move_mcfg_cmd_arguments_ok
  8768 0000AB4E 80FB4F              <1> 	cmp	bl, 79
  8769 0000AB51 72F0                <1> 	jb	short loc_move_mcfg_first_cmd_char
  8770 0000AB53 EB30                <1> 	jmp	short loc_move_mcfg_cmd_arguments_ok
  8771                              <1> 
  8772                              <1> loc_move_mcfg_next_cmd_char:
  8773 0000AB55 8A041E              <1> 	mov	al, [esi+ebx]
  8774 0000AB58 FEC3                <1> 	inc	bl
  8775 0000AB5A 3C20                <1> 	cmp	al, 20h
  8776 0000AB5C 7614                <1> 	jna	short loc_move_mcfg_cmd_ok
  8777                              <1> 
  8778                              <1> loc_move_mcfg_cmd_capitalizing:
  8779 0000AB5E 3C61                <1> 	cmp	al, 61h ; 'a'
  8780 0000AB60 7206                <1> 	jb	short loc_move_mcfg_cmd_caps_ok
  8781 0000AB62 3C7A                <1> 	cmp	al, 7Ah ; 'z'
  8782 0000AB64 7702                <1> 	ja	short loc_move_mcfg_cmd_caps_ok
  8783 0000AB66 24DF                <1> 	and	al, 0DFh ; sub	al, 'a'-'A'
  8784                              <1> 
  8785                              <1> loc_move_mcfg_cmd_caps_ok:
  8786 0000AB68 AA                  <1> 	stosb 
  8787 0000AB69 FEC1                <1> 	inc	cl
  8788 0000AB6B 80FB4F              <1> 	cmp	bl, 79
  8789 0000AB6E 72E5                <1> 	jb	short loc_move_mcfg_next_cmd_char
  8790 0000AB70 EB13                <1> 	jmp	short loc_move_mcfg_cmd_arguments_ok
  8791                              <1> 
  8792                              <1> loc_move_mcfg_cmd_ok:
  8793 0000AB72 30C0                <1> 	xor	al, al ; 0
  8794                              <1> 
  8795                              <1> loc_move_mcfg_cmd_arguments:
  8796 0000AB74 8807                <1> 	mov	[edi], al
  8797 0000AB76 47                  <1> 	inc	edi
  8798 0000AB77 80FB4F              <1> 	cmp	bl, 79
  8799 0000AB7A 7309                <1> 	jnb	short loc_move_mcfg_cmd_arguments_ok
  8800 0000AB7C 8A041E              <1> 	mov	al, [esi+ebx]
  8801 0000AB7F FEC3                <1> 	inc	bl
  8802 0000AB81 3C20                <1> 	cmp	al, 20h
  8803 0000AB83 73EF                <1> 	jnb	short loc_move_mcfg_cmd_arguments
  8804                              <1> 	
  8805                              <1> loc_move_mcfg_cmd_arguments_ok:
  8806 0000AB85 C60700              <1> 	mov	byte [edi], 0
  8807                              <1>        
  8808                              <1> loc_mcfg_process_cmd_interpreter:
  8809 0000AB88 E825E0FFFF          <1> 	call    command_interpreter
  8810                              <1> 
  8811                              <1> loc_mcfg_ci_return_addr: 
  8812 0000AB8D A1[E48A0100]        <1> 	mov	eax, [MainProgCfg_FileSize]
  8813 0000AB92 89C2                <1> 	mov	edx, eax
  8814 0000AB94 8B35[E88A0100]      <1> 	mov	esi, [MainProgCfg_LineOffset]
  8815 0000AB9A 01F2                <1> 	add	edx, esi
  8816 0000AB9C 0305[0C960100]      <1> 	add	eax, [csftdf_sf_mem_addr]
  8817 0000ABA2 29F0                <1> 	sub	eax, esi
  8818 0000ABA4 0F873FFFFFFF        <1>         ja      loc_mcfg_process_next_line_check
  8819                              <1> 
  8820 0000ABAA E81D000000          <1> 	call	mcfg_deallocate_mem
  8821                              <1>  
  8822 0000ABAF B94F000000          <1>  	mov	ecx, 79 ; 80 ?
  8823 0000ABB4 BF[A68B0100]        <1> 	mov	edi, CommandBuffer
  8824 0000ABB9 30C0                <1> 	xor	al, al
  8825 0000ABBB F3AA                <1> 	rep	stosb
  8826                              <1> 
  8827                              <1> 	; 06/05/2016
  8828 0000ABBD BE[5F4D0100]        <1> 	mov	esi, nextline
  8829 0000ABC2 E89EC9FFFF          <1> 	call	print_msg
  8830 0000ABC7 E963D6FFFF          <1> 	jmp	dos_prompt
  8831                              <1> 
  8832                              <1> mcfg_deallocate_mem:
  8833 0000ABCC A1[0C960100]        <1> 	mov	eax, [csftdf_sf_mem_addr] ; start address
  8834 0000ABD1 8B0D[10960100]      <1> 	mov	ecx, [csftdf_sf_mem_bsize] ; block size	
  8835                              <1> 	;call	deallocate_memory_block
  8836                              <1> 	;retn
  8837 0000ABD7 E9B6BAFFFF          <1> 	jmp	deallocate_memory_block
  8838                              <1> 
  8839                              <1> mcfg_read_file_sectors:
  8840                              <1> 	; 14/04/2016
  8841 0000ABDC 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  8842 0000ABE0 7669                <1>         jna	short mcfg_read_fs_file_sectors
  8843                              <1> 
  8844                              <1> mcfg_read_fat_file_sectors:
  8845                              <1> 	; return:
  8846                              <1> 	;   CF = 0 & EDX > 0 -> END OF FILE
  8847                              <1> 	;   CF = 0 & EDX = 0 -> not EOF
  8848                              <1> 	;   CF = 1 -> read error (error code in AL)	
  8849                              <1> 
  8850                              <1> mcfg_read_fat_file_secs_0:
  8851 0000ABE2 8B15[E48A0100]      <1> 	mov	edx, [MainProgCfg_FileSize]
  8852 0000ABE8 2B15[24960100]      <1> 	sub	edx, [csftdf_sf_rbytes]
  8853 0000ABEE 3B15[1C960100]      <1> 	cmp	edx, [csftdf_r_size]	
  8854 0000ABF4 7306                <1> 	jnb	short mcfg_read_fat_file_secs_1
  8855 0000ABF6 8915[1C960100]      <1> 	mov	[csftdf_r_size], edx
  8856                              <1> 		
  8857                              <1> mcfg_read_fat_file_secs_1:
  8858 0000ABFC A1[1C960100]        <1> 	mov	eax, [csftdf_r_size]
  8859 0000AC01 29D2                <1> 	sub	edx, edx
  8860 0000AC03 0FB74E11            <1> 	movzx	ecx, word [esi+LD_BPB+BytesPerSec]
  8861 0000AC07 01C8                <1> 	add	eax, ecx
  8862 0000AC09 48                  <1> 	dec	eax
  8863 0000AC0A F7F1                <1> 	div	ecx
  8864 0000AC0C 89C1                <1> 	mov	ecx, eax ; sector count
  8865 0000AC0E A1[14960100]        <1> 	mov	eax, [csftdf_sf_cluster]
  8866                              <1> 
  8867                              <1> 	; EBX = memory block address (current)
  8868                              <1> 	
  8869 0000AC13 E88C230000          <1> 	call	read_fat_file_sectors
  8870 0000AC18 7230                <1> 	jc	short mcfg_read_fat_file_secs_3
  8871                              <1> 
  8872                              <1> 	; EBX = next memory address
  8873                              <1> 
  8874 0000AC1A A1[24960100]        <1> 	mov	eax, [csftdf_sf_rbytes]
  8875 0000AC1F 0305[1C960100]      <1> 	add	eax, [csftdf_r_size]
  8876 0000AC25 8B15[E48A0100]      <1> 	mov	edx, [MainProgCfg_FileSize]
  8877 0000AC2B 39D0                <1> 	cmp	eax, edx
  8878 0000AC2D 731B                <1> 	jnb	short mcfg_read_fat_file_secs_3 ; edx > 0
  8879 0000AC2F A3[24960100]        <1> 	mov	[csftdf_sf_rbytes], eax
  8880                              <1> 
  8881 0000AC34 53                  <1> 	push	ebx ; *
  8882                              <1> 	; get next cluster (csftdf_r_size! bytes)
  8883 0000AC35 A1[14960100]        <1> 	mov	eax, [csftdf_sf_cluster]
  8884 0000AC3A E837210000          <1> 	call	get_next_cluster
  8885 0000AC3F 5B                  <1> 	pop	ebx ; *
  8886 0000AC40 7301                <1> 	jnc	short mcfg_read_fat_file_secs_2
  8887                              <1> 
  8888                              <1> 	;mov	eax, 17; Read error !
  8889 0000AC42 C3                  <1> 	retn
  8890                              <1> 
  8891                              <1> mcfg_read_fat_file_secs_2:
  8892 0000AC43 29D2                <1> 	sub	edx, edx ; 0
  8893 0000AC45 A3[14960100]        <1> 	mov	[csftdf_sf_cluster], eax ; next cluster
  8894                              <1> 
  8895                              <1> mcfg_read_fat_file_secs_3:
  8896 0000AC4A C3                  <1> 	retn
  8897                              <1> 
  8898                              <1> mcfg_read_fs_file_sectors:
  8899 0000AC4B C3                  <1> 	retn
  8900                              <1> 
  8901                              <1> loc_mcfg_load_fs_file:
  8902 0000AC4C C3                  <1> 	retn
  8903                              <1> 
  8904                              <1> load_and_execute_file:
  8905                              <1> 	; 04/01/2017
  8906                              <1> 	; 06/05/2016, 07/05/2016, 11/05/2016
  8907                              <1> 	; 23/04/2016, 24/04/2016
  8908                              <1> 	; 22/04/2016 (TRDOS 386 = TRDOS v2.0)
  8909                              <1> 	; 05/11/2011 
  8910                              <1> 	; (TRDOS v1, CMDINTR.ASM, 'cmp_cmd_run', 'cmp_cmd_external')
  8911                              <1> 	; ('loc_run_check_filename')
  8912                              <1> 	; 29/08/2011
  8913                              <1> 	; 10/09/2011
  8914                              <1> 	; INPUT->
  8915                              <1> 	;	ESI = Path Name address (CommandBuffer address)
  8916                              <1> 	; OUTPUT ->
  8917                              <1> 	;	none (error message will be shown if an error will occur)
  8918                              <1> 	;
  8919                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI, EBP will be changed) 
  8920                              <1> 	;
  8921                              <1> loc_run_check_filename:
  8922 0000AC4D 803E20              <1> 	cmp	byte [esi], 20h
  8923 0000AC50 0F822BE3FFFF        <1> 	jb	loc_cmd_failed
  8924 0000AC56 7703                <1> 	ja	short loc_run_check_filename_ok
  8925 0000AC58 46                  <1> 	inc	esi
  8926 0000AC59 EBF2                <1> 	jmp	short loc_run_check_filename
  8927                              <1> 
  8928                              <1> loc_run_check_filename_ok:
  8929 0000AC5B C605[578B0100]00    <1> 	mov	byte [CmdArgStart], 0 ; reset
  8930 0000AC62 56                  <1> 	push	esi ; *
  8931                              <1> loc_run_get_first_arg_pos:
  8932 0000AC63 46                  <1> 	inc	esi
  8933 0000AC64 8A06                <1> 	mov	al, [esi]
  8934 0000AC66 3C20                <1> 	cmp	al, 20h
  8935 0000AC68 77F9                <1> 	ja	short loc_run_get_first_arg_pos
  8936 0000AC6A C60600              <1> 	mov	byte [esi], 0
  8937                              <1> loc_run_get_external_arg_pos:
  8938                              <1> 	; 11/05/2016
  8939 0000AC6D 46                  <1> 	inc	esi
  8940 0000AC6E 8A06                <1> 	mov	al, [esi]
  8941 0000AC70 3C20                <1> 	cmp	al, 20h
  8942 0000AC72 760C                <1> 	jna	short loc_run_parse_path_name
  8943 0000AC74 89F0                <1> 	mov	eax, esi
  8944 0000AC76 2D[A68B0100]        <1> 	sub	eax, CommandBuffer
  8945 0000AC7B A2[578B0100]        <1> 	mov	byte [CmdArgStart], al
  8946                              <1> loc_run_parse_path_name:
  8947 0000AC80 5E                  <1> 	pop	esi ; *
  8948 0000AC81 BF[96930100]        <1> 	mov	edi, FindFile_Drv
  8949 0000AC86 E8D7090000          <1> 	call	parse_path_name
  8950 0000AC8B 0F82F0E2FFFF        <1> 	jc	loc_cmd_failed
  8951                              <1> 
  8952                              <1> loc_run_check_filename_exists:
  8953 0000AC91 BE[D8930100]        <1> 	mov	esi, FindFile_Name
  8954 0000AC96 803E20              <1> 	cmp	byte [esi], 20h
  8955 0000AC99 0F86E2E2FFFF        <1> 	jna	loc_cmd_failed
  8956                              <1> 
  8957                              <1> loc_run_check_exe_filename_ext:
  8958 0000AC9F E890020000          <1> 	call	check_prg_filename_ext
  8959 0000ACA4 0F82D7E2FFFF        <1> 	jc	loc_cmd_failed
  8960                              <1> 	
  8961                              <1> loc_run_check_exe_filename_ext_ok:
  8962 0000ACAA 66A3[AE960100]      <1> 	mov	word [EXE_ID], ax
  8963                              <1> 
  8964                              <1> loc_run_drv:
  8965 0000ACB0 C605[AD960100]00    <1> 	mov	byte [Run_Manual_Path], 0
  8966 0000ACB7 A1[F08A0100]        <1> 	mov	eax, [Current_Dir_FCluster]
  8967 0000ACBC A3[A8960100]        <1>         mov     [Run_CDirFC], eax
  8968                              <1> 	;
  8969 0000ACC1 8A35[F68A0100]      <1> 	mov	dh, [Current_Drv]
  8970 0000ACC7 8835[52920100]      <1> 	mov	[RUN_CDRV], dh
  8971                              <1> 
  8972 0000ACCD 8A15[96930100]      <1> 	mov	dl, [FindFile_Drv]
  8973 0000ACD3 38F2                <1> 	cmp	dl, dh
  8974 0000ACD5 7412                <1> 	je	short loc_run_change_directory
  8975                              <1>                
  8976 0000ACD7 8005[AD960100]02    <1> 	add	byte [Run_Manual_Path], 2
  8977                              <1> 
  8978 0000ACDE E80BD4FFFF          <1> 	call	change_current_drive
  8979 0000ACE3 0F82C3E2FFFF        <1> 	jc	loc_run_cmd_failed
  8980                              <1> 
  8981                              <1> loc_run_change_directory:
  8982 0000ACE9 803D[97930100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  8983 0000ACF0 7623                <1> 	jna	short loc_run_find_executable_file
  8984                              <1> 
  8985 0000ACF2 FE05[AD960100]      <1> 	inc	byte [Run_Manual_Path]
  8986                              <1>      
  8987 0000ACF8 FE05[C3400100]      <1> 	inc	byte [Restore_CDIR]
  8988                              <1> 
  8989 0000ACFE BE[97930100]        <1> 	mov	esi, FindFile_Directory
  8990 0000AD03 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  8991 0000AD05 E842030000          <1> 	call	change_current_directory
  8992 0000AD0A 0F829CE2FFFF        <1> 	jc	loc_run_cmd_failed
  8993                              <1> 
  8994                              <1> loc_run_change_prompt_dir_string:
  8995 0000AD10 E857020000          <1> 	call	change_prompt_dir_string
  8996                              <1> 
  8997                              <1> loc_run_find_executable_file:
  8998 0000AD15 66C705[AC960100]00- <1> 	mov	word [Run_Auto_Path], 0
  8998 0000AD1D 00                  <1>
  8999                              <1> 
  9000                              <1> loc_run_find_executable_file_next:
  9001 0000AD1E BE[D8930100]        <1> 	mov	esi, FindFile_Name
  9002                              <1> loc_run_find_program_file_next:
  9003 0000AD23 66B80018            <1> 	mov	ax, 1800h ; Except volume label and dirs
  9004 0000AD27 E865E7FFFF          <1> 	call	find_first_file
  9005                              <1> 	; ESI = Directory Entry (FindFile_DirEntry) Location
  9006                              <1> 	; EDI = Directory Buffer Directory Entry Location
  9007                              <1> 	; EAX = File size
  9008 0000AD2C 0F835C010000        <1> 	jnc	loc_load_and_run_file
  9009                              <1> 	 
  9010 0000AD32 3C02                <1> 	cmp	al, 2 ; file not found
  9011 0000AD34 0F8572E2FFFF        <1> 	jne	loc_run_cmd_failed
  9012                              <1> 
  9013 0000AD3A 66A1[AE960100]      <1> 	mov	ax, word [EXE_ID]
  9014 0000AD40 80FC2E              <1> 	cmp	ah, '.' ; File name has extension sign
  9015 0000AD43 7424                <1> 	je	short loc_run_check_auto_path
  9016                              <1> 
  9017 0000AD45 08C0                <1> 	or	al, al
  9018 0000AD47 7520                <1> 	jnz	short loc_run_check_auto_path
  9019                              <1> 
  9020 0000AD49 80FC08              <1> 	cmp	ah, 8 ; count of file name chars
  9021 0000AD4C 771B                <1> 	ja	short loc_run_check_auto_path
  9022                              <1> 
  9023                              <1> loc_run_change_file_ext_to_prg:
  9024 0000AD4E 0FB6DC              <1> 	movzx	ebx, ah ; count of file name chars
  9025 0000AD51 BE[D8930100]        <1> 	mov	esi, FindFile_Name
  9026 0000AD56 01F3                <1> 	add	ebx, esi	
  9027                              <1> 	; 07/05/2016
  9028 0000AD58 C7032E505247        <1> 	mov	dword [ebx],  '.PRG'
  9029 0000AD5E 66C705[AE960100]50- <1> 	mov	word [EXE_ID], 'P.'
  9029 0000AD66 2E                  <1>
  9030 0000AD67 EBBA                <1> 	jmp	short loc_run_find_program_file_next	
  9031                              <1> 
  9032                              <1> loc_run_check_auto_path:
  9033                              <1> 	; NOTE: /// 07/05/2016 ///
  9034                              <1> 	; If the path is given, value of byte [Run_Manual_Path]
  9035                              <1> 	; will not be ZERO. If so, file searching by using
  9036                              <1> 	; Automatic Path (via 'PATH' environment variable)
  9037                              <1> 	; will not be applicable, because the program file 
  9038                              <1> 	; is already/absolutely not found.
  9039                              <1> 
  9040 0000AD69 A0[AD960100]        <1> 	mov	al, [Run_Manual_Path]
  9041 0000AD6E 08C0                <1> 	or	al, al
  9042 0000AD70 0F850BE2FFFF        <1> 	jnz	loc_cmd_failed
  9043                              <1> 
  9044                              <1> loc_run_check_auto_path_again:
  9045 0000AD76 66833D[AC960100]FF  <1> 	cmp	word [Run_Auto_Path], 0FFFFh		 
  9046                              <1> 		; 0FFFFh = Not a valid run path (in ENV block) 
  9047 0000AD7E 0F83FDE1FFFF        <1> 	jnb	loc_cmd_failed
  9048                              <1> 	; xor	al, al 
  9049 0000AD84 BE[8F410100]        <1> 	mov	esi, Cmd_Path ; 'PATH'
  9050 0000AD89 BF[F68B0100]        <1> 	mov	edi, TextBuffer
  9051 0000AD8E E848F9FFFF          <1> 	call	get_environment_string
  9052 0000AD93 730E                <1> 	jnc	short loc_run_chk_filename_ext_again
  9053 0000AD95 66C705[AC960100]FF- <1> 	mov	word [Run_Auto_Path], 0FFFFh ; invalid
  9053 0000AD9D FF                  <1>
  9054 0000AD9E E9DEE1FFFF          <1> 	jmp	loc_cmd_failed
  9055                              <1> 
  9056                              <1> loc_run_chk_filename_ext_again:
  9057 0000ADA3 89C1                <1> 	mov	ecx, eax ; string length (with zero tail)
  9058 0000ADA5 49                  <1> 	dec	ecx ; without zero tail
  9059 0000ADA6 66A1[AE960100]      <1> 	mov	ax, [EXE_ID]
  9060 0000ADAC 80FC2E              <1> 	cmp	ah, '.'
  9061 0000ADAF 740E                <1> 	je	short loc_run_chk_auto_path_pos
  9062                              <1> 	 
  9063                              <1> loc_run_change_file_ext_to_noext_again:
  9064 0000ADB1 0FB6DC              <1> 	movzx	ebx, ah
  9065 0000ADB4 BE[D8930100]        <1> 	mov	esi, FindFile_Name
  9066 0000ADB9 01F3                <1> 	add 	ebx, esi
  9067 0000ADBB 29C0                <1> 	sub	eax, eax
  9068 0000ADBD 8903                <1> 	mov	[ebx], eax ; 0 ; erase extension (.PRG)
  9069                              <1> 
  9070                              <1> loc_run_chk_auto_path_pos:
  9071                              <1> 	;movzx	eax,  word [Run_Auto_Path]
  9072 0000ADBF 66A1[AC960100]      <1> 	mov	ax, [Run_Auto_Path]
  9073 0000ADC5 39C8                <1> 	cmp	eax, ecx ; ecx = string length (except zero tail)
  9074 0000ADC7 0F83B4E1FFFF        <1> 	jnb	loc_cmd_failed
  9075                              <1> 	;or	eax, eax
  9076 0000ADCD 6609C0              <1> 	or	ax, ax
  9077 0000ADD0 7502                <1> 	jnz	short loc_run_auto_path_pos_move
  9078 0000ADD2 B005                <1> 	mov	al, 5
  9079                              <1> 
  9080                              <1> loc_run_auto_path_pos_move:
  9081 0000ADD4 89FE                <1> 	mov	esi, edi ; offset TextBuffer
  9082 0000ADD6 01C6                <1> 	add	esi, eax
  9083                              <1> 
  9084                              <1> loc_run_auto_path_pos_space_loop:
  9085 0000ADD8 AC                  <1> 	lodsb
  9086 0000ADD9 3C20                <1> 	cmp	al, 20h 
  9087 0000ADDB 74FB                <1> 	je	short loc_run_auto_path_pos_space_loop
  9088 0000ADDD 0F829EE1FFFF        <1> 	jb	loc_cmd_failed 
  9089 0000ADE3 AA                  <1> 	stosb
  9090                              <1> loc_run_auto_path_pos_move_next: 
  9091 0000ADE4 AC                  <1> 	lodsb
  9092 0000ADE5 3C3B                <1> 	cmp	al, ';'
  9093 0000ADE7 7414                <1> 	je	short loc_run_auto_path_pos_move_last_byte
  9094 0000ADE9 3C20                <1> 	cmp	al, 20h
  9095 0000ADEB 74F7                <1> 	je	short loc_run_auto_path_pos_move_next
  9096 0000ADED 7203                <1> 	jb	short loc_byte_ptr_end_of_path
  9097 0000ADEF AA                  <1> 	stosb
  9098 0000ADF0 EBF2                <1> 	jmp	short loc_run_auto_path_pos_move_next 
  9099                              <1> 
  9100                              <1> loc_byte_ptr_end_of_path: 
  9101 0000ADF2 66C705[AC960100]FF- <1> 	mov	word [Run_Auto_Path], 0FFFFh ; end of path
  9101 0000ADFA FF                  <1>
  9102 0000ADFB EB0D                <1> 	jmp	short loc_run_auto_path_move_ok 
  9103                              <1> 
  9104                              <1> loc_run_auto_path_pos_move_last_byte:
  9105 0000ADFD 89F0                <1> 	mov	eax, esi
  9106 0000ADFF 2D[F68B0100]        <1> 	sub	eax, TextBuffer 
  9107 0000AE04 66A3[AC960100]      <1> 	mov	[Run_Auto_Path], ax ; next path position
  9108                              <1> 
  9109                              <1> loc_run_auto_path_move_ok:
  9110 0000AE0A 4F                  <1> 	dec	edi
  9111 0000AE0B B02F                <1> 	mov	al, '/'
  9112 0000AE0D 3807                <1> 	cmp	[edi], al
  9113 0000AE0F 7403                <1> 	je	short loc_run_auto_path_move_file_name
  9114 0000AE11 47                  <1> 	inc	edi
  9115 0000AE12 8807                <1> 	mov	[edi], al
  9116                              <1> 
  9117                              <1> loc_run_auto_path_move_file_name:
  9118 0000AE14 47                  <1> 	inc	edi   
  9119 0000AE15 BE[D8930100]        <1> 	mov	esi, FindFile_Name
  9120                              <1> 
  9121                              <1> loc_run_auto_path_move_fn_loop:
  9122 0000AE1A AC                  <1> 	lodsb
  9123 0000AE1B AA                  <1> 	stosb
  9124 0000AE1C 08C0                <1> 	or	al, al
  9125 0000AE1E 75FA                <1> 	jnz	short loc_run_auto_path_move_fn_loop
  9126                              <1> 
  9127 0000AE20 BE[F68B0100]        <1> 	mov	esi, TextBuffer
  9128 0000AE25 BF[96930100]        <1> 	mov	edi, FindFile_Drv
  9129 0000AE2A E833080000          <1> 	call	parse_path_name
  9130 0000AE2F 0F824CE1FFFF        <1> 	jc	loc_cmd_failed
  9131                              <1> 
  9132 0000AE35 8A35[F68A0100]      <1> 	mov	dh, [Current_Drv]
  9133 0000AE3B 8A15[96930100]      <1> 	mov	dl, [FindFile_Drv]
  9134 0000AE41 38F2                <1> 	cmp	dl, dh
  9135 0000AE43 740B                <1> 	je	short loc_run_change_directory_again
  9136                              <1>                
  9137 0000AE45 E8A4D2FFFF          <1> 	call	change_current_drive
  9138 0000AE4A 0F825CE1FFFF        <1> 	jc	loc_run_cmd_failed
  9139                              <1> 
  9140                              <1> loc_run_change_directory_again:
  9141 0000AE50 803D[97930100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  9142 0000AE57 761D                <1> 	jna	short loc_load_executable_cdir_chk_again
  9143                              <1> 
  9144 0000AE59 FE05[C3400100]      <1> 	inc	byte [Restore_CDIR]
  9145 0000AE5F BE[97930100]        <1> 	mov	esi, FindFile_Directory
  9146 0000AE64 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  9147 0000AE66 E8E1010000          <1> 	call	change_current_directory
  9148 0000AE6B 0F823BE1FFFF        <1> 	jc	loc_run_cmd_failed
  9149                              <1> 
  9150                              <1> loc_run_chg_prompt_dir_str_again:
  9151 0000AE71 E8F6000000          <1> 	call	change_prompt_dir_string
  9152                              <1> 
  9153                              <1> loc_load_executable_cdir_chk_again:
  9154 0000AE76 A1[F08A0100]        <1> 	mov	eax, [Current_Dir_FCluster]
  9155 0000AE7B 3B05[A8960100]      <1> 	cmp	eax, [Run_CDirFC]
  9156 0000AE81 0F8597FEFFFF        <1> 	jne	loc_run_find_executable_file_next
  9157 0000AE87 30C0                <1> 	xor	al, al ; 0
  9158 0000AE89 E9E8FEFFFF          <1> 	jmp	loc_run_check_auto_path_again
  9159                              <1> 
  9160                              <1> loc_load_and_run_file:
  9161                              <1> 	; 13/11/2017
  9162                              <1> 	; 04/01/2017
  9163                              <1> 	; 23/04/2016
  9164 0000AE8E BE[D8930100]        <1> 	mov	esi, FindFile_Name
  9165 0000AE93 BF[F68B0100]        <1> 	mov	edi, TextBuffer
  9166                              <1> 
  9167                              <1>  	; 24/04/2016
  9168 0000AE98 31D2                <1> 	xor	edx, edx
  9169 0000AE9A 668915[4A040300]    <1> 	mov	word [argc], dx ; 0
  9170 0000AEA1 8915[8C030300]      <1> 	mov	dword [u.nread], edx ; 0
  9171                              <1> 
  9172                              <1> loc_load_and_run_file_1:
  9173 0000AEA7 AC                  <1> 	lodsb	
  9174 0000AEA8 AA                  <1> 	stosb
  9175 0000AEA9 FF05[8C030300]      <1> 	inc	dword [u.nread]
  9176 0000AEAF 20C0                <1> 	and	al, al
  9177 0000AEB1 75F4                <1> 	jnz 	short loc_load_and_run_file_1
  9178                              <1> 	
  9179 0000AEB3 A0[578B0100]        <1> 	mov	al, [CmdArgStart]
  9180 0000AEB8 20C0                <1> 	and	al, al
  9181 0000AEBA 7445                <1> 	jz	short loc_load_and_run_file_7
  9182                              <1> 
  9183 0000AEBC 0FB6F0              <1> 	movzx	esi, al ; 11/05/2016
  9184 0000AEBF B950000000          <1> 	mov	ecx, 80
  9185 0000AEC4 29F1                <1> 	sub	ecx, esi
  9186 0000AEC6 81C6[A68B0100]      <1> 	add	esi, CommandBuffer
  9187                              <1> 
  9188 0000AECC 66FF05[4A040300]    <1> 	inc	word [argc] ; 11/05/2016
  9189                              <1> 
  9190                              <1> loc_load_and_run_file_2:
  9191 0000AED3 AC                  <1> 	lodsb
  9192 0000AED4 3C20                <1> 	cmp	al, 20h
  9193 0000AED6 7717                <1> 	ja	short loc_load_and_run_file_5	
  9194 0000AED8 721E                <1> 	jb	short loc_load_and_run_file_6
  9195                              <1> 
  9196                              <1> loc_load_and_run_file_3:
  9197 0000AEDA 803E20              <1> 	cmp	byte [esi], 20h
  9198 0000AEDD 7707                <1> 	ja	short loc_load_and_run_file_4
  9199 0000AEDF 7217                <1> 	jb	short loc_load_and_run_file_6
  9200 0000AEE1 46                  <1> 	inc	esi
  9201 0000AEE2 E2F6                <1> 	loop	loc_load_and_run_file_3
  9202 0000AEE4 EB12                <1> 	jmp	short loc_load_and_run_file_6
  9203                              <1> 
  9204                              <1> loc_load_and_run_file_4:
  9205 0000AEE6 28C0                <1> 	sub	al, al ; 0
  9206 0000AEE8 66FF05[4A040300]    <1> 	inc	word [argc]
  9207                              <1> loc_load_and_run_file_5:
  9208 0000AEEF AA                  <1> 	stosb
  9209 0000AEF0 FF05[8C030300]      <1> 	inc	dword [u.nread]
  9210 0000AEF6 E2DB                <1> 	loop	loc_load_and_run_file_2
  9211                              <1> 			
  9212                              <1> loc_load_and_run_file_6:
  9213 0000AEF8 30C0                <1> 	xor	al, al ; 0
  9214 0000AEFA AA                  <1> 	stosb
  9215 0000AEFB FF05[8C030300]      <1> 	inc	dword [u.nread]
  9216                              <1> loc_load_and_run_file_7:
  9217 0000AF01 8807                <1> 	mov 	[edi], al ; 0
  9218 0000AF03 66FF05[4A040300]    <1> 	inc	word [argc] ; 24/04/2016
  9219 0000AF0A FF05[8C030300]      <1> 	inc	dword [u.nread] ; 24/04/2016
  9220 0000AF10 BE[F68B0100]        <1> 	mov	esi, TextBuffer
  9221 0000AF15 8B15[04940100]      <1> 	mov	edx, [FindFile_DirEntry+DirEntry_FileSize]
  9222 0000AF1B 66A1[FC930100]      <1> 	mov	ax, [FindFile_DirEntry+DirEntry_FstClusHI]
  9223 0000AF21 C1E010              <1> 	shl	eax, 16 ; 13/11/2017
  9224 0000AF24 66A1[02940100]      <1> 	mov	ax, [FindFile_DirEntry+DirEntry_FstClusLO]
  9225                              <1> 	; EAX = First Cluster number
  9226                              <1> 	; EDX = File Size
  9227                              <1> 	; ESI = Argument list address
  9228                              <1> 	; [argc] = argument count
  9229                              <1> 	; [u.nread] = argument list length
  9230 0000AF2A E85A640000          <1> 	call	load_and_run_file ; trdosk6.s
  9231                              <1>         ;jc	loc_run_cmd_failed ; 04/01/2017
  9232                              <1> loc_load_and_run_file_8: ; 06/05/2016
  9233 0000AF2F E98BE9FFFF          <1> 	jmp	loc_file_rw_restore_retn
  9234                              <1> 
  9235                              <1> check_prg_filename_ext:
  9236                              <1> 	; 23/04/2016 (TRDOS 386 = TRDOS v2.0)
  9237                              <1> 	; 10/09/2011 
  9238                              <1> 	; (TRDOS v1, CMDINTR.ASM, 'proc_check_exe_filename_ext')
  9239                              <1> 	; 14/11/2009
  9240                              <1> 	; INPUT -> 
  9241                              <1> 	;	ESI = Dot File Name
  9242                              <1> 	; OUTPUT ->
  9243                              <1> 	;     cf = 0 -> EXE_ID in AL
  9244                              <1> 	;	ESI = Last char + 1 position
  9245                              <1> 	;     cf = 1 -> Invalid executable file name
  9246                              <1> 	;	or no file name extension if AH<=8
  9247                              <1> 	;	AL = Last file name char     
  9248                              <1> 	;     cf = 0 -> AL='P' (PRG), AL=0 (no extension)
  9249                              <1> 	;
  9250                              <1> 	; (Modified registers: EAX, ESI)
  9251                              <1>   
  9252 0000AF34 30E4                <1> 	xor	ah, ah
  9253                              <1> loc_run_check_filename_ext:	
  9254 0000AF36 AC                  <1> 	lodsb
  9255 0000AF37 3C21                <1> 	cmp	al, 21h
  9256 0000AF39 7229                <1> 	jb	short loc_check_exe_fn_retn 
  9257 0000AF3B FEC4                <1> 	inc	ah
  9258 0000AF3D 3C2E                <1> 	cmp	al, '.'
  9259 0000AF3F 75F5                <1> 	jne	short loc_run_check_filename_ext	
  9260                              <1> 		 
  9261                              <1> loc_run_check_filename_ext_dot:
  9262 0000AF41 80FC02              <1> 	cmp	ah, 2 ; .??? is not valid
  9263 0000AF44 88C4                <1> 	mov	ah, al ; '.' 
  9264 0000AF46 7219                <1> 	jb	short loc_check_prg_fn_retn
  9265                              <1> 
  9266                              <1> loc_run_check_filename_ext_dot_ok:
  9267 0000AF48 AC                  <1> 	lodsb
  9268 0000AF49 24DF                <1> 	and	al, 0DFh 
  9269                              <1> 
  9270                              <1> loc_run_check_filename_ext_prg:
  9271 0000AF4B 3C50                <1> 	cmp	al, 'P'
  9272 0000AF4D 7212                <1> 	jb	short loc_check_prg_fn_retn
  9273 0000AF4F 7711                <1> 	ja	short loc_check_prg_fn_stc
  9274 0000AF51 AC                  <1> 	lodsb
  9275 0000AF52 24DF                <1> 	and	al, 0DFh 
  9276 0000AF54 3C52                <1> 	cmp	al, 'R'
  9277 0000AF56 750A                <1> 	jne	short loc_check_prg_fn_stc
  9278 0000AF58 AC                  <1> 	lodsb
  9279 0000AF59 24DF                <1> 	and	al, 0DFh
  9280 0000AF5B 3C47                <1> 	cmp	al, 'G'
  9281 0000AF5D 7503                <1> 	jne	short loc_check_prg_fn_stc
  9282                              <1> 
  9283 0000AF5F B050                <1> 	mov	al, 'P'
  9284                              <1> loc_check_prg_fn_retn:
  9285 0000AF61 C3                  <1> 	retn
  9286                              <1> 
  9287                              <1> loc_check_prg_fn_stc:
  9288 0000AF62 F9                  <1> 	stc
  9289 0000AF63 C3                  <1> 	retn
  9290                              <1>  
  9291                              <1> loc_check_exe_fn_retn:
  9292 0000AF64 28C0                <1> 	sub	al, al ; 0
  9293 0000AF66 C3                  <1> 	retn
  9294                              <1>               
  9295                              <1> find_and_list_files:
  9296 0000AF67 C3                  <1> 	retn
  9297                              <1> set_exec_arguments:
  9298 0000AF68 C3                  <1> 	retn
  9299                              <1> delete_fs_directory:
  9300 0000AF69 31C0                <1> 	xor eax, eax
  9301 0000AF6B C3                  <1> 	retn
  3090                                  %include 'trdosk4.s' ; 24/01/2016
  3091                              <1> ; ****************************************************************************
  3092                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - Directory Functions : trdosk4.s
  3093                              <1> ; ----------------------------------------------------------------------------
  3094                              <1> ; Last Update: 02/03/2021
  3095                              <1> ; ----------------------------------------------------------------------------
  3096                              <1> ; Beginning: 24/01/2016
  3097                              <1> ; ----------------------------------------------------------------------------
  3098                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
  3099                              <1> ; ----------------------------------------------------------------------------
  3100                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
  3101                              <1> ; DIR.ASM (09/10/2011)
  3102                              <1> ; ****************************************************************************
  3103                              <1> 
  3104                              <1> ; DIR.ASM  [ TRDOS KERNEL - COMMAND EXECUTER SECTION - DIRECTORY FUNCTIONS ]
  3105                              <1> ; (c) 2004-2010  Erdogan TAN  [ 17/01/2004 ]  Last Update: 09/10/2011
  3106                              <1> ; FILE.ASM [ FILE FUNCTIONS ] Last Update: 09/10/2011
  3107                              <1> 
  3108                              <1> change_prompt_dir_string:
  3109                              <1> 	; 05/10/2016
  3110                              <1> 	; 24/01/2016 (TRDOS 386 = TRDOS v2.0)
  3111                              <1> 	; 27/03/2011
  3112                              <1> 	; 09/10/2009
  3113                              <1> 	; INPUT/OUTPUT => none
  3114                              <1> 	; this procedure changes current directory string/text  
  3115                              <1> 	; 2005
  3116                              <1> 
  3117 0000AF6C BE[53920100]        <1> 	mov	esi, PATH_Array
  3118                              <1> change_prompt_dir_str: ; 05/10/2016 (call from 'set_working_path')
  3119 0000AF71 BF[FA8A0100]        <1> 	mov	edi, Current_Directory
  3120 0000AF76 8A25[F48A0100]      <1> 	mov	ah, [Current_Dir_Level]
  3121 0000AF7C E807000000          <1> 	call	set_current_directory_string
  3122 0000AF81 880D[558B0100]      <1> 	mov	[Current_Dir_StrLen], cl
  3123                              <1> 
  3124 0000AF87 C3                  <1> 	retn
  3125                              <1> 
  3126                              <1> set_current_directory_string:
  3127                              <1> 	; 24/01/2016 (TRDOS 386 = TRDOS v2.0)
  3128                              <1> 	; 27/03/2011
  3129                              <1> 	; 09/10/2009
  3130                              <1> 	; INPUT:
  3131                              <1> 	;    ESI = Path Array Address 
  3132                              <1> 	;    EDI = Current Directory String Buffer
  3133                              <1> 	;    AH = Current Directory Level
  3134                              <1> 	; OUTPUT => EAX, EBX, ESI will be changed
  3135                              <1> 	;    EDI will be same with input
  3136                              <1> 	;    ECX = Current Directory String Length 
  3137                              <1> 
  3138 0000AF88 57                  <1> 	push    edi
  3139 0000AF89 80FC00              <1> 	cmp     ah, 0
  3140 0000AF8C 7652                <1> 	jna	short pass_write_path
  3141 0000AF8E 83C610              <1> 	add	esi, 16
  3142 0000AF91 89F3                <1> 	mov	ebx, esi
  3143                              <1> loc_write_path:
  3144 0000AF93 B908000000          <1> 	mov	ecx, 8
  3145                              <1> path_write_dirname1:
  3146 0000AF98 AC                  <1> 	lodsb
  3147 0000AF99 3C20                <1> 	cmp	al, 20h
  3148 0000AF9B 7612                <1> 	jna	short pass_write_dirname1
  3149 0000AF9D AA                  <1> 	stosb
  3150 0000AF9E 81FF[548B0100]      <1> 	cmp	edi, End_Of_Current_Dir_Str
  3151 0000AFA4 733A                <1> 	jnb	short pass_write_path
  3152 0000AFA6 E2F0                <1> 	loop	path_write_dirname1
  3153 0000AFA8 803E20              <1> 	cmp	byte [esi], 20h
  3154 0000AFAB 7624                <1> 	jna	short pass_write_dirname2
  3155 0000AFAD EB0A                <1> 	jmp     short loc_put_dot_cont_ext
  3156                              <1> pass_write_dirname1:
  3157 0000AFAF 89DE                <1> 	mov	esi, ebx
  3158 0000AFB1 83C608              <1> 	add	esi, 8
  3159 0000AFB4 803E20              <1> 	cmp	byte [esi], 20h
  3160 0000AFB7 7618                <1> 	jna	short pass_write_dirname2
  3161                              <1> loc_put_dot_cont_ext:
  3162 0000AFB9 C6072E              <1> 	mov	byte [edi], "."
  3163                              <1> 	;mov	ecx, 3
  3164 0000AFBC B103                <1> 	mov	cl, 3
  3165                              <1> loc_check_dir_name_ext:
  3166 0000AFBE AC                  <1> 	lodsb
  3167 0000AFBF 47                  <1> 	inc	edi
  3168 0000AFC0 3C20                <1> 	cmp	al, 20h
  3169 0000AFC2 760D                <1> 	jna	short pass_write_dirname2
  3170 0000AFC4 8807                <1> 	mov	[edi], al
  3171 0000AFC6 81FF[548B0100]      <1> 	cmp	edi, End_Of_Current_Dir_Str
  3172 0000AFCC 7312                <1> 	jnb	short pass_write_path
  3173 0000AFCE E2EE                <1> 	loop    loc_check_dir_name_ext
  3174 0000AFD0 47                  <1> 	inc	edi
  3175                              <1> pass_write_dirname2:
  3176 0000AFD1 FECC                <1> 	dec	ah
  3177 0000AFD3 740B                <1> 	jz      short pass_write_path
  3178 0000AFD5 83C310              <1> 	add	ebx, 16
  3179 0000AFD8 89DE                <1> 	mov	esi, ebx
  3180 0000AFDA C6072F              <1> 	mov	byte [edi],"/"
  3181 0000AFDD 47                  <1> 	inc	edi
  3182 0000AFDE EBB3                <1> 	jmp	short loc_write_path
  3183                              <1> pass_write_path:
  3184 0000AFE0 C60700              <1> 	mov	byte [edi], 0
  3185 0000AFE3 47                  <1> 	inc	edi
  3186 0000AFE4 89F9                <1> 	mov	ecx, edi
  3187 0000AFE6 5F                  <1> 	pop	edi
  3188 0000AFE7 29F9                <1> 	sub	ecx, edi
  3189                              <1> 	; ECX = Current Directory String Length
  3190 0000AFE9 C3                  <1> 	retn
  3191                              <1> 
  3192                              <1> get_current_directory:
  3193                              <1> 	; 15/10/2016
  3194                              <1> 	; 14/02/2016
  3195                              <1> 	; 24/01/2016 (TRDOS 386 = TRDOS v2.0)
  3196                              <1> 	; 27/03/2011
  3197                              <1> 	;
  3198                              <1> 	; INPUT-> ESI = Current Directory Buffer
  3199                              <1> 	;         DL = TRDOS Logical Dos Drive Number + 1
  3200                              <1> 	;              (0= Default/Current Drive)
  3201                              <1> 	;           
  3202                              <1> 	;   Note: Required dir buffer length may be <= 92 bytes
  3203                              <1> 	;         for TRDOS (7*12 name chars + 7 slash + 0)
  3204                              <1> 	; OUTPUT ->  ESI = Current Directory Buffer
  3205                              <1> 	;            EAX, EBX, ECX, EDX, EDI will be changed
  3206                              <1> 	;            CX/CL = Current Directory String Length
  3207                              <1> 	;	     DL = Drive Number (0 based)
  3208                              <1> 	;            (If input is 0, output is current drv number) 
  3209                              <1> 	;            DH = same with input 
  3210                              <1> 	;   cf = 0 -> AL = 0
  3211                              <1> 	;   cf = 1 -> error code in AL 
  3212                              <1>               
  3213                              <1> loc_get_current_drive_0:
  3214 0000AFEA 80FA00              <1> 	cmp	dl, 0
  3215 0000AFED 7708                <1> 	ja	short loc_get_current_drive_1
  3216 0000AFEF 8A15[F68A0100]      <1> 	mov	dl, [Current_Drv]
  3217 0000AFF5 EB17                <1> 	jmp	short loc_get_current_drive_2
  3218                              <1> loc_get_current_drive_1:
  3219 0000AFF7 FECA                <1> 	dec 	dl
  3220 0000AFF9 3A15[C2400100]      <1> 	cmp	dl, [Last_DOS_DiskNo]
  3221 0000AFFF 760D                <1> 	jna	short loc_get_current_drive_2
  3222 0000B001 B80F000000          <1> 	mov	eax, 0Fh ; Invalid drive (Drive not ready!)
  3223 0000B006 F5                  <1> 	cmc 	; stc
  3224 0000B007 C3                  <1> 	retn
  3225                              <1> 
  3226                              <1> loc_get_current_drive_not_ready_retn:
  3227 0000B008 5E                  <1> 	pop	esi
  3228                              <1> 	;mov	eax, 15
  3229 0000B009 66B80F00            <1> 	mov	ax, 15 ; Drive not ready
  3230 0000B00D C3                  <1> 	retn  
  3231                              <1>  
  3232                              <1> loc_get_current_drive_2:
  3233 0000B00E 31C0                <1> 	xor	eax, eax
  3234 0000B010 88D4                <1> 	mov	ah, dl
  3235 0000B012 56                  <1> 	push	esi
  3236 0000B013 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  3237 0000B018 01C6                <1> 	add	esi, eax
  3238 0000B01A 8A06                <1> 	mov	al, [esi+LD_Name] 
  3239 0000B01C 3C41                <1> 	cmp	al, 'A'
  3240 0000B01E 72E8                <1> 	jb	short loc_get_current_drive_not_ready_retn
  3241                              <1> 
  3242 0000B020 8A667F              <1> 	mov	ah, [esi+LD_CDirLevel]
  3243 0000B023 08E4                <1> 	or	ah, ah
  3244 0000B025 7506                <1> 	jnz	short loc_get_current_drive_3
  3245                              <1> 
  3246                              <1> 	;xor	ah, ah ; mov ah, 0
  3247 0000B027 8826                <1> 	mov	[esi], ah
  3248 0000B029 31C9                <1> 	xor	ecx, ecx
  3249 0000B02B EB1C                <1> 	jmp	short loc_get_current_drive_4
  3250                              <1> 
  3251                              <1> loc_get_current_drive_3:
  3252 0000B02D BF[53920100]        <1>         mov     edi, PATH_Array
  3253 0000B032 57                  <1> 	push	edi
  3254 0000B033 81C680000000        <1> 	add	esi, LD_CurrentDirectory
  3255 0000B039 B920000000          <1> 	mov	ecx, 32
  3256 0000B03E F3A5                <1> 	rep	movsd
  3257 0000B040 5E                  <1> 	pop	esi ; Path Array Address
  3258 0000B041 5F                  <1> 	pop	edi ; pushed esi (current dir buffer offset) 
  3259                              <1> 	;
  3260 0000B042 E841FFFFFF          <1> 	call	set_current_directory_string
  3261 0000B047 89FE                <1> 	mov	esi, edi
  3262                              <1> 
  3263                              <1> loc_get_current_drive_4:
  3264 0000B049 30C0                <1> 	xor	al, al
  3265 0000B04B C3                  <1> 	retn
  3266                              <1> 
  3267                              <1> change_current_directory:
  3268                              <1> 	; 02/03/2021 (TRDOS 386 v2.0.3) ((BugFix))
  3269                              <1> 	; 19/02/2016
  3270                              <1> 	; 11/02/2016
  3271                              <1> 	; 10/02/2016
  3272                              <1> 	; 08/02/2016
  3273                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
  3274                              <1> 	; 18/09/2011 (DIR.ASM, 09/10/2011)	
  3275                              <1> 	; 04/10/2009
  3276                              <1> 	; 2005
  3277                              <1> 	; INPUT -> 
  3278                              <1> 	;	ESI = Directory string
  3279                              <1> 	;	ah = CD command (CDh = save current dir string)
  3280                              <1> 	; OUTPUT -> 
  3281                              <1> 	; 	EDI = DOS Drive Description Table
  3282                              <1> 	; 	cf = 1 -> error
  3283                              <1> 	;	   EAX = Error code
  3284                              <1> 	;	cf = 0 -> successful
  3285                              <1> 	;	   ESI = PATH_Array
  3286                              <1> 	;	   EAX = Current Directory First Cluster
  3287                              <1> 	;
  3288                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI will be changed)
  3289                              <1> 	
  3290 0000B04C 8825[E1920100]      <1> 	mov	[CD_COMMAND], ah
  3291 0000B052 803E2F              <1> 	cmp	byte [esi], '/'
  3292 0000B055 7505                <1> 	jne	short loc_ccd_cdir_level
  3293 0000B057 46                  <1> 	inc	esi
  3294 0000B058 30C0                <1> 	xor	al, al
  3295 0000B05A EB05                <1> 	jmp	short loc_ccd_parse_path_name
  3296                              <1> loc_ccd_cdir_level:
  3297 0000B05C A0[F48A0100]        <1> 	mov	al, [Current_Dir_Level]
  3298                              <1> loc_ccd_parse_path_name:
  3299 0000B061 88C4                <1> 	mov	ah, al
  3300 0000B063 BF[53920100]        <1> 	mov	edi, PATH_Array
  3301                              <1> 
  3302                              <1> ; Reset directory levels > cdir level
  3303                              <1> 	; is this required !?
  3304                              <1> 	;
  3305                              <1> 	; Relations:
  3306                              <1> 	; MAINPROG.ASM (pass_ccdrv_reset_cdir_FAT_fcluster)
  3307                              <1> 	; proc_parse_dir_name,
  3308                              <1> 	; proc_change_current_directory (this procedure)
  3309                              <1> 	; proc_change_prompt_dir_string 
  3310                              <1>  
  3311 0000B068 0FB6C8              <1> 	movzx	ecx, al
  3312 0000B06B FEC1                <1> 	inc	cl
  3313 0000B06D C0E104              <1> 	shl	cl, 4
  3314 0000B070 01CF                <1> 	add	edi, ecx
  3315 0000B072 B107                <1> 	mov	cl, 7
  3316 0000B074 28C1                <1> 	sub	cl, al
  3317 0000B076 C0E102              <1> 	shl	cl, 2
  3318 0000B079 89C3                <1> 	mov	ebx, eax
  3319 0000B07B 31C0                <1> 	xor	eax, eax ; 0
  3320 0000B07D F3AB                <1> 	rep	stosd
  3321 0000B07F 89D8                <1> 	mov	eax, ebx
  3322                              <1> 
  3323 0000B081 BF[53920100]        <1> 	mov	edi, PATH_Array
  3324                              <1> 
  3325 0000B086 803E20              <1> 	cmp	byte [esi], 20h
  3326 0000B089 F5                  <1> 	cmc
  3327 0000B08A 7305                <1> 	jnc	short pass_ccd_parse_dir_name
  3328                              <1> 
  3329                              <1> 		; ESI = Path name
  3330                              <1> 		; AL = CCD_Level
  3331 0000B08C E871010000          <1>         call    parse_dir_name
  3332                              <1> 		; AL = CCD_Level 
  3333                              <1> 		; AH = Last_Dir_Level
  3334                              <1> 		; (EDI = PATH_Array)
  3335                              <1> 
  3336                              <1> pass_ccd_parse_dir_name:
  3337 0000B091 9C                  <1> 	pushf
  3338                              <1> 
  3339                              <1> 	;mov	[CCD_Level], al
  3340                              <1>         ;mov	[Last_Dir_Level], ah
  3341 0000B092 66A3[D7920100]      <1> 	mov	[CCD_Level], ax
  3342                              <1> 
  3343 0000B098 31DB                <1> 	xor	ebx, ebx
  3344 0000B09A 8A3D[F68A0100]      <1> 	mov	bh, [Current_Drv]
  3345 0000B0A0 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  3346 0000B0A5 01DE                <1> 	add	esi, ebx
  3347                              <1> 
  3348 0000B0A7 9D                  <1> 	popf 
  3349 0000B0A8 720A                <1> 	jc	short loc_ccd_bad_path_name_retn
  3350                              <1> 
  3351 0000B0AA 8935[D3920100]      <1> 	mov	[CCD_DriveDT], esi
  3352                              <1> 
  3353 0000B0B0 3C07                <1> 	cmp	al, 7
  3354 0000B0B2 7209                <1> 	jb	short loc_ccd_load_child_dir
  3355                              <1> 
  3356                              <1> loc_ccd_bad_path_name_retn:
  3357 0000B0B4 87F7                <1> 	xchg	esi, edi
  3358 0000B0B6 B813000000          <1> 	mov	eax, 19 ; Bad directory/path name 
  3359 0000B0BB F9                  <1> 	stc
  3360                              <1> loc_ccd_retn_p:
  3361 0000B0BC C3                  <1> 	retn
  3362                              <1> 
  3363                              <1> loc_ccd_load_child_dir:
  3364                              <1> 	; AL = CCD_Level
  3365 0000B0BD 08C0                <1> 	or	al, al
  3366 0000B0BF 7467                <1> 	jz	short loc_ccd_load_root_dir
  3367                              <1> 
  3368 0000B0C1 6689C1              <1> 	mov	cx, ax
  3369 0000B0C4 C0E004              <1> 	shl	al, 4
  3370 0000B0C7 0FB6F0              <1> 	movzx	esi, al
  3371 0000B0CA 01FE                <1>      	add	esi, edi  ; offset PATH_Array
  3372                              <1> 
  3373 0000B0CC 8B460C              <1> 	mov	eax, [esi+12]
  3374 0000B0CF 38E9                <1> 	cmp	cl, ch
  3375 0000B0D1 0F84F9000000        <1>         je      loc_ccd_load_sub_directory
  3376 0000B0D7 A3[F08A0100]        <1> 	mov	[Current_Dir_FCluster], eax
  3377                              <1> 
  3378                              <1> loc_ccd_load_child_dir_next:
  3379 0000B0DC 83C610              <1> 	add	esi, 16 ; DOS DirEntry Format FileName Address
  3380                              <1> 
  3381                              <1>  	; Directory attribute : 10h
  3382 0000B0DF B010                <1> 	mov	al, 00010000b ; 10h (Attrib AND mask)
  3383                              <1> 	;mov	ah, 11001000b ; C8h
  3384                              <1> 	; Volume name attribute: 8h
  3385 0000B0E1 B408                <1> 	mov	ah, 00001000b ; 08h (Attrib NAND, AND --> zero mask)
  3386                              <1> 
  3387                              <1> 	;xor	cx, cx  
  3388 0000B0E3 31C9                <1> 	xor	ecx, ecx ; 02/03/2021
  3389 0000B0E5 E8B5010000          <1> 	call	locate_current_dir_file
  3390 0000B0EA 7353                <1> 	jnc	short loc_ccd_set_dir_cluster_ptr
  3391                              <1> 
  3392                              <1> 	 ; 19/02/2016
  3393                              <1> 	;mov	edi, [CCD_DriveDT]
  3394 0000B0EC 8A25[D7920100]      <1> 	mov	ah, [CCD_Level]
  3395 0000B0F2 803D[E1920100]CD    <1> 	cmp	byte [CD_COMMAND], 0CDh ;'CD' command or another
  3396 0000B0F9 7509                <1> 	jne	short loc_ccd_load_child_dir_err
  3397                              <1> 	; It is better to save recent successful part 
  3398                              <1> 	; of the (requested) path as current directory.
  3399                              <1> 	; (Otherwise the path would be reset to back
  3400                              <1> 	; on the next 'CD' command.)
  3401 0000B0FB 88E1                <1> 	mov	cl, ah
  3402 0000B0FD 50                  <1> 	push	eax
  3403 0000B0FE E8E3000000          <1> 	call	loc_ccd_save_current_dir
  3404 0000B103 58                  <1> 	pop	eax
  3405                              <1> loc_ccd_load_child_dir_err:            
  3406 0000B104 3C03                <1> 	cmp	al, 3	; AL = 2 => File not found error
  3407 0000B106 7202                <1> 	jb	short loc_ccd_path_not_found_retn
  3408 0000B108 F9                  <1> 	stc
  3409 0000B109 C3                  <1> 	retn
  3410                              <1> 
  3411                              <1> loc_ccd_path_not_found_retn:
  3412 0000B10A B003                <1> 	mov	al, 3	; Path not found
  3413 0000B10C C3                  <1> 	retn
  3414                              <1> 
  3415                              <1> loc_ccd_load_FAT_root_dir:
  3416 0000B10D 803D[F58A0100]02    <1> 	cmp	byte [Current_FATType], 2
  3417 0000B114 776B                <1> 	ja	short loc_ccd_load_FAT32_root_dir
  3418                              <1> 
  3419                              <1> 	;mov	esi, [CCD_DriveDT]
  3420                              <1> 	;push	esi
  3421 0000B116 E8B61D0000          <1> 	call	load_FAT_root_directory
  3422                              <1> 	;pop	edi ; Dos Drv Description Table
  3423                              <1> 
  3424 0000B11B 89F7                <1> 	mov	edi, esi
  3425 0000B11D BE[53920100]        <1> 	mov	esi, PATH_Array
  3426 0000B122 7298                <1> 	jc	short loc_ccd_retn_p
  3427                              <1> 
  3428 0000B124 31C0                <1> 	xor	eax, eax
  3429 0000B126 EB78                <1>         jmp	short loc_ccd_set_cdfc
  3430                              <1> 
  3431                              <1> loc_ccd_load_root_dir:
  3432 0000B128 803D[F58A0100]01    <1> 	cmp	byte [Current_FATType], 1
  3433 0000B12F 73DC                <1> 	jnb	short loc_ccd_load_FAT_root_dir
  3434                              <1> 
  3435                              <1> loc_ccd_load_FS_root_dir:
  3436 0000B131 E8621E0000          <1> 	call	load_FS_root_directory
  3437 0000B136 EB5C                <1> 	jmp	short pass_ccd_load_FAT_sub_directory
  3438                              <1> 
  3439                              <1> loc_ccd_load_FS_sub_directory_next:
  3440 0000B138 E85C1E0000          <1> 	call	load_FS_sub_directory
  3441 0000B13D EB1F                <1> 	jmp	short pass_ccd_set_dir_cluster_ptr  
  3442                              <1> 
  3443                              <1> loc_ccd_set_dir_cluster_ptr:
  3444                              <1> 	; EDI = Directory Entry
  3445 0000B13F 668B4714            <1> 	mov	ax, [edi+20] ; First Cluster High Word
  3446 0000B143 C1E010              <1> 	shl	eax, 16
  3447 0000B146 668B471A            <1> 	mov	ax, [edi+26] ; First Cluster Low Word
  3448                              <1> 
  3449 0000B14A 8B35[D3920100]      <1> 	mov	esi, [CCD_DriveDT]
  3450 0000B150 803D[F58A0100]01    <1> 	cmp	byte [Current_FATType], 1
  3451 0000B157 72DF                <1> 	jb	short loc_ccd_load_FS_sub_directory_next
  3452                              <1> 	;push	esi
  3453 0000B159 E8FE1D0000          <1> 	call	load_FAT_sub_directory
  3454                              <1> 	;pop	edi ; Dos Drv Description Table
  3455                              <1> 
  3456                              <1> pass_ccd_set_dir_cluster_ptr:
  3457                              <1> 	;mov	edi, esi
  3458 0000B15E BE[53920100]        <1> 	mov	esi, PATH_Array
  3459 0000B163 7264                <1> 	jc	short loc_ccd_retn_c
  3460                              <1> 
  3461 0000B165 A1[21920100]        <1> 	mov	eax, [DirBuff_Cluster]
  3462                              <1> 
  3463 0000B16A FE05[D7920100]      <1> 	inc	byte [CCD_Level]
  3464 0000B170 0FB61D[D7920100]    <1> 	movzx	ebx, byte [CCD_Level]
  3465 0000B177 C0E304              <1> 	shl	bl, 4 ; * 16 (<= 128)   
  3466 0000B17A 01DE                <1> 	add	esi, ebx ; 19/02/2016
  3467 0000B17C 89460C              <1> 	mov	[esi+12], eax
  3468 0000B17F EB1F                <1> 	jmp	short loc_ccd_set_cdfc
  3469                              <1> 
  3470                              <1> loc_ccd_load_FAT32_root_dir:
  3471 0000B181 BE[53920100]        <1> 	mov	esi, PATH_Array
  3472 0000B186 8B460C              <1> 	mov	eax, [esi+12]
  3473 0000B189 8B35[D3920100]      <1> 	mov	esi, [CCD_DriveDT]
  3474                              <1>  
  3475                              <1> loc_ccd_load_FAT_sub_directory:
  3476                              <1> 	;push	esi
  3477 0000B18F E8C81D0000          <1> 	call	load_FAT_sub_directory
  3478                              <1> 	;pop	edi ; Dos Drv Description Table
  3479                              <1> 
  3480                              <1> pass_ccd_load_FAT_sub_directory:
  3481                              <1> 	;mov	edi, esi
  3482 0000B194 BE[53920100]        <1> 	mov	esi, PATH_Array
  3483 0000B199 722E                <1> 	jc	short loc_ccd_retn_c
  3484                              <1> 
  3485 0000B19B A1[21920100]        <1> 	mov	eax, [DirBuff_Cluster]
  3486                              <1> 
  3487                              <1> loc_ccd_set_cdfc:
  3488 0000B1A0 8A0D[D7920100]      <1> 	mov	cl, [CCD_Level]
  3489 0000B1A6 880D[F48A0100]      <1> 	mov	[Current_Dir_Level], cl
  3490 0000B1AC A3[F08A0100]        <1> 	mov	[Current_Dir_FCluster], eax
  3491                              <1> 
  3492 0000B1B1 8A2D[D8920100]      <1> 	mov	ch, [Last_Dir_Level]
  3493 0000B1B7 38E9                <1> 	cmp	cl, ch 
  3494 0000B1B9 0F821DFFFFFF        <1> 	jb	loc_ccd_load_child_dir_next
  3495                              <1> 	
  3496 0000B1BF 803D[E1920100]CD    <1> 	cmp	byte [CD_COMMAND], 0CDh ;'CD' command or another
  3497 0000B1C6 741E                <1> 	je	short loc_ccd_save_current_dir
  3498                              <1> 
  3499                              <1>         ; jne -> don't save, restore (the previous cdir) later !
  3500                              <1>         ; (saving the cdir would prevent previous cdir restoration!)
  3501                              <1> 
  3502 0000B1C8 F8                  <1> 	clc
  3503                              <1> 
  3504                              <1> loc_ccd_retn_c:
  3505 0000B1C9 8B3D[D3920100]      <1> 	mov	edi, [CCD_DriveDT]
  3506 0000B1CF C3                  <1> 	retn
  3507                              <1> 
  3508                              <1> loc_ccd_load_sub_directory:
  3509 0000B1D0 8B35[D3920100]      <1> 	mov	esi, [CCD_DriveDT]
  3510 0000B1D6 803D[F58A0100]01    <1> 	cmp	byte [Current_FATType], 1
  3511 0000B1DD 73B0                <1> 	jnb	short loc_ccd_load_FAT_sub_directory 
  3512 0000B1DF E8B51D0000          <1> 	call	load_FS_sub_directory
  3513 0000B1E4 EBAE                <1> 	jmp	short pass_ccd_load_FAT_sub_directory 
  3514                              <1> 
  3515                              <1> loc_ccd_save_current_dir:
  3516                              <1> 	; 02/03/2021 (TRDOS 386 v2.0.3) ((BugFix))
  3517                              <1> 	; ('find_directory_entry' has been fixed to prevent large
  3518                              <1> 	; ECX value > 65535)
  3519                              <1> 	; 
  3520 0000B1E6 BE[53920100]        <1> 	mov	esi, PATH_Array ; 19/02/2016
  3521 0000B1EB 8B3D[D3920100]      <1> 	mov	edi, [CCD_DriveDT]
  3522 0000B1F1 57                  <1> 	push	edi
  3523 0000B1F2 83C77F              <1>         add     edi, LD_CDirLevel
  3524 0000B1F5 880F                <1> 	mov	[edi], cl
  3525 0000B1F7 47                  <1> 	inc	edi ; LD_CurrentDirectory 
  3526 0000B1F8 56                  <1> 	push	esi
  3527                              <1> 	;;mov	ecx, 32  ; always < 65536 (in this procedure)
  3528 0000B1F9 66B92000            <1> 	mov	cx, 32
  3529                              <1> 	; 02/03/2021
  3530                              <1> 	;mov	ecx, 32
  3531 0000B1FD F3A5                <1> 	rep	movsd
  3532                              <1> 	; Current directory has been saved to 
  3533                              <1> 	; the DOS drive description table, cdir area !
  3534 0000B1FF 5E                  <1> 	pop	esi  ; PATH_Array
  3535 0000B200 5F                  <1> 	pop	edi  ; Dos Drv Description Table
  3536                              <1> 
  3537 0000B201 C3                  <1> 	retn
  3538                              <1> 
  3539                              <1> parse_dir_name:
  3540                              <1> 	; 11/02/2016
  3541                              <1> 	; 10/02/2016
  3542                              <1> 	; 07/02/2016 (TRDOS 386 = TRDOS v2.0)
  3543                              <1> 	; 18/09/2011
  3544                              <1> 	; 17/10/2009
  3545                              <1> 	; INPUT ->
  3546                              <1> 	;	ESI = ASCIIZ Directory String Address
  3547                              <1> 	;	AL = Current Directory Level
  3548                              <1> 	;	EDI = Destination Adress
  3549                              <1> 	;	     (8 levels, each one 12+4 byte)
  3550                              <1> 	; OUTPUT ->
  3551                              <1> 	;	EDI = Dir Entry Formatted Array
  3552                              <1> 	;	     with zero cluster pointer at the last level
  3553                              <1> 	;	AH = Last Dir Level
  3554                              <1> 	;	AL = Current Dir Level
  3555                              <1> 	;
  3556                              <1> 	; (esi, ebx, ecx will be changed) 
  3557                              <1> 
  3558                              <1> 	;mov	[PATH_Array_Ptr], edi
  3559 0000B202 88C4                <1> 	mov	ah, al
  3560 0000B204 66A3[78930100]      <1> 	mov	[PATH_CDLevel], ax
  3561                              <1> repeat_ppdn_check_slash:
  3562 0000B20A AC                  <1> 	lodsb
  3563 0000B20B 3C2F                <1> 	cmp	al, '/'
  3564 0000B20D 74FB                <1> 	je	short repeat_ppdn_check_slash
  3565 0000B20F 3C21                <1> 	cmp	al, 21h
  3566 0000B211 7219                <1> 	jb	short loc_ppdn_retn
  3567 0000B213 57                  <1> 	push	edi
  3568                              <1> loc_ppdn_get_dir_name:
  3569 0000B214 B90C000000          <1> 	mov	ecx, 12
  3570 0000B219 BF[7A930100]        <1> 	mov	edi, Dir_File_Name
  3571                              <1> repeat_ppdn_get_dir_name:
  3572 0000B21E AA                  <1> 	stosb
  3573 0000B21F AC                  <1> 	lodsb
  3574 0000B220 3C2F                <1> 	cmp	al, '/'
  3575 0000B222 740A                <1> 	je	short loc_check_level_dot_conv_dir_name
  3576 0000B224 3C20                <1> 	cmp	al, 20h
  3577 0000B226 7605                <1> 	jna	short loc_ppdn_end_of_path_scan
  3578 0000B228 E2F4                <1> 	loop	repeat_ppdn_get_dir_name
  3579 0000B22A 5F                  <1> 	pop	edi
  3580 0000B22B F9                  <1> 	stc
  3581                              <1> loc_ppdn_retn:
  3582 0000B22C C3                  <1> 	retn
  3583                              <1> 
  3584                              <1> loc_ppdn_end_of_path_scan:
  3585 0000B22D 4E                  <1> 	dec	esi
  3586                              <1> loc_check_level_dot_conv_dir_name:
  3587 0000B22E 31C0                <1> 	xor	eax, eax
  3588 0000B230 AA                  <1> 	stosb
  3589 0000B231 89F3                <1> 	mov	ebx, esi
  3590 0000B233 BE[7A930100]        <1> 	mov	esi, Dir_File_Name
  3591 0000B238 AC                  <1> 	lodsb
  3592                              <1> repeat_ppdn_name_check_dot:
  3593 0000B239 3C2E                <1> 	cmp	al, '.'
  3594 0000B23B 7509                <1> 	jne	short loc_ppdn_convert_sub_dir_name
  3595                              <1> repeat_ppdn_name_dot_dot:
  3596 0000B23D AC                  <1> 	lodsb
  3597 0000B23E 3C2E                <1> 	cmp	al, '.'
  3598 0000B240 743E                <1> 	je	short loc_ppdn_dot_dot
  3599 0000B242 3C21                <1> 	cmp	al, 21h
  3600 0000B244 7226                <1> 	jb	short pass_ppdn_convert_sub_dir_name
  3601                              <1> loc_ppdn_convert_sub_dir_name:
  3602 0000B246 8A25[79930100]      <1> 	mov	ah, [PATH_Level]
  3603 0000B24C 80FC07              <1> 	cmp	ah, 7
  3604 0000B24F 731B                <1> 	jnb	short pass_ppdn_convert_sub_dir_name
  3605 0000B251 FEC4                <1> 	inc	ah  
  3606 0000B253 8825[79930100]      <1> 	mov	[PATH_Level], ah
  3607 0000B259 BE[7A930100]        <1> 	mov	esi, Dir_File_Name
  3608                              <1> 	;mov	edi, [PATH_Array_Ptr]
  3609 0000B25E B010                <1> 	mov	al, 16
  3610 0000B260 F6E4                <1> 	mul	ah
  3611 0000B262 8B3C24              <1> 	mov	edi, [esp]
  3612                              <1> 	;push	edi 
  3613 0000B265 01C7                <1> 	add	edi, eax
  3614 0000B267 E82B030000          <1> 	call	convert_file_name
  3615                              <1> 	;pop	edi
  3616                              <1> pass_ppdn_convert_sub_dir_name:
  3617 0000B26C 89DE                <1> 	mov	esi, ebx
  3618                              <1> repeat_ppdn_check_last_slash:
  3619 0000B26E AC                  <1> 	lodsb
  3620 0000B26F 3C2F                <1> 	cmp	al, '/'
  3621 0000B271 74FB                <1> 	je	short repeat_ppdn_check_last_slash
  3622 0000B273 3C21                <1> 	cmp	al, 21h
  3623 0000B275 739D                <1> 	jnb	short loc_ppdn_get_dir_name
  3624                              <1> end_of_parse_dir_name:
  3625 0000B277 5F                  <1> 	pop	edi
  3626 0000B278 F5                  <1> 	cmc  
  3627                              <1> 	;mov	al, [PATH_CDLevel]
  3628                              <1> 	;mov	ah, [PATH_Level]
  3629 0000B279 66A1[78930100]      <1> 	mov	ax, [PATH_CDLevel]
  3630 0000B27F C3                  <1> 	retn
  3631                              <1> 
  3632                              <1> loc_ppdn_dot_dot:
  3633 0000B280 AC                  <1> 	lodsb
  3634 0000B281 3C21                <1> 	cmp	al, 21h
  3635 0000B283 73F2                <1> 	jnb	short end_of_parse_dir_name 
  3636                              <1> loc_ppdn_dot_dot_prev_level:
  3637 0000B285 66A1[78930100]      <1> 	mov	ax, [PATH_CDLevel]
  3638 0000B28B 80EC01              <1> 	sub	ah, 1
  3639 0000B28E 80D400              <1> 	adc	ah, 0
  3640 0000B291 38E0                <1> 	cmp	al, ah
  3641 0000B293 7602                <1> 	jna	short pass_ppdn_set_al_to_ah
  3642 0000B295 88E0                <1> 	mov	al, ah
  3643                              <1> pass_ppdn_set_al_to_ah:
  3644 0000B297 66A3[78930100]      <1> 	mov	[PATH_CDLevel], ax
  3645 0000B29D EBCD                <1> 	jmp	short pass_ppdn_convert_sub_dir_name
  3646                              <1> 
  3647                              <1> locate_current_dir_file:
  3648                              <1> 	; 20/11/2017
  3649                              <1> 	; 14/02/2016
  3650                              <1> 	; 13/02/2016
  3651                              <1> 	; 10/02/2016
  3652                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
  3653                              <1> 	; 14/08/2010
  3654                              <1> 	; 19/09/2009
  3655                              <1>         ; 2005
  3656                              <1> 	; INPUT ->
  3657                              <1> 	;	ESI = DOS DirEntry Format FileName Address
  3658                              <1> 	;	AL = Attributes Mask 
  3659                              <1> 	;	(<AL AND EntryAttrib> must be equal to AL)
  3660                              <1> 	;	AH = Negative Attributes Mask (If AH>0)
  3661                              <1> 	;	(<AH AND EntryAttrib> must be ZERO)
  3662                              <1> 	;	CH > 0 Find First Free Dir Entry or Deleted Entry
  3663                              <1> 	;	CL = 0 -> Return the First Free Dir Entry
  3664                              <1> 	;	CL = E5h -> Return the 1st deleted entry
  3665                              <1> 	;	CL = FFh -> Return the 1st deleted or free entry
  3666                              <1> 	;	CL > 0 and CL <> E5h and CL <> FFh -> Return the first 
  3667                              <1> 	;	     proper entry (which fits with Atributes Masks)
  3668                              <1> 	;	CX = 0 Find Valid File/Directory/VolumeName
  3669                              <1> 	;	? = Any One Char
  3670                              <1> 	;	* = Every Chars
  3671                              <1> 	; OUTPUT ->
  3672                              <1> 	;	EDI = Directory Entry Address (in Directory Buffer)
  3673                              <1> 	;	ESI = DOS DirEntry Format FileName Address
  3674                              <1> 	;	CF = 0 -> No Error, Proper Entry,
  3675                              <1> 	;	DL = Attributes
  3676                              <1> 	;	DH = Previous Entry Attr (LongName Check)
  3677                              <1> 	;	AL > 0 -> Ambiguous filename wildcard "?" used
  3678                              <1> 	;	AH > 0 -> Ambiguous filename wildcard "*" used
  3679                              <1> 	;	AX = 0 -> Filename full fits with directory entry
  3680                              <1> 	;	CH = The 1st Name Char of Current Dir Entry
  3681                              <1> 	;	CF = 1 -> Proper entry not found, Error Code in EAX/AL
  3682                              <1> 	;	CL = 0 and CH = 0 -> Free Entry (End Of Dir)
  3683                              <1> 	;	CL = 0 and CH = E5h -> Deleted Entry fits with filters
  3684                              <1> 	;	CL > 0 -> Entry not found, CH invalid
  3685                              <1> 	;	CF = 0 -> 
  3686                              <1> 	;	EBX = Current Directory Entry Index/Number (BX)
  3687                              <1> 
  3688                              <1> 	;mov	word [DirBuff_EntryCounter], 0 ; Zero Based
  3689                              <1> 
  3690 0000B29F 8935[DB920100]      <1> 	mov	[CDLF_FNAddress], esi
  3691 0000B2A5 66A3[D9920100]      <1> 	mov	[CDLF_AttributesMask], ax
  3692 0000B2AB 66890D[DF920100]    <1> 	mov	[CDLF_DEType], cx
  3693                              <1> 
  3694 0000B2B2 31DB                <1> 	xor	ebx, ebx
  3695 0000B2B4 881D[F0920100]      <1> 	mov	[PreviousAttr], bl ; 0  ; 13/02/2016
  3696                              <1> 
  3697 0000B2BA 8A3D[F68A0100]      <1> 	mov	bh, [Current_Drv]
  3698 0000B2C0 381D[1C920100]      <1> 	cmp	byte [DirBuff_ValidData], bl ; 0
  3699 0000B2C6 761D                <1> 	jna	short loc_lcdf_reload_current_dir2
  3700 0000B2C8 8A1D[1A920100]      <1>         mov     bl, [DirBuff_DRV]
  3701 0000B2CE 80EB41              <1> 	sub	bl, 'A'
  3702 0000B2D1 38DF                <1> 	cmp	bh, bl
  3703 0000B2D3 750E                <1> 	jne	short loc_lcdf_reload_current_dir1
  3704 0000B2D5 8B15[21920100]      <1> 	mov	edx, [DirBuff_Cluster]
  3705 0000B2DB 3B15[F08A0100]      <1> 	cmp	edx, [Current_Dir_FCluster]
  3706 0000B2E1 7412                <1> 	je	short loc_cdir_locatefile_search
  3707                              <1> 
  3708                              <1> loc_lcdf_reload_current_dir1:
  3709 0000B2E3 30DB                <1> 	xor	bl, bl
  3710                              <1> loc_lcdf_reload_current_dir2:
  3711 0000B2E5 89DE                <1> 	mov	esi, ebx
  3712 0000B2E7 81C600010900        <1>         add     esi, Logical_DOSDisks
  3713 0000B2ED E874000000          <1> 	call	reload_current_directory 
  3714 0000B2F2 735D                <1> 	jnc	short loc_locatefile_search_again 
  3715 0000B2F4 C3                  <1> 	retn  
  3716                              <1> 
  3717                              <1> loc_cdir_locatefile_search:
  3718 0000B2F5 31DB                <1> 	xor	ebx, ebx
  3719 0000B2F7 55                  <1> 	push	ebp ; 20/11/2017
  3720 0000B2F8 E8A6000000          <1> 	call	find_directory_entry
  3721 0000B2FD 5D                  <1> 	pop	ebp ; 20/11/2017
  3722 0000B2FE 7349                <1> 	jnc	short loc_cdir_locate_file_retn
  3723                              <1> 
  3724                              <1> loc_locatefile_check_stc_reason:
  3725 0000B300 08ED                <1> 	or	ch, ch
  3726 0000B302 7444                <1> 	jz	short loc_cdir_locate_file_stc_retn
  3727                              <1> 
  3728                              <1> loc_locatefile_check_next_entryblock:
  3729 0000B304 8A3D[F68A0100]      <1> 	mov	bh, [Current_Drv]
  3730 0000B30A 28DB                <1> 	sub	bl, bl
  3731 0000B30C 0FB7F3              <1> 	movzx	esi, bx
  3732 0000B30F 81C600010900        <1>         add     esi, Logical_DOSDisks
  3733                              <1> 
  3734 0000B315 803D[F48A0100]00    <1> 	cmp	byte [Current_Dir_Level], 0
  3735 0000B31C 760A                <1> 	jna	short loc_locatefile_check_FAT_type
  3736                              <1>             
  3737 0000B31E 803D[F58A0100]01    <1> 	cmp	byte [Current_FATType], 1
  3738 0000B325 730A                <1> 	jnb	short loc_locatefile_load_subdir_cluster
  3739 0000B327 C3                  <1> 	retn  
  3740                              <1> 
  3741                              <1> loc_locatefile_check_FAT_type:
  3742 0000B328 803D[F58A0100]03    <1> 	cmp	byte [Current_FATType], 3
  3743 0000B32F 7218                <1> 	jb	short loc_cdir_locate_file_retn
  3744                              <1> 
  3745                              <1> loc_locatefile_load_subdir_cluster:
  3746 0000B331 A1[21920100]        <1> 	mov	eax, [DirBuff_Cluster]
  3747 0000B336 E83B1A0000          <1> 	call	get_next_cluster
  3748 0000B33B 730D                <1> 	jnc	short loc_locatefile_next_cluster
  3749 0000B33D 09C0                <1> 	or	eax, eax
  3750 0000B33F 7507                <1> 	jnz	short loc_locatefile_drive_not_ready_read_err
  3751 0000B341 F9                  <1> 	stc
  3752                              <1> loc_locatefile_file_notfound:
  3753 0000B342 B802000000          <1> 	mov	eax, 2 ; File/Directory/VolName not found
  3754 0000B347 C3                  <1> 	retn
  3755                              <1> 
  3756                              <1> loc_locatefile_drive_not_ready_read_err:
  3757                              <1> 	;mov	eax, 17 ;Drive not ready or read error
  3758                              <1> loc_cdir_locate_file_stc_retn:
  3759 0000B348 F5                  <1> 	cmc ;stc
  3760                              <1> loc_cdir_locate_file_retn:
  3761 0000B349 C3                  <1> 	retn
  3762                              <1> 
  3763                              <1> loc_locatefile_next_cluster:
  3764 0000B34A E80D1C0000          <1> 	call	load_FAT_sub_directory
  3765                              <1> 	;jc	short loc_locatefile_drive_not_ready_read_err
  3766 0000B34F 72F8                <1> 	jc	short loc_cdir_locate_file_retn 
  3767                              <1> 
  3768                              <1> loc_locatefile_search_again:
  3769 0000B351 8B35[DB920100]      <1> 	mov	esi, [CDLF_FNAddress] 
  3770 0000B357 66A1[D9920100]      <1> 	mov	ax, [CDLF_AttributesMask]
  3771 0000B35D 668B0D[DF920100]    <1> 	mov	cx, [CDLF_DEType] 
  3772 0000B364 EB8F                <1> 	jmp	short loc_cdir_locatefile_search
  3773                              <1> 
  3774                              <1> reload_current_directory:
  3775                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
  3776                              <1> 	; 13/06/2010
  3777                              <1> 	; 22/09/2009
  3778                              <1>         ;
  3779                              <1> 	; INPUT ->
  3780                              <1> 	;	ESI = Dos drive description table address
  3781                              <1> 	
  3782                              <1> 	;mov	al, [esi+LD_FATType]
  3783 0000B366 A0[F58A0100]        <1> 	mov	al, [Current_FATType]
  3784 0000B36B 3C02                <1> 	cmp	al, 2
  3785 0000B36D 7729                <1> 	ja	short loc_reload_FAT_sub_directory
  3786 0000B36F 8A25[F48A0100]      <1> 	mov	ah, [Current_Dir_Level]
  3787 0000B375 08C0                <1> 	or	al, al
  3788 0000B377 740A                <1> 	jz	short loc_reload_FS_directory
  3789 0000B379 08E4                <1> 	or	ah, ah
  3790 0000B37B 751B                <1> 	jnz	short loc_reload_FAT_sub_directory
  3791                              <1> loc_reload_FAT_12_16_root_directory:
  3792 0000B37D E84F1B0000          <1> 	call	load_FAT_root_directory
  3793 0000B382 C3                  <1> 	retn
  3794                              <1> loc_reload_FS_directory:
  3795 0000B383 20E4                <1> 	and	ah, ah
  3796 0000B385 7506                <1> 	jnz	short loc_reload_FS_sub_directory 
  3797                              <1> loc_reload_FS_root_directory: 
  3798 0000B387 E80C1C0000          <1> 	call	load_FS_root_directory
  3799 0000B38C C3                  <1> 	retn
  3800                              <1> loc_reload_FS_sub_directory:
  3801 0000B38D A1[F08A0100]        <1> 	mov	eax, [Current_Dir_FCluster]
  3802 0000B392 E8021C0000          <1> 	call	load_FS_sub_directory
  3803 0000B397 C3                  <1> 	retn 
  3804                              <1> loc_reload_FAT_sub_directory:
  3805 0000B398 A1[F08A0100]        <1> 	mov	eax, [Current_Dir_FCluster]
  3806 0000B39D E8BA1B0000          <1> 	call	load_FAT_sub_directory
  3807 0000B3A2 C3                  <1> 	retn
  3808                              <1> 
  3809                              <1> find_directory_entry:
  3810                              <1> 	; 02/03/2021 (TRDOS 386 v2.0.3) ((BugFix))
  3811                              <1> 	; 14/02/2016
  3812                              <1> 	; 13/02/2016
  3813                              <1> 	; 10/02/2016
  3814                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
  3815                              <1> 	; 14/08/2010 (DIR.ASM, "proc_find_direntry")
  3816                              <1> 	; 19/09/2009
  3817                              <1> 	; 2005
  3818                              <1> 	; INPUT ->
  3819                              <1> 	;	ESI = Sub Dir or File Name Address
  3820                              <1> 	;	AL = Attributes Mask 
  3821                              <1> 	;	(<AL AND EntryAttrib> must be equal to AL)
  3822                              <1> 	;	AH = Negative Attributes Mask (If AH>0)
  3823                              <1> 	;	(<AH AND EntryAttrib> must be ZERO)
  3824                              <1> 	;	CH > 0 Find First Free Dir Entry or Deleted Entry
  3825                              <1> 	;	CL = 0 -> Return the First Free Dir Entry
  3826                              <1> 	;	CL = E5h -> Return the 1st deleted entry
  3827                              <1> 	;	CL = FFh -> Return the 1st deleted or free entry
  3828                              <1> 	;	CL > 0 and CL <> E5h and CL <> FFh -> Return the first 
  3829                              <1> 	;            proper entry (which fits with Atributes Masks)
  3830                              <1> 	;	CX = 0 -> Find Valid File/Directory/VolumeName
  3831                              <1> 	;	? = Any One Char
  3832                              <1> 	;	* = Every Chars
  3833                              <1> 	;	EBX = Current Dir Entry (BX)
  3834                              <1> 	;
  3835                              <1> 	; OUTPUT -> 
  3836                              <1> 	;	EDI = Directory Entry Address (in DirectoryBuffer)
  3837                              <1> 	;	ESI = Sub Dir or File Name Address
  3838                              <1> 	;	CF = 0 -> No Error, Proper Entry,
  3839                              <1> 	;	DL = Attributes
  3840                              <1> 	;	DH = Previous Entry Attr (LongName Check)
  3841                              <1> 	;	AL > 0 -> Ambiguous filename wildcard "?" used
  3842                              <1> 	;	AH > 0 -> Ambiguous filename wildcard "*" used
  3843                              <1> 	;	AX = 0 -> Filename full fits with directory entry
  3844                              <1> 	;	EBX = CurrentDirEntry (BX)
  3845                              <1> 	;	CH = The 1st Name Char of Current Dir Entry
  3846                              <1> 	;	CF = 1 -> Proper entry not found, Error Code in AX/AL
  3847                              <1> 	;	CL = 0 and CH = 0 -> Free Entry (End Of Dir)
  3848                              <1> 	;	CL = 0 and CH = E5h -> Deleted Entry fits with filters
  3849                              <1> 	;	CL > 0 -> Entry not found, CH invalid
  3850                              <1> 	;
  3851                              <1> 	; (EAX, EBX, ECX, EDX, EDI, EBP will be changed)	 
  3852                              <1> 
  3853 0000B3A3 663B1D[1F920100]    <1> 	cmp	bx, [DirBuff_LastEntry]
  3854 0000B3AA 0F8739010000        <1>         ja      loc_ffde_stc_retn_255
  3855                              <1> 
  3856                              <1> 	;mov    [DirBuff_CurrentEntry], bx  
  3857                              <1> 
  3858 0000B3B0 BF00000800          <1>   	mov	edi, Directory_Buffer
  3859 0000B3B5 66A3[EC920100]      <1> 	mov	[FDE_AttrMask], ax
  3860                              <1> 
  3861 0000B3BB 29C0                <1> 	sub	eax, eax
  3862                              <1>             
  3863                              <1> 	;;mov	[PreviousAttr], al ; 0 ;; 13/02/2016
  3864 0000B3BD 66A3[EE920100]      <1> 	mov	[AmbiguousFileName], ax ; 0
  3865                              <1> 
  3866 0000B3C3 6689D8              <1> 	mov	ax, bx
  3867 0000B3C6 66C1E005            <1> 	shl	ax, 5 ; ; * 32 ; Directory entry size
  3868 0000B3CA 01C7                <1> 	add     edi, eax
  3869                              <1> 
  3870 0000B3CC 08ED                <1> 	or	ch, ch
  3871 0000B3CE 0F852D010000        <1>         jnz     loc_find_free_deleted_entry_0
  3872                              <1> 
  3873 0000B3D4 08C9                <1> 	or      cl, cl
  3874 0000B3D6 0F850D010000        <1>         jnz     loc_ffde_stc_retn_255
  3875                              <1>  
  3876                              <1> check_find_dir_entry:
  3877 0000B3DC 66A1[EC920100]      <1> 	mov	ax, [FDE_AttrMask]
  3878 0000B3E2 8A2F                <1> 	mov	ch, [edi]
  3879 0000B3E4 80FD00              <1> 	cmp     ch, 0 ; Is it never used entry?
  3880 0000B3E7 0F8600010000        <1> 	jna	loc_find_direntry_stc_retn 
  3881 0000B3ED 56                  <1> 	push	esi
  3882 0000B3EE 8A570B              <1> 	mov	dl, [edi+0Bh] ; File attributes
  3883 0000B3F1 80FDE5              <1> 	cmp	ch, 0E5h ; Is it a deleted file?
  3884 0000B3F4 746D                <1> 	je	short loc_find_dir_next_entry_prevdeleted
  3885                              <1> 
  3886 0000B3F6 80FA0F              <1> 	cmp     dl, 0Fh ; longname sub component check
  3887 0000B3F9 7505                <1> 	jne     short loc_check_attributes_mask
  3888 0000B3FB E8EE010000          <1> 	call	save_longname_sub_component
  3889                              <1> 
  3890                              <1> loc_check_attributes_mask:
  3891 0000B400 88C6                <1> 	mov	dh, al
  3892 0000B402 20D6                <1> 	and	dh, dl    
  3893 0000B404 38F0                <1> 	cmp	al, dh
  3894 0000B406 0F85BA000000        <1>         jne     loc_find_dir_next_entry
  3895 0000B40C 20D4                <1> 	and	ah, dl
  3896 0000B40E 0F85B2000000        <1>         jnz     loc_find_dir_next_entry
  3897 0000B414 80FA0F              <1> 	cmp	dl, 0Fh
  3898 0000B417 751A                <1> 	jne	short pass_direntry_attr_check
  3899                              <1> 
  3900 0000B419 3C0F                <1> 	cmp	al, 0Fh ; AL = 0Fh -> find long name
  3901 0000B41B 0F85A5000000        <1>         jne     loc_find_dir_next_entry
  3902                              <1> 
  3903 0000B421 5E                  <1> 	pop	esi
  3904 0000B422 6631C0              <1> 	xor	ax, ax
  3905 0000B425 8A35[F0920100]      <1> 	mov	dh, [PreviousAttr]
  3906 0000B42B 66891D[1D920100]    <1> 	mov	[DirBuff_CurrentEntry], bx
  3907 0000B432 C3                  <1> 	retn
  3908                              <1> 
  3909                              <1> pass_direntry_attr_check:
  3910 0000B433 89FD                <1> 	mov	ebp, edi ; 14/02/2016
  3911 0000B435 B908000000          <1> 	mov	ecx, 8
  3912                              <1> loc_lodsb_find_dir:
  3913 0000B43A AC                  <1> 	lodsb
  3914 0000B43B 3C2A                <1> 	cmp	al, '*'
  3915 0000B43D 7508                <1> 	jne	short pass_fde_ambiguous1_check
  3916 0000B43F FE05[EF920100]      <1>         inc     byte [AmbiguousFileName+1]
  3917 0000B445 EB28                <1> 	jmp	short loc_check_direntry_extension
  3918                              <1> 
  3919                              <1> pass_fde_ambiguous1_check:
  3920 0000B447 3C3F                <1> 	cmp	al, '?'
  3921 0000B449 750D                <1> 	jne	short pass_fde_ambiguous2_check
  3922 0000B44B FE05[EE920100]      <1> 	inc	byte [AmbiguousFileName]
  3923 0000B451 803F20              <1> 	cmp	byte [edi], 20h
  3924 0000B454 764E                <1> 	jna	short loc_find_dir_next_entry_ebp
  3925 0000B456 EB14                <1> 	jmp	short loc_scasb_find_dir_inc_di
  3926                              <1> 
  3927                              <1> pass_fde_ambiguous2_check:
  3928 0000B458 3C20                <1> 	cmp	al, 20h
  3929 0000B45A 750C                <1> 	jne	short loc_scasb_find_dir
  3930 0000B45C 803F20              <1> 	cmp	byte [edi], 20h
  3931 0000B45F 7543                <1> 	jne	short loc_find_dir_next_entry_ebp
  3932 0000B461 EB0C                <1> 	jmp	short loc_check_direntry_extension
  3933                              <1> 
  3934                              <1> loc_find_dir_next_entry_prevdeleted:
  3935 0000B463 80CA80              <1> 	or	dl, 80h  ; Bit 7 -> deleted entry sign
  3936 0000B466 EB5E                <1> 	jmp	short loc_find_dir_next_entry
  3937                              <1> 
  3938                              <1> loc_scasb_find_dir:
  3939 0000B468 3A07                <1> 	cmp	al, [edi]
  3940 0000B46A 7538                <1> 	jne	short loc_find_dir_next_entry_ebp
  3941                              <1> loc_scasb_find_dir_inc_di:
  3942 0000B46C 47                  <1> 	inc	edi
  3943 0000B46D E2CB                <1> 	loop	loc_lodsb_find_dir
  3944                              <1> 
  3945                              <1> loc_check_direntry_extension:
  3946 0000B46F BE08000000          <1> 	mov	esi, 8
  3947 0000B474 89F7                <1> 	mov	edi, esi ; 8
  3948 0000B476 033424              <1> 	add	esi, [esp] ; Sub Dir or File Name Address
  3949 0000B479 01EF                <1> 	add	edi, ebp
  3950 0000B47B B103                <1> 	mov	cl, 3
  3951                              <1> loc_lodsb_find_dir_ext:
  3952 0000B47D AC                  <1> 	lodsb
  3953 0000B47E 3C2A                <1> 	cmp	al, '*'
  3954 0000B480 7508                <1> 	jne	short pass_fde_ambiguous3_check
  3955 0000B482 FE05[EF920100]      <1> 	inc	byte [AmbiguousFileName+1]
  3956 0000B488 EB1E                <1> 	jmp	short loc_find_dir_proper_direntry
  3957                              <1> 
  3958                              <1> pass_fde_ambiguous3_check:
  3959 0000B48A 3C3F                <1> 	cmp	al, '?'
  3960 0000B48C 750D                <1> 	jne	short pass_fde_ambiguous4_check
  3961 0000B48E FE05[EE920100]      <1> 	inc	byte [AmbiguousFileName]
  3962 0000B494 803F20              <1> 	cmp	byte [edi], 20h
  3963 0000B497 760B                <1> 	jna	short loc_find_dir_next_entry_ebp
  3964 0000B499 EB49                <1> 	jmp	short loc_scasb_find_dir_ext_inc_di
  3965                              <1> 
  3966                              <1> pass_fde_ambiguous4_check:
  3967 0000B49B 3C20                <1> 	cmp	al, 20h
  3968 0000B49D 7541                <1> 	jne	short loc_scasb_find_dir_ext
  3969 0000B49F 803F20              <1> 	cmp	byte [edi], 20h
  3970 0000B4A2 7404                <1> 	je	short loc_find_dir_proper_direntry
  3971                              <1> 
  3972                              <1> loc_find_dir_next_entry_ebp:
  3973 0000B4A4 89EF                <1> 	mov	edi, ebp ; 14/02/2016
  3974 0000B4A6 EB1E                <1> 	jmp	short loc_find_dir_next_entry
  3975                              <1> 
  3976                              <1> loc_find_dir_proper_direntry:
  3977 0000B4A8 30C9                <1> 	xor	cl, cl
  3978                              <1> loc_find_dir_proper_direntry_1:
  3979 0000B4AA 5E                  <1> 	pop	esi
  3980 0000B4AB 89EF                <1>         mov     edi, ebp
  3981 0000B4AD 8A2F                <1> 	mov	ch, [edi]
  3982 0000B4AF 8A570B              <1> 	mov     dl, [edi+0Bh] ; Dir entry attributes
  3983 0000B4B2 66A1[EE920100]      <1> 	mov	ax, [AmbiguousFileName]
  3984                              <1> loc_find_dir_proper_direntry_2:
  3985 0000B4B8 8A35[F0920100]      <1> 	mov     dh, [PreviousAttr]
  3986 0000B4BE 66891D[1D920100]    <1> 	mov	[DirBuff_CurrentEntry], bx
  3987 0000B4C5 C3                  <1> 	retn
  3988                              <1> 
  3989                              <1> loc_find_dir_next_entry:
  3990 0000B4C6 8815[F0920100]      <1> 	mov	byte [PreviousAttr], dl ; LongName check
  3991                              <1> loc_find_dir_next_entry_1:
  3992 0000B4CC 5E                  <1> 	pop	esi
  3993 0000B4CD 83C720              <1> 	add	edi, 32
  3994                              <1> 	;inc	word [DirBuff_EntryCounter]
  3995 0000B4D0 6643                <1> 	inc	bx
  3996 0000B4D2 663B1D[1F920100]    <1> 	cmp	bx, [DirBuff_LastEntry]
  3997 0000B4D9 770E                <1> 	ja	short loc_ffde_stc_retn_255
  3998 0000B4DB E9FCFEFFFF          <1>         jmp     check_find_dir_entry 
  3999                              <1> 
  4000                              <1> loc_scasb_find_dir_ext:
  4001 0000B4E0 3A07                <1> 	cmp	al, [edi]
  4002 0000B4E2 75C0                <1> 	jne	short loc_find_dir_next_entry_ebp
  4003                              <1> loc_scasb_find_dir_ext_inc_di:
  4004 0000B4E4 47                  <1> 	inc	edi
  4005 0000B4E5 E296                <1> 	loop    loc_lodsb_find_dir_ext
  4006 0000B4E7 EBC1                <1> 	jmp	short loc_find_dir_proper_direntry_1
  4007                              <1> 
  4008                              <1> loc_ffde_stc_retn_255:
  4009                              <1> 	; 02/03/2021 (TRDOS 386 v2.0.3) ((BugFix))
  4010                              <1> 	; (ECX must not be > 65535)
  4011                              <1> 	; ((because 'loc_ccd_save_current_dir'
  4012                              <1> 	;  sets CX to 32 for 'rep movsd')) 
  4013 0000B4E9 66B9FFFF            <1> 	mov	cx, 0FFFFh
  4014                              <1> 	;xor	ecx, ecx
  4015                              <1> 	;dec	ecx ; 0FFFFFFFFh
  4016                              <1> 	;xor	eax, eax
  4017                              <1> loc_find_direntry_stc_retn:
  4018                              <1> loc_check_ffde_retn_1:
  4019                              <1> 	;mov	ax, 2
  4020 0000B4ED B802000000          <1> 	mov	eax, 2 ; File Not Found
  4021 0000B4F2 8A35[F0920100]      <1> 	mov	dh, [PreviousAttr]
  4022 0000B4F8 66891D[1D920100]    <1> 	mov	[DirBuff_CurrentEntry], bx
  4023 0000B4FF F9                  <1> 	stc
  4024 0000B500 C3                  <1> 	retn
  4025                              <1> 
  4026                              <1> loc_find_free_deleted_entry_0:
  4027 0000B501 66A1[EC920100]      <1> 	mov	ax, [FDE_AttrMask]
  4028 0000B507 8A2F                <1> 	mov	ch, [edi]
  4029 0000B509 8A570B              <1> 	mov	dl, [edi+0Bh] ; File attributes
  4030 0000B50C 08C9                <1> 	or	cl, cl 
  4031 0000B50E 7407                <1> 	jz	short loc_check_ffde_0_repeat
  4032                              <1> 	;cmp	cl, 0E5h
  4033                              <1> 	;je	short pass_loc_check_ffde_0_err
  4034 0000B510 80F9FF              <1> 	cmp	cl, 0FFh
  4035 0000B513 7432                <1> 	je	short loc_find_free_deleted_entry_1
  4036 0000B515 EB4D                <1> 	jmp	short pass_loc_check_ffde_0_err
  4037                              <1> 
  4038                              <1> loc_check_ffde_0_repeat:
  4039 0000B517 08ED                <1> 	or	ch, ch
  4040 0000B519 7511                <1> 	jnz	short loc_check_ffde_0_next
  4041                              <1> 
  4042                              <1> loc_check_ffde_retn_2:
  4043 0000B51B 6629C0              <1> 	sub	ax, ax
  4044 0000B51E 8A35[F0920100]      <1> 	mov	dh, [PreviousAttr]
  4045 0000B524 66891D[1D920100]    <1> 	mov	[DirBuff_CurrentEntry], bx
  4046 0000B52B C3                  <1> 	retn
  4047                              <1>  
  4048                              <1> loc_check_ffde_0_next:
  4049 0000B52C 6643                <1> 	inc	bx
  4050 0000B52E 83C720              <1> 	add	edi, 32
  4051                              <1> 	;inc	word [DirBuff_EntryCounter]
  4052                              <1> 	 
  4053 0000B531 663B1D[1F920100]    <1>         cmp	bx, [DirBuff_LastEntry]
  4054 0000B538 77AF                <1> 	ja	short loc_ffde_stc_retn_255
  4055 0000B53A 8815[F0920100]      <1> 	mov	[PreviousAttr], dl
  4056 0000B540 8A2F                <1> 	mov	ch, [edi]
  4057 0000B542 8A570B              <1> 	mov	dl, [edi+0Bh] ; file attributes
  4058 0000B545 EBD0                <1> 	jmp	short loc_check_ffde_0_repeat
  4059                              <1> 
  4060                              <1> loc_find_free_deleted_entry_1:
  4061 0000B547 28D2                <1> 	sub	dl, dl      
  4062                              <1> loc_find_free_deleted_entry_2:
  4063 0000B549 20ED                <1> 	and	ch, ch  
  4064 0000B54B 74CE                <1> 	jz	short loc_check_ffde_retn_2
  4065 0000B54D 80FDE5              <1> 	cmp	ch, 0E5h
  4066 0000B550 74C9                <1> 	je	short loc_check_ffde_retn_2
  4067 0000B552 6643                <1> 	inc	bx
  4068 0000B554 83C720              <1> 	add	edi, 32
  4069 0000B557 663B1D[1F920100]    <1> 	cmp	bx, [DirBuff_LastEntry]
  4070 0000B55E 7789                <1> 	ja	short loc_ffde_stc_retn_255
  4071 0000B560 8A2F                <1> 	mov	ch, [edi]
  4072 0000B562 EBE5                <1> 	jmp	short loc_find_free_deleted_entry_2
  4073                              <1> 
  4074                              <1> pass_loc_check_ffde_0_err:
  4075 0000B564 38CD                <1> 	cmp	ch, cl
  4076 0000B566 741F                <1> 	je	short loc_check_ffde_attrib 
  4077                              <1> 
  4078 0000B568 6643                <1> 	inc	bx
  4079 0000B56A 83C720              <1> 	add	edi, 32
  4080 0000B56D 663B1D[1F920100]    <1> 	cmp	bx, [DirBuff_LastEntry]
  4081 0000B574 0F876FFFFFFF        <1>         ja      loc_ffde_stc_retn_255
  4082 0000B57A 8815[F0920100]      <1> 	mov	[PreviousAttr], dl
  4083 0000B580 8A2F                <1> 	mov	ch, [edi]
  4084 0000B582 8A570B              <1> 	mov	dl, [edi+0Bh]
  4085 0000B585 EBDD                <1> 	jmp	short pass_loc_check_ffde_0_err
  4086                              <1> 
  4087                              <1> loc_check_ffde_attrib:
  4088 0000B587 88C6                <1> 	mov	dh, al
  4089 0000B589 20D6                <1> 	and	dh, dl    
  4090 0000B58B 38F0                <1> 	cmp	al, dh
  4091 0000B58D 759D                <1> 	jne	short loc_check_ffde_0_next
  4092 0000B58F 20D4                <1> 	and	ah, dl
  4093 0000B591 7599                <1> 	jnz	short loc_check_ffde_0_next
  4094 0000B593 30C9                <1> 	xor	cl, cl 
  4095 0000B595 EB84                <1>         jmp     loc_check_ffde_retn_2
  4096                              <1> 
  4097                              <1> convert_file_name:
  4098                              <1> 	; 06/03/2016
  4099                              <1> 	; 11/02/2016
  4100                              <1> 	; 07/02/2016 (TRDOS 386 = TRDOS v2.0)
  4101                              <1> 	; 06/10/2009
  4102                              <1> 	; 2005
  4103                              <1> 	;
  4104                              <1> 	; INPUT  ->
  4105                              <1> 	;	ESI = Dot File Name Location
  4106                              <1> 	;	EDI = Dir Entry Format File Name Location
  4107                              <1> 	; OUTPUT ->
  4108                              <1> 	;	EDI = Dir Entry Format File Name Location
  4109                              <1> 	;	ESI = Dot File Name Location (capitalized)
  4110                              <1> 	;
  4111                              <1> 	; (ECX, AL will be changed) 
  4112                              <1>      
  4113 0000B597 56                  <1> 	push	esi  
  4114 0000B598 57                  <1> 	push	edi
  4115                              <1> 
  4116 0000B599 B90B000000          <1> 	mov	ecx, 11
  4117 0000B59E B020                <1> 	mov	al, 20h
  4118 0000B5A0 F3AA                <1> 	rep	stosb
  4119                              <1> 
  4120 0000B5A2 8B3C24              <1> 	mov	edi, [esp]
  4121                              <1> 
  4122 0000B5A5 B10C                <1> 	mov	cl, 12 ; file name length (max.)
  4123                              <1> 	; 06/03/2016
  4124                              <1> 	; Directory entry name limit (11 bytes) check for
  4125                              <1> 	; 'rename_directory_entry' procedure.
  4126                              <1> 	; (EDI points to Directory Entry)
  4127                              <1> 	; (If the file name would not contain a dot
  4128                              <1> 	; and file name length would be 12, this would cause to
  4129                              <1> 	; overwrite the attributes byte of the directory entry.)
  4130                              <1> 	;
  4131 0000B5A7 B50B                <1> 	mov	ch, 11 ; directory entry's name length
  4132                              <1> loc_check_first_dot:
  4133 0000B5A9 8A06                <1> 	mov	al, [esi]
  4134 0000B5AB 3C2E                <1> 	cmp	al, 2Eh
  4135 0000B5AD 750C                <1> 	jne	short pass_check_first_dot
  4136 0000B5AF 8807                <1> 	mov	[edi], al
  4137 0000B5B1 47                  <1> 	inc	edi
  4138 0000B5B2 46                  <1> 	inc	esi
  4139 0000B5B3 FEC9                <1> 	dec	cl
  4140 0000B5B5 75F2                <1> 	jnz	short loc_check_first_dot
  4141                              <1> 	;;(ecx <= 12)
  4142                              <1> 	;;loop	loc_check_first_dot 
  4143 0000B5B7 EB30                <1> 	jmp	short stop_convert_file
  4144                              <1> 
  4145                              <1> loc_get_fchar:
  4146 0000B5B9 8A06                <1> 	mov	al, [esi]
  4147                              <1> pass_check_first_dot:
  4148 0000B5BB 3C61                <1> 	cmp	al, 61h ; 'a'
  4149 0000B5BD 7208                <1> 	jb	short pass_name_capitalize
  4150 0000B5BF 3C7A                <1> 	cmp	al, 7Ah ; 'z'
  4151 0000B5C1 7704                <1> 	ja	short pass_name_capitalize
  4152 0000B5C3 24DF                <1> 	and	al, 0DFh
  4153 0000B5C5 8806                <1> 	mov	[esi], al
  4154                              <1> pass_name_capitalize:
  4155 0000B5C7 3C21                <1> 	cmp	al, 21h
  4156 0000B5C9 721E                <1> 	jb	short stop_convert_file
  4157 0000B5CB 3C2E                <1> 	cmp	al, 2Eh ; '.'
  4158 0000B5CD 750C                <1> 	jne	short pass_dot_space
  4159                              <1> add_dot_space: 
  4160 0000B5CF 80F904              <1> 	cmp	cl, 4
  4161 0000B5D2 760E                <1> 	jna	short inc_and_loop
  4162 0000B5D4 47                  <1> 	inc	edi
  4163 0000B5D5 FECD                <1> 	dec	ch ; 06/03/2016
  4164 0000B5D7 FEC9                <1> 	dec	cl
  4165 0000B5D9 EBF4                <1> 	jmp	short add_dot_space
  4166                              <1> 	
  4167                              <1> 	;mov	al, 4
  4168                              <1> 	;cmp	cl, al
  4169                              <1> 	;jna	short inc_and_loop
  4170                              <1> 	;sub	cl, al
  4171                              <1> 	;add	edi, ecx
  4172                              <1> 	;mov	cl, al
  4173                              <1> 	;jmp	short inc_and_loop	
  4174                              <1> 
  4175                              <1> pass_dot_space:
  4176 0000B5DB 8807                <1> 	mov	[edi], al
  4177                              <1> loc_after_double_dot:
  4178                              <1> 	; 06/03/2016
  4179 0000B5DD FECD                <1> 	dec	ch ; count down for 11 bytes dir entry limit
  4180 0000B5DF 740A                <1> 	jz	short stop_convert_file_x
  4181 0000B5E1 47                  <1> 	inc	edi
  4182                              <1> inc_and_loop:
  4183 0000B5E2 FEC9                <1> 	dec	cl ; count down for 12 bytes filename limit 
  4184 0000B5E4 7403                <1> 	jz	short stop_convert_file	
  4185 0000B5E6 46                  <1> 	inc	esi
  4186                              <1> 	;;(ecx <= 12)
  4187                              <1> 	;;loop	loc_get_fchar
  4188 0000B5E7 EBD0                <1> 	jmp	short loc_get_fchar
  4189                              <1> 
  4190                              <1> stop_convert_file:
  4191                              <1> 	; 06/03/2016
  4192 0000B5E9 30ED                <1> 	xor	ch, ch
  4193                              <1> 	; ECX < 256 ; 'find_first_file' -> xor cl, cl
  4194                              <1> stop_convert_file_x:
  4195 0000B5EB 5F                  <1> 	pop	edi
  4196 0000B5EC 5E                  <1> 	pop	esi
  4197 0000B5ED C3                  <1> 	retn
  4198                              <1>  
  4199                              <1> save_longname_sub_component:
  4200                              <1> 	; 13/02/2016
  4201                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
  4202                              <1> 	; 28/02/2010
  4203                              <1> 	; 17/10/2009
  4204                              <1> 	; INPUT ->
  4205                              <1> 	;	EDI = Directory Entry    
  4206                              <1> 	;     	// This procedure is called
  4207                              <1> 	;	// from 'find_directory_entry' procedure.
  4208                              <1> 	;	// If the last entry returns with
  4209                              <1> 	;	// a non-zero LongnameFound value and
  4210                              <1> 	;	// if LFN_CheckSum value is equal to
  4211                              <1> 	;	// the next shortname checksum,
  4212                              <1> 	;	// long name is valid.
  4213                              <1> 	;	// If a longname is longer than 65 bytes,
  4214                              <1> 	;	// it is invalid for trdos. (>45h)
  4215                              <1>  
  4216 0000B5EE 57                  <1> 	push	edi
  4217 0000B5EF 56                  <1> 	push	esi
  4218                              <1> 	;push	ebx
  4219                              <1> 	;push	ecx
  4220                              <1> 	;push	edx
  4221 0000B5F0 50                  <1> 	push	eax
  4222                              <1>            
  4223 0000B5F1 29C9                <1> 	sub	ecx, ecx
  4224                              <1> 	;sub	eax, eax
  4225 0000B5F3 B11A                <1> 	mov	cl, 26
  4226                              <1> 
  4227 0000B5F5 0FB607              <1> 	movzx	eax, byte [edi] ; LDIR_Order
  4228 0000B5F8 3C41                <1> 	cmp	al, 41h  ; 40h (last long entry sign) + 1
  4229 0000B5FA 722B                <1> 	jb	short pass_pslnsc_last_long_entry
  4230                              <1> 
  4231 0000B5FC 88C4                <1> 	mov	ah, al
  4232 0000B5FE 80EC40              <1> 	sub	ah, 40h
  4233 0000B601 8825[F2920100]      <1> 	mov	[LFN_EntryLength], ah
  4234                              <1> 	
  4235 0000B607 3C45                <1> 	cmp	al, 45h  ; 40h (last long entry sign) + 5
  4236                              <1>  		; Max 130 byte length is usable in TRDOS
  4237                              <1> ; 26*5 = 130
  4238 0000B609 7753                <1> 	ja	short loc_pslnsc_retn
  4239                              <1> 
  4240 0000B60B 2407                <1> 	and	al, 07h ; 0Fh
  4241 0000B60D A2[F1920100]        <1> 	mov	[LongNameFound], al
  4242                              <1> 
  4243 0000B612 FEC8                <1> 	dec	al
  4244                              <1> 	;mov	cl, 26
  4245 0000B614 F6E1                <1> 	mul	cl
  4246                              <1> 
  4247 0000B616 89C6                <1> 	mov	esi, eax
  4248 0000B618 01CE                <1> 	add	esi, ecx
  4249                              <1> 		; to make is an ASCIIZ string
  4250                              <1> 		; with ax+26 bytes length
  4251 0000B61A 81C6[F4920100]      <1> 	add	esi, LongFileName
  4252 0000B620 66C7060000          <1> 	mov	word [esi], 0   
  4253 0000B625 EB16                <1> 	jmp	short loc_pslsc_move_ldir_name2 
  4254                              <1> 
  4255                              <1> pass_pslnsc_last_long_entry:
  4256 0000B627 3C04                <1> 	cmp	al, 04h
  4257 0000B629 7733                <1> 	ja	short loc_pslnsc_retn
  4258 0000B62B FE0D[F1920100]      <1> 	dec	byte [LongNameFound]
  4259 0000B631 3A05[F1920100]      <1> 	cmp	al, [LongNameFound]
  4260 0000B637 7525                <1> 	jne	short loc_pslnsc_retn
  4261                              <1> 
  4262                              <1> loc_pslsc_move_ldir_name1:
  4263 0000B639 FEC8                <1> 	dec	al
  4264                              <1> 	;mov	cl, 26
  4265 0000B63B F6E1                <1> 	mul	cl
  4266                              <1> 
  4267                              <1> loc_pslsc_move_ldir_name2:
  4268 0000B63D 8A4F0D              <1> 	mov	cl, [edi+0Dh] ; long name checksum
  4269 0000B640 880D[F3920100]      <1> 	mov	[LFN_CheckSum], cl 
  4270 0000B646 89FE                <1> 	mov	esi, edi ; LDIR_Order
  4271 0000B648 BF[F4920100]        <1> 	mov	edi, LongFileName
  4272 0000B64D 01C7                <1> 	add	edi, eax
  4273 0000B64F 46                  <1> 	inc	esi
  4274 0000B650 B105                <1> 	mov	cl, 5 ; chars 1 to 5
  4275 0000B652 F366A5              <1> 	rep	movsw
  4276 0000B655 83C603              <1> 	add	esi, 3
  4277 0000B658 A5                  <1> 	movsd	; char 6 & 7 
  4278 0000B659 A5                  <1> 	movsd	; char 8 & 9
  4279 0000B65A A5                  <1> 	movsd	; char 10 & 11
  4280 0000B65B 46                  <1> 	inc	esi
  4281 0000B65C 46                  <1> 	inc	esi 
  4282 0000B65D A5                  <1> 	movsd   ; char 12 & 13 
  4283                              <1> 
  4284                              <1> loc_pslnsc_retn:
  4285 0000B65E 58                  <1>  	pop	eax
  4286                              <1> 	;pop	edx
  4287                              <1> 	;pop	ecx
  4288                              <1> 	;pop	ebx
  4289 0000B65F 5E                  <1> 	pop	esi  
  4290 0000B660 5F                  <1> 	pop	edi
  4291                              <1>  
  4292 0000B661 C3                  <1>     	retn
  4293                              <1> 
  4294                              <1> parse_path_name:
  4295                              <1> 	; 10/02/2016
  4296                              <1> 	; 08/02/2016 (TRDOS 386 = TRDOS v2.0)
  4297                              <1> 	; 10/009/2011 ('proc_parse_pathname')
  4298                              <1> 	; 27/11/2009
  4299                              <1> 	; 05/12/2004
  4300                              <1> 	;
  4301                              <1> 	; INPUT ->
  4302                              <1> 	;	ESI = Beginning of ASCIIZ pathname string
  4303                              <1> 	;       EDI = Destination Address
  4304                              <1> 	;	      (which is TR-DOS FindFile data buffer)
  4305                              <1> 	; OUTPUT ->
  4306                              <1> 	;	CF = 1 -> Error
  4307                              <1> 	;	     EAX = Error Code (AL)
  4308                              <1> 	;
  4309                              <1> 	; (Modified registers: eax, ecx, esi, edi) 
  4310                              <1> 	
  4311                              <1> 	; Clear the pathname bytes in TR-DOS Findfile data buffer 
  4312 0000B662 57                  <1> 	push	edi
  4313 0000B663 B914000000          <1> 	mov	ecx, 20  ; 80 bytes
  4314 0000B668 31C0                <1> 	xor	eax, eax
  4315 0000B66A F3AB                <1> 	rep	stosd 
  4316 0000B66C 5F                  <1> 	pop	edi
  4317                              <1> 
  4318 0000B66D 668B06              <1> 	mov	ax, [esi]
  4319 0000B670 80FC3A              <1> 	cmp	ah, ':'
  4320 0000B673 741C                <1> 	je	short loc_ppn_change_drive
  4321 0000B675 A0[F68A0100]        <1> 	mov	al, [Current_Drv]
  4322 0000B67A EB33                <1> 	jmp	short pass_ppn_change_drive
  4323                              <1> 
  4324                              <1> pass_ppn_cdir:
  4325 0000B67C 8B35[16940100]      <1> 	mov	esi, [First_Path_Pos]
  4326 0000B682 AC                  <1> 	lodsb
  4327                              <1> loc_ppn_get_filename:
  4328 0000B683 83C741              <1> 	add	edi, 65 ; FindFile_Name location
  4329                              <1> 	; TRDOS Filename length must not be more than 12 bytes
  4330                              <1> 	;mov	ecx, 12
  4331 0000B686 B10C                <1> 	mov	cl, 12
  4332                              <1> loc_ppn_get_fnchar_next:
  4333 0000B688 AA                  <1> 	stosb
  4334 0000B689 AC                  <1> 	lodsb
  4335 0000B68A 3C21                <1> 	cmp	al, 21h
  4336 0000B68C 7274                <1> 	jb	short loc_ppn_clc_return 
  4337 0000B68E E2F8                <1>         loop    loc_ppn_get_fnchar_next
  4338                              <1> loc_ppn_return:
  4339 0000B690 C3                  <1> 	retn
  4340                              <1> 
  4341                              <1> loc_ppn_change_drive:
  4342 0000B691 24DF                <1> 	and	al, 0DFh
  4343 0000B693 2C41                <1> 	sub	al, 'A'; A:
  4344 0000B695 726F                <1> 	jc	short loc_ppn_invalid_drive
  4345 0000B697 3805[C2400100]      <1> 	cmp	[Last_DOS_DiskNo], al
  4346 0000B69D 7267                <1> 	jb	short loc_ppn_invalid_drive
  4347                              <1> 
  4348 0000B69F 46                  <1> 	inc	esi
  4349 0000B6A0 46                  <1> 	inc	esi
  4350 0000B6A1 8A26                <1> 	mov	ah, [esi]
  4351 0000B6A3 80FC21              <1> 	cmp	ah, 21h
  4352 0000B6A6 7307                <1> 	jnb	short pass_ppn_change_drive
  4353                              <1> 
  4354                              <1> loc_ppn_cmd_failed:
  4355                              <1> 	; File or directory name is not existing
  4356 0000B6A8 8807                <1> 	mov	[edi], al ; Drv 
  4357 0000B6AA 66B80100            <1> 	mov	ax, 1 ; eax = 1
  4358                              <1> 	; TR-DOS Error Code 01h = Bad Command Argument
  4359                              <1> 	; MS-DOS Error Code 01h : Invalid Function Number
  4360                              <1> 	;stc
  4361                              <1> 	; (MainProg ErrMsg: "Bad command or file name!")
  4362 0000B6AE C3                  <1> 	retn
  4363                              <1> 
  4364                              <1> pass_ppn_change_drive:
  4365 0000B6AF 8935[16940100]      <1> 	mov	[First_Path_Pos], esi
  4366 0000B6B5 C705[1A940100]0000- <1> 	mov	dword [Last_Slash_Pos], 0
  4366 0000B6BD 0000                <1>
  4367 0000B6BF AA                  <1> 	stosb
  4368 0000B6C0 8A06                <1> 	mov	al, [esi]
  4369                              <1> loc_scan_ppn_dslash:
  4370 0000B6C2 3C2F                <1> 	cmp	al, '/'
  4371 0000B6C4 7506                <1>   	jne	short loc_scan_next_slash_pos
  4372 0000B6C6 8935[1A940100]      <1> 	mov	[Last_Slash_Pos], esi
  4373                              <1> loc_scan_next_slash_pos:
  4374 0000B6CC 46                  <1> 	inc	esi
  4375 0000B6CD 8A06                <1> 	mov	al, [esi]
  4376 0000B6CF 3C20                <1> 	cmp	al, 20h
  4377 0000B6D1 77EF                <1> 	ja	short loc_scan_ppn_dslash
  4378 0000B6D3 833D[1A940100]00    <1> 	cmp	dword [Last_Slash_Pos], 0
  4379 0000B6DA 76A0                <1> 	jna	short pass_ppn_cdir
  4380                              <1> 	
  4381 0000B6DC 8B0D[1A940100]      <1> 	mov	ecx, [Last_Slash_Pos]
  4382 0000B6E2 8B35[16940100]      <1> 	mov	esi, [First_Path_Pos]
  4383 0000B6E8 29F1                <1> 	sub	ecx, esi
  4384 0000B6EA 41                  <1> 	inc	ecx
  4385                              <1> 	;cmp	ecx, 64
  4386 0000B6EB 80F940              <1> 	cmp	cl, 64
  4387 0000B6EE 7715                <1> 	ja	short loc_ppn_invalid_drive_stc
  4388                              <1> 
  4389 0000B6F0 89F8                <1> 	mov	eax, edi ; Dest Dir String Location (65 byte)
  4390 0000B6F2 F3A4                <1> 	rep	movsb
  4391                              <1> 	;mov	[edi], cl ; 0, End of Dir String
  4392 0000B6F4 8B35[1A940100]      <1> 	mov	esi, [Last_Slash_Pos]
  4393 0000B6FA 46                  <1> 	inc	esi
  4394 0000B6FB 89C7                <1> 	mov	edi, eax
  4395 0000B6FD AC                  <1> 	lodsb
  4396 0000B6FE 3C21                <1> 	cmp	al, 21h
  4397 0000B700 7381                <1> 	jnb	short loc_ppn_get_filename
  4398                              <1> loc_ppn_clc_return:
  4399                              <1> 	;clc
  4400 0000B702 31C0                <1> 	xor	eax, eax
  4401 0000B704 C3                  <1> 	retn
  4402                              <1> 
  4403                              <1> loc_ppn_invalid_drive_stc:
  4404 0000B705 F5                  <1> 	cmc	 ; stc
  4405                              <1> loc_ppn_invalid_drive:
  4406                              <1> 	; cf = 1
  4407                              <1> 	; The Drive Letter/Char < "A" or > "Z"
  4408 0000B706 66B80F00            <1> 	mov	ax, 0Fh
  4409                              <1> 	; MS-DOS Error Code 0Fh = Disk Drive Invalid 
  4410                              <1> 	; (MainProg ErrMsg: "Drive not ready or read error!")
  4411 0000B70A C3                  <1> 	retn
  4412                              <1> 
  4413                              <1> find_longname:
  4414                              <1> 	; 13/02/2016 (TRDOS 386 = TRDOS v2.0)
  4415                              <1> 	; 24/01/2010 (DIR.ASM, 'proc_find_longname')
  4416                              <1> 	; 17/10/2009
  4417                              <1> 	
  4418                              <1> 	; INPUT -> 
  4419                              <1> 	;	ESI = DOS short file name address
  4420                              <1> 	; 	for example: "filename.ext"
  4421                              <1> 	;
  4422                              <1> 	; OUTPUT ->
  4423                              <1> 	; 	ESI = ASCIIZ longname address (cf = 0)
  4424                              <1> 	;	cf = 1 -> error number returns in EAX (AL)
  4425                              <1> 	;	AL = 0 & CF=1 -> longname not found
  4426                              <1> 	;	     the file/directory has no longname
  4427                              <1> 	; 	cf = 0 -> AL = FAT Type 
  4428                              <1>  
  4429                              <1> 	; 17/10/2009
  4430                              <1> 	; ASCIIZ string will be returned
  4431                              <1> 	; as LongFileName
  4432                              <1> 	; clearing/reset is not needed
  4433                              <1> 	;mov	ecx, 33
  4434                              <1> 	;mov	edi, LongFileName
  4435                              <1> 	;sub	ax, ax ; 0
  4436                              <1> 	;rep	stosw
  4437                              <1> 
  4438                              <1> 	;mov	byte [LongNameFound], 0
  4439                              <1> 
  4440                              <1> 	; ESI = ASCIIZ file/directory name address
  4441                              <1> 	;   AL = Attributes AND mask 
  4442                              <1> 	;	(Result of AND must be equal to AL)
  4443                              <1> 	;   AH = Negative attributes mask 
  4444                              <1> 	;	(Result of AND must be ZERO)
  4445 0000B70B 66B80008            <1> 	mov	ax, 0800h 
  4446                              <1> 		; it must not be volume name or longname
  4447 0000B70F E87DDDFFFF          <1> 	call	find_first_file
  4448 0000B714 7216                <1> 	jc	short loc_fln_retn
  4449                              <1>  
  4450                              <1> loc_fln_check_FAT_Type:
  4451 0000B716 803D[F58A0100]01    <1> 	cmp	byte [Current_FATType], 1
  4452 0000B71D 7306                <1> 	jnb	short loc_fln_check_longname_yes_sign
  4453                              <1> 
  4454 0000B71F E839000000          <1> 	call	get_fs_longname
  4455 0000B724 C3                  <1> 	retn
  4456                              <1> 
  4457                              <1> loc_fln_check_longname_yes_sign:
  4458 0000B725 08FF                <1> 	or	bh, bh
  4459 0000B727 7504                <1> 	jnz	short loc_fln_check_longnamefound_number
  4460                              <1> loc_fln_longname_not_found_retn:
  4461 0000B729 31C0                <1> 	xor	eax, eax 
  4462                              <1> 	; cf = 1 & al = 0 -> longname not found
  4463 0000B72B F9                  <1> 	stc
  4464                              <1> loc_fln_retn:
  4465 0000B72C C3                  <1> 	retn
  4466                              <1> 
  4467                              <1> loc_fln_check_longnamefound_number:
  4468                              <1> 	; 'LongNameFound' is set by
  4469                              <1>         ; by 'save_longname_sub_component'
  4470                              <1> 	; which is called from
  4471                              <1> 	; 'find_directory_entry' 
  4472                              <1> 	; which is called from 
  4473                              <1> 	; 'find_first_file'
  4474                              <1> 	; It must 1 if the longname is valid
  4475 0000B72D 803D[F1920100]01    <1>         cmp     byte [LongNameFound], 1
  4476 0000B734 75F3                <1> 	jne	short loc_fln_longname_not_found_retn
  4477                              <1>              
  4478                              <1> loc_fln_calculate_checksum: 
  4479 0000B736 E813000000          <1> 	call	calculate_checksum
  4480                              <1> 	; AL = shortname checksum
  4481                              <1> 
  4482                              <1> loc_fln_longname_validation:
  4483                              <1> 	; 'LFN_CheckSum' has been set already
  4484                              <1> 	; by 'save_longname_sub_component'
  4485                              <1> 	; which is called from
  4486                              <1> 	; 'find_directory_entry' 
  4487                              <1> 	; which is called from 
  4488                              <1> 	; 'find_first_file'
  4489 0000B73B 3805[F3920100]      <1> 	cmp	[LFN_CheckSum], al
  4490 0000B741 75E6                <1> 	jne	short loc_fln_longname_not_found_retn
  4491                              <1> 
  4492 0000B743 BE[F4920100]        <1> 	mov	esi, LongFileName
  4493 0000B748 A0[F58A0100]        <1> 	mov	al, [Current_FATType]
  4494 0000B74D C3                  <1> 	retn
  4495                              <1> 
  4496                              <1> calculate_checksum:
  4497                              <1> 	; 13/02/2016 (TRDOS 386 = TRDOS v2.0)
  4498                              <1> 	; 17/10/2009 (DIR.ASM, 'proc_calculate_checksum')
  4499                              <1>         ;    
  4500                              <1> 	; INPUT ->
  4501                              <1> 	;	ESI = 11 byte DOS File Name location
  4502                              <1> 	;	(in DOS Directory Entry Format)
  4503                              <1> 	; OUTPUT ->
  4504                              <1> 	;	 AL = 8 bit checksum (CRC) value
  4505                              <1> 	;
  4506                              <1> 	; (Modified registers: EAX, ECX, ESI)
  4507                              <1> 
  4508                              <1> 	; Erdogan Tan [ 17-10-2009 ]
  4509                              <1> 	;  'ror al, 1' instruction
  4510                              <1> 
  4511                              <1> 	; Erdogan Tan [ 20-06-2004 ]
  4512                              <1> 	; This 8086 assembly code is an original code
  4513                              <1> 	; which is adapted from C code in
  4514                              <1> 	; Microsoft FAT32 File System Specification
  4515                              <1> 	; Version 1.03, December 6, 2000
  4516                              <1> 	; Page 28
  4517                              <1> 
  4518 0000B74E 30C0                <1> 	xor	al, al
  4519 0000B750 B90B000000          <1> 	mov	ecx, 11
  4520                              <1> loc_next_sum:
  4521                              <1> 	;xor	ah, ah
  4522                              <1> 	;test	al, 1
  4523                              <1> 	;jz	short pass_ah_80h
  4524                              <1> 	;mov	ah, 80h
  4525                              <1> ;pass_ah_80h:
  4526                              <1> 	;shr	al, 1
  4527 0000B755 D0C8                <1> 	ror	al, 1 ; 17/10/2009  
  4528 0000B757 0206                <1> 	add	al, [esi]
  4529 0000B759 46                  <1> 	inc	esi
  4530                              <1> 	;add	al, ah
  4531 0000B75A E2F9                <1> 	loop	loc_next_sum
  4532 0000B75C C3                  <1> 	retn
  4533                              <1> 
  4534                              <1> get_fs_longname:
  4535                              <1> 	; temporary (13/02/2016)
  4536 0000B75D 31C0                <1> 	xor eax, eax
  4537 0000B75F F9                  <1> 	stc
  4538 0000B760 C3                  <1> 	retn
  4539                              <1> 
  4540                              <1> make_sub_directory:
  4541                              <1> 	; 16/10/2016
  4542                              <1> 	; 02/03/2016, 03/03/2016
  4543                              <1> 	; 26/02/2016, 27/02/2016
  4544                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
  4545                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_make_directory')
  4546                              <1> 	; 10/07/2010
  4547                              <1> 	; INPUT ->
  4548                              <1> 	; 	ESI = ASCIIZ Directory Name
  4549                              <1> 	;	CL = Directory Attributes
  4550                              <1> 	; OUTPUT ->
  4551                              <1> 	;	EAX = New sub dir's first cluster
  4552                              <1> 	;	ESI = Logical Dos Drv Descr. Table Addr.
  4553                              <1> 	;	CF = 1 -> error code in AL (EAX)
  4554                              <1> 
  4555                              <1> 	;test	cl, 10h  ; directory
  4556                              <1> 	;jz	short loc_make_directory_access_denied
  4557                              <1> 	;test	cl, 08h ; volume name
  4558                              <1> 	;jnz	short loc_make_directory_access_denied
  4559                              <1> 
  4560 0000B761 80E107              <1> 	and	cl, 07h
  4561 0000B764 880D[70940100]      <1> 	mov	byte [mkdir_attrib], cl
  4562                              <1> 
  4563 0000B76A 56                  <1> 	push	esi
  4564 0000B76B 31DB                <1> 	xor	ebx, ebx
  4565 0000B76D 8A3D[F68A0100]      <1> 	mov	bh, [Current_Drv]
  4566 0000B773 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  4567 0000B778 01DE                <1> 	add	esi, ebx
  4568 0000B77A 5B                  <1> 	pop	ebx
  4569                              <1> 
  4570                              <1> 	; 10/07/2010 -> 1st writable disk check for trdos
  4571                              <1> 	; LD_DiskType = 0 for write protection (read only) 
  4572 0000B77B 807E0101            <1> 	cmp	byte [esi+LD_DiskType], 1 ; 0 = Invalid
  4573 0000B77F 730B                <1> 	jnb	short loc_mkdir_check_file_sytem
  4574                              <1> 	; 16/10/2016 (13h -> 30)
  4575 0000B781 B81E000000          <1> 	mov	eax, 30 ; 'Disk write-protected' error
  4576 0000B786 BA00000000          <1> 	mov	edx, 0
  4577                              <1> 	; err retn: EDX = 0, EBX = Dir name offset
  4578                              <1> 	;ESI = Logical DOS drive description table address
  4579 0000B78B C3                  <1> 	retn
  4580                              <1> 
  4581                              <1> ;loc_make_directory_access_denied:
  4582                              <1> 	;mov	ax, 05h ; access denied (invalid attributes input)
  4583                              <1> 	;stc
  4584                              <1> 	;retn
  4585                              <1> 
  4586                              <1> loc_mkdir_check_file_sytem:
  4587 0000B78C 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
  4588 0000B790 730B                <1> 	jnb	short loc_mkdir_check_free_sectors
  4589                              <1> 
  4590                              <1> loc_make_fs_directory:
  4591 0000B792 A1[F08A0100]        <1> 	mov	eax, [Current_Dir_FCluster]
  4592                              <1> 	; EAX = Parent directory DDT Address
  4593                              <1> 	; ESI = Logical DOS Drive DT Address
  4594                              <1> 	; EBX = Directory name offset (as ASCIIZ name)
  4595 0000B797 E8D5150000          <1> 	call	make_fs_directory
  4596 0000B79C C3                  <1> 	retn
  4597                              <1> 
  4598                              <1> loc_mkdir_check_free_sectors:
  4599 0000B79D 0FB64613            <1>         movzx   eax, byte [esi+LD_BPB+SecPerClust]
  4600 0000B7A1 8B4E74              <1> 	mov	ecx, [esi+LD_FreeSectors]
  4601 0000B7A4 39C1                <1> 	cmp	ecx, eax
  4602 0000B7A6 7255                <1> 	jb	short loc_mkdir_insufficient_disk_space
  4603                              <1> 
  4604                              <1> loc_make_fat_directory:
  4605 0000B7A8 891D[60940100]      <1> 	mov	[mkdir_DirName_Offset], ebx
  4606 0000B7AE 890D[6C940100]      <1> 	mov	[mkdir_FreeSectors], ecx
  4607                              <1> 
  4608                              <1> 	;mov	al, [esi+LD_BPB+SecPerClust]
  4609 0000B7B4 A2[72940100]        <1> 	mov	byte [mkdir_SecPerClust], al
  4610                              <1> 
  4611                              <1> loc_mkdir_gffc_1:
  4612 0000B7B9 E80F180000          <1> 	call	get_first_free_cluster
  4613 0000B7BE 722A                <1> 	jc	short loc_mkdir_gffc_retn
  4614                              <1> 
  4615                              <1> ;loc_mkdir_gffc_1_cont: 
  4616                              <1> 	;cmp	eax, 2
  4617                              <1> 	;jb	short loc_mkdir_gffc_insufficient_disk_space
  4618                              <1> 
  4619                              <1> ;loc_mkdir_gffc_1_save_fcluster:  
  4620 0000B7C0 A3[64940100]        <1> 	mov	[mkdir_FFCluster], eax
  4621                              <1> 
  4622                              <1> loc_mkdir_locate_ffe:
  4623                              <1> 	; Current directory fcluster <> Directory buffer cluster
  4624                              <1> 	; Current directory will be reloaded by
  4625                              <1> 	; 'locate_current_dir_file' procedure
  4626                              <1> 	;
  4627                              <1> 	; ESI = Logical DOS Drive Description Table Address 
  4628                              <1> 	;push	esi ; 27/02/2016
  4629 0000B7C5 31C0                <1> 	xor	eax, eax
  4630 0000B7C7 89C1                <1>         mov	ecx, eax
  4631 0000B7C9 6649                <1> 	dec	cx ; FFFFh  
  4632                              <1> 	; CX = FFFFh -> find first deleted or free entry
  4633                              <1> 	; ESI would be ASCIIZ filename address if the call
  4634                              <1> 	; would not be for first free or deleted dir entry
  4635 0000B7CB E8CFFAFFFF          <1> 	call	locate_current_dir_file
  4636 0000B7D0 734C                <1> 	jnc	short loc_mkdir_set_ff_dir_entry_1
  4637                              <1> 	;pop	esi 
  4638                              <1> 	; ESI = Logical DOS Drive Description Table Address 
  4639 0000B7D2 83F802              <1> 	cmp	eax, 2  ; cmp al, 2 ; File/Dir not found !
  4640 0000B7D5 752B                <1> 	jne	short loc_mkdir_stc_return
  4641                              <1> 
  4642                              <1> loc_mkdir_add_new_cluster:
  4643 0000B7D7 3805[F58A0100]      <1> 	cmp	byte [Current_FATType], al ; 2
  4644                              <1> 	;cmp	byte ptr [esi+LD_FATType], 2
  4645 0000B7DD 770C                <1> 	ja	short loc_mkdir_add_new_cluster_check_fsc
  4646 0000B7DF 803D[F48A0100]01    <1> 	cmp	byte [Current_Dir_Level], 1
  4647                              <1> 	;cmp	byte [esi+LD_CDirLevel], 1
  4648 0000B7E6 7303                <1> 	jnb	short loc_mkdir_add_new_cluster_check_fsc
  4649                              <1> 
  4650 0000B7E8 B00C                <1> 	mov	al, 12 ; No more files 
  4651                              <1> loc_mkdir_gffc_retn:
  4652 0000B7EA C3                  <1> 	retn
  4653                              <1> 
  4654                              <1> loc_mkdir_add_new_cluster_check_fsc:
  4655 0000B7EB 8B0D[6C940100]      <1> 	mov	ecx, [mkdir_FreeSectors]
  4656                              <1> 	;movzx	eax, byte [mkdir_SecPerClust]
  4657 0000B7F1 A0[72940100]        <1> 	mov	al, [mkdir_SecPerClust]
  4658 0000B7F6 66D1E0              <1> 	shl	ax, 1 ; AX = 2 * AX
  4659 0000B7F9 39C1                <1> 	cmp	ecx, eax
  4660 0000B7FB 7350                <1> 	jnb	short loc_mkdir_add_new_subdir_cluster
  4661                              <1> 
  4662                              <1> loc_mkdir_insufficient_disk_space:
  4663                              <1> 	;mov	edx, ecx
  4664                              <1> ;loc_mkdir_gffc_insufficient_disk_space:
  4665 0000B7FD 66B82700            <1> 	mov	ax, 27h ; MSDOS err => insufficient disk space
  4666                              <1> 	; err retn: EDX = Free sectors, EBX = Dir name offset
  4667                              <1>         ; ESI -> Dos drive description table address
  4668                              <1> 	;; ecx = edx
  4669                              <1> 	;
  4670 0000B801 C3                  <1> 	retn
  4671                              <1> 
  4672                              <1> loc_mkdir_stc_return:
  4673 0000B802 F9                  <1> 	stc
  4674 0000B803 C3                  <1> 	retn 
  4675                              <1> 
  4676                              <1> loc_mkdir_gffc_2:
  4677 0000B804 E8C4170000          <1> 	call	get_first_free_cluster
  4678 0000B809 72DF                <1> 	jc	short loc_mkdir_gffc_retn
  4679                              <1> 
  4680                              <1> ;loc_mkdir_gffc_1_cont: 
  4681                              <1> 	;cmp	eax, 2
  4682                              <1> 	;jb	short loc_mkdir_gffc_insufficient_disk_space
  4683                              <1> 
  4684                              <1> ;loc_mkdir_gffc_2_save_fcluster:  
  4685 0000B80B A3[64940100]        <1> 	mov	[mkdir_FFCluster], eax
  4686                              <1> 
  4687 0000B810 A1[68940100]        <1> 	mov	eax, [mkdir_LastDirCluster]
  4688                              <1> 
  4689 0000B815 E842170000          <1> 	call	load_FAT_sub_directory 
  4690 0000B81A 72CE                <1> 	jc	short loc_mkdir_gffc_retn
  4691                              <1> 
  4692 0000B81C 31FF                <1> 	xor	edi, edi
  4693                              <1> loc_mkdir_set_ff_dir_entry_1:
  4694                              <1> 	; 27/02/2016
  4695 0000B81E 56                  <1> 	push	esi ; Logical DOS Drv Desc. Tbl. address
  4696                              <1> 	; EDI = Directory Entry Address
  4697 0000B81F 8B35[60940100]      <1> 	mov	esi, [mkdir_DirName_Offset]
  4698 0000B825 A1[64940100]        <1> 	mov	eax, [mkdir_FFCluster]
  4699                              <1> 
  4700 0000B82A 66B91000            <1> 	mov	cx, 10h	; CL = Directory attribute
  4701                              <1> 			; CH = 0 -> File size is 0
  4702 0000B82E 0A0D[70940100]      <1> 	or	cl, [mkdir_attrib] ; S, H, R  
  4703 0000B834 E8B0010000          <1> 	call	make_directory_entry
  4704                              <1> 
  4705 0000B839 5E                  <1> 	pop	esi
  4706                              <1> 
  4707 0000B83A C605[1C920100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  4708 0000B841 E880020000          <1> 	call	save_directory_buffer
  4709 0000B846 0F83DA000000        <1>         jnc     loc_mkdir_set_ff_dir_entry_2
  4710                              <1> 
  4711                              <1> loc_mkdir_return:
  4712 0000B84C C3                  <1> 	retn
  4713                              <1> 
  4714                              <1> loc_mkdir_add_new_subdir_cluster:
  4715 0000B84D 8B15[21920100]      <1> 	mov	edx, [DirBuff_Cluster]
  4716 0000B853 8915[68940100]      <1> 	mov	[mkdir_LastDirCluster], edx       
  4717                              <1> 
  4718 0000B859 A1[64940100]        <1> 	mov	eax, [mkdir_FFCluster]
  4719 0000B85E E8F9160000          <1> 	call	load_FAT_sub_directory 
  4720 0000B863 72E7                <1> 	jc	short loc_mkdir_return
  4721                              <1> 	; eax = 0
  4722                              <1> 	; ecx =  directory buffer sector count (<= 128)
  4723                              <1> 
  4724                              <1> pass_mkdir_add_new_subdir_cluster:
  4725 0000B865 29FF                <1> 	sub	edi, edi ; 0
  4726                              <1> 	;mov	al, 128 ; double word
  4727                              <1> 	;mul	ecx ; ecx =  directory buffer sector count
  4728                              <1> 	;mov	ecx, eax
  4729                              <1> 	;shl	cx, 7 ; 128 * sector count	
  4730 0000B867 668B4611            <1> 	mov	ax, [esi+LD_BPB+BytesPerSec] ; 512
  4731 0000B86B 66C1E802            <1> 	shr	ax, 2 ; 'byte count / 4' for 'stosd'
  4732 0000B86F 66F7E1              <1> 	mul	cx ; max = 128*(512/4) -> 16384 (stosd)
  4733 0000B872 6689C1              <1> 	mov	cx, ax
  4734 0000B875 6629C0              <1> 	sub	ax, ax ; 0
  4735 0000B878 F3AB                <1> 	rep	stosd ; clear directory buffer
  4736                              <1> 
  4737 0000B87A C605[1C920100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  4738 0000B881 E840020000          <1> 	call	save_directory_buffer 
  4739 0000B886 72C4                <1> 	jc	short loc_mkdir_return
  4740                              <1> 
  4741                              <1> loc_mkdir_save_added_cluster:
  4742 0000B888 A1[68940100]        <1> 	mov	eax, [mkdir_LastDirCluster]
  4743 0000B88D 8B0D[64940100]      <1> 	mov	ecx, [mkdir_FFCluster]
  4744                              <1> 	; 01/03/2016
  4745 0000B893 31D2                <1> 	xor	edx, edx
  4746 0000B895 8915[12920100]      <1> 	mov	[FAT_ClusterCounter], edx ; 0 ; reset
  4747 0000B89B E800180000          <1> 	call	update_cluster
  4748 0000B8A0 7304                <1> 	jnc	short loc_mkdir_save_fat_buffer_0
  4749 0000B8A2 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  4750 0000B8A4 7518                <1> 	jnz	short loc_mkdir_save_fat_buffer_stc_retn
  4751                              <1> 
  4752                              <1> loc_mkdir_save_fat_buffer_0:
  4753 0000B8A6 A1[64940100]        <1> 	mov	eax, [mkdir_FFCluster]
  4754 0000B8AB A3[68940100]        <1> 	mov	[mkdir_LastDirCluster], eax
  4755                              <1> 
  4756 0000B8B0 31C9                <1> 	xor	ecx, ecx
  4757 0000B8B2 49                  <1> 	dec	ecx ; FFFFFFFFh
  4758                              <1> 	; ESI = Logical DOS Drive Description Table address 
  4759 0000B8B3 E8E8170000          <1> 	call	update_cluster
  4760 0000B8B8 731A                <1> 	jnc	short loc_mkdir_save_fat_buffer_1
  4761 0000B8BA 09C0                <1> 	or	eax, eax
  4762 0000B8BC 7416                <1> 	jz	short loc_mkdir_save_fat_buffer_1
  4763                              <1> 
  4764                              <1> loc_mkdir_save_fat_buffer_stc_retn:
  4765                              <1> 	; 01/03/2016
  4766 0000B8BE 803D[12920100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
  4767 0000B8C5 720C                <1> 	jb	short loc_mkdir_save_fat_buffer_retn
  4768                              <1> 
  4769 0000B8C7 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate free space (BL = 0)
  4770                              <1> 			   ; (BH = FFh -> Use ESI as Drv Param. Tbl.)
  4771 0000B8CB 50                  <1> 	push	eax
  4772 0000B8CC E8211B0000          <1> 	call	calculate_fat_freespace
  4773 0000B8D1 58                  <1> 	pop	eax
  4774 0000B8D2 F9                  <1> 	stc
  4775                              <1> loc_mkdir_save_fat_buffer_retn:
  4776 0000B8D3 C3                  <1> 	retn
  4777                              <1> 
  4778                              <1> loc_mkdir_save_fat_buffer_1:
  4779                              <1> 	; byte [FAT_BuffValidData] = 2 
  4780 0000B8D4 E8841A0000          <1> 	call	save_fat_buffer
  4781 0000B8D9 72E3                <1> 	jc	short loc_mkdir_save_fat_buffer_stc_retn
  4782                              <1> 
  4783                              <1> 	; 01/03/2016
  4784 0000B8DB 803D[12920100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
  4785 0000B8E2 721B                <1> 	jb	short loc_mkdir_save_fat_buffer_2
  4786                              <1> 
  4787                              <1> 	; ESI = Logical DOS Drive Description Table address 
  4788 0000B8E4 A1[12920100]        <1> 	mov	eax, [FAT_ClusterCounter]
  4789 0000B8E9 66BB01FF            <1> 	mov	bx, 0FF01h ; add free clusters 
  4790 0000B8ED E8001B0000          <1> 	call	calculate_fat_freespace
  4791                              <1> 
  4792                              <1> 	;inc	eax ; 0FFFFFFFFh -> 0 ; recalculation is needed!
  4793                              <1> 	;jnz	short loc_mkdir_save_fat_buffer_2
  4794                              <1> 
  4795                              <1> 	; ecx > 0 -> Recalculation is needed
  4796 0000B8F2 09C9                <1> 	or	ecx, ecx 
  4797 0000B8F4 7409                <1> 	jz	short loc_mkdir_save_fat_buffer_2
  4798                              <1> 
  4799 0000B8F6 66BB00FF            <1> 	mov	bx, 0FF00h ; ; recalculate free space
  4800 0000B8FA E8F31A0000          <1> 	call	calculate_fat_freespace
  4801                              <1> 
  4802                              <1> loc_mkdir_save_fat_buffer_2:
  4803 0000B8FF C605[73940100]01    <1> 	mov	byte [mkdir_add_new_cluster], 1
  4804 0000B906 E9C4000000          <1> 	jmp	loc_mkdir_upd_parent_dir_lmdt
  4805                              <1> 
  4806                              <1> loc_mkdir_update_sub_dir_cluster:
  4807 0000B90B A1[64940100]        <1> 	mov	eax, [mkdir_FFCluster]
  4808 0000B910 29C9                <1> 	sub	ecx, ecx ; 0
  4809                              <1> 	; 01/03/2016
  4810 0000B912 890D[12920100]      <1> 	mov	[FAT_ClusterCounter], ecx ; 0 ; Reset
  4811 0000B918 49                  <1> 	dec	ecx ; 0FFFFFFFFh
  4812                              <1> 
  4813                              <1> 	; ESI = Logical DOS Drive Descisption Table address  
  4814 0000B919 E882170000          <1> 	call	update_cluster
  4815 0000B91E 7379                <1> 	jnc	short loc_mkdir_save_fat_buffer_3
  4816 0000B920 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  4817 0000B922 7475                <1> 	jz	short loc_mkdir_save_fat_buffer_3
  4818                              <1> 	; 01/03/2016
  4819 0000B924 EB98                <1> 	jmp	short loc_mkdir_save_fat_buffer_stc_retn
  4820                              <1> 
  4821                              <1> loc_mkdir_set_ff_dir_entry_2:
  4822                              <1> 	; ESI = Logical DOS Drive Description Table address  
  4823 0000B926 A1[64940100]        <1> 	mov	eax, [mkdir_FFCluster]
  4824                              <1> 	; Load disk sectors as a directory cluster
  4825 0000B92B E82C160000          <1> 	call	load_FAT_sub_directory 
  4826 0000B930 7266                <1> 	jc	short retn_make_fat_directory
  4827                              <1> 	
  4828                              <1> 	; eax = 0
  4829                              <1> 	; ecx =  directory buffer sector count (<= 128)
  4830                              <1> 
  4831 0000B932 BF40000800          <1> 	mov	edi, Directory_Buffer + 64 ; 26/02/2016
  4832                              <1> 
  4833                              <1> 	; 02/03/2016
  4834 0000B937 668B4611            <1> 	mov	ax, [esi+LD_BPB+BytesPerSec] ; 512
  4835 0000B93B 66C1E802            <1> 	shr	ax, 2 ; 'byte count / 4' for 'stosd'
  4836 0000B93F F7E1                <1> 	mul 	ecx
  4837 0000B941 89C1                <1> 	mov	ecx, eax
  4838 0000B943 6629C0              <1> 	sub	ax, ax
  4839 0000B946 F3AB                <1> 	rep	stosd
  4840                              <1> 
  4841                              <1> 	;;mov	al, 128 ; double word
  4842                              <1> 	;;mul	ecx ; ecx =  directory buffer sector count
  4843                              <1> 	;;mov	ecx, eax
  4844                              <1> 	;shl	cx, 7 ; 128 * sector count	
  4845                              <1> 	;;sub	eax, eax
  4846                              <1> 	;;sub	al, al ; 0
  4847                              <1> 	;rep	stosd ; clear directory buffer
  4848                              <1> 
  4849 0000B948 BF00000800          <1> 	mov	edi, Directory_Buffer ; 26/02/2016
  4850                              <1> 	
  4851 0000B94D 56                  <1> 	push	esi
  4852                              <1> 
  4853 0000B94E BE[74940100]        <1> 	mov	esi, mkdir_Name
  4854 0000B953 66C7062E00          <1> 	mov	word [esi], 2Eh ; db '.', '0'
  4855                              <1> 
  4856 0000B958 A1[64940100]        <1> 	mov	eax, [mkdir_FFCluster]
  4857 0000B95D 66B91000            <1> 	mov	cx, 10h ; CL = Directory attribute
  4858                              <1> 			; CH = 0 -> File size is 0
  4859 0000B961 E883000000          <1> 	call	make_directory_entry
  4860                              <1> 
  4861 0000B966 BF20000800          <1> 	mov	edi, Directory_Buffer + 32 ; 26/02/2016
  4862                              <1> 
  4863                              <1> 	; 03/03/2016
  4864                              <1> 	; Following modification has been done according to 
  4865                              <1> 	; 'Microsoft Extensible Firmware Initiative
  4866                              <1> 	; FAT32 File System Specification' document,
  4867                              <1> 	; 'FAT: General Overview of On-Disk FormatPage 25'.
  4868                              <1> 	; "Finally, you set DIR_FstClusLO and DIR_FstClusHI
  4869                              <1> 	; for the dotdot entry (the second entry) to the
  4870                              <1> 	; first cluster number of the directory in which you 
  4871                              <1> 	; just created the directory (value is 0 if this directory
  4872                              <1> 	; is the root directory even for FAT32 volumes)."
  4873                              <1> 	; (Correctness of this modification has been verified
  4874                              <1> 	;  by using Windows 98 'scandisk.exe'.)
  4875                              <1> 
  4876 0000B96B 29C0                <1> 	sub	eax, eax
  4877 0000B96D 3805[F48A0100]      <1> 	cmp	byte [Current_Dir_Level], al ; 0
  4878 0000B973 7605                <1> 	jna	short loc_mkdir_set_ff_dir_entry_3
  4879 0000B975 A1[F08A0100]        <1> 	mov	eax, [Current_Dir_FCluster] ; parent dir
  4880                              <1> loc_mkdir_set_ff_dir_entry_3:
  4881 0000B97A 66C746012E00        <1> 	mov	word [esi+1], 2Eh ; db '.', '0'
  4882                              <1> 
  4883                              <1> 	;mov	cx, 10h
  4884 0000B980 E864000000          <1> 	call	make_directory_entry
  4885                              <1> 
  4886 0000B985 5E                  <1> 	pop	esi
  4887                              <1> 
  4888 0000B986 C605[1C920100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  4889 0000B98D E834010000          <1> 	call	save_directory_buffer
  4890 0000B992 0F8373FFFFFF        <1>         jnc     loc_mkdir_update_sub_dir_cluster
  4891                              <1>  
  4892                              <1> retn_make_fat_directory:
  4893 0000B998 C3                  <1> 	retn
  4894                              <1> 
  4895                              <1> loc_mkdir_save_fat_buffer_3:
  4896                              <1> 	; 01/03/2016
  4897                              <1> 	; byte [FAT_BuffValidData] = 2 
  4898 0000B999 E8BF190000          <1> 	call	save_fat_buffer
  4899 0000B99E 0F821AFFFFFF        <1>         jc      loc_mkdir_save_fat_buffer_stc_retn
  4900                              <1> 
  4901 0000B9A4 803D[12920100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
  4902 0000B9AB 721B                <1> 	jb	short loc_mkdir_save_fat_buffer_4
  4903                              <1> 
  4904                              <1> 	; ESI = Logical DOS Drive Description Table address 
  4905 0000B9AD A1[12920100]        <1> 	mov	eax, [FAT_ClusterCounter]
  4906 0000B9B2 66BB01FF            <1> 	mov	bx, 0FF01h ; add free clusters 
  4907 0000B9B6 E8371A0000          <1> 	call	calculate_fat_freespace
  4908                              <1> 
  4909                              <1> 	;inc	eax ; 0FFFFFFFFh -> 0 ; recalculation is needed!
  4910                              <1>         ;jnz    short loc_mkdir_save_fat_buffer_4
  4911                              <1> 
  4912                              <1> 	; ecx > 0 -> Recalculation is needed
  4913 0000B9BB 09C9                <1> 	or	ecx, ecx 
  4914 0000B9BD 7409                <1>         jz      short loc_mkdir_save_fat_buffer_4
  4915                              <1> 
  4916 0000B9BF 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate free space
  4917 0000B9C3 E82A1A0000          <1> 	call	calculate_fat_freespace
  4918                              <1> 
  4919                              <1> loc_mkdir_save_fat_buffer_4:	
  4920 0000B9C8 C605[73940100]00    <1> 	mov	byte [mkdir_add_new_cluster], 0
  4921                              <1> 
  4922                              <1> loc_mkdir_upd_parent_dir_lmdt:
  4923 0000B9CF E88D010000          <1> 	call	update_parent_dir_lmdt
  4924                              <1> 
  4925                              <1> 	; 01/03/2016
  4926 0000B9D4 803D[73940100]00    <1> 	cmp	byte [mkdir_add_new_cluster], 0
  4927 0000B9DB 0F8723FEFFFF        <1>         ja      loc_mkdir_gffc_2
  4928                              <1> 
  4929                              <1> loc_mkdir_retn_new_dir_cluster:
  4930 0000B9E1 A1[64940100]        <1> 	mov	eax, [mkdir_FFCluster]
  4931 0000B9E6 31D2                <1> 	xor	edx, edx
  4932                              <1> loc_mkdir_retn:
  4933 0000B9E8 C3                  <1> 	retn
  4934                              <1> 
  4935                              <1> make_directory_entry:
  4936                              <1> 	; 02/03/2016
  4937                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
  4938                              <1> 	; 09/08/2010 (DIR.ASM, 'proc_make_directory_entry')
  4939                              <1> 	; 17/07/2010
  4940                              <1> 	; INPUT ->
  4941                              <1> 	; 	EDI = Directory Entry Address
  4942                              <1> 	;	ESI = Dot File Name Location
  4943                              <1> 	;	EAX = First Cluster
  4944                              <1> 	;	File Size = 0 (Must be set later)
  4945                              <1> 	;	CL = Attributes
  4946                              <1> 	;	CH = 0 (File size = 0) 
  4947                              <1> 	;	(If CH>0, File size is in dword [EBX]) (*)
  4948                              <1> 	; OUTPUT -> 
  4949                              <1> 	;	EDI = Directory Entry Address
  4950                              <1> 	;	ESI = Dot File Name Location (Capitalized)
  4951                              <1> 	;	If CH input = 0, File Size = 0
  4952                              <1> 	;	Otherwise file size is as dword [EBX] (*)
  4953                              <1> 	;	DX = Date, AX = Time in DOS Dir Entry format
  4954                              <1> 	;	EBX = same
  4955                              <1> 	;	ECX = same
  4956                              <1> 
  4957 0000B9E9 51                  <1> 	push	ecx
  4958                              <1> 
  4959 0000B9EA 884F0B              <1> 	mov	[edi+11], cl ; Attributes
  4960 0000B9ED 6689471A            <1> 	mov	[edi+26], ax ; FClusterLw, 26
  4961 0000B9F1 C1E810              <1> 	shr	eax, 16
  4962 0000B9F4 66894714            <1> 	mov	[edi+20], ax ; FClusterHw, 20
  4963 0000B9F8 6631C0              <1> 	xor	ax, ax 
  4964 0000B9FB 6689470C            <1> 	mov	[edi+12], ax ; NTReserved, 12
  4965                              <1> 			     ; CrtTimeTenth, 13
  4966 0000B9FF 08ED                <1> 	or	ch, ch
  4967 0000BA01 7402                <1> 	jz	short loc_make_direntry_set_filesize
  4968                              <1> 
  4969 0000BA03 8B03                <1> 	mov	eax, [ebx]
  4970                              <1>         
  4971                              <1> loc_make_direntry_set_filesize:
  4972 0000BA05 89471C              <1> 	mov	[edi+28], eax ; FileSize, 28
  4973                              <1> 	
  4974 0000BA08 E88AFBFFFF          <1> 	call	convert_file_name
  4975                              <1> 	;EDI = Dir Entry Format File Name Location
  4976                              <1> 	;ESI = Dot File Name Location (capitalized)
  4977                              <1> 
  4978 0000BA0D E816000000          <1> 	call	convert_current_date_time
  4979                              <1> 	; OUTPUT -> DX = Date in dos dir entry format
  4980                              <1>         ; 	    AX = Time in dos dir entry format
  4981 0000BA12 6689470E            <1> 	mov	[edi+14], ax ; CrtTime, 14
  4982 0000BA16 66895710            <1> 	mov	[edi+16], dx ; CrtDate, 16
  4983 0000BA1A 66895712            <1> 	mov	[edi+18], dx ; LastAccDate, 18
  4984 0000BA1E 66894716            <1> 	mov	[edi+22], ax ; WrtTime, 14
  4985 0000BA22 66895718            <1> 	mov	[edi+24], dx ; WrtDate, 16
  4986 0000BA26 59                  <1> 	pop	ecx
  4987                              <1> 
  4988 0000BA27 C3                  <1> 	retn
  4989                              <1> 
  4990                              <1> convert_current_date_time:
  4991                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
  4992                              <1> 	; 13/06/2010 (DIR.ASM, 'proc_convert_current_date_time')
  4993                              <1> 	; converts date&time to dos dir entry format
  4994                              <1> 	; INPUT -> none
  4995                              <1> 	; OUTPUT -> DX = Date in dos dir entry format
  4996                              <1> 	;           AX = Time in dos dir entry format
  4997                              <1>  
  4998 0000BA28 B404                <1> 	mov	ah, 04h ; Return Current Date
  4999 0000BA2A E80FB0FFFF          <1> 	call	int1Ah 
  5000                              <1> 
  5001 0000BA2F 88E8                <1> 	mov	al, ch ; <- century BCD
  5002 0000BA31 240F                <1> 	and	al, 0Fh
  5003 0000BA33 88EC                <1> 	mov	ah, ch
  5004 0000BA35 C0EC04              <1> 	shr	ah, 4
  5005 0000BA38 D50A                <1> 	aad
  5006 0000BA3A 88C5                <1> 	mov	ch, al ; -> century 
  5007                              <1> 
  5008 0000BA3C 88C8                <1> 	mov	al, cl ; <- year BCD
  5009 0000BA3E 240F                <1> 	and	al, 0Fh
  5010 0000BA40 88CC                <1> 	mov	ah, cl
  5011 0000BA42 C0EC04              <1> 	shr	ah, 4
  5012 0000BA45 D50A                <1> 	aad
  5013 0000BA47 88C1                <1> 	mov	cl, al ; -> year
  5014                              <1> 
  5015 0000BA49 88E8                <1> 	mov	al, ch
  5016 0000BA4B B464                <1> 	mov	ah, 100
  5017 0000BA4D F6E4                <1> 	mul	ah
  5018 0000BA4F 30ED                <1> 	xor	ch, ch
  5019 0000BA51 6601C8              <1> 	add	ax, cx
  5020 0000BA54 662DBC07            <1> 	sub	ax, 1980 ; ms-dos epoch
  5021 0000BA58 6689C1              <1> 	mov	cx, ax
  5022                              <1> 
  5023 0000BA5B 88F0                <1> 	mov	al, dh ; <- month in bcd
  5024 0000BA5D 240F                <1> 	and	al, 0Fh
  5025 0000BA5F 88F4                <1> 	mov	ah, dh
  5026 0000BA61 C0EC04              <1> 	shr	ah, 4
  5027 0000BA64 D50A                <1> 	aad
  5028 0000BA66 88C6                <1> 	mov	dh, al ; -> month
  5029                              <1> 
  5030 0000BA68 88D0                <1> 	mov	al, dl ; <- day BCD
  5031 0000BA6A 240F                <1> 	and	al, 0Fh
  5032 0000BA6C 88D4                <1> 	mov	ah, dl
  5033 0000BA6E C0EC04              <1> 	shr	ah, 4
  5034 0000BA71 D50A                <1> 	aad
  5035 0000BA73 88C2                <1> 	mov	dl, al ; -> day
  5036                              <1> 
  5037 0000BA75 88C8                <1> 	mov	al, cl ; count of years from 1980
  5038 0000BA77 66C1E004            <1> 	shl	ax, 4
  5039 0000BA7B 08F0                <1> 	or	al, dh ; month of year, 1 to 12
  5040 0000BA7D 66C1E005            <1> 	shl	ax, 5
  5041 0000BA81 08D0                <1> 	or	al, dl ; day of year, 1 to 31
  5042                              <1> 	
  5043 0000BA83 6650                <1> 	push	ax ; push date
  5044                              <1> 
  5045 0000BA85 B402                <1> 	mov	ah, 02h ; Return Current Time
  5046 0000BA87 E8B2AFFFFF          <1> 	call	int1Ah
  5047                              <1> 
  5048 0000BA8C 88E8                <1> 	mov	al, ch ; <- hours BCD
  5049 0000BA8E 240F                <1> 	and	al, 0Fh
  5050 0000BA90 88EC                <1> 	mov	ah, ch
  5051 0000BA92 C0EC04              <1> 	shr	ah, 4
  5052 0000BA95 D50A                <1> 	aad
  5053 0000BA97 88C5                <1> 	mov	ch, al ; -> hours
  5054                              <1> 
  5055 0000BA99 88C8                <1> 	mov	al, cl ; <- minutes BCD
  5056 0000BA9B 240F                <1> 	and	al, 0Fh
  5057 0000BA9D 88CC                <1> 	mov	ah, cl
  5058 0000BA9F C0EC04              <1> 	shr	ah, 4
  5059 0000BAA2 D50A                <1> 	aad
  5060 0000BAA4 88C1                <1> 	mov	cl, al ; -> minutes
  5061                              <1> 
  5062 0000BAA6 88F0                <1> 	mov	al, dh ; <- seconds BCD
  5063 0000BAA8 240F                <1> 	and	al, 0Fh
  5064 0000BAAA 88F4                <1> 	mov	ah, dh
  5065 0000BAAC C0EC04              <1> 	shr	ah, 4
  5066 0000BAAF D50A                <1> 	aad
  5067 0000BAB1 88C6                <1> 	mov	dh, al ; -> seconds
  5068                              <1> 
  5069 0000BAB3 88E8                <1> 	mov	al, ch ; hours
  5070 0000BAB5 66C1E006            <1> 	shl	ax, 6
  5071 0000BAB9 08C8                <1> 	or	al, cl ; minutes
  5072 0000BABB 66C1E005            <1> 	shl	ax, 5
  5073 0000BABF D0EE                <1> 	shr	dh, 1 ; 2 seconds
  5074                              <1> 	; There is a bug in TRDOS v1 here !
  5075                              <1> 	; it was 'or al, dl' ! 
  5076 0000BAC1 08F0                <1> 	or	al, dh ; seconds
  5077                              <1> 
  5078 0000BAC3 665A                <1> 	pop	dx ; pop date
  5079                              <1> 	
  5080 0000BAC5 C3                  <1> 	retn
  5081                              <1> 
  5082                              <1> save_directory_buffer:
  5083                              <1> 	; 15/10/2016
  5084                              <1> 	; 23/03/2016
  5085                              <1> 	; 26/02/2016
  5086                              <1> 	; 22/02/2016 (TRDOS 386 = TRDOS v2.0)
  5087                              <1> 	; 01/08/2011
  5088                              <1> 	; 14/03/2010
  5089                              <1> 	; INPUT ->
  5090                              <1> 	; 	 none
  5091                              <1> 	; OUTPUT ->
  5092                              <1> 	;  cf = 0 -> write OK...
  5093                              <1> 	;  cf = 1 -> error code in AL (EAX)
  5094                              <1> 	;  cf = 1 & AL = 0Dh => CH & CL = FS & FAT type
  5095                              <1> 	;  EBX = Directory Buffer Address
  5096                              <1> 	;
  5097                              <1> 	;  (EAX, ECX, EDX will be modified)
  5098                              <1>  
  5099 0000BAC6 BB00000800          <1> 	mov	ebx, Directory_Buffer
  5100 0000BACB 803D[1C920100]02    <1> 	cmp	byte [DirBuff_ValidData], 2
  5101 0000BAD2 7403                <1> 	je	short loc_save_dir_buffer
  5102 0000BAD4 31C0                <1> 	xor	eax, eax
  5103 0000BAD6 C3                  <1> 	retn            
  5104                              <1> 
  5105                              <1> loc_save_dir_buffer:
  5106 0000BAD7 56                  <1> 	push	esi
  5107 0000BAD8 31DB                <1> 	xor	ebx, ebx 
  5108 0000BADA 8A3D[1A920100]      <1>         mov     bh, [DirBuff_DRV]
  5109 0000BAE0 80EF41              <1> 	sub	bh, 'A'
  5110 0000BAE3 BE00010900          <1>         mov     esi, Logical_DOSDisks
  5111 0000BAE8 01DE                <1> 	add	esi, ebx
  5112 0000BAEA 668B4E03            <1>         mov     cx, [esi+LD_FATType]
  5113                              <1> 	; CH = FS Type (A1h for FS)
  5114                              <1> 	; CL = FAT Type (0 for FS)
  5115 0000BAEE 08C9                <1> 	or	cl, cl
  5116 0000BAF0 7433                <1> 	jz	short loc_save_dir_buff_stc_retn
  5117                              <1> 
  5118                              <1> loc_save_dir_buffer_check_cluster_no:    
  5119 0000BAF2 A1[21920100]        <1> 	mov	eax, [DirBuff_Cluster]
  5120 0000BAF7 28FF                <1> 	sub	bh, bh ; ebx = 0
  5121 0000BAF9 09C0                <1> 	or	eax, eax
  5122 0000BAFB 7540                <1> 	jnz	short loc_save_sub_dir_buffer
  5123 0000BAFD 8A25[1B920100]      <1> 	mov	ah, [DirBuff_FATType]
  5124 0000BB03 FEC3                <1> 	inc	bl ;  bl = 1
  5125 0000BB05 38DC                <1> 	cmp	ah, bl
  5126 0000BB07 721D                <1> 	jb	short loc_save_dir_buff_inv_data_retn
  5127 0000BB09 FEC3                <1> 	inc	bl ; bl = 2
  5128 0000BB0B 38E3                <1> 	cmp	bl, ah
  5129 0000BB0D 7217                <1> 	jb	short loc_save_dir_buff_inv_data_retn
  5130                              <1> 
  5131                              <1> loc_save_root_dir_buffer:
  5132 0000BB0F 668B5E17            <1> 	mov	bx, [esi+LD_BPB+RootDirEnts]
  5133 0000BB13 6683C30F            <1> 	add	bx, 15
  5134 0000BB17 66C1EB04            <1> 	shr	bx, 4 ; 16 dir entries per sector
  5135 0000BB1B 6609DB              <1> 	or	bx, bx
  5136 0000BB1E 7405                <1> 	jz	short loc_save_dir_buff_stc_retn
  5137                              <1> 	;mov	ecx, ebx 
  5138 0000BB20 8B4664              <1> 	mov	eax, [esi+LD_ROOTBegin] ; 26/02/2016
  5139 0000BB23 EB23                <1> 	jmp	short loc_write_directory_to_disk
  5140                              <1> 
  5141                              <1> loc_save_dir_buff_stc_retn:
  5142 0000BB25 F9                  <1> 	stc
  5143                              <1> loc_save_dir_buff_inv_data_retn:
  5144                              <1> 	; 15/10/2016 (0Dh -> 29)
  5145 0000BB26 B01D                <1> 	mov	al, 29 ; Invalid data !
  5146 0000BB28 C605[1C920100]00    <1> 	mov	byte [DirBuff_ValidData], 0
  5147 0000BB2F EB05                <1> 	jmp	short loc_save_dir_buff_retn 
  5148                              <1> 
  5149                              <1> loc_write_directory_to_disk_err:
  5150                              <1> 	; 15/10/2016 (disk write error code, 1Dh -> 18)
  5151 0000BB31 B812000000          <1> 	mov	eax, 18 ; Drive not ready or write error 
  5152                              <1> 
  5153                              <1> loc_save_dir_buff_retn:
  5154 0000BB36 BB00000800          <1> 	mov	ebx, Directory_Buffer
  5155 0000BB3B 5E                  <1> 	pop	esi
  5156 0000BB3C C3                  <1> 	retn
  5157                              <1>  
  5158                              <1> loc_save_sub_dir_buffer:
  5159                              <1> 	; ebx  = 0
  5160 0000BB3D 83E802              <1> 	sub	eax, 2
  5161 0000BB40 8A5E13              <1> 	mov	bl, [esi+LD_BPB+SecPerClust]
  5162 0000BB43 F7E3                <1> 	mul	ebx
  5163 0000BB45 034668              <1>         add     eax, [esi+LD_DATABegin]
  5164                              <1>  	;mov	ecx, ebx
  5165                              <1> 
  5166                              <1> loc_write_directory_to_disk:
  5167 0000BB48 89D9                <1>  	mov	ecx, ebx
  5168 0000BB4A BB00000800          <1> 	mov	ebx, Directory_Buffer
  5169 0000BB4F E85A700000          <1> 	call	disk_write
  5170 0000BB54 72DB                <1> 	jc	short loc_write_directory_to_disk_err
  5171                              <1> 
  5172                              <1> loc_save_dir_buff_validate_retn:
  5173 0000BB56 C605[1C920100]01    <1> 	mov	byte [DirBuff_ValidData], 1
  5174 0000BB5D 31C0                <1> 	xor	eax, eax
  5175                              <1> 	; 26/02/2016
  5176 0000BB5F EBD5                <1> 	jmp	short loc_save_dir_buff_retn
  5177                              <1> 
  5178                              <1> update_parent_dir_lmdt:
  5179                              <1> 	; 29/12/2017
  5180                              <1> 	; 22/02/2016 (TRDOS 386 = TRDOS v2.0)
  5181                              <1> 	; 01/08/2011
  5182                              <1> 	; 16/10/2010 
  5183                              <1> 	; 
  5184                              <1> 	; INPUT -> 
  5185                              <1> 	;	none
  5186                              <1>  	; OUTPUT ->
  5187                              <1> 	;	(last modification date & time of the parent dir
  5188                              <1> 	;	will be changed/updated)
  5189                              <1> 	;
  5190                              <1> 	; (EAX, EBX, ECX, EDX, EDI will be changed)
  5191                              <1> 
  5192 0000BB61 29C0                <1> 	sub	eax, eax
  5193 0000BB63 8A25[F48A0100]      <1> 	mov	ah, [Current_Dir_Level]
  5194 0000BB69 A0[F58A0100]        <1> 	mov	al, [Current_FATType]
  5195 0000BB6E 3C01                <1> 	cmp	al, 1
  5196 0000BB70 723A                <1> 	jb	short loc_UPDLMDT_proc_retn
  5197                              <1>     
  5198                              <1> loc_update_parent_dir_lm_date_time:
  5199 0000BB72 08E4                <1> 	or	ah, ah
  5200 0000BB74 7436                <1> 	jz	short loc_UPDLMDT_proc_retn
  5201                              <1> 
  5202 0000BB76 56                  <1> 	push	esi ; *
  5203 0000BB77 8825[94940100]      <1> 	mov	[UPDLMDT_CDirLevel], ah
  5204 0000BB7D 8B15[F08A0100]      <1> 	mov	edx, [Current_Dir_FCluster]
  5205 0000BB83 8915[95940100]      <1> 	mov	[UPDLMDT_CDirFCluster], edx
  5206                              <1> 
  5207 0000BB89 FECC                <1> 	dec	ah
  5208 0000BB8B B90C000000          <1> 	mov	ecx, 12
  5209 0000BB90 BE[53920100]        <1>         mov     esi, PATH_Array
  5210                              <1> 
  5211 0000BB95 8825[F48A0100]      <1> 	mov	[Current_Dir_Level], ah
  5212 0000BB9B 08E4                <1> 	or	ah, ah
  5213 0000BB9D 750E                <1> 	jnz	short loc_update_parent_dir_lmdt_load_sub_dir_1
  5214 0000BB9F 803D[F58A0100]02    <1> 	cmp	byte [Current_FATType], 2
  5215 0000BBA6 770B                <1> 	ja	short loc_update_parent_dir_lmdt_load_sub_dir_2
  5216 0000BBA8 28C0                <1> 	sub	al, al ; eax = 0
  5217 0000BBAA EB0A                <1> 	jmp	short loc_update_parent_dir_lmdt_load_sub_dir_3
  5218                              <1> 
  5219                              <1> loc_UPDLMDT_proc_retn:
  5220 0000BBAC C3                  <1> 	retn
  5221                              <1>          
  5222                              <1> loc_update_parent_dir_lmdt_load_sub_dir_1:
  5223 0000BBAD B010                <1> 	mov	al, 16
  5224 0000BBAF F6E4                <1> 	mul	ah 
  5225 0000BBB1 01C6                <1> 	add	esi, eax
  5226                              <1> 
  5227                              <1> loc_update_parent_dir_lmdt_load_sub_dir_2:  
  5228 0000BBB3 8B460C              <1> 	mov	eax, [esi+12] ; Parent Dir First Cluster
  5229                              <1> 
  5230                              <1> loc_update_parent_dir_lmdt_load_sub_dir_3:
  5231 0000BBB6 A3[F08A0100]        <1> 	mov	[Current_Dir_FCluster], eax
  5232                              <1> 
  5233 0000BBBB 83C610              <1> 	add	esi, 16
  5234 0000BBBE 66BF[7A93]          <1> 	mov	di, Dir_File_Name  
  5235 0000BBC2 F3A4                <1> 	rep	movsb
  5236                              <1> 	
  5237 0000BBC4 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  5238 0000BBC9 29DB                <1> 	sub	ebx, ebx
  5239 0000BBCB 8A3D[F68A0100]      <1> 	mov	bh, [Current_Drv]
  5240 0000BBD1 01DE                <1> 	add	esi, ebx
  5241 0000BBD3 E88EF7FFFF          <1> 	call	reload_current_directory
  5242 0000BBD8 7230                <1> 	jc	short loc_update_parent_dir_lmdt_restore_cdirlevel
  5243                              <1> 
  5244                              <1> loc_update_parent_dir_lmdt_locate_dir: 
  5245 0000BBDA BE[7A930100]        <1> 	mov	esi, Dir_File_Name        
  5246 0000BBDF 6631C9              <1> 	xor	cx, cx
  5247 0000BBE2 66B81008            <1> 	mov	ax, 0810h ; Only directories
  5248 0000BBE6 E8B4F6FFFF          <1>         call    locate_current_dir_file
  5249                              <1> 	; EDI = DirBuff Directory Entry Address
  5250 0000BBEB 721D                <1> 	jc	short loc_update_parent_dir_lmdt_restore_cdirlevel
  5251                              <1> 
  5252 0000BBED E836FEFFFF          <1> 	call	convert_current_date_time
  5253 0000BBF2 66895712            <1> 	mov	[edi+18], dx ; Last Access Date
  5254 0000BBF6 66895718            <1> 	mov	[edi+24], dx ; Last Write Date
  5255 0000BBFA 66894716            <1> 	mov	[edi+22], ax ; Last Write Time
  5256                              <1> 
  5257 0000BBFE C605[1C920100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  5258 0000BC05 E8BCFEFFFF          <1> 	call	save_directory_buffer
  5259                              <1> 	; 29/12/2017
  5260                              <1> 	;jc	short loc_update_parent_dir_lmdt_restore_cdirlevel
  5261                              <1> 	;xor	al, al 
  5262                              <1> loc_update_parent_dir_lmdt_restore_cdirlevel:
  5263                              <1>  	;current directory level restoration
  5264 0000BC0A 8A25[94940100]      <1> 	mov	ah, [UPDLMDT_CDirLevel]
  5265 0000BC10 8825[F48A0100]      <1> 	mov	[Current_Dir_Level], ah
  5266 0000BC16 8B15[95940100]      <1>         mov     edx, [UPDLMDT_CDirFCluster]
  5267 0000BC1C 8915[F08A0100]      <1> 	mov	[Current_Dir_FCluster], edx
  5268                              <1> 
  5269 0000BC22 5E                  <1> 	pop	esi ; *
  5270 0000BC23 C3                  <1> 	retn
  5271                              <1> 
  5272                              <1> delete_longname:
  5273                              <1> 	; 27/02/2016 (TRDOS 386 = TRDOS v2.0)
  5274                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_delete_longname')
  5275                              <1> 	; 14/03/2010
  5276                              <1> 	; INPUT ->
  5277                              <1> 	; 	EAX = Directory Entry (Index) Number (< 65536)
  5278                              <1> 	; OUTPUT ->
  5279                              <1> 	;	cf = 0 -> OK  (EAX = 0)
  5280                              <1> 	; 	cf = 1 -> error code in EAX (AL)
  5281                              <1> 	;
  5282                              <1> 	; (Modified registers: EAX, EDX, ECX, EBX, EDI) 
  5283                              <1> 
  5284 0000BC24 66A3[C4940100]      <1> 	mov	[DLN_EntryNumber], ax
  5285 0000BC2A C605[C6940100]40    <1>         mov     byte [DLN_40h], 40h
  5286                              <1> 
  5287 0000BC31 E858000000          <1> 	call	locate_current_dir_entry
  5288 0000BC36 7308                <1> 	jnc	short loc_dln_check_attributes
  5289 0000BC38 C3                  <1> 	retn
  5290                              <1> 
  5291                              <1> loc_dln_longname_not_found:
  5292 0000BC39 B802000000          <1> 	mov	eax, 2
  5293 0000BC3E F9                  <1> 	stc
  5294 0000BC3F C3                  <1> 	retn
  5295                              <1> 
  5296                              <1> loc_dln_check_attributes:
  5297 0000BC40 B00F                <1> 	mov	al, 0Fh  ; long name
  5298 0000BC42 8A670B              <1> 	mov	ah, [edi+0Bh] ; dir entry attributes
  5299 0000BC45 38C4                <1> 	cmp	ah, al
  5300 0000BC47 75F0                <1> 	jne	short loc_dln_longname_not_found
  5301 0000BC49 8A27                <1> 	mov	ah, [edi]
  5302 0000BC4B 2A25[C6940100]      <1> 	sub	ah, [DLN_40h]
  5303 0000BC51 76E6                <1> 	jna	short loc_dln_longname_not_found         
  5304 0000BC53 80FC14              <1> 	cmp	ah, 14h ; 84-64=20 -> 20*13=260 bytes
  5305 0000BC56 77E1                <1> 	ja	short loc_dln_longname_not_found
  5306                              <1>              
  5307 0000BC58 C607E5              <1> 	mov	byte [edi], 0E5h  ; deleted sign
  5308 0000BC5B C605[1C920100]02    <1> 	mov	byte [DirBuff_ValidData], 2 ; changed/write sign
  5309 0000BC62 C605[C6940100]00    <1> 	mov	byte [DLN_40h], 0 ; 40h -> 0
  5310                              <1> 	  
  5311                              <1> loc_dln_delete_next_ln_entry:
  5312 0000BC69 80FC01              <1> 	cmp	ah, 1
  5313 0000BC6C 7616                <1> 	jna	short loc_dln_longname_retn
  5314                              <1> loc_dln_delete_next_ln_entry_0:
  5315 0000BC6E 66FF05[C4940100]    <1> 	inc	word [DLN_EntryNumber]
  5316 0000BC75 0FB705[C4940100]    <1> 	movzx	eax, word [DLN_EntryNumber] 
  5317 0000BC7C E80D000000          <1> 	call	locate_current_dir_entry
  5318 0000BC81 73BD                <1> 	jnc	short loc_dln_check_attributes
  5319                              <1> 
  5320                              <1> loc_dln_longname_stc_retn:
  5321 0000BC83 C3                  <1> 	retn 
  5322                              <1> 	   
  5323                              <1> loc_dln_longname_retn:
  5324                              <1> 	;cmp	byte [DirBuff_ValidData], 2
  5325                              <1> 	;jne	short loc_dln_longname_retn_xor_eax
  5326 0000BC84 E83DFEFFFF          <1> 	call	save_directory_buffer
  5327 0000BC89 72F8                <1> 	jc	short loc_dln_longname_stc_retn
  5328                              <1> 
  5329                              <1> loc_dln_longname_retn_xor_eax:
  5330 0000BC8B 31C0                <1> 	xor	eax, eax
  5331 0000BC8D C3                  <1> 	retn
  5332                              <1> 
  5333                              <1> locate_current_dir_entry:
  5334                              <1> 	; 16/10/2016
  5335                              <1> 	; 15/10/2016
  5336                              <1> 	; 23/03/2016
  5337                              <1> 	; 27/02/2016 (TRDOS 386 = TRDOS v2.0)
  5338                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_locate_current_dir_entry')
  5339                              <1> 	; 07/03/2010
  5340                              <1> 	; INPUT ->
  5341                              <1> 	;	EAX = Directory Entry (Index) Number (< 65536) 
  5342                              <1> 	; OUTPUT ->
  5343                              <1> 	;	EDI = Directory Entry Address
  5344                              <1> 	; 	EAX = Cluster Number of Directory Buffer
  5345                              <1> 	;	EBX = Directory Buffer Entry Offset
  5346                              <1> 	;	ECX = DirBuff Valid Data identifier (CL)
  5347                              <1> 	;   	If CF = 0 and CL = 2 then
  5348                              <1> 	;	   directory buffer modified and
  5349                              <1> 	;	   must be written to disk.
  5350                              <1> 	; 	If CF = 0  and CL = 1 then
  5351                              <1> 	;	   dir buffer has been written to disk, already.
  5352                              <1> 	;	CF = 1 -> Error code in EAX (AL)
  5353                              <1> 	;
  5354                              <1> 	; (Modified registers: EAX, EDX, ECX, EBX, EDI) 
  5355                              <1> 
  5356                              <1> loc_locate_current_dir_entry:
  5357 0000BC8E 56                  <1> 	push	esi
  5358 0000BC8F 89C1                <1> 	mov	ecx, eax
  5359 0000BC91 BA20000000          <1> 	mov	edx, 32
  5360 0000BC96 F7E2                <1> 	mul	edx 
  5361 0000BC98 A3[D0940100]        <1> 	mov	[LCDE_ByteOffset], eax
  5362 0000BC9D 31DB                <1> 	xor	ebx, ebx
  5363 0000BC9F 8A3D[F68A0100]      <1> 	mov	bh, [Current_Drv]
  5364 0000BCA5 A0[1A920100]        <1>         mov     al, [DirBuff_DRV]
  5365 0000BCAA 2C41                <1> 	sub	al, 'A'
  5366 0000BCAC BE00010900          <1>         mov     esi, Logical_DOSDisks
  5367 0000BCB1 01DE                <1> 	add	esi, ebx
  5368 0000BCB3 38C7                <1> 	cmp	bh, al
  5369 0000BCB5 0F8592000000        <1>         jne     loc_lcde_reload_current_directory
  5370                              <1> loc_lcde_cdl_check:
  5371 0000BCBB 803D[F48A0100]00    <1> 	cmp	byte [Current_Dir_Level], 0
  5372 0000BCC2 772A                <1> 	ja	short loc_lcde_calc_dirbuff_cluster_offset
  5373                              <1> 	; 27/02/2016
  5374                              <1> 	; TRDOS v1 has bug here for FAT32 fs !
  5375                              <1> 	; (Root Directory Entries for FAT32 = 0)
  5376 0000BCC4 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3  ; FAT32
  5377 0000BCC8 7324                <1> 	jnb	short loc_lcde_calc_dirbuff_cluster_offset
  5378                              <1> 
  5379                              <1> loc_lcde_cdl_check_FAT12_16:
  5380 0000BCCA 668B4617            <1> 	mov	ax, [esi+LD_BPB+RootDirEnts]
  5381 0000BCCE 6648                <1> 	dec	ax
  5382                              <1> 	;xor	dx, dx  
  5383 0000BCD0 6639C8              <1> 	cmp	ax, cx ; cx = Directory Entry (Index) Number
  5384 0000BCD3 720E                <1> 	jb	short loc_lcde_stc_12h_retn
  5385 0000BCD5 66890D[C8940100]    <1> 	mov	[LCDE_EntryIndex], cx
  5386 0000BCDC 31C0                <1> 	xor	eax, eax
  5387 0000BCDE E993000000          <1>         jmp     loc_lcde_check_dir_buffer_cluster
  5388                              <1> 
  5389                              <1> loc_lcde_stc_12h_retn:
  5390 0000BCE3 5E                  <1> 	pop	esi
  5391 0000BCE4 89CB                <1> 	mov	ebx, ecx
  5392 0000BCE6 89D1                <1> 	mov	ecx, edx
  5393                              <1> 	; 16/10/2016 (12h -> 12)
  5394 0000BCE8 B80C000000          <1> 	mov	eax, 12 ; No more files
  5395 0000BCED C3                  <1> 	retn 
  5396                              <1> 
  5397                              <1> loc_lcde_calc_dirbuff_cluster_offset:
  5398 0000BCEE 8A5E13              <1> 	mov	bl, [esi+LD_BPB+SecPerClust]
  5399 0000BCF1 30FF                <1> 	xor	bh, bh
  5400 0000BCF3 668B4611            <1> 	mov	ax, [esi+LD_BPB+BytesPerSec]
  5401 0000BCF7 66F7E3              <1> 	mul	bx
  5402 0000BCFA 6609D2              <1>  	or	dx, dx ; If bytes per cluster > 32KB it is invalid
  5403 0000BCFD 755D                <1> 	jnz	short loc_lcde_invalid_format
  5404                              <1> 	;mov	ecx, eax
  5405 0000BCFF 6689C1              <1> 	mov	cx, ax ; BYTES PER CLUSTER
  5406 0000BD02 A1[D0940100]        <1> 	mov	eax, [LCDE_ByteOffset]
  5407                              <1> 	;sub	edx, edx
  5408 0000BD07 F7F1                <1> 	div	ecx
  5409 0000BD09 3DFFFF0000          <1> 	cmp	eax, 65535
  5410 0000BD0E 774C                <1> 	ja	short loc_lcde_invalid_format
  5411                              <1> 
  5412                              <1> 	; cluster sequence number of directory (< 65536)
  5413 0000BD10 66A3[CA940100]      <1> 	mov	[LCDE_ClusterSN], ax 
  5414                              <1> 
  5415 0000BD16 6689D0              <1> 	mov	ax, dx ; byte offset in cluster (directory buffer)
  5416 0000BD19 66BB2000            <1> 	mov	bx, 32 ; ; 1 dir entry = 32 bytes
  5417 0000BD1D 6629D2              <1>         sub     dx, dx  ; 0
  5418 0000BD20 66F7F3              <1> 	div	bx 
  5419 0000BD23 66A3[C8940100]      <1> 	mov	[LCDE_EntryIndex], ax ; dir entry index/sequence number
  5420                              <1> 				      ; (in directory buffer/cluster)	  
  5421                              <1> loc_lcde_get_current_sub_dir_fcluster:
  5422 0000BD29 A1[F08A0100]        <1> 	mov	eax, [Current_Dir_FCluster]
  5423                              <1> 
  5424                              <1> loc_lcde_get_next_cluster:
  5425 0000BD2E 66833D[CA940100]00  <1> 	cmp	word [LCDE_ClusterSN], 0
  5426 0000BD36 763E                <1> 	jna	short loc_lcde_check_dir_buffer_cluster
  5427 0000BD38 A3[CC940100]        <1> 	mov	[LCDE_Cluster], eax
  5428 0000BD3D E834100000          <1> 	call	get_next_cluster
  5429 0000BD42 7220                <1> 	jc	short loc_lcde_check_gnc_error
  5430 0000BD44 66FF0D[CA940100]    <1>   	dec	word [LCDE_ClusterSN]
  5431 0000BD4B EBE1                <1> 	jmp	short loc_lcde_get_next_cluster
  5432                              <1> 
  5433                              <1> loc_lcde_reload_current_directory:
  5434 0000BD4D 51                  <1> 	push	ecx
  5435 0000BD4E E813F6FFFF          <1> 	call	reload_current_directory
  5436 0000BD53 59                  <1> 	pop	ecx
  5437 0000BD54 0F8361FFFFFF        <1>         jnc     loc_lcde_cdl_check
  5438 0000BD5A 5E                  <1> 	pop	esi
  5439 0000BD5B C3                  <1> 	retn
  5440                              <1> 
  5441                              <1> loc_lcde_invalid_format:
  5442                              <1> 	; 15/10/2016 (0Bh -> 28)
  5443 0000BD5C B81C000000          <1> 	mov	eax, 28 ; Invalid Format !
  5444                              <1> loc_lcde_drive_not_ready_read_err:
  5445 0000BD61 F9                  <1> 	stc
  5446 0000BD62 5E                  <1> 	pop	esi 
  5447 0000BD63 C3                  <1> 	retn  
  5448                              <1> 
  5449                              <1> loc_lcde_check_gnc_error:
  5450 0000BD64 09C0                <1> 	or	eax, eax
  5451 0000BD66 75F9                <1> 	jnz	short loc_lcde_drive_not_ready_read_err
  5452 0000BD68 66FF0D[CA940100]    <1> 	dec	word [LCDE_ClusterSN]
  5453 0000BD6F 75EB                <1> 	jnz	short loc_lcde_invalid_format 
  5454 0000BD71 A1[CC940100]        <1> 	mov	eax, [LCDE_Cluster]
  5455                              <1> 
  5456                              <1> loc_lcde_check_dir_buffer_cluster:
  5457 0000BD76 3B05[21920100]      <1> 	cmp	eax, [DirBuff_Cluster]
  5458 0000BD7C 755C                <1> 	jne	short loc_lcde_load_dir_cluster
  5459 0000BD7E 803D[1C920100]00    <1> 	cmp	byte [DirBuff_ValidData], 0
  5460 0000BD85 7727                <1> 	ja	short lcde_check_dir_buffer_cluster_next
  5461 0000BD87 803D[F48A0100]00    <1> 	cmp	byte [Current_Dir_Level], 0    
  5462 0000BD8E 775F                <1> 	ja	short loc_lcde_load_dir_cluster_0
  5463                              <1> 	; 27/02/2016
  5464                              <1> 	; TRDOS v1 has bug here for FAT32 fs !
  5465 0000BD90 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3  ; FAT32
  5466 0000BD94 7359                <1> 	jnb	short loc_lcde_load_dir_cluster_0
  5467                              <1> 	;
  5468 0000BD96 0FB74E17            <1> 	movzx	ecx, word [esi+LD_BPB+RootDirEnts]
  5469 0000BD9A 6683C10F            <1> 	add	cx, 15 ; round up (16 entries per sector)
  5470 0000BD9E 66C1E904            <1> 	shr	cx, 4 ; 1 sector contains 16 dir entries	
  5471                              <1> 
  5472 0000BDA2 8B4664              <1>         mov     eax, [esi+LD_ROOTBegin]
  5473 0000BDA5 EB54                <1> 	jmp	short loc_lcde_load_dir_cluster_1 
  5474                              <1> 
  5475                              <1> loc_lcde_validate_dirBuff:
  5476 0000BDA7 C605[1C920100]01    <1> 	mov	byte [DirBuff_ValidData], 1
  5477                              <1> 
  5478                              <1> lcde_check_dir_buffer_cluster_next:
  5479 0000BDAE 0FB71D[C8940100]    <1> 	movzx	ebx, word [LCDE_EntryIndex]
  5480 0000BDB5 663B1D[1F920100]    <1> 	cmp	bx, [DirBuff_LastEntry]
  5481 0000BDBC 779E                <1> 	ja	short loc_lcde_invalid_format 
  5482 0000BDBE B820000000          <1> 	mov	eax, 32
  5483 0000BDC3 F7E3                <1> 	mul	ebx
  5484                              <1> 	;or	edx, edx
  5485                              <1> 	;jnz	short loc_lcde_invalid_format
  5486                              <1> 
  5487 0000BDC5 BF00000800          <1> 	mov	edi, Directory_Buffer  
  5488 0000BDCA 01C7                <1> 	add	edi, eax ; add entry offset to buffer address
  5489                              <1> 
  5490                              <1> loc_lcde_dir_buffer_last_check:
  5491 0000BDCC A1[21920100]        <1> 	mov	eax, [DirBuff_Cluster]
  5492 0000BDD1 0FB60D[1C920100]    <1> 	movzx	ecx, byte [DirBuff_ValidData]
  5493                              <1> 
  5494                              <1> loc_lcde_retn:
  5495 0000BDD8 5E                  <1> 	pop	esi
  5496 0000BDD9 C3                  <1> 	retn
  5497                              <1> 
  5498                              <1> loc_lcde_load_dir_cluster:
  5499                              <1> 	;cmp	byte [DirBuff_ValidData], 2
  5500                              <1> 	;jne	short loc_lcde_load_dir_cluster_n2
  5501 0000BDDA 50                  <1> 	push	eax
  5502 0000BDDB E8E6FCFFFF          <1> 	call	save_directory_buffer
  5503 0000BDE0 58                  <1> 	pop	eax
  5504 0000BDE1 72F5                <1> 	jc	short loc_lcde_retn
  5505                              <1> 
  5506                              <1> loc_lcde_load_dir_cluster_n2:
  5507 0000BDE3 C605[1C920100]00    <1> 	mov	byte [DirBuff_ValidData], 0
  5508 0000BDEA A3[21920100]        <1> 	mov	[DirBuff_Cluster], eax
  5509                              <1> 
  5510                              <1> loc_lcde_load_dir_cluster_0:
  5511 0000BDEF 83E802              <1> 	sub	eax, 2
  5512 0000BDF2 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
  5513 0000BDF6 F7E1                <1> 	mul	ecx
  5514 0000BDF8 034668              <1>         add     eax, [esi+LD_DATABegin]
  5515                              <1> 
  5516                              <1> loc_lcde_load_dir_cluster_1:
  5517 0000BDFB BB00000800          <1> 	mov	ebx, Directory_Buffer
  5518                              <1> 	; ecx = sector count
  5519 0000BE00 E8B86D0000          <1> 	call	disk_read
  5520 0000BE05 73A0                <1> 	jnc	short loc_lcde_validate_dirBuff
  5521                              <1> 
  5522                              <1> 	; 15/10/2016 
  5523                              <1> 	; (Disk read error instead of drv not ready err)
  5524 0000BE07 B811000000          <1> 	mov	eax, 17 ; Drive not ready or read error !
  5525 0000BE0C EBCA                <1> 	jmp	short loc_lcde_retn
  5526                              <1> 
  5527                              <1> 
  5528                              <1> remove_file:
  5529                              <1> 	; 15/10/2016
  5530                              <1> 	; 28/02/2016 (TRDOS 386 = TRDOS v2.0)
  5531                              <1> 	; 10/04/2011 (FILE.ASM, 'proc_delete_file')
  5532                              <1> 	; 09/08/2010
  5533                              <1> 	; INPUT ->
  5534                              <1> 	;	EDI = Directory Buffer Entry Address
  5535                              <1> 	;	 CX = Directory Buffer Entry Counter/Index
  5536                              <1> 	;	 BL = Longname Entry Length
  5537                              <1> 	;	 BH = Logical DOS Drive Number 
  5538                              <1> 
  5539 0000BE0E 29C0                <1> 	sub	eax, eax
  5540 0000BE10 88FC                <1> 	mov	ah, bh
  5541 0000BE12 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  5542 0000BE17 01C6                <1> 	add	esi, eax
  5543                              <1> 
  5544 0000BE19 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
  5545 0000BE1D 7312                <1> 	jnb	short loc_del_fat_file 
  5546                              <1>               
  5547 0000BE1F 807E04A1            <1> 	cmp	byte [esi+LD_FSType], 0A1h
  5548 0000BE23 7406                <1> 	je	short loc_del_fs_file
  5549                              <1> 
  5550                              <1> loc_del_file_invalid_format:
  5551 0000BE25 30E4                <1> 	xor	ah, ah
  5552                              <1> 	; 15/10/2016 (0Bh -> 28)
  5553 0000BE27 B01C                <1> 	mov	al, 28  ; Invalid Format
  5554 0000BE29 F9                  <1> 	stc 
  5555 0000BE2A C3                  <1> 	retn
  5556                              <1> 
  5557                              <1> loc_del_fs_file:
  5558 0000BE2B E83F0F0000          <1> 	call	delete_fs_file
  5559 0000BE30 C3                  <1> 	retn
  5560                              <1> 
  5561                              <1> loc_del_fat_file:
  5562 0000BE31 E808000000          <1> 	call	delete_directory_entry
  5563 0000BE36 7205                <1> 	jc	short loc_del_file_err_retn 
  5564                              <1> 
  5565                              <1> loc_delfile_unlink_cluster_chain:
  5566 0000BE38 E863170000          <1> 	call	truncate_cluster_chain
  5567                              <1> 	;jc	short loc_del_file_err_retn
  5568                              <1> 
  5569                              <1> loc_delfile_return:
  5570                              <1> loc_del_file_err_retn:
  5571 0000BE3D C3                  <1> 	retn
  5572                              <1> 
  5573                              <1> delete_directory_entry:
  5574                              <1> 	; 15/10/2016
  5575                              <1> 	; 28/02/2016 (TRDOS 386 = TRDOS v2.0)
  5576                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_delete_directory_entry')
  5577                              <1> 	; 10/04/2011 
  5578                              <1> 	; INPUT ->
  5579                              <1> 	; 	ESI = Logical Dos Drive Descripton Table Address 
  5580                              <1> 	;	EDI = Directory Buffer Entry Address
  5581                              <1> 	;	 CX = Directory Buffer Entry Counter/Index
  5582                              <1> 	;	 BL = Longname Entry Length
  5583                              <1> 	; OUTPUT ->
  5584                              <1> 	; 	ESI = Logical dos drive descripton table address 
  5585                              <1> 	;	EAX = First cluster to be truncated/unlinked
  5586                              <1> 	;       CF = 1 -> Error code in EAX (AL)
  5587                              <1> 	;       CF = 0 & BH <> 0 -> LMDT write error  (BH = 1)
  5588                              <1> 	;       CF = 0 & BL <> 0 -> Long name delete error (BL = FFh) 
  5589                              <1> 	;
  5590                              <1> 	;  (EDI, EBX, ECX register contents will be changed)
  5591                              <1> 
  5592 0000BE3E 881D[5E940100]      <1> 	mov	[DelFile_LNEL], bl
  5593 0000BE44 66890D[5C940100]    <1> 	mov	[DelFile_EntryCounter], cx
  5594                              <1> 
  5595 0000BE4B 668B4714            <1> 	mov	ax, [edi+20] ; First Cluster High Word
  5596 0000BE4F C1E010              <1> 	shl	eax, 16
  5597 0000BE52 668B471A            <1> 	mov	ax, [edi+26] ; First Cluster Low Word
  5598                              <1> 
  5599 0000BE56 A3[58940100]        <1> 	mov	[DelFile_FCluster], eax
  5600                              <1> 
  5601                              <1> loc_del_short_name:
  5602 0000BE5B C607E5              <1> 	mov	byte [edi], 0E5h  ; Deleted sign
  5603                              <1> 
  5604 0000BE5E C605[1C920100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  5605 0000BE65 E85CFCFFFF          <1> 	call	save_directory_buffer
  5606 0000BE6A 723D                <1> 	jc	short loc_delete_direntry_err_return
  5607                              <1>  
  5608                              <1> loc_del_long_name:
  5609 0000BE6C 0FB615[5E940100]    <1> 	movzx	edx, byte [DelFile_LNEL]
  5610 0000BE73 08D2                <1> 	or	dl, dl
  5611 0000BE75 7416                <1> 	jz	short loc_del_dir_entry_update_parent_dir_lm_date
  5612                              <1> 
  5613 0000BE77 8835[5E940100]      <1> 	mov	byte [DelFile_LNEL], dh ; 0              
  5614                              <1>   
  5615 0000BE7D 0FB705[5C940100]    <1> 	movzx	eax,  word [DelFile_EntryCounter]
  5616 0000BE84 29D0                <1> 	sub	eax, edx
  5617                              <1> 	;jnc	short loc_del_long_name_continue
  5618 0000BE86 7205                <1> 	jc	short loc_del_dir_entry_update_parent_dir_lm_date   
  5619                              <1> 
  5620                              <1> ;loc_del_direntry_inv_data_return: ; 15/10/2016 (0Dh -> 29)
  5621                              <1> ;	mov	eax, 29 ; 0Dh (TRDOS 8086) ; Invalid data
  5622                              <1> ;	retn
  5623                              <1> 
  5624                              <1> loc_del_long_name_continue: 
  5625                              <1> 	; AX = Directory Entry Number of the long name last entry
  5626 0000BE88 E897FDFFFF          <1> 	call	delete_longname
  5627                              <1> 	;jc	short loc_delete_direntry_err_return
  5628                              <1> 
  5629                              <1> loc_del_dir_entry_update_parent_dir_lm_date:
  5630 0000BE8D 801D[5E940100]00    <1> 	sbb	byte [DelFile_LNEL], 0 ; 0FFh if cf = 1
  5631                              <1> 
  5632 0000BE94 E8C8FCFFFF          <1> 	call	update_parent_dir_lmdt
  5633 0000BE99 B700                <1> 	mov	bh, 0
  5634 0000BE9B 80D700              <1> 	adc	bh, 0
  5635                              <1> 
  5636 0000BE9E 8A1D[5E940100]      <1> 	mov	bl, byte [DelFile_LNEL]
  5637                              <1>  
  5638                              <1> loc_delete_direntry_return:
  5639 0000BEA4 A1[58940100]        <1> 	mov	eax, [DelFile_FCluster]
  5640                              <1> loc_delete_direntry_err_return:
  5641 0000BEA9 C3                  <1> 	retn
  5642                              <1> 
  5643                              <1> rename_directory_entry:
  5644                              <1> 	; 13/11/2017
  5645                              <1> 	; 15/10/2016
  5646                              <1> 	; 06/03/2016 (TRDOS 386 = TRDOS v2.0)
  5647                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_rename_directory_entry')
  5648                              <1> 	; 19/11/2010
  5649                              <1> 	; INPUT -> (Current Directory)
  5650                              <1> 	;	CX = Directory Entry Number
  5651                              <1> 	;      EAX = First Cluster number of file or directory
  5652                              <1> 	;      EBX = Longname Length (dir entry count) (< 256)
  5653                              <1> 	;      ESI = New file (or directory) name (no path).
  5654                              <1> 	;           (ASCIIZ string)  
  5655                              <1> 	; OUTPUT -> 
  5656                              <1> 	;      CF = 0 -> successfull
  5657                              <1> 	;      CF = 1 -> error code in EAX (AL)
  5658                              <1> 	;
  5659                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI will be changed)
  5660                              <1> 
  5661 0000BEAA 803D[F58A0100]00    <1> 	cmp	byte [Current_FATType], 0
  5662 0000BEB1 7706                <1> 	ja	short loc_rename_directory_entry
  5663                              <1> 
  5664 0000BEB3 E8B80E0000          <1> 	call	rename_fs_file_or_directory
  5665 0000BEB8 C3                  <1> 	retn 
  5666                              <1> 	
  5667                              <1> loc_rename_directory_entry:
  5668 0000BEB9 881D[5E940100]      <1> 	mov	[DelFile_LNEL], bl
  5669 0000BEBF 66890D[5C940100]    <1> 	mov	[DelFile_EntryCounter], cx
  5670 0000BEC6 A3[58940100]        <1> 	mov	[DelFile_FCluster], eax
  5671                              <1> 
  5672 0000BECB 0FB7C1              <1> 	movzx	eax, cx
  5673 0000BECE E8BBFDFFFF          <1> 	call	locate_current_dir_entry
  5674 0000BED3 7308                <1> 	jnc	short loc_rename_direntry_check_fcluster
  5675                              <1> 
  5676                              <1> loc_rename_direntry_pop_retn:
  5677 0000BED5 C3                  <1> 	retn
  5678                              <1> 
  5679                              <1> loc_rename_direntry_pop_invd_retn:
  5680 0000BED6 F9                  <1> 	stc
  5681                              <1> loc_rename_direntry_invd_retn:
  5682                              <1> 	; 15/10/2016 (0Dh -> 29)
  5683 0000BED7 B81D000000          <1> 	mov	eax, 29 ; Invalid data
  5684                              <1> loc_rename_retn:
  5685 0000BEDC C3                  <1> 	retn 
  5686                              <1> 
  5687                              <1> loc_rename_direntry_check_fcluster:
  5688 0000BEDD 668B5714            <1> 	mov	dx, [edi+20] ; First Cluster HW
  5689 0000BEE1 C1E210              <1> 	shl	edx, 16 ; 13/11/2017
  5690 0000BEE4 668B571A            <1> 	mov	dx, [edi+26] ; First Cluster LW
  5691 0000BEE8 3B15[58940100]      <1> 	cmp	edx, [DelFile_FCluster]
  5692 0000BEEE 75E6                <1> 	jne	short loc_rename_direntry_pop_invd_retn
  5693                              <1> 	; ESI = New file (or directory) name. (ASCIIZ string)
  5694                              <1> 	; 06/03/2016
  5695                              <1> 	; TRDOS v2 - NOTE: 'convert_file_name' procedure
  5696                              <1> 	; has been modified for eliminating following situation.
  5697                              <1> 	; 
  5698                              <1> 	; TRDOS v1 - NOTE: If file/dir name is more than 11 bytes
  5699                              <1> 	; without a dot, attributes (edi+11) byte will be overwritten !
  5700                              <1> 	; (Dot file name input must be proper for 11 byte dir entry
  5701                              <1> 	;  type file name output.) 
  5702 0000BEF0 E8A2F6FFFF          <1> 	call	convert_file_name
  5703                              <1> 
  5704 0000BEF5 C605[1C920100]02    <1>         mov     byte [DirBuff_ValidData], 2
  5705 0000BEFC E8C5FBFFFF          <1> 	call	save_directory_buffer
  5706 0000BF01 72D9                <1> 	jc	short loc_rename_retn
  5707                              <1> 
  5708                              <1> loc_rename_direntry_del_ln:
  5709 0000BF03 0FB615[5E940100]    <1> 	movzx	edx, byte [DelFile_LNEL]
  5710 0000BF0A 08D2                <1> 	or	dl, dl
  5711 0000BF0C 7410                <1> 	jz	short loc_rename_direntry_update_parent_dir_lm_date
  5712                              <1> 
  5713 0000BF0E 0FB705[5C940100]    <1> 	movzx	eax, word [DelFile_EntryCounter]
  5714 0000BF15 29D0                <1> 	sub	eax, edx
  5715 0000BF17 72BE                <1> 	jc	short loc_rename_direntry_invd_retn
  5716                              <1> 
  5717                              <1> loc_rename_direntry_del_ln_continue: 
  5718                              <1> 	; EAX = Directory Entry Number of the long name last entry
  5719 0000BF19 E806FDFFFF          <1> 	call	delete_longname
  5720                              <1> 
  5721                              <1> loc_rename_direntry_update_parent_dir_lm_date:
  5722 0000BF1E E83EFCFFFF          <1> 	call	update_parent_dir_lmdt
  5723 0000BF23 31C0                <1> 	xor	eax, eax 
  5724 0000BF25 C3                  <1> 	retn
  5725                              <1> 
  5726                              <1> move_source_file_to_destination_file:
  5727                              <1> 	; 15/10/2016
  5728                              <1> 	; 11/03/2016
  5729                              <1> 	; 10/03/2016 (TRDOS 386 = TRDOS v2.0)
  5730                              <1> 	; 01/08/2011 (FILE.ASM)
  5731                              <1> 	; 04/08/2010
  5732                              <1> 	;
  5733                              <1> 	;   Phase 1 -> Check destination file, 
  5734                              <1> 	;              'not found' is required
  5735                              <1> 	;   Phase 2 -> Check source file
  5736                              <1> 	;              'found' and proper attributes is required
  5737                              <1> 	;   Phase 3 -> Make destination directory entry,
  5738                              <1> 	;           add new dir cluster or section if it is required
  5739                              <1> 	;   Phase 4 -> Delete source directory entry.
  5740                              <1> 	;       cf = 1 causes to return before the phase 4.
  5741                              <1> 	;    (source file protection against any possible errors)    
  5742                              <1> 	;
  5743                              <1> 	; 08/05/2011 major modification
  5744                              <1> 	;            -> destination file deleting is removed   
  5745                              <1> 	;            for msdos move/rename compatibility.
  5746                              <1> 	;            (Access denied error will return if
  5747                              <1> 	;            the destination file is found...)
  5748                              <1> 	; INPUT ->
  5749                              <1> 	;	 ESI = Source File Pathname (Asciiz)
  5750                              <1> 	;        EDI = Destination File Pathname (Asciiz)
  5751                              <1> 	;        AL = 0 --> Interrupt (System call)
  5752                              <1> 	;        AL > 0 --> Command Interpreter (Question)
  5753                              <1> 	;        AL = 1 --> Question Phase
  5754                              <1> 	;        AL = 2 --> Progress Phase        
  5755                              <1> 	; OUTPUT -> 
  5756                              <1> 	;	 cf = 0 -> OK
  5757                              <1> 	;        EAX = Destination directory first cluster
  5758                              <1> 	;        ESI = Logical DOS drive description table 
  5759                              <1> 	;        EBX = Destination file structure offset
  5760                              <1> 	;        CX = 0 (CX > 0 --> calculate free space error)
  5761                              <1> 	;        cf = 1 -> Error code in EAX (AL) 
  5762                              <1> 	;
  5763                              <1> 	;  (EDX, ECX, EBX, ESI, EDI will be changed)
  5764                              <1> 
  5765 0000BF26 3C02                <1> 	cmp	al, 2
  5766 0000BF28 0F847F010000        <1> 	je	msftdf_df2_check_directory
  5767 0000BF2E A2[DE950100]        <1> 	mov	[move_cmd_phase], al
  5768                              <1> 
  5769                              <1> msftdf_parse_sf_path:
  5770                              <1> 	; ESI = ASCIIZ pathname (Source)
  5771 0000BF33 57                  <1> 	push	edi 
  5772 0000BF34 BF[DC940100]        <1> 	mov	edi, SourceFile_Drv
  5773 0000BF39 E824F7FFFF          <1> 	call	parse_path_name
  5774 0000BF3E 5E                  <1> 	pop	esi
  5775 0000BF3F 7211                <1> 	jc	short msftdf_psf_retn
  5776                              <1> 
  5777                              <1> msftdf_parse_df_path:
  5778                              <1> 	; ESI = ASCIIZ pathname	(Destination)
  5779 0000BF41 BF[5C950100]        <1> 	mov	edi, DestinationFile_Drv
  5780 0000BF46 E817F7FFFF          <1> 	call	parse_path_name
  5781 0000BF4B 7306                <1> 	jnc	short msftdf_check_sf_drv
  5782                              <1> 
  5783 0000BF4D 3C01                <1> 	cmp	al, 1 ; File or directory name is not existing
  5784 0000BF4F 7602                <1> 	jna	short msftdf_check_sf_drv
  5785                              <1> 
  5786                              <1> msftdf_stc_retn:
  5787 0000BF51 F9                  <1> 	stc
  5788                              <1> msftdf_psf_retn:
  5789 0000BF52 C3                  <1> 	retn 
  5790                              <1> 
  5791                              <1> msftdf_check_sf_drv:
  5792 0000BF53 A0[DC940100]        <1> 	mov	al, [SourceFile_Drv]
  5793                              <1> 
  5794                              <1> msftdf_check_df_drv:
  5795 0000BF58 8A15[5C950100]      <1> 	mov	dl, [DestinationFile_Drv]
  5796                              <1> 
  5797                              <1> msftdf_compare_sf_df_drv:
  5798 0000BF5E 29DB                <1> 	sub	ebx, ebx
  5799 0000BF60 8A3D[F68A0100]      <1> 	mov	bh, [Current_Drv]
  5800 0000BF66 38C2                <1> 	cmp	dl, al
  5801 0000BF68 7409                <1> 	je	short msftdf_check_sf_df_drv_ok
  5802                              <1> 
  5803                              <1> msftdf_not_same_drv:
  5804                              <1>         ; DL = source file's drive number
  5805 0000BF6A 88C6                <1> 	mov	dh, al ; destination file's drive number
  5806                              <1> 	; 15/10/2016 (11h -> 21)
  5807 0000BF6C B815000000          <1> 	mov	eax, 21 ; Not the same drive
  5808 0000BF71 F9                  <1> 	stc
  5809 0000BF72 C3                  <1> 	retn 
  5810                              <1> 
  5811                              <1> msftdf_check_sf_df_drv_ok:
  5812 0000BF73 8815[DF950100]      <1> 	mov	[msftdf_sf_df_drv], dl
  5813                              <1> 
  5814 0000BF79 29C0                <1>         sub	eax, eax
  5815 0000BF7B 88D4                <1> 	mov	ah, dl
  5816 0000BF7D 0500010900          <1> 	add	eax, Logical_DOSDisks
  5817 0000BF82 A3[E0950100]        <1> 	mov	[msftdf_drv_offset], eax
  5818                              <1> 
  5819 0000BF87 38FA                <1> 	cmp	dl, bh ; byte [Current_Drv]
  5820 0000BF89 7407                <1> 	je	short msftdf_df_check_directory
  5821                              <1> 
  5822                              <1> msftdf_change_drv:
  5823 0000BF8B E85EC1FFFF          <1> 	call 	change_current_drive
  5824 0000BF90 726D                <1> 	jc	short msftdf_df_error_retn
  5825                              <1> 	  
  5826                              <1> msftdf_check_destination_file:
  5827                              <1> msftdf_df_check_directory:
  5828 0000BF92 BE[5D950100]        <1> 	mov	esi, DestinationFile_Directory
  5829 0000BF97 803E20              <1> 	cmp	byte [esi], 20h
  5830 0000BF9A 760F                <1> 	jna	short msftdf_df_find_1
  5831                              <1> 
  5832                              <1> msftdf_df_change_directory:
  5833 0000BF9C FE05[C3400100]      <1> 	inc	byte [Restore_CDIR]
  5834 0000BFA2 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  5835 0000BFA4 E8A3F0FFFF          <1> 	call	change_current_directory
  5836 0000BFA9 7254                <1> 	jc	short msftdf_df_error_retn
  5837                              <1> 
  5838                              <1> ;msftdf_df_change_prompt_dir_string:
  5839                              <1> ;	call 	change_prompt_dir_string
  5840                              <1> 
  5841                              <1> msftdf_df_find_1:
  5842 0000BFAB BE[9E950100]        <1>         mov     esi, DestinationFile_Name
  5843 0000BFB0 803E20              <1> 	cmp	byte [esi], 20h
  5844 0000BFB3 7631                <1> 	jna	short msftdf_df_copy_sf_name
  5845                              <1> 
  5846                              <1> msftdf_df_find_2:
  5847 0000BFB5 6631C0              <1> 	xor	ax, ax ; DestinationFile_AttributesMask -> any/zero
  5848 0000BFB8 E8D4D4FFFF          <1> 	call	find_first_file
  5849 0000BFBD 0F838D000000        <1> 	jnc	msftdf_permission_denied_retn
  5850                              <1> 
  5851                              <1> msftdf_df_check_error_code:
  5852                              <1> 	;cmp	eax, 2 ; File not found error
  5853 0000BFC3 3C02                <1> 	cmp	al, 2
  5854 0000BFC5 7537                <1> 	jne	short msftdf_df_stc_retn
  5855                              <1>               
  5856                              <1> msftdf_df_check_fname:
  5857                              <1> 	; 15/10/2016
  5858 0000BFC7 BE[9E950100]        <1> 	mov	esi, DestinationFile_Name ; *
  5859 0000BFCC E87ED8FFFF          <1> 	call	check_filename
  5860 0000BFD1 7307                <1> 	jnc	short msftdf_convert_df_direntry_name
  5861                              <1> 	; invalid file name chars !
  5862 0000BFD3 B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME  ; 26
  5863 0000BFD8 EB24                <1> 	jmp	short msftdf_df_stc_retn
  5864                              <1> 
  5865                              <1> msftdf_convert_df_direntry_name:
  5866                              <1> 	; mov	esi, DestinationFile_Name ; *
  5867 0000BFDA BF[AE950100]        <1> 	mov	edi, DestinationFile_DirEntry
  5868 0000BFDF E8B3F5FFFF          <1> 	call	convert_file_name
  5869 0000BFE4 EB1A                <1>   	jmp	short msftdf_restore_current_dir_1
  5870                              <1> 
  5871                              <1> msftdf_df_copy_sf_name:
  5872 0000BFE6 89F7                <1> 	mov	edi, esi
  5873 0000BFE8 57                  <1> 	push	edi 
  5874 0000BFE9 BE[1E950100]        <1>         mov     esi, SourceFile_Name
  5875 0000BFEE B90C000000          <1> 	mov	ecx, 12
  5876                              <1> msftdf_df_copy_sf_name_loop:
  5877 0000BFF3 AC                  <1> 	lodsb
  5878 0000BFF4 AA                  <1>         stosb
  5879 0000BFF5 08C0                <1> 	or	al, al
  5880 0000BFF7 7402                <1> 	jz	short msftdf_df_copy_sf_name_ok	
  5881 0000BFF9 E2F8                <1>         loop    msftdf_df_copy_sf_name_loop
  5882                              <1> msftdf_df_copy_sf_name_ok:	
  5883 0000BFFB 5E                  <1> 	pop	esi  
  5884 0000BFFC EBB7                <1> 	jmp	short msftdf_df_find_2
  5885                              <1> 
  5886                              <1> msftdf_df_stc_retn:
  5887 0000BFFE F9                  <1> 	stc
  5888                              <1> msftdf_restore_cdir_failed:
  5889                              <1> msftdf_df_error_retn:
  5890 0000BFFF C3                  <1> 	retn
  5891                              <1> 
  5892                              <1> msftdf_restore_current_dir_1:
  5893 0000C000 803D[C3400100]00    <1> 	cmp	byte [Restore_CDIR], 0
  5894 0000C007 760D                <1> 	jna	short msftdf_sf_check_directory
  5895 0000C009 8B35[E0950100]      <1> 	mov	esi, [msftdf_drv_offset] 
  5896 0000C00F E891C1FFFF          <1> 	call	restore_current_directory
  5897 0000C014 72E9                <1> 	jc	short msftdf_restore_cdir_failed
  5898                              <1> 
  5899                              <1> msftdf_sf_check_directory:
  5900 0000C016 BE[DD940100]        <1> 	mov	esi, SourceFile_Directory
  5901 0000C01B 803E20              <1> 	cmp	byte [esi], 20h
  5902 0000C01E 760F                <1> 	jna	short msftdf_sf_find
  5903                              <1> msftdf_sf_change_directory:
  5904 0000C020 FE05[C3400100]      <1> 	inc	byte [Restore_CDIR]
  5905 0000C026 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  5906 0000C028 E81FF0FFFF          <1> 	call	change_current_directory
  5907 0000C02D 7227                <1> 	jc	short msftdf_return
  5908                              <1> 
  5909                              <1> ;msftdf_sf_change_prompt_dir_string:
  5910                              <1> ;	call	change_prompt_dir_string
  5911                              <1> 
  5912                              <1> msftdf_sf_find:
  5913 0000C02F BE[1E950100]        <1>         mov     esi, SourceFile_Name  ; Offset 66
  5914 0000C034 66B80018            <1> 	mov	ax, 1800h ; Only files
  5915 0000C038 E854D4FFFF          <1> 	call	find_first_file
  5916 0000C03D 7217                <1> 	jc	short msftdf_return
  5917                              <1> 
  5918                              <1> msftdf_sf_ambgfn_check:
  5919 0000C03F 6609D2              <1> 	or	dx, dx ; Ambiguous filename chars used sign (DX>0)
  5920 0000C042 7407                <1> 	jz	short msftdf_sf_found
  5921                              <1> 
  5922                              <1> msftdf_ambiguous_file_name_error:
  5923 0000C044 B802000000          <1> 	mov	eax, 2 ; File not found error
  5924 0000C049 F9                  <1> 	stc
  5925 0000C04A C3                  <1> 	retn
  5926                              <1> 
  5927                              <1> msftdf_sf_found:
  5928 0000C04B 80E31F              <1> 	and	bl, 1Fh ; Attributes, D-V-S-H-R
  5929 0000C04E 7416                <1> 	jz	short msftdf_save_sf_structure
  5930                              <1> 
  5931                              <1> msftdf_permission_denied_retn:
  5932 0000C050 B805000000          <1> 	mov	eax, 05h ; Access (Permission) denied !
  5933 0000C055 F9                  <1> 	stc
  5934                              <1> msftdf_rest_cdir_err_retn:
  5935                              <1> msftdf_return:
  5936 0000C056 C3                  <1> 	retn
  5937                              <1> 
  5938                              <1> msftdf_phase_1_return:
  5939 0000C057 31C0                <1> 	xor	eax, eax
  5940 0000C059 A2[DE950100]        <1> 	mov	[move_cmd_phase], al ; 0
  5941 0000C05E FEC0                <1> 	inc	al ; mov al, 1
  5942 0000C060 BB[ADC00000]        <1> 	mov	ebx, msftdf_df2_check_directory
  5943                              <1> 	;mov	edx, 0FFFFFFFFh 
  5944 0000C065 C3                  <1> 	retn
  5945                              <1> 
  5946                              <1> msftdf_save_sf_structure:
  5947 0000C066 BE[E8930100]        <1> 	mov	esi, FindFile_DirEntry
  5948 0000C06B BF[2E950100]        <1> 	mov	edi, SourceFile_DirEntry
  5949 0000C070 B908000000          <1> 	mov	ecx, 8
  5950 0000C075 F3A5                <1> 	rep	movsd
  5951                              <1> 
  5952                              <1> msftdf_df_copy_sf_parameters:
  5953 0000C077 BE0B000000          <1> 	mov	esi, 11
  5954 0000C07C 89F7                <1> 	mov	edi, esi
  5955 0000C07E 81C6[2E950100]      <1> 	add	esi, SourceFile_DirEntry
  5956 0000C084 81C7[AE950100]      <1> 	add	edi, DestinationFile_DirEntry
  5957                              <1> 	;mov	ecx, 21
  5958 0000C08A B115                <1> 	mov	cl, 21
  5959 0000C08C F3A4                <1> 	rep	movsb
  5960                              <1> 
  5961                              <1> msftdf_restore_current_dir_2:
  5962 0000C08E 803D[C3400100]00    <1> 	cmp	byte [Restore_CDIR], 0
  5963 0000C095 760D                <1> 	jna	short msftdf_df2_check_move_cmd_phase
  5964 0000C097 8B35[E0950100]      <1>  	mov	esi, [msftdf_drv_offset]
  5965 0000C09D E803C1FFFF          <1> 	call	restore_current_directory
  5966 0000C0A2 72B2                <1> 	jc	short msftdf_rest_cdir_err_retn
  5967                              <1> 
  5968                              <1> msftdf_df2_check_move_cmd_phase:
  5969 0000C0A4 803D[DE950100]01    <1> 	cmp	byte [move_cmd_phase], 1
  5970 0000C0AB 74AA                <1> 	je	short msftdf_phase_1_return
  5971                              <1> 
  5972                              <1> msftdf_df2_check_directory:
  5973 0000C0AD BE[5D950100]        <1> 	mov	esi, DestinationFile_Directory
  5974 0000C0B2 803E20              <1> 	cmp	byte [esi], 20h
  5975 0000C0B5 760F                <1> 	jna	short msftdf_make_dfde_locate_ffe_on_directory
  5976                              <1> msftdf_df2_change_directory:
  5977 0000C0B7 FE05[C3400100]      <1> 	inc	byte [Restore_CDIR]
  5978 0000C0BD 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  5979 0000C0BF E888EFFFFF          <1> 	call	change_current_directory
  5980 0000C0C4 7290                <1> 	jc	short msftdf_return
  5981                              <1> 
  5982                              <1> ;msftdf_df2_change_prompt_dir_string:
  5983                              <1> ;	call	change_prompt_dir_string
  5984                              <1> 
  5985                              <1> msftdf_make_dfde_locate_ffe_on_directory:
  5986                              <1> 	; Current directory fcluster <> Directory buffer cluster
  5987                              <1> 	; Current directory will be reloaded by
  5988                              <1> 	; 'locate_current_dir_file' procedure
  5989                              <1> 	;
  5990                              <1> 	;xor	ax, ax
  5991 0000C0C6 31C0                <1> 	xor	eax, eax
  5992 0000C0C8 89C1                <1> 	mov	ecx, eax
  5993 0000C0CA 6649                <1> 	dec	cx ; FFFFh  
  5994                              <1> 		; CX = FFFFh -> find first deleted or free entry
  5995                              <1> 		; ESI would be ASCIIZ filename address if the call
  5996                              <1> 		; would not be for first free or deleted dir entry  
  5997 0000C0CC E8CEF1FFFF          <1> 	call	locate_current_dir_file
  5998 0000C0D1 733F                <1> 	jnc	msftdf_make_dfde_set_ff_dir_entry
  5999                              <1> 	
  6000                              <1> 	;cmp	eax, 2
  6001 0000C0D3 3C02                <1>         cmp	al, 2
  6002 0000C0D5 7537                <1> 	jne	short msftdf_error_retn
  6003                              <1> 
  6004                              <1> msftdf_add_new_dir_entry_check_fs:
  6005 0000C0D7 8B35[E0950100]      <1> 	mov	esi, [msftdf_drv_offset]
  6006 0000C0DD A1[21920100]        <1> 	mov 	eax, [DirBuff_Cluster]
  6007 0000C0E2 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  6008 0000C0E6 7711                <1> 	ja	short msftdf_add_new_subdir_cluster
  6009                              <1> 
  6010                              <1> msftdf_add_new_fs_subdir_section:
  6011                              <1> 	;CL=0, CH=E5h --> deleted entry, CH=0 --> free entry
  6012                              <1>         ;xor	cx, cx
  6013 0000C0E8 30ED                <1> 	xor	ch, ch ; cx = 0 --> add a new subdir section
  6014 0000C0EA E8830C0000          <1> 	call	add_new_fs_section
  6015 0000C0EF 721E                <1>         jc	short msftdf_dsfde_error_retn
  6016                              <1> 	;mov	[createfile_LastDirCluster], eax
  6017                              <1> 
  6018 0000C0F1 E8A30E0000          <1> 	call	load_FS_sub_directory 
  6019                              <1> 	;mov	ebx, Directory_Buffer 
  6020 0000C0F6 7318                <1> 	jnc	short msftdf_add_new_fs_subdir_section_ok
  6021 0000C0F8 C3                  <1> 	retn	 
  6022                              <1> 
  6023                              <1> msftdf_add_new_subdir_cluster:
  6024 0000C0F9 E881150000          <1> 	call	add_new_cluster
  6025 0000C0FE 720F                <1> 	jc	short msftdf_dsfde_error_retn
  6026                              <1> 	
  6027                              <1> 	;mov	[createfile_LastDirCluster], eax
  6028                              <1> 
  6029 0000C100 E8570E0000          <1> 	call	load_FAT_sub_directory
  6030 0000C105 7309                <1> 	jnc	short msftdf_add_new_subdir_cluster_ok
  6031                              <1> 	; EBX = Directory buffer address
  6032                              <1> 
  6033                              <1> msftdf_ansdc_update_parent_dir_lmdt:
  6034                              <1> msftdf_make_dfde_err_upd_pdir_lmdt:
  6035 0000C107 50                  <1> 	push	eax
  6036 0000C108 E854FAFFFF          <1> 	call	update_parent_dir_lmdt
  6037 0000C10D 58                  <1> 	pop	eax
  6038                              <1> 
  6039                              <1> msftdf_error_retn:
  6040 0000C10E F9                  <1> 	stc
  6041                              <1> msftdf_dsfde_restore_cdir_failed:
  6042                              <1> msftdf_dsfde_error_retn:
  6043 0000C10F C3                  <1> 	retn
  6044                              <1> 
  6045                              <1> msftdf_add_new_fs_subdir_section_ok:
  6046                              <1> msftdf_add_new_subdir_cluster_ok:
  6047 0000C110 89DF                <1> 	mov	edi, ebx ; Directory buffer address
  6048                              <1> 
  6049                              <1> msftdf_make_dfde_set_ff_dir_entry:
  6050 0000C112 8B15[F08A0100]      <1> 	mov	edx, [Current_Dir_FCluster]
  6051 0000C118 8915[44960100]      <1> 	mov	[createfile_FFCluster], edx
  6052                              <1> 	; EDI = Directory entry offset
  6053 0000C11E BE[AE950100]        <1> 	mov	esi, DestinationFile_DirEntry
  6054 0000C123 B908000000          <1> 	mov	ecx, 8
  6055 0000C128 F3A5                <1> 	rep	movsd
  6056                              <1> 
  6057 0000C12A C605[1C920100]02    <1> 	mov	byte [DirBuff_ValidData], 2 
  6058 0000C131 E890F9FFFF          <1> 	call	save_directory_buffer
  6059 0000C136 72CF                <1> 	jc	short msftdf_make_dfde_err_upd_pdir_lmdt
  6060                              <1> 
  6061                              <1> msftdf_make_dfde_update_pdir_lmdt:
  6062 0000C138 E824FAFFFF          <1> 	call	update_parent_dir_lmdt
  6063                              <1> 
  6064                              <1> msftdf_dsfde_restore_current_dir_1:
  6065 0000C13D 803D[C3400100]00    <1> 	cmp	byte [Restore_CDIR], 0
  6066 0000C144 760D                <1> 	jna	short msftdf_dsfde_check_directory
  6067 0000C146 8B35[E0950100]      <1>  	mov	esi, [msftdf_drv_offset]
  6068 0000C14C E854C0FFFF          <1> 	call	restore_current_directory
  6069 0000C151 72BC                <1> 	jc	short msftdf_dsfde_restore_cdir_failed
  6070                              <1> 
  6071                              <1> msftdf_dsfde_check_directory:
  6072 0000C153 BE[DD940100]        <1> 	mov	esi, SourceFile_Directory
  6073 0000C158 803E20              <1> 	cmp	byte [esi], 20h
  6074 0000C15B 760F                <1> 	jna	short msftdf_dsfde_find_file
  6075                              <1> 
  6076                              <1> msftdf_dsfde_change_directory:
  6077 0000C15D FE05[C3400100]      <1> 	inc	byte [Restore_CDIR]
  6078 0000C163 28E4                <1> 	sub	ah, ah ; CD_COMMAND sign -> 0 
  6079 0000C165 E8E2EEFFFF          <1> 	call	change_current_directory
  6080 0000C16A 72A3                <1> 	jc	short msftdf_dsfde_error_retn
  6081                              <1> 
  6082                              <1> ;msftdf_dsfde_sf_change_prompt_dir_string:
  6083                              <1> ;	call	change_prompt_dir_string
  6084                              <1> 
  6085                              <1> msftdf_dsfde_find_file:
  6086 0000C16C BE[1E950100]        <1> 	mov	esi, SourceFile_Name  ; Offset 66
  6087 0000C171 668B460E            <1> 	mov	ax, [esi+14] ; 80 -> SourceFile_AttributesMask
  6088 0000C175 E817D3FFFF          <1> 	call	find_first_file
  6089 0000C17A 7293                <1> 	jc	short msftdf_dsfde_error_retn
  6090                              <1> 
  6091                              <1> msftdf_dsfde_delete_direntry:
  6092 0000C17C 8B35[E0950100]      <1> 	mov	esi, [msftdf_drv_offset]
  6093                              <1> 	
  6094 0000C182 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  6095 0000C186 770A                <1> 	ja	short msftdf_delete_FAT_direntry
  6096                              <1> 	
  6097 0000C188 30DB                <1> 	xor	bl, bl
  6098                              <1> 	; BL = 0 -> File
  6099                              <1> 	; EDI -> Directory buffer entry offset/address 
  6100 0000C18A E8E40B0000          <1> 	call	delete_fs_directory_entry
  6101 0000C18F 7315                <1> 	jnc	short msftdf_dsfde_restore_current_dir_2
  6102 0000C191 C3                  <1> 	retn
  6103                              <1> 
  6104                              <1> msftdf_delete_FAT_direntry:	
  6105 0000C192 8A1D[E5930100]      <1> 	mov	bl, [FindFile_LongNameEntryLength]
  6106 0000C198 668B0D[10940100]    <1> 	mov	cx, [FindFile_DirEntryNumber]
  6107                              <1> 	; ESI = Logical DOS drive description table address
  6108                              <1> 	; EDI = Directory buffer entry offset/address 
  6109 0000C19F E89AFCFFFF          <1> 	call	delete_directory_entry
  6110 0000C1A4 721C                <1> 	jc	short msftdf_retn
  6111                              <1> 
  6112                              <1> msftdf_dsfde_restore_current_dir_2:
  6113 0000C1A6 803D[C3400100]00    <1> 	cmp	byte [Restore_CDIR], 0
  6114 0000C1AD 7607                <1> 	jna	short msftdf_new_dir_fcluster_retn
  6115                              <1> 	;mov	esi, [msftdf_drv_offset]
  6116 0000C1AF E8F1BFFFFF          <1> 	call	restore_current_directory
  6117 0000C1B4 720C                <1> 	jc	short msftdf_retn
  6118                              <1> 
  6119                              <1> msftdf_new_dir_fcluster_retn:
  6120 0000C1B6 31C9                <1> 	xor	ecx, ecx 
  6121 0000C1B8 A1[44960100]        <1> 	mov	eax, [createfile_FFCluster]
  6122 0000C1BD BB[5C950100]        <1> 	mov	ebx, DestinationFile_Drv
  6123                              <1> 
  6124                              <1> msftdf_retn:
  6125 0000C1C2 C3                  <1> 	retn
  6126                              <1> 
  6127                              <1> 
  6128                              <1> copy_source_file_to_destination_file:
  6129                              <1> 	; 17/10/2016
  6130                              <1> 	; 16/10/2016
  6131                              <1> 	; 15/10/2016
  6132                              <1> 	; 30/03/2016, 31/03/2016
  6133                              <1> 	; 24/03/2016, 25/03/2016, 28/03/2016
  6134                              <1> 	; 21/03/2016, 22/03/2016, 23/03/2016
  6135                              <1> 	; 16/03/2016, 17/03/2016, 18/03/2016
  6136                              <1> 	; 15/03/2016 (TRDOS 386 = TRDOS v2.0)
  6137                              <1> 	; 02/09/2011 (FILE.ASM 'copy_source_file_to_destination_file')
  6138                              <1> 	; 01/08/2010 - 18/05/2011
  6139                              <1> 	;
  6140                              <1> 	;   Command Interpreter phase 1 enter ->
  6141                              <1> 	;           AL = 1 -> Caller is command interpreter
  6142                              <1> 	;           AL = 2 -> The second call, re-enter/continue
  6143                              <1> 	;   Phase 1 -> Check source file
  6144                              <1> 	;              'found' is required
  6145                              <1> 	;   Phase 2 -> Check destination file, 
  6146                              <1> 	;              save 'found' or 'not found' status
  6147                              <1> 	;              'permission denied' error will be return
  6148                              <1> 	;              if attributes have not for ordinary file 
  6149                              <1> 	;              without readonly attribute
  6150                              <1> 	;   Command Interpreter phase 1 return ->
  6151                              <1> 	;              DH = Source file attributes
  6152                              <1> 	;              DL = Destination file found status
  6153                              <1> 	;              EAX = 0 
  6154                              <1> 	;   Command Interpreter phase 2 enter ->
  6155                              <1> 	;              AL = 2 -> Continue from the last position
  6156                              <1> 	;              AH = 
  6157                              <1> 	;   Phase 3 -> Load source file or use read/write cluster method
  6158                              <1> 	;   Phase 4 -> Create destination file if it is not found
  6159                              <1> 	;   Phase 5 -> Open destination file
  6160                              <1> 	;   Phase 6 -> Read from source and write to destination
  6161                              <1> 	;   Phase 7 -> Unload source file, if it is loaded at memory
  6162                              <1> 	;       cf = 1 causes to return before the phase 7
  6163                              <1> 	;              but loaded file will be unloaded
  6164                              <1> 	;	       (allocated memory block will be deallocated) 
  6165                              <1> 	;
  6166                              <1> 	; INPUT -> 
  6167                              <1> 	;	 ESI = Source File Pathname (Asciiz)
  6168                              <1> 	;        EDI = Destination File Pathname (Asciiz)
  6169                              <1> 	;        AL = 0 --> Interrupt (System call)
  6170                              <1> 	;        AL > 0 --> Command Interpreter (Question)
  6171                              <1> 	;        AL = 1 --> Question Phase
  6172                              <1> 	;        AL = 2 --> Progress Phase        
  6173                              <1> 	;
  6174                              <1> 	; OUTPUT -> 
  6175                              <1> 	;	cf = 0 -> OK
  6176                              <1> 	;	EAX = Destination file first cluster
  6177                              <1> 	;
  6178                              <1> 	;        CL > 0 if there is file reading error before EOF
  6179                              <1> 	;	        (incomplete copy) 
  6180                              <1> 	;        CH > 0 if file is (full) loaded at memory
  6181                              <1> 	;
  6182                              <1> 	;	cf = 1 -> Error code in AL (EAX) 
  6183                              <1> 	;
  6184                              <1> 	; (EBX, ECX, ESI, EDI register contents will be changed)           
  6185                              <1> 
  6186                              <1> 
  6187 0000C1C3 3C02                <1> 	cmp	al, 2
  6188 0000C1C5 0F845A020000        <1> 	je	csftdf2_check_cdrv
  6189                              <1> 
  6190                              <1> ; Phase 1
  6191                              <1> 
  6192 0000C1CB A2[04960100]        <1> 	mov	byte [copy_cmd_phase], al
  6193                              <1> 
  6194 0000C1D0 57                  <1> 	push	edi ; *
  6195                              <1> 
  6196                              <1> csftdf_parse_sf_path:
  6197 0000C1D1 BF[DC940100]        <1> 	mov	edi, SourceFile_Drv
  6198 0000C1D6 E887F4FFFF          <1> 	call	parse_path_name
  6199 0000C1DB 721C                <1> 	jc	short csftdf_parse_sf_path_failed
  6200                              <1> 
  6201                              <1> csftdf_parse_df_path:	
  6202 0000C1DD 5E                  <1> 	pop	esi ; * (pushed edi) 
  6203                              <1> 
  6204                              <1> csftdf_sf_check_filename_exists:
  6205 0000C1DE 803D[1E950100]21    <1> 	cmp	byte [SourceFile_Name], 21h
  6206 0000C1E5 7215                <1> 	jb	short csftdf_sf_file_not_found_error
  6207                              <1> 
  6208 0000C1E7 BF[5C950100]        <1> 	mov	edi, DestinationFile_Drv
  6209 0000C1EC E871F4FFFF          <1> 	call	parse_path_name
  6210 0000C1F1 7310                <1> 	jnc	short csftdf_check_sf_cdrv
  6211                              <1> 	
  6212 0000C1F3 3C01                <1> 	cmp	al, 1 ; File or directory name is not existing
  6213 0000C1F5 760C                <1> 	jna	short csftdf_check_sf_cdrv
  6214                              <1> 
  6215                              <1> csftdf_parse_df_path_failed:
  6216 0000C1F7 F9                  <1> 	stc 
  6217                              <1> csftdf_sf_error_retn: 
  6218 0000C1F8 C3                  <1> 	retn
  6219                              <1> 
  6220                              <1> csftdf_parse_sf_path_failed:	
  6221 0000C1F9 5F                  <1> 	pop	edi ; *
  6222 0000C1FA EBFC                <1> 	jmp	short csftdf_sf_error_retn
  6223                              <1> 
  6224                              <1> csftdf_sf_file_not_found_error:
  6225 0000C1FC B802000000          <1> 	mov	eax, 2 ; File not found 
  6226 0000C201 EBF5                <1> 	jmp	short csftdf_sf_error_retn
  6227                              <1> 
  6228                              <1> csftdf_check_sf_cdrv:
  6229 0000C203 8A3D[F68A0100]      <1> 	mov	bh, [Current_Drv]
  6230                              <1> 
  6231 0000C209 883D[07960100]      <1> 	mov	[csftdf_cdrv], bh ; 23/03/2016
  6232                              <1> 
  6233 0000C20F 8A15[DC940100]      <1> 	mov	dl, [SourceFile_Drv]
  6234 0000C215 38FA                <1> 	cmp	dl, bh ; byte [Current_Drv]
  6235 0000C217 7407                <1> 	je	short csftdf_sf_check_directory
  6236                              <1> 
  6237 0000C219 E8D0BEFFFF          <1> 	call	change_current_drive
  6238 0000C21E 72D8                <1> 	jc	short csftdf_sf_error_retn
  6239                              <1> 
  6240                              <1> csftdf_sf_check_directory:
  6241 0000C220 BE[DD940100]        <1> 	mov	esi, SourceFile_Directory
  6242 0000C225 803E20              <1> 	cmp	byte [esi], 20h
  6243 0000C228 760F                <1> 	jna	short csftdf_find_sf
  6244                              <1> 
  6245                              <1> csftdf_sf_change_directory:
  6246 0000C22A FE05[C3400100]      <1> 	inc	byte [Restore_CDIR]
  6247 0000C230 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  6248 0000C232 E815EEFFFF          <1> 	call	change_current_directory
  6249 0000C237 72BF                <1> 	jc	short csftdf_sf_error_retn
  6250                              <1> 
  6251                              <1> ;csftdf_sf_change_prompt_dir_string:
  6252                              <1> ;	call	change_prompt_dir_string
  6253                              <1> 
  6254                              <1> csftdf_find_sf:
  6255 0000C239 BE[1E950100]        <1> 	mov	esi, SourceFile_Name
  6256 0000C23E 66B80018            <1> 	mov	ax, 1800h ; Except volume label and dirs
  6257 0000C242 E84AD2FFFF          <1> 	call	find_first_file
  6258 0000C247 72AF                <1> 	jc	short csftdf_sf_error_retn
  6259                              <1> 
  6260                              <1> csftdf_sf_ambgfn_check:
  6261 0000C249 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
  6262 0000C24C 7407                <1> 	jz	short csftdf_sf_found
  6263                              <1> 
  6264                              <1> csftdf_ambiguous_file_name_error:
  6265 0000C24E B802000000          <1> 	mov	eax, 2 ; File not found error
  6266 0000C253 F9                  <1> 	stc
  6267 0000C254 C3                  <1> 	retn
  6268                              <1> 
  6269                              <1> csftdf_sf_found:
  6270 0000C255 A3[08960100]        <1> 	mov	[csftdf_filesize], eax
  6271                              <1> 
  6272 0000C25A 09C0                <1> 	or	eax, eax
  6273 0000C25C 7507                <1> 	jnz	short csftdf_set_source_file_direntry
  6274                              <1> 
  6275                              <1> csftdf_sf_file_size_zero:
  6276 0000C25E B814000000          <1> 	mov	eax, 20 ; TRDOS zero length (file size) error
  6277 0000C263 F9                  <1> 	stc
  6278 0000C264 C3                  <1> 	retn
  6279                              <1> 
  6280                              <1> csftdf_set_source_file_direntry:
  6281 0000C265 BE[E8930100]        <1> 	mov	esi, FindFile_DirEntry
  6282 0000C26A BF[2E950100]        <1> 	mov	edi, SourceFile_DirEntry
  6283 0000C26F B908000000          <1> 	mov	ecx, 8
  6284 0000C274 F3A5                <1> 	rep	movsd
  6285                              <1> 
  6286                              <1> csftdf_sf_restore_cdrv:
  6287                              <1> 	; 22/03/2016
  6288 0000C276 8A15[07960100]      <1> 	mov	dl, [csftdf_cdrv]
  6289 0000C27C 3A15[F68A0100]      <1> 	cmp	dl, [Current_Drv]
  6290 0000C282 7407                <1> 	je	short csftdf_sf_restore_cdir
  6291 0000C284 E865BEFFFF          <1> 	call	change_current_drive 
  6292 0000C289 724F                <1> 	jc	short csftdf_df_error_retn ; 30/03/2016
  6293                              <1> 
  6294                              <1> csftdf_sf_restore_cdir:
  6295 0000C28B 803D[C3400100]00    <1> 	cmp	byte [Restore_CDIR], 0
  6296 0000C292 7612                <1> 	jna	short csftdf_df_check_filename_exists
  6297 0000C294 29C0                <1> 	sub	eax, eax
  6298 0000C296 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  6299 0000C29B 88D4                <1> 	mov	ah, dl ; byte [csftdf_cdrv]
  6300 0000C29D 01C6                <1> 	add	esi, eax
  6301 0000C29F E801BFFFFF          <1> 	call	restore_current_directory
  6302 0000C2A4 7234                <1> 	jc	short csftdf_df_error_retn
  6303                              <1>   
  6304                              <1> csftdf_df_check_filename_exists:
  6305 0000C2A6 803D[9E950100]20    <1> 	cmp	byte [DestinationFile_Name], 20h
  6306 0000C2AD 7716                <1> 	ja	short csftdf_check_df_cdrv
  6307                              <1> 
  6308                              <1> csftdf_copy_sf_name:
  6309 0000C2AF BF[9E950100]        <1> 	mov	edi, DestinationFile_Name
  6310 0000C2B4 BE[1E950100]        <1> 	mov	esi, SourceFile_Name
  6311 0000C2B9 B10C                <1> 	mov	cl, 12
  6312                              <1> 
  6313                              <1> csftdf_df_copy_sf_name_loop:
  6314 0000C2BB AC                  <1> 	lodsb
  6315 0000C2BC AA                  <1> 	stosb
  6316 0000C2BD 08C0                <1> 	or	al, al
  6317 0000C2BF 7404                <1> 	jz	short csftdf_check_df_cdrv             
  6318 0000C2C1 FEC9                <1> 	dec	cl
  6319 0000C2C3 75F6                <1> 	jnz	csftdf_df_copy_sf_name_loop
  6320                              <1> 
  6321                              <1> csftdf_check_df_cdrv:
  6322 0000C2C5 8A15[5C950100]      <1> 	mov	dl, [DestinationFile_Drv]
  6323 0000C2CB 3A15[F68A0100]      <1> 	cmp	dl, [Current_Drv]
  6324 0000C2D1 7408                <1> 	je	short csftdf_df_check_directory
  6325                              <1> 
  6326 0000C2D3 E816BEFFFF          <1> 	call	change_current_drive
  6327 0000C2D8 7301                <1> 	jnc	short csftdf_df_check_directory
  6328                              <1> 
  6329                              <1> csftdf_df_error_retn:
  6330 0000C2DA C3                  <1> 	retn
  6331                              <1> 
  6332                              <1> csftdf_df_check_directory:
  6333 0000C2DB BE[5D950100]        <1> 	mov	esi, DestinationFile_Directory
  6334 0000C2E0 803E20              <1>         cmp     byte [esi], 20h
  6335 0000C2E3 760F                <1> 	jna	short csftdf_find_df
  6336                              <1> 
  6337                              <1> csftdf_df_change_directory:
  6338 0000C2E5 FE05[C3400100]      <1> 	inc	byte [Restore_CDIR]
  6339 0000C2EB 28E4                <1> 	sub	ah, ah ; CD_COMMAND sign -> 0 
  6340 0000C2ED E85AEDFFFF          <1> 	call	change_current_directory
  6341 0000C2F2 72E6                <1> 	jc	short csftdf_df_error_retn
  6342                              <1> 
  6343                              <1> ;csftdf_df_change_prompt_dir_string:
  6344                              <1> ;	call	change_prompt_dir_string
  6345                              <1> 
  6346                              <1> csftdf_find_df:
  6347                              <1> 	; 23/03/2016
  6348 0000C2F4 29DB                <1> 	sub	ebx, ebx
  6349 0000C2F6 8A3D[5C950100]      <1> 	mov	bh,  [DestinationFile_Drv]
  6350 0000C2FC 81C300010900        <1> 	add	ebx, Logical_DOSDisks
  6351 0000C302 891D[34960100]      <1> 	mov	[csftdf_df_drv_dt], ebx
  6352                              <1> 
  6353 0000C308 BE[9E950100]        <1> 	mov	esi, DestinationFile_Name
  6354 0000C30D 6631C0              <1> 	xor	ax, ax 
  6355                              <1> 		; DestinationFile_AttributesMask -> any/zero
  6356 0000C310 E87CD1FFFF          <1> 	call	find_first_file
  6357 0000C315 7218                <1> 	jc	short csftdf_df_check_error_code
  6358                              <1> 
  6359                              <1> csftdf_df_ambgfn_check:
  6360 0000C317 6609D2              <1> 	or	dx, dx ; Ambiguous filename chars used sign (DX>0)
  6361 0000C31A 752A                <1> 	jnz	short csftdf_df_error_inv_fname
  6362                              <1> 	
  6363                              <1> csftdf_df_found:
  6364 0000C31C C605[06960100]01    <1> 	mov	byte [DestinationFileFound], 1
  6365                              <1> 	; 17/10/2016 (cl -> bl)
  6366 0000C323 80E31F              <1> 	and	bl, 1Fh ; Attributes, D-V-S-H-R
  6367 0000C326 745F                <1> 	jz	short csftdf_df_save_first_cluster
  6368                              <1> 
  6369                              <1> csftdf_df_permission_denied_retn:	 
  6370 0000C328 B805000000          <1> 	mov	eax, 05h ; Access/Permission denied.
  6371                              <1> csftdf_df_error_stc_retn:
  6372 0000C32D F9                  <1> 	stc
  6373 0000C32E C3                  <1> 	retn
  6374                              <1> 
  6375                              <1> csftdf_df_check_error_code:
  6376                              <1> 	;cmp	eax, 2
  6377 0000C32F 3C02                <1> 	cmp	al, 2
  6378 0000C331 75FA                <1> 	jne	short csftdf_df_error_stc_retn
  6379                              <1> 
  6380 0000C333 C605[06960100]00    <1> 	mov	byte [DestinationFileFound], 0
  6381                              <1> 
  6382                              <1> 	; 15/10/2016
  6383 0000C33A BE[D8930100]        <1> 	mov	esi, FindFile_Name ; *
  6384 0000C33F E80BD5FFFF          <1> 	call	check_filename
  6385 0000C344 7307                <1> 	jnc	short csftdf_df_valid_fname
  6386                              <1> csftdf_df_error_inv_fname: ; 'invalid file name !'
  6387 0000C346 B81A000000          <1> 	mov 	eax, ERR_INV_FILE_NAME  ; 26
  6388 0000C34B F9                  <1> 	stc	
  6389 0000C34C C3                  <1> 	retn
  6390                              <1> 
  6391                              <1> csftdf_df_valid_fname:	
  6392                              <1> 	; 21/03/2016
  6393                              <1> 	; (Capitalized file name)
  6394                              <1> 	;mov	esi, FindFile_Name ; * ; 15/10/2016
  6395 0000C34D BF[9E950100]        <1> 	mov	edi, DestinationFile_Name
  6396 0000C352 A5                  <1> 	movsd
  6397 0000C353 A5                  <1> 	movsd	
  6398 0000C354 A5                  <1> 	movsd
  6399                              <1> 	;movsb
  6400                              <1> 
  6401                              <1> csftdf_check_disk_free_size_0:
  6402 0000C355 A1[4A950100]        <1> 	mov	eax, [SourceFile_DirEntry+DirEntry_FileSize]
  6403                              <1> 
  6404                              <1> csftdf_check_disk_free_size_1:
  6405                              <1> 	;sub	ebx, ebx
  6406                              <1> 	;mov 	esi, Logical_DOSDisks
  6407                              <1> 	;mov	bh,  [DestinationFile_Drv]
  6408                              <1> 	;add	esi, ebx
  6409                              <1> 	
  6410 0000C35A 8B35[34960100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; 23/03/2016
  6411                              <1> 
  6412 0000C360 0FB74E11            <1> 	movzx	ecx, word [esi+LD_BPB+BytesPerSec] ; 17, LD_BPB + 0Bh
  6413 0000C364 01C8                <1> 	add	eax, ecx
  6414 0000C366 48                  <1> 	dec	eax  ; file size (additional bytes) + 511 (round up)
  6415                              <1> csftdf_check_disk_free_size_3: ; 16/03/2016
  6416 0000C367 29D2                <1> 	sub	edx, edx
  6417 0000C369 F7F1                <1> 	div	ecx ; bytes per sector
  6418                              <1> 
  6419                              <1> csftdf_check_disk_free_size:
  6420 0000C36B 3B4674              <1> 	cmp	eax, [esi+LD_FreeSectors]
  6421 0000C36E 0F8294000000        <1>         jb      csftdf_check_disk_free_size_ok
  6422 0000C374 770A                <1> 	ja	short csftdf_df_insufficient_disk_space
  6423                              <1> 
  6424 0000C376 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0 ; FS needs FDT sector also.
  6425 0000C37A 0F8788000000        <1>         ja      csftdf_check_disk_free_size_ok 
  6426                              <1> 
  6427                              <1> csftdf_df_insufficient_disk_space:
  6428 0000C380 B827000000          <1> 	mov	eax, 27h ; insufficient disk space
  6429 0000C385 EBA6                <1> 	jmp	short csftdf_df_error_stc_retn
  6430                              <1> 
  6431                              <1> csftdf_df_save_first_cluster:
  6432                              <1> 	; ESI = FindFile_DirEntry (for the old destination file)
  6433                              <1> 	; EAX = Old destination file size
  6434                              <1> 	; 24/03/2016
  6435                              <1> 	; EDI = Directory entry address (within Dir Buffer boundaries)
  6436 0000C387 81EF00000800        <1> 	sub	edi, Directory_Buffer  ; (<65536)
  6437 0000C38D 66C1EF05            <1> 	shr	di, 5 ; Convert entry offset to entry index/number
  6438 0000C391 66893D[D6950100]    <1> 	mov	[DestinationFile_DirEntryNumber], di ; (<2048)
  6439                              <1> 
  6440                              <1> csftdf_df_check_sf_df_fcluster:
  6441 0000C398 668B5614            <1> 	mov	dx, [esi+DirEntry_FstClusHI]
  6442 0000C39C C1E210              <1> 	shl	edx, 16
  6443 0000C39F 668B561A            <1> 	mov	dx, [esi+DirEntry_FstClusLO]
  6444 0000C3A3 8915[18960100]      <1> 	mov	[csftdf_df_cluster], edx
  6445                              <1> csftdf_df_check_sf_df_fcluster_1:
  6446 0000C3A9 668B15[42950100]    <1> 	mov	dx, [SourceFile_DirEntry+DirEntry_FstClusHI]
  6447 0000C3B0 C1E210              <1> 	shl	edx, 16
  6448 0000C3B3 668B15[48950100]    <1> 	mov	dx, [SourceFile_DirEntry+DirEntry_FstClusLO]
  6449 0000C3BA 3B15[18960100]      <1> 	cmp	edx, [csftdf_df_cluster]
  6450 0000C3C0 7512                <1> 	jne	short csftdf_df_check_sf_df_fcluster_ok
  6451                              <1> csftdf_df_check_sf_df_drv:
  6452 0000C3C2 8A15[DC940100]      <1> 	mov	dl, [SourceFile_Drv]
  6453 0000C3C8 3A15[5C950100]      <1> 	cmp	dl, [DestinationFile_Drv]
  6454 0000C3CE 7504                <1> 	jne	short csftdf_df_check_sf_df_fcluster_ok
  6455                              <1> 
  6456                              <1> 	; source and destination files are same !
  6457                              <1> 	; (they have same first cluster value on same logical disk)
  6458                              <1> 
  6459 0000C3D0 31C0                <1> 	xor	eax, eax ; mov eax, 0 -> Bad command or file name !
  6460 0000C3D2 F9                  <1> 	stc
  6461 0000C3D3 C3                  <1> 	retn 
  6462                              <1>    
  6463                              <1> csftdf_df_check_sf_df_fcluster_ok:
  6464                              <1> csftdf_df_move_findfile_struct:
  6465                              <1> 	; mov	esi, FindFile_DirEntry
  6466 0000C3D4 BF[AE950100]        <1> 	mov	edi, DestinationFile_DirEntry
  6467 0000C3D9 B908000000          <1> 	mov	ecx, 8
  6468 0000C3DE F3A5                <1> 	rep	movsd
  6469                              <1> 	
  6470                              <1> csftdf_check_disk_free_size_2:
  6471 0000C3E0 89C2                <1> 	mov	edx, eax ; Old destination file size
  6472                              <1> 
  6473                              <1> 	;mov	eax, [SourceFile_DirEntry+DirEntry_FileSize]
  6474 0000C3E2 A1[08960100]        <1> 	mov	eax, [csftdf_filesize] ; 23/03/2016
  6475                              <1> 
  6476                              <1> 	;;sub	ecx, ecx ; 0
  6477                              <1> 	;mov 	esi, Logical_DOSDisks
  6478                              <1> 	;mov	ch,  [DestinationFile_Drv]
  6479                              <1> 	;add	esi, ecx
  6480                              <1> 	;
  6481                              <1> 	;mov	[csftdf_df_drv_dt], esi
  6482                              <1> 
  6483 0000C3E7 8B35[34960100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; 23/03/2016
  6484                              <1> 
  6485 0000C3ED 668B4E11            <1> 	mov	cx, [esi+LD_BPB+BytesPerSec] ; 17, LD_BPB + 0Bh
  6486 0000C3F1 01CA                <1> 	add	edx, ecx ; + 512
  6487 0000C3F3 01C8                <1> 	add	eax, ecx ; + 512
  6488 0000C3F5 4A                  <1> 	dec	edx ; old file size + 511 (round up)
  6489 0000C3F6 48                  <1> 	dec	eax ; new file size + 511 (round up)
  6490 0000C3F7 F7D9                <1> 	neg	ecx ; -512 ; 0FFFFFE00h
  6491 0000C3F9 21CA                <1> 	and	edx, ecx ; = old sector count * 512 
  6492 0000C3FB 21C8                <1> 	and	eax, ecx ; = new sector count * 512 
  6493                              <1> 
  6494 0000C3FD 29D0                <1> 	sub	eax, edx ; new file size - old file size (on disk)
  6495 0000C3FF 7607                <1> 	jna	short csftdf_check_disk_free_size_ok
  6496                              <1> 
  6497 0000C401 F7D9                <1> 	neg	ecx ; 512 (bytes per sector) ; 200h
  6498                              <1> 	; check free space for additional sectors
  6499                              <1> 	; eax = number of additional sectors * bytes per sector
  6500                              <1> 	; esi = Logical DOS drive number (of destination disk)
  6501 0000C403 E95FFFFFFF          <1>         jmp     csftdf_check_disk_free_size_3
  6502                              <1>  
  6503                              <1> csftdf_check_disk_free_size_ok:
  6504                              <1> 	; 18/03/2016
  6505                              <1> csftdf_df_check_copy_cmd_phase:
  6506 0000C408 A0[04960100]        <1> 	mov	al, [copy_cmd_phase]
  6507 0000C40D 3C01                <1> 	cmp	al, 1
  6508 0000C40F 7514                <1> 	jne	short csftdf2_check_cdrv
  6509                              <1> 	
  6510 0000C411 31C0                <1> 	xor	eax, eax
  6511 0000C413 A2[04960100]        <1> 	mov	[copy_cmd_phase], al ; 0
  6512                              <1> 
  6513 0000C418 8A15[06960100]      <1> 	mov	dl, [DestinationFileFound]            
  6514 0000C41E 8A35[39950100]      <1> 	mov	dh, [SourceFile_DirEntry+11] ; Attributes
  6515                              <1>  
  6516                              <1> csftdf_return:	
  6517 0000C424 C3                  <1> 	retn
  6518                              <1> 
  6519                              <1> ; Phase 2
  6520                              <1> 
  6521                              <1> csftdf2_check_cdrv:
  6522                              <1> 	; 18/03/2016
  6523                              <1> 	; Here, destination drive and directory are ready !
  6524                              <1> 	; (checking/restoring is not needed)
  6525                              <1> 	; (Since at the end of the phase 1)
  6526                              <1> 
  6527                              <1> ;	mov	dl, [DestinationFile_Drv]
  6528                              <1> ;	cmp	dl, [Current_Drv]
  6529                              <1> ;	je	short csftdf2_df_check_directory
  6530                              <1> ;
  6531                              <1> ;	call	change_current_drive
  6532                              <1> ;	jc	short csftdf2_read_error
  6533                              <1> ;
  6534                              <1> ;csftdf2_df_check_directory:
  6535                              <1> ;	mov	esi, DestinationFile_Directory  
  6536                              <1> ;	cmp	byte [esi], 20h
  6537                              <1> ;	jna	short csftdf2_df_check_found_or_not
  6538                              <1> ;
  6539                              <1> ;csftdf2_df_change_directory:
  6540                              <1> ;	inc	byte [Restore_CDIR]
  6541                              <1> ;	xor	ah, ah ; CD_COMMAND sign -> 0 
  6542                              <1> ;	call	change_current_directory
  6543                              <1> ;	jc	short csftdf2_stc_return
  6544                              <1> ;
  6545                              <1> ;;csftdf2_df_change_prompt_dir_string:
  6546                              <1> ;;	call	change_prompt_dir_string
  6547                              <1> 
  6548                              <1> csftdf2_df_check_found_or_not:
  6549                              <1> 	; 21/03/2016
  6550 0000C425 803D[06960100]00    <1> 	cmp	byte [DestinationFileFound], 0 
  6551 0000C42C 7739                <1> 	ja	short csftdf2_set_sf_percentage
  6552                              <1> 
  6553                              <1> csftdf2_create_file:
  6554 0000C42E BE[9E950100]        <1> 	mov	esi, DestinationFile_Name
  6555 0000C433 A1[08960100]        <1> 	mov	eax, [csftdf_filesize]
  6556 0000C438 30C9                <1> 	xor	cl, cl ; 0
  6557                              <1> 
  6558 0000C43A 31DB                <1> 	xor	ebx, ebx ; 0
  6559 0000C43C 4B                  <1> 	dec	ebx ; 0FFFFFFFFh 
  6560                              <1> 
  6561                              <1> 	; INPUT ->
  6562                              <1> 	; 	EAX -> File Size
  6563                              <1> 	; 	ESI = ASCIIZ File name
  6564                              <1> 	;	 CL = File attributes
  6565                              <1> 	;	EBX = FFFFFFFFh -> empty file sign for FAT fs
  6566                              <1> 	;	EBX <> FFFFFFFFh -> use file size for FAT fs 
  6567                              <1> 	;
  6568                              <1> 	; OUTPUT ->
  6569                              <1> 	;	EAX = New file's first cluster
  6570                              <1> 	;	ESI = Logical Dos Drv Descr. Table Addr.
  6571                              <1> 	;	EBX = CreateFile_Size address
  6572                              <1> 	;	ECX = Sectors per cluster (<256)
  6573                              <1> 	;	EDX = Directory Entry Index/Number (<65536)
  6574                              <1> 	;		
  6575                              <1> 	;	cf = 1 -> error code in AL (EAX)
  6576                              <1> 
  6577 0000C43D E8EC050000          <1> 	call	create_file
  6578                              <1> 	;pop	esi
  6579 0000C442 0F82A3050000        <1>         jc      csftdf2_rw_error
  6580                              <1> 
  6581                              <1> csftdf2_create_file_OK:
  6582 0000C448 A3[18960100]        <1> 	mov	[csftdf_df_cluster], eax
  6583                              <1> 	
  6584                              <1> 	; 24/03/2016
  6585 0000C44D 668915[D6950100]    <1> 	mov	[DestinationFile_DirEntryNumber], dx 
  6586                              <1> 
  6587                              <1> 	; 21/03/2016
  6588 0000C454 BE00000800          <1> 	mov	esi, Directory_Buffer
  6589 0000C459 C1E205              <1> 	shl	edx, 5 ; 32 * index number
  6590 0000C45C 01D6                <1> 	add	esi, edx
  6591 0000C45E BF[AE950100]        <1> 	mov	edi, DestinationFile_DirEntry	
  6592 0000C463 B108                <1> 	mov	cl, 8 ; 32 bytes
  6593 0000C465 F3A5                <1> 	rep	movsd
  6594                              <1> 
  6595                              <1> csftdf2_set_sf_percentage:
  6596                              <1> 	; 17/03/2016
  6597 0000C467 31C0                <1> 	xor	eax, eax	
  6598 0000C469 A2[2C960100]        <1> 	mov 	[csftdf_percentage], al ; 0, reset
  6599                              <1> 
  6600 0000C46E A3[24960100]        <1> 	mov	[csftdf_sf_rbytes], eax ; 0, reset
  6601 0000C473 A3[28960100]        <1> 	mov	[csftdf_df_wbytes], eax ; 0, reset
  6602                              <1> 
  6603 0000C478 8A25[DC940100]      <1> 	mov	ah, [SourceFile_Drv]	
  6604 0000C47E BE00010900          <1> 	mov	esi, Logical_DOSDisks
  6605 0000C483 01C6                <1> 	add	esi, eax
  6606                              <1> 	
  6607 0000C485 8935[30960100]      <1> 	mov	[csftdf_sf_drv_dt], esi ; 23/03/2016
  6608                              <1> 
  6609 0000C48B 668B15[42950100]    <1> 	mov	dx, [SourceFile_DirEntry+DirEntry_FstClusHI]
  6610 0000C492 C1E210              <1> 	shl	edx, 16
  6611 0000C495 668B15[48950100]    <1> 	mov	dx, [SourceFile_DirEntry+DirEntry_FstClusLO]
  6612 0000C49C 8915[14960100]      <1> 	mov	[csftdf_sf_cluster], edx
  6613                              <1> 
  6614                              <1> 	; 16/03/2016
  6615                              <1> 	; Note: Singlix FS boot sector parameters (for cluster
  6616                              <1> 	;	related calculations) has same offset
  6617                              <1> 	;	values from LD_BPB as in FAT file system.
  6618                              <1> 	;	[esi+LD_BPB+SecPerClust] is 1 for Singlix FS.
  6619                              <1> 	;	
  6620 0000C4A2 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
  6621 0000C4A6 880D[5A950100]      <1> 	mov	[SourceFile_SecPerClust], cl
  6622                              <1> 
  6623                              <1> 	; 17/03/2016
  6624 0000C4AC 386E03              <1> 	cmp	[esi+LD_FATType], ch ; 0
  6625 0000C4AF 7707                <1> 	ja	short csftdf2_set_sf_percent_rsize1
  6626                              <1> 
  6627 0000C4B1 B800000100          <1> 	mov	eax, 65536 ; read/write buffer size for Singlix FS
  6628 0000C4B6 EB06                <1> 	jmp	short csftdf2_set_sf_percent_rsize2	
  6629                              <1>  
  6630                              <1> csftdf2_set_sf_percent_rsize1:
  6631 0000C4B8 668B4611            <1> 	mov	ax, [esi+LD_BPB+BytesPerSec]
  6632 0000C4BC F7E1                <1> 	mul	ecx
  6633                              <1> 	;sub	edx, edx
  6634                              <1> csftdf2_set_sf_percent_rsize2:
  6635 0000C4BE A3[1C960100]        <1> 	mov	[csftdf_r_size], eax
  6636                              <1> 
  6637                              <1> csftdf2_set_df_percentage:
  6638                              <1> 	;sub	eax, eax
  6639                              <1> 	;mov	ah, [DestinationFile_Drv]	
  6640                              <1> 	;mov	edi, Logical_DOSDisks
  6641                              <1> 	;add	edi, eax
  6642                              <1> 	;mov	[csftdf_df_drv_dt], edi ; 17/03/2016
  6643                              <1> 
  6644 0000C4C3 8B3D[34960100]      <1> 	mov	edi, [csftdf_df_drv_dt] ; 23/03/2016
  6645                              <1> 
  6646                              <1> 	; 16/03/2016
  6647                              <1> 	; Note: Singlix FS boot sector parameters (for cluster
  6648                              <1> 	;	related calculations) has same offset
  6649                              <1> 	;	values from LD_BPB as in FAT file system.
  6650                              <1> 	;	[edi+LD_BPB+SecPerClust] is 1 for Singlix FS.
  6651                              <1> 	;	
  6652                              <1> 	;movzx	ecx, byte [edi+LD_BPB+SecPerClust]
  6653 0000C4C9 8A4F13              <1> 	mov	cl, [edi+LD_BPB+SecPerClust]
  6654 0000C4CC 880D[DA950100]      <1> 	mov	[DestinationFile_SecPerClust], cl
  6655                              <1> 
  6656                              <1> 	; 17/03/2016
  6657 0000C4D2 386F03              <1> 	cmp	[edi+LD_FATType], ch ; 0
  6658 0000C4D5 7707                <1> 	ja	short csftdf2_set_df_percent_wsize1
  6659                              <1> 	
  6660 0000C4D7 B800000100          <1> 	mov	eax, 65536 ; read/write buffer size for Singlix FS
  6661 0000C4DC EB06                <1> 	jmp	short csftdf2_set_df_percent_wsize2	
  6662                              <1> 
  6663                              <1> csftdf2_set_df_percent_wsize1:
  6664 0000C4DE 0FB74711            <1> 	movzx	eax, word [edi+LD_BPB+BytesPerSec]
  6665 0000C4E2 F7E1                <1> 	mul	ecx
  6666                              <1> 	;sub	edx, edx
  6667                              <1> csftdf2_set_df_percent_wsize2:
  6668 0000C4E4 A3[20960100]        <1> 	mov	[csftdf_w_size], eax
  6669                              <1> 
  6670 0000C4E9 A1[08960100]        <1> 	mov	eax, [csftdf_filesize]
  6671                              <1> 
  6672 0000C4EE 3D00000100          <1> 	cmp	eax, 65536 ; 64KB	; small file
  6673 0000C4F3 721F                <1> 	jb	short csftdf2_load_file ; do not display percentage
  6674                              <1> 	
  6675                              <1> csftdf2_reset_wf_percent_ptr_chk_64k:
  6676 0000C4F5 B201                <1> 	mov	dl, 1 ; 25/03/2016
  6677                              <1> 
  6678 0000C4F7 3D00000400          <1> 	cmp	eax, 65536*4 ; 256KB
  6679 0000C4FC 7310                <1> 	jnb	short csftdf2_enable_percentage_display ; big file
  6680                              <1> 
  6681                              <1> 	; 64-128KB file size for floppy disks
  6682 0000C4FE 3815[DC940100]      <1> 	cmp	byte [SourceFile_Drv], dl ; 1 ; read from floppy disk ?
  6683 0000C504 7608                <1> 	jna	short csftdf2_enable_percentage_display
  6684                              <1> 
  6685 0000C506 3815[5C950100]      <1> 	cmp	byte [DestinationFile_Drv], dl ; 1 ; write to floppy disk ?
  6686 0000C50C 7706                <1> 	ja	short csftdf2_load_file
  6687                              <1> 
  6688                              <1> csftdf2_enable_percentage_display:	
  6689 0000C50E 8815[2C960100]      <1> 	mov	[csftdf_percentage], dl ; 1	
  6690                              <1> 	
  6691                              <1> csftdf2_load_file:
  6692                              <1> 	; 13/05/2016
  6693                              <1> 	; 19/03/2016
  6694                              <1> 	; 18/03/2016
  6695                              <1> 	; 17/03/2016
  6696 0000C514 B40F                <1> 	mov	ah, 0Fh
  6697 0000C516 E85652FFFF          <1> 	call	_int10h
  6698                              <1> 	; 13/05/2016
  6699 0000C51B 883D[2D960100]      <1> 	mov	[csftdf_videopage], bh ; active video page
  6700 0000C521 B403                <1> 	mov	ah, 03h
  6701 0000C523 E84952FFFF          <1> 	call	_int10h
  6702 0000C528 668915[2E960100]    <1> 	mov	[csftdf_cursorpos], dx
  6703                              <1> 
  6704 0000C52F 29C0                <1> 	sub	eax, eax
  6705 0000C531 A2[05960100]        <1> 	mov	[csftdf_rw_err], al ; 0 
  6706                              <1> 
  6707                              <1> ; ///
  6708                              <1> csftdf_sf_amb: ; 15/03/2016
  6709 0000C536 8B0D[08960100]      <1> 	mov	ecx, [csftdf_filesize]	; 23/03/2016
  6710                              <1> 
  6711                              <1> 	; TRDOS 386 (TRDOS v2.0)
  6712                              <1> 	; Allocate contiguous memory block for loading the file
  6713                              <1> 	
  6714                              <1> 	;mov	ecx, [SourceFile_DirEntry+DirEntry_FileSize]
  6715                              <1> 	
  6716                              <1> 	;sub	eax, eax ; First free memory aperture
  6717                              <1> 	
  6718                              <1> 	; eax = 0 (Allocate memory from the beginning)
  6719                              <1> 	; ecx = File (Allocation) size in bytes
  6720                              <1> 	
  6721 0000C53C E8449FFFFF          <1> 	call	allocate_memory_block
  6722 0000C541 7304                <1> 	jnc	short loc_check_sf_save_loading_parms
  6723                              <1> 
  6724 0000C543 29C0                <1> 	sub	eax, eax
  6725 0000C545 29C9                <1> 	sub	ecx, ecx
  6726                              <1> 	
  6727                              <1> loc_check_sf_save_loading_parms:
  6728 0000C547 A3[0C960100]        <1> 	mov	[csftdf_sf_mem_addr], eax ; loading address
  6729 0000C54C 890D[10960100]      <1> 	mov	[csftdf_sf_mem_bsize], ecx ; block size
  6730                              <1> ; ///   
  6731                              <1> 	; 19/03/2016
  6732 0000C552 8B35[30960100]      <1> 	mov	esi, [csftdf_sf_drv_dt] ; logical dos drv desc. tbl.
  6733                              <1> 
  6734                              <1> 	; 17/03/2016
  6735 0000C558 09C0                <1> 	or	eax, eax ; contiguous free memory block address 
  6736 0000C55A 0F845B010000        <1>         jz      csftdf2_read_sf_cluster
  6737                              <1> 
  6738                              <1> 	; 18/03/2016
  6739 0000C560 8B1D[0C960100]      <1> 	mov	ebx, [csftdf_sf_mem_addr] ; memory block address
  6740                              <1> 
  6741 0000C566 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  6742 0000C56A 0F8605020000        <1>         jna     csftdf2_load_fs_file
  6743                              <1> 
  6744                              <1> csftdf2_load_fat_file:
  6745 0000C570 53                  <1> 	push	ebx ; *
  6746                              <1> 
  6747                              <1> csftdf2_load_fat_file_next:
  6748 0000C571 BE[13470100]        <1> 	mov	esi, msg_reading
  6749 0000C576 E8EAAFFFFF          <1> 	call	print_msg
  6750                              <1> 
  6751 0000C57B 803D[2C960100]00    <1> 	cmp	byte [csftdf_percentage], 0
  6752 0000C582 7605                <1> 	jna	short csftdf2_load_fat_file_1
  6753                              <1> 	
  6754 0000C584 E87C000000          <1> 	call	csftdf2_print_percentage ; 19/03/2016
  6755                              <1> 
  6756                              <1> csftdf2_load_fat_file_1:
  6757 0000C589 8B35[30960100]      <1> 	mov	esi, [csftdf_sf_drv_dt]	
  6758 0000C58F 5B                  <1> 	pop	ebx ; *
  6759                              <1> 
  6760                              <1> csftdf2_load_fat_file_2:
  6761 0000C590 E8B8000000          <1> 	call	csftdf2_read_fat_file_sectors ; 19/03/2016
  6762 0000C595 0F8250040000        <1>         jc      csftdf2_rw_error ; eocc! or disk error! 
  6763                              <1> 
  6764 0000C59B 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
  6765 0000C59D 7520                <1> 	jnz	short csftdf2_load_fat_file_ok
  6766                              <1> 
  6767 0000C59F 803D[2C960100]00    <1> 	cmp	byte [csftdf_percentage], 0
  6768 0000C5A6 76E8                <1> 	jna	short csftdf2_load_fat_file_2
  6769                              <1> 
  6770 0000C5A8 53                  <1> 	push	ebx ; *	
  6771                              <1> 
  6772                              <1> 	; Set cursor position
  6773                              <1> 	; AH= 02h, BH= Page Number, DH= Row, DL= Column
  6774 0000C5A9 8A3D[2D960100]      <1> 	mov	bh, [csftdf_videopage]
  6775 0000C5AF 668B15[2E960100]    <1> 	mov	dx, [csftdf_cursorpos]
  6776 0000C5B6 B402                <1> 	mov	ah, 2
  6777 0000C5B8 E8B451FFFF          <1> 	call	_int10h
  6778 0000C5BD EBB2                <1> 	jmp	short csftdf2_load_fat_file_next
  6779                              <1> 	
  6780                              <1> csftdf2_load_fat_file_ok:
  6781 0000C5BF 803D[2C960100]00    <1> 	cmp	byte [csftdf_percentage], 0
  6782 0000C5C6 0F8651020000        <1>         jna     csftdf2_save_file ; 25/03/2016
  6783                              <1> 	
  6784                              <1> 	; "Reading... 100%"
  6785 0000C5CC BF[2B470100]        <1> 	mov	edi, percentagestr
  6786 0000C5D1 B031                <1> 	mov	al, '1'
  6787 0000C5D3 AA                  <1> 	stosb
  6788 0000C5D4 B030                <1> 	mov	al, '0'
  6789 0000C5D6 AA                  <1> 	stosb
  6790 0000C5D7 AA                  <1> 	stosb
  6791                              <1> 
  6792 0000C5D8 8A3D[2D960100]      <1> 	mov	bh, [csftdf_videopage]
  6793 0000C5DE 668B15[2E960100]    <1> 	mov	dx, [csftdf_cursorpos]
  6794 0000C5E5 B402                <1> 	mov	ah, 2
  6795 0000C5E7 E88551FFFF          <1> 	call	_int10h
  6796                              <1> 
  6797 0000C5EC BE[13470100]        <1> 	mov	esi, msg_reading
  6798 0000C5F1 E86FAFFFFF          <1> 	call	print_msg
  6799                              <1> 	
  6800 0000C5F6 BE[2B470100]        <1> 	mov	esi, percentagestr
  6801 0000C5FB E865AFFFFF          <1> 	call	print_msg
  6802                              <1> 
  6803 0000C600 E918020000          <1>         jmp     csftdf2_save_file ; 25/03/2016
  6804                              <1> 
  6805                              <1> csftdf2_print_percentage:
  6806                              <1> 	; 09/12/2017
  6807                              <1> 	; 19/03/2016
  6808                              <1> 	; 18/03/2016
  6809 0000C605 B020                <1> 	mov	al, 20h
  6810 0000C607 BF[2B470100]        <1> 	mov	edi, percentagestr
  6811 0000C60C AA                  <1> 	stosb
  6812 0000C60D AA                  <1> 	stosb
  6813 0000C60E A1[24960100]        <1> 	mov	eax, [csftdf_sf_rbytes]
  6814 0000C613 BA64000000          <1> 	mov	edx, 100
  6815 0000C618 F7E2                <1> 	mul	edx
  6816 0000C61A 8B0D[08960100]      <1> 	mov	ecx, [csftdf_filesize]	
  6817 0000C620 F7F1                <1> 	div	ecx
  6818 0000C622 B10A                <1> 	mov	cl, 10
  6819 0000C624 F6F1                <1> 	div	cl
  6820 0000C626 80C430              <1> 	add	ah, '0'
  6821 0000C629 8827                <1> 	mov	[edi], ah
  6822 0000C62B 20C0                <1> 	and	al, al
  6823 0000C62D 740A                <1> 	jz	short csftdf2_print_percent_1
  6824 0000C62F 4F                  <1> 	dec	edi
  6825                              <1> 	;cbw
  6826 0000C630 28E4                <1> 	sub	ah, ah ; 09/12/2017
  6827 0000C632 F6F1                <1> 	div	cl
  6828 0000C634 80C430              <1> 	add	ah, '0'
  6829 0000C637 8827                <1> 	mov	[edi], ah
  6830                              <1> 	;and	al, al
  6831                              <1> 	;jz	short csftdf2_print_percent_1
  6832                              <1> 	;dec	edi
  6833                              <1> 	;mov	[edi], '1' ; 100%		
  6834                              <1> 
  6835                              <1> csftdf2_print_percent_1:
  6836 0000C639 BE[2B470100]        <1> 	mov	esi, percentagestr
  6837                              <1> 	;call	print_msg
  6838                              <1> 	;retn
  6839 0000C63E E922AFFFFF          <1> 	jmp	print_msg
  6840                              <1> 
  6841                              <1> csftdf2_read_file_sectors:
  6842                              <1> 	; 19/03/2016
  6843 0000C643 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  6844 0000C647 0F8627070000        <1>         jna     csftdf2_read_fs_file_sectors
  6845                              <1> 
  6846                              <1> csftdf2_read_fat_file_sectors:
  6847                              <1> 	; 19/03/2016
  6848                              <1> 	; 18/03/2016
  6849                              <1> 	; return:
  6850                              <1> 	;   CF = 0 & EDX > 0 -> END OF FILE
  6851                              <1> 	;   CF = 0 & EDX = 0 -> not EOF
  6852                              <1> 	;   CF = 1 -> read error (error code in AL)	
  6853                              <1> 
  6854                              <1> csftdf2_read_fat_file_secs_0:
  6855 0000C64D 8B15[08960100]      <1> 	mov	edx, [csftdf_filesize]
  6856 0000C653 2B15[24960100]      <1> 	sub	edx, [csftdf_sf_rbytes]
  6857 0000C659 3B15[1C960100]      <1> 	cmp	edx, [csftdf_r_size]	
  6858 0000C65F 7306                <1> 	jnb	short csftdf2_read_fat_file_secs_1
  6859 0000C661 8915[1C960100]      <1> 	mov	[csftdf_r_size], edx
  6860                              <1> 		
  6861                              <1> csftdf2_read_fat_file_secs_1:
  6862 0000C667 A1[1C960100]        <1> 	mov	eax, [csftdf_r_size]
  6863 0000C66C 29D2                <1> 	sub	edx, edx
  6864 0000C66E 0FB74E11            <1> 	movzx	ecx, word [esi+LD_BPB+BytesPerSec]
  6865 0000C672 01C8                <1> 	add	eax, ecx
  6866 0000C674 48                  <1> 	dec	eax
  6867 0000C675 F7F1                <1> 	div	ecx
  6868 0000C677 89C1                <1> 	mov	ecx, eax ; sector count
  6869 0000C679 A1[14960100]        <1> 	mov	eax, [csftdf_sf_cluster]
  6870                              <1> 
  6871                              <1> 	; EBX = memory block address (current)
  6872                              <1> 	
  6873 0000C67E E821090000          <1> 	call	read_fat_file_sectors
  6874 0000C683 7235                <1> 	jc	short csftdf2_read_fat_file_secs_3
  6875                              <1> 
  6876                              <1> 	; EBX = next memory address
  6877                              <1> 
  6878 0000C685 A1[24960100]        <1> 	mov	eax, [csftdf_sf_rbytes]
  6879 0000C68A 0305[1C960100]      <1> 	add	eax, [csftdf_r_size]
  6880 0000C690 8B15[08960100]      <1> 	mov	edx, [csftdf_filesize]
  6881 0000C696 39D0                <1> 	cmp	eax, edx
  6882 0000C698 7320                <1> 	jnb	short csftdf2_read_fat_file_secs_3 ; edx > 0
  6883 0000C69A A3[24960100]        <1> 	mov	[csftdf_sf_rbytes], eax
  6884                              <1> 
  6885 0000C69F 53                  <1> 	push	ebx ; *
  6886                              <1> 	; get next cluster (csftdf_r_size! bytes)
  6887 0000C6A0 A1[14960100]        <1> 	mov	eax, [csftdf_sf_cluster]
  6888 0000C6A5 E8CC060000          <1> 	call	get_next_cluster
  6889 0000C6AA 5B                  <1> 	pop	ebx ; *
  6890 0000C6AB 7306                <1> 	jnc	short csftdf2_read_fat_file_secs_2
  6891                              <1> 
  6892                              <1> 	; 15/10/2016
  6893                              <1> 	;Disk read error instad of drv not ready err
  6894 0000C6AD B811000000          <1> 	mov	eax, 17 ; Read error !
  6895 0000C6B2 C3                  <1> 	retn
  6896                              <1> 
  6897                              <1> csftdf2_read_fat_file_secs_2:
  6898 0000C6B3 29D2                <1> 	sub	edx, edx ; 0
  6899 0000C6B5 A3[14960100]        <1> 	mov	[csftdf_sf_cluster], eax ; next cluster
  6900                              <1> 
  6901                              <1> csftdf2_read_fat_file_secs_3:
  6902 0000C6BA C3                  <1> 	retn
  6903                              <1> 
  6904                              <1> csftdf2_read_sf_cluster:
  6905                              <1> 	; 19/03/2016
  6906 0000C6BB BB00000700          <1> 	mov	ebx, Cluster_Buffer ; buffer address (64KB)
  6907                              <1> 
  6908 0000C6C0 803D[2C960100]00    <1> 	cmp	byte [csftdf_percentage], 0
  6909 0000C6C7 760D                <1> 	jna	short csftdf2_read_sf_clust_2
  6910                              <1> 
  6911 0000C6C9 53                  <1> 	push	ebx ; *	
  6912                              <1> 
  6913                              <1> csftdf2_read_sf_clust_next:
  6914 0000C6CA E836FFFFFF          <1> 	call	csftdf2_print_percentage
  6915                              <1> 
  6916                              <1> csftdf2_read_sf_clust_0:
  6917 0000C6CF 8B35[30960100]      <1> 	mov	esi, [csftdf_sf_drv_dt]	
  6918                              <1> csftdf2_read_sf_clust_1:
  6919 0000C6D5 5B                  <1> 	pop	ebx ; *
  6920                              <1> 
  6921                              <1> csftdf2_read_sf_clust_2:
  6922 0000C6D6 89DA                <1> 	mov	edx, ebx
  6923 0000C6D8 0315[1C960100]      <1> 	add	edx, [csftdf_r_size]
  6924 0000C6DE 81FA00000800        <1> 	cmp	edx, Cluster_Buffer + 65536
  6925 0000C6E4 772F                <1> 	ja	short csftdf2_write_df_cluster
  6926                              <1> 
  6927 0000C6E6 E858FFFFFF          <1> 	call	csftdf2_read_file_sectors ; 19/03/2016
  6928 0000C6EB 0F8280020000        <1>         jc      csftdf2_save_fat_file_err2 ; eocc! or disk error! 
  6929                              <1> 
  6930 0000C6F1 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
  6931 0000C6F3 7520                <1> 	jnz	short csftdf2_write_df_cluster
  6932                              <1> 
  6933 0000C6F5 803D[2C960100]00    <1> 	cmp	byte [csftdf_percentage], 0
  6934 0000C6FC 76D8                <1> 	jna	short csftdf2_read_sf_clust_2
  6935                              <1> 
  6936 0000C6FE 53                  <1> 	push	ebx ; *	
  6937                              <1> 
  6938                              <1> 	; Set cursor position
  6939                              <1> 	; AH= 02h, BH= Page Number, DH= Row, DL= Column
  6940 0000C6FF 8A3D[2D960100]      <1> 	mov	bh, [csftdf_videopage]
  6941 0000C705 668B15[2E960100]    <1> 	mov	dx, [csftdf_cursorpos]
  6942 0000C70C B402                <1> 	mov	ah, 2
  6943 0000C70E E85E50FFFF          <1> 	call	_int10h
  6944 0000C713 EBB5                <1> 	jmp	short csftdf2_read_sf_clust_next
  6945                              <1> 
  6946                              <1> csftdf2_write_df_cluster:
  6947                              <1> 	; 19/03/2016
  6948 0000C715 8B35[34960100]      <1> 	mov	esi, [csftdf_df_drv_dt]	
  6949 0000C71B BB00000700          <1> 	mov	ebx, Cluster_Buffer ; buffer address (64KB)
  6950                              <1> 
  6951                              <1> csftdf2_write_df_clust_next:
  6952 0000C720 E855000000          <1> 	call	csftdf2_write_file_sectors ; 19/03/2016
  6953 0000C725 0F8246020000        <1>         jc      csftdf2_save_fat_file_err2 ; eocc! or disk error! 
  6954                              <1> 
  6955 0000C72B 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
  6956 0000C72D 750A                <1> 	jnz	short csftdf2_rw_f_clust_ok
  6957                              <1> 
  6958 0000C72F 81FB00000800        <1> 	cmp	ebx, Cluster_Buffer + 65536
  6959 0000C735 72E9                <1> 	jb	short csftdf2_write_df_clust_next
  6960                              <1> 	
  6961 0000C737 EB82                <1> 	jmp	short csftdf2_read_sf_cluster
  6962                              <1>  
  6963                              <1> csftdf2_rw_f_clust_ok:
  6964 0000C739 803D[2C960100]00    <1> 	cmp	byte [csftdf_percentage], 0
  6965 0000C740 0F86B2010000        <1>         jna     csftdf2_save_fat_file_4 ; 25/03/2016
  6966                              <1> 
  6967                              <1> 	; "100%"
  6968 0000C746 BF[2B470100]        <1> 	mov	edi, percentagestr
  6969 0000C74B B031                <1> 	mov	al, '1'
  6970 0000C74D AA                  <1> 	stosb
  6971 0000C74E B030                <1> 	mov	al, '0'
  6972 0000C750 AA                  <1> 	stosb
  6973 0000C751 AA                  <1> 	stosb
  6974                              <1> 
  6975 0000C752 8A3D[2D960100]      <1> 	mov	bh, [csftdf_videopage]
  6976 0000C758 668B15[2E960100]    <1> 	mov	dx, [csftdf_cursorpos]
  6977 0000C75F B402                <1> 	mov	ah, 2
  6978 0000C761 E80B50FFFF          <1> 	call	_int10h
  6979                              <1> 
  6980 0000C766 BE[2B470100]        <1> 	mov	esi, percentagestr
  6981 0000C76B E8F5ADFFFF          <1> 	call	print_msg
  6982                              <1> 
  6983 0000C770 E983010000          <1>         jmp     csftdf2_save_fat_file_4
  6984                              <1> 
  6985                              <1> csftdf2_load_fs_file:
  6986                              <1> 	; temporary - 18/03/2016
  6987 0000C775 E96F020000          <1>         jmp     csftdf2_read_error
  6988                              <1> 
  6989                              <1> csftdf2_write_file_sectors:
  6990                              <1> 	; 19/03/2016
  6991 0000C77A 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  6992 0000C77E 0F86F1050000        <1>         jna     csftdf2_write_fs_file_sectors
  6993                              <1> 
  6994                              <1> csftdf2_write_fat_file_sectors:
  6995                              <1> 	; 19/03/2016
  6996                              <1> 	; 18/03/2016
  6997                              <1> 	; return:
  6998                              <1> 	;   CF = 0 & EDX > 0 -> END OF FILE
  6999                              <1> 	;   CF = 0 & EDX = 0 -> not EOF
  7000                              <1> 	;   CF = 1 -> write error (error code in AL)	
  7001                              <1> 
  7002                              <1> csftdf2_write_fat_file_secs_0:
  7003 0000C784 8B15[08960100]      <1> 	mov	edx, [csftdf_filesize]
  7004 0000C78A 2B15[28960100]      <1> 	sub	edx, [csftdf_df_wbytes]
  7005 0000C790 3B15[20960100]      <1> 	cmp	edx, [csftdf_w_size]	
  7006 0000C796 7306                <1> 	jnb	short csftdf2_write_fat_file_secs_1
  7007 0000C798 8915[20960100]      <1> 	mov	[csftdf_w_size], edx		
  7008                              <1> 
  7009                              <1> csftdf2_write_fat_file_secs_1:
  7010 0000C79E A1[20960100]        <1> 	mov	eax, [csftdf_w_size]
  7011 0000C7A3 29D2                <1> 	sub	edx, edx
  7012 0000C7A5 0FB74E11            <1> 	movzx	ecx, word [esi+LD_BPB+BytesPerSec]
  7013 0000C7A9 01C8                <1> 	add	eax, ecx
  7014 0000C7AB 48                  <1> 	dec	eax
  7015 0000C7AC F7F1                <1> 	div	ecx
  7016 0000C7AE 89C1                <1> 	mov	ecx, eax ; sector count
  7017 0000C7B0 A1[18960100]        <1> 	mov	eax, [csftdf_df_cluster]
  7018                              <1> 
  7019                              <1> 	; EBX = memory block address (current)	
  7020                              <1> 
  7021 0000C7B5 E8A20F0000          <1> 	call	write_fat_file_sectors
  7022 0000C7BA 7259                <1> 	jc	short csftdf2_write_fat_file_secs_4
  7023                              <1> 
  7024                              <1> 	; EBX = next memory address
  7025                              <1> 
  7026 0000C7BC A1[28960100]        <1> 	mov	eax, [csftdf_df_wbytes]
  7027 0000C7C1 0305[20960100]      <1> 	add	eax, [csftdf_w_size]
  7028 0000C7C7 8B15[08960100]      <1> 	mov	edx, [csftdf_filesize]
  7029 0000C7CD 39D0                <1> 	cmp	eax, edx
  7030 0000C7CF 7344                <1> 	jnb	short csftdf2_write_fat_file_secs_4
  7031 0000C7D1 A3[28960100]        <1> 	mov	[csftdf_df_wbytes], eax
  7032                              <1> 	;
  7033 0000C7D6 A3[CA950100]        <1> 	mov	[DestinationFile_DirEntry+DirEntry_FileSize], eax
  7034                              <1> 
  7035 0000C7DB 53                  <1> 	push	ebx ; *
  7036                              <1> 
  7037 0000C7DC 803D[06960100]01    <1> 	cmp	byte [DestinationFileFound], 1
  7038 0000C7E3 7210                <1> 	jb	short csftdf2_write_fat_file_secs_2
  7039                              <1> 
  7040                              <1> 	; get next cluster (csftdf_w_size! bytes)
  7041 0000C7E5 A1[18960100]        <1> 	mov	eax, [csftdf_df_cluster]
  7042 0000C7EA E887050000          <1> 	call	get_next_cluster
  7043 0000C7EF 731C                <1> 	jnc	short csftdf2_write_fat_file_secs_3
  7044                              <1> 
  7045 0000C7F1 21C0                <1> 	and	eax, eax ; end of cluster chain!?
  7046 0000C7F3 7521                <1> 	jnz	short csftdf2_write_fat_file_secs_5 ; disk error !
  7047                              <1> 
  7048                              <1> csftdf2_write_fat_file_secs_2:
  7049 0000C7F5 A1[18960100]        <1> 	mov	eax, [csftdf_df_cluster] ; last cluster
  7050 0000C7FA E8800E0000          <1> 	call	add_new_cluster		
  7051 0000C7FF 7215                <1> 	jc	short csftdf2_write_fat_file_secs_5
  7052                              <1> 
  7053                              <1> 	; NOTE: Destination file size may be bigger than
  7054                              <1> 	; source file size when the last reading fails after here.
  7055                              <1> 	; (The last -empty- cluster of destination file must be 
  7056                              <1> 	; truncated and LMDT must be current date&time for partial
  7057                              <1> 	; copy result!) 
  7058 0000C801 8B15[20960100]      <1> 	mov	edx, [csftdf_w_size] ; bytes per cluster
  7059 0000C807 0115[CA950100]      <1> 	add	[DestinationFile_DirEntry+DirEntry_FileSize], edx
  7060                              <1> 
  7061                              <1> csftdf2_write_fat_file_secs_3:
  7062 0000C80D 5B                  <1> 	pop	ebx ; *
  7063 0000C80E 29D2                <1> 	sub	edx, edx ; 0
  7064 0000C810 A3[18960100]        <1> 	mov	[csftdf_df_cluster], eax ; next cluster
  7065                              <1> 
  7066                              <1> csftdf2_write_fat_file_secs_4:
  7067 0000C815 C3                  <1> 	retn
  7068                              <1> 
  7069                              <1> csftdf2_write_fat_file_secs_5:
  7070 0000C816 5B                  <1> 	pop	ebx ; *
  7071                              <1> 	; 16/10/2016 (1Dh -> 18)
  7072 0000C817 B812000000          <1> 	mov	eax, 18 ; Write error !
  7073 0000C81C C3                  <1> 	retn
  7074                              <1> 
  7075                              <1> csftdf2_save_file:
  7076                              <1> 	; 09/12/2017
  7077                              <1> 	; 25/03/2016
  7078                              <1> 	; 19/03/2016
  7079                              <1> 	; 18/03/2016
  7080 0000C81D 8B35[34960100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; logical dos drv desc. tbl.
  7081                              <1> 
  7082 0000C823 8B1D[0C960100]      <1> 	mov	ebx, [csftdf_sf_mem_addr] ; memory block address
  7083                              <1> 
  7084 0000C829 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  7085 0000C82D 0F86F4010000        <1>         jna     csftdf2_save_fs_file
  7086                              <1> 
  7087                              <1> csftdf2_save_fat_file:
  7088 0000C833 53                  <1> 	push	ebx; *
  7089                              <1> 
  7090 0000C834 803D[2C960100]00    <1> 	cmp	byte [csftdf_percentage], 0
  7091 0000C83B 7724                <1> 	ja	short csftdf2_save_fat_file_0
  7092                              <1> 
  7093                              <1> 	; Set cursor position
  7094                              <1> 	; AH= 02h, BH= Page Number, DH= Row, DL= Column
  7095 0000C83D 8A3D[2D960100]      <1> 	mov	bh, [csftdf_videopage]
  7096 0000C843 668B15[2E960100]    <1> 	mov	dx, [csftdf_cursorpos]
  7097 0000C84A B402                <1> 	mov	ah, 2
  7098 0000C84C E8204FFFFF          <1> 	call	_int10h
  7099                              <1> 	
  7100 0000C851 BE[1F470100]        <1> 	mov	esi, msg_writing
  7101 0000C856 E80AADFFFF          <1> 	call	print_msg
  7102                              <1> 
  7103                              <1> csftdf2_save_fat_file_next:
  7104 0000C85B 8B35[34960100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; 25/03/2016
  7105                              <1> 
  7106                              <1> csftdf2_save_fat_file_0:
  7107 0000C861 5B                  <1> 	pop	ebx ; *
  7108                              <1> 
  7109                              <1> csftdf2_save_fat_file_1:
  7110 0000C862 E813FFFFFF          <1> 	call	csftdf2_write_file_sectors ; 19/03/2016	
  7111 0000C867 0F827E010000        <1>         jc      csftdf2_rw_error ; eocc! or disk error! 
  7112                              <1> 
  7113 0000C86D 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
  7114 0000C86F 756D                <1>         jnz     short csftdf2_save_fat_file_3 ; 25/03/2016
  7115                              <1> 
  7116 0000C871 803D[2C960100]00    <1> 	cmp	byte [csftdf_percentage], 0
  7117 0000C878 76E8                <1> 	jna	short csftdf2_save_fat_file_1
  7118                              <1> 
  7119 0000C87A B020                <1> 	mov	al, 20h
  7120 0000C87C BF[2B470100]        <1> 	mov	edi, percentagestr
  7121 0000C881 AA                  <1> 	stosb
  7122 0000C882 AA                  <1> 	stosb
  7123 0000C883 A1[28960100]        <1> 	mov	eax, [csftdf_df_wbytes]
  7124 0000C888 BA64000000          <1> 	mov	edx, 100
  7125 0000C88D F7E2                <1> 	mul	edx
  7126 0000C88F 8B0D[08960100]      <1> 	mov	ecx, [csftdf_filesize]	
  7127 0000C895 F7F1                <1> 	div	ecx
  7128 0000C897 B10A                <1> 	mov	cl, 10
  7129 0000C899 F6F1                <1> 	div	cl
  7130 0000C89B 80C430              <1> 	add	ah, '0'
  7131 0000C89E 8827                <1> 	mov	[edi], ah
  7132 0000C8A0 20C0                <1> 	and	al, al
  7133 0000C8A2 740A                <1> 	jz	short csftdf2_save_fat_file_2
  7134 0000C8A4 4F                  <1> 	dec	edi
  7135                              <1> 	;cbw
  7136 0000C8A5 30E4                <1> 	xor	ah, ah ; 09/12/2017
  7137 0000C8A7 F6F1                <1> 	div	cl
  7138 0000C8A9 80C430              <1> 	add	ah, '0'
  7139 0000C8AC 8827                <1> 	mov	[edi], ah
  7140                              <1> 	;and	al, al
  7141                              <1> 	;jz	short csftdf2_save_fat_file_2
  7142                              <1> 	;dec	edi
  7143                              <1> 	;mov	[edi], '1' ; 100%		
  7144                              <1> 
  7145                              <1> csftdf2_save_fat_file_2:
  7146 0000C8AE 53                  <1> 	push	ebx ; *
  7147                              <1> 
  7148 0000C8AF E802000000          <1> 	call	csftdf2_print_wr_percentage ; 25/03/2016
  7149                              <1> 
  7150 0000C8B4 EBA5                <1>         jmp     csftdf2_save_fat_file_next
  7151                              <1> 
  7152                              <1> csftdf2_print_wr_percentage:
  7153                              <1> 	; Set cursor position
  7154                              <1> 	; AH= 02h, BH= Page Number, DH= Row, DL= Column
  7155 0000C8B6 8A3D[2D960100]      <1> 	mov	bh, [csftdf_videopage]
  7156 0000C8BC 668B15[2E960100]    <1> 	mov	dx, [csftdf_cursorpos]
  7157 0000C8C3 B402                <1> 	mov	ah, 2
  7158 0000C8C5 E8A74EFFFF          <1> 	call	_int10h
  7159                              <1> 
  7160 0000C8CA BE[1F470100]        <1> 	mov	esi, msg_writing
  7161 0000C8CF E891ACFFFF          <1> 	call	print_msg
  7162                              <1> 
  7163 0000C8D4 BE[2B470100]        <1> 	mov	esi, percentagestr
  7164                              <1> 	;call	print_msg
  7165                              <1> 	;retn
  7166 0000C8D9 E987ACFFFF          <1> 	jmp	print_msg
  7167                              <1> 
  7168                              <1> csftdf2_save_fat_file_3:
  7169 0000C8DE 803D[2C960100]00    <1> 	cmp	byte [csftdf_percentage], 0
  7170 0000C8E5 7611                <1>         jna     csftdf2_save_fat_file_4 ; 25/03/2016
  7171                              <1> 
  7172                              <1> 	; "100%"
  7173 0000C8E7 BF[2B470100]        <1> 	mov	edi, percentagestr
  7174 0000C8EC B031                <1> 	mov	al, '1'
  7175 0000C8EE AA                  <1> 	stosb
  7176 0000C8EF B030                <1> 	mov	al, '0'
  7177 0000C8F1 AA                  <1> 	stosb
  7178 0000C8F2 AA                  <1> 	stosb
  7179                              <1> 
  7180 0000C8F3 E8BEFFFFFF          <1> 	call	csftdf2_print_wr_percentage
  7181                              <1> 
  7182                              <1> csftdf2_save_fat_file_4:
  7183 0000C8F8 803D[06960100]00    <1> 	cmp	byte [DestinationFileFound], 0
  7184 0000C8FF 7647                <1> 	jna	short csftdf2_save_fat_file_6
  7185                              <1> 
  7186 0000C901 8B35[34960100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; 31/03/2016	
  7187                              <1> 
  7188 0000C907 A1[18960100]        <1> 	mov	eax, [csftdf_df_cluster] ; last cluster
  7189 0000C90C E865040000          <1> 	call	get_next_cluster
  7190 0000C911 7235                <1> 	jc	short csftdf2_save_fat_file_6 ; eocc! or disk error!
  7191                              <1> 
  7192 0000C913 A1[18960100]        <1> 	mov	eax, [csftdf_df_cluster] ; last cluster
  7193                              <1> 	;xor	ecx, ecx
  7194                              <1> 	;mov	[FAT_ClusterCounter], ecx ; 0 ; reset
  7195                              <1> 	;dec	ecx ; 0FFFFFFFFh
  7196                              <1> 	;shr	ecx, 4 ; 28 bit ; 0FFFFFFFh
  7197 0000C918 B9FFFFFF0F          <1> 	mov	ecx, 0FFFFFFFh
  7198 0000C91D E87E070000          <1> 	call	update_cluster
  7199 0000C922 7224                <1> 	jc	short csftdf2_save_fat_file_6 ; really last cluster!?
  7200                              <1> 
  7201 0000C924 A3[18960100]        <1> 	mov	[csftdf_df_cluster], eax ; next cluster
  7202                              <1> 	
  7203                              <1> 	; byte [FAT_BuffValidData] = 2 
  7204 0000C929 E82F0A0000          <1> 	call	save_fat_buffer
  7205 0000C92E 730E                <1> 	jnc	short csftdf2_save_fat_file_5
  7206                              <1> 	
  7207 0000C930 8B15[08960100]      <1> 	mov	edx, [csftdf_filesize]
  7208 0000C936 8915[CA950100]      <1> 	mov	[DestinationFile_DirEntry+DirEntry_FileSize], edx
  7209 0000C93C EB58                <1> 	jmp	short csftdf2_save_fat_file_err3
  7210                              <1> 
  7211                              <1> csftdf2_save_fat_file_5:
  7212 0000C93E A1[18960100]        <1> 	mov	eax, [csftdf_df_cluster]
  7213                              <1> 
  7214                              <1> 	; EAX = First cluster to be truncated/unlinked
  7215                              <1> 	; ESI = Logical dos drive description table address
  7216 0000C943 E8580C0000          <1> 	call	truncate_cluster_chain
  7217                              <1> 
  7218                              <1> csftdf2_save_fat_file_6:
  7219                              <1> 	; 28/03/2016
  7220 0000C948 BE[39950100]        <1> 	mov	esi, SourceFile_DirEntry+DirEntry_Attr ; +11 to + 18
  7221 0000C94D BF[B9950100]        <1> 	mov	edi, DestinationFile_DirEntry+DirEntry_Attr ; +11 to + 18
  7222 0000C952 A4                  <1> 	movsb ; +11
  7223 0000C953 A5                  <1> 	movsd ; +12 .. +15
  7224 0000C954 66A5                <1> 	movsw ; +16 .. +17
  7225                              <1> 		; + 18
  7226 0000C956 83C604              <1> 	add	esi, 4
  7227 0000C959 83C704              <1> 	add	edi, 4
  7228 0000C95C A5                  <1> 	movsd	; DirEntry_WrtTime ; +22 .. +25
  7229                              <1> 
  7230 0000C95D 8B15[08960100]      <1> 	mov	edx, [csftdf_filesize]
  7231 0000C963 8915[CA950100]      <1> 	mov	[DestinationFile_DirEntry+DirEntry_FileSize], edx
  7232                              <1> 
  7233 0000C969 E8BAF0FFFF          <1> 	call	convert_current_date_time
  7234                              <1> 	; DX = Date in dos dir entry format
  7235                              <1> 	; AX = Time in dos dir entry format
  7236 0000C96E EB4D                <1> 	jmp	short csftdf2_save_fat_file_7
  7237                              <1> 
  7238                              <1> csftdf2_save_fat_file_err1:
  7239 0000C970 5B                  <1> 	pop	ebx ; *	
  7240                              <1> csftdf2_save_fat_file_err2:
  7241 0000C971 A1[28960100]        <1> 	mov	eax, [csftdf_df_wbytes]
  7242 0000C976 8B15[CA950100]      <1> 	mov	edx, [DestinationFile_DirEntry+DirEntry_FileSize]
  7243 0000C97C 39C2                <1> 	cmp	edx, eax
  7244 0000C97E 7616                <1> 	jna	short csftdf2_save_fat_file_err3
  7245 0000C980 A1[18960100]        <1> 	mov	eax, [csftdf_df_cluster] ; last (empty) cluster
  7246                              <1> 	; ESI = Logical dos drive description table address
  7247 0000C985 E8160C0000          <1> 	call	truncate_cluster_chain
  7248 0000C98A 720A                <1> 	jc	short csftdf2_save_fat_file_err3
  7249 0000C98C A1[28960100]        <1> 	mov	eax, [csftdf_df_wbytes]	
  7250 0000C991 A3[CA950100]        <1> 	mov	[DestinationFile_DirEntry+DirEntry_FileSize], eax
  7251                              <1> csftdf2_save_fat_file_err3:
  7252 0000C996 E88DF0FFFF          <1> 	call	convert_current_date_time
  7253                              <1> 	; DX = Date in dos dir entry format
  7254                              <1> 	; AX = Time in dos dir entry format
  7255 0000C99B C605[BB950100]00    <1> 	mov	byte [DestinationFile_DirEntry+DirEntry_CrtTimeTenth], 0
  7256 0000C9A2 66A3[BC950100]      <1> 	mov	[DestinationFile_DirEntry+DirEntry_CrtTime], ax
  7257 0000C9A8 668915[BE950100]    <1> 	mov	[DestinationFile_DirEntry+DirEntry_CrtDate], dx		
  7258 0000C9AF 66A3[C4950100]      <1> 	mov	[DestinationFile_DirEntry+DirEntry_WrtTime], ax
  7259 0000C9B5 668915[C6950100]    <1> 	mov	[DestinationFile_DirEntry+DirEntry_WrtDate], dx
  7260 0000C9BC F9                  <1> 	stc
  7261                              <1> csftdf2_save_fat_file_7:
  7262 0000C9BD 9C                  <1> 	pushf
  7263 0000C9BE 668915[C0950100]    <1> 	mov	[DestinationFile_DirEntry+DirEntry_LastAccDate], dx
  7264 0000C9C5 BE[AE950100]        <1> 	mov	esi, DestinationFile_DirEntry
  7265 0000C9CA BF00000800          <1> 	mov	edi, Directory_Buffer
  7266 0000C9CF 0FB70D[D6950100]    <1> 	movzx	ecx, word [DestinationFile_DirEntryNumber] ; (<2048)
  7267 0000C9D6 66C1E105            <1> 	shl	cx, 5 ; 32 * directory entry number
  7268 0000C9DA 01CF                <1> 	add	edi, ecx
  7269                              <1> 	;mov	ecx, 8
  7270 0000C9DC 66B90800            <1> 	mov	cx, 8
  7271 0000C9E0 F3A5                <1> 	rep	movsd
  7272 0000C9E2 9D                  <1> 	popf
  7273 0000C9E3 730B                <1> 	jnc	short csftdf2_write_file_OK
  7274                              <1> 	 		
  7275                              <1> csftdf2_write_error:
  7276                              <1> 	; 18/03/2016
  7277 0000C9E5 B01D                <1> 	mov	al, 1Dh ; write error
  7278 0000C9E7 EB02                <1> 	jmp	short csftdf2_rw_error
  7279                              <1> 
  7280                              <1> 	; 16/03/2016
  7281                              <1> csftdf2_read_error:
  7282 0000C9E9 B011                <1> 	mov	al, 17 ; ; Drive not ready or read error!
  7283                              <1> csftdf2_rw_error:
  7284 0000C9EB A2[05960100]        <1> 	mov	[csftdf_rw_err], al 
  7285                              <1> 
  7286                              <1> csftdf2_write_file_OK:
  7287                              <1> 	; 18/03/2016
  7288 0000C9F0 C605[1C920100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  7289 0000C9F7 E8CAF0FFFF          <1> 	call	save_directory_buffer
  7290                              <1> 
  7291                              <1>  	; Update last modification date&time of destination
  7292                              <1> 	; file's (parent) directory
  7293 0000C9FC E860F1FFFF          <1> 	call	update_parent_dir_lmdt
  7294                              <1> 	;
  7295 0000CA01 A1[0C960100]        <1> 	mov	eax, [csftdf_sf_mem_addr] ; start address
  7296                              <1> 
  7297 0000CA06 21C0                <1> 	and	eax, eax
  7298 0000CA08 750E                <1> 	jnz	short csftdf2_dealloc_mblock
  7299                              <1> 
  7300 0000CA0A 88C5                <1> 	mov	ch, al ; 0 (Cluster r/w, not full loading)
  7301                              <1> csftdf2_dealloc_retn:
  7302 0000CA0C 8A0D[05960100]      <1> 	mov	cl, [csftdf_rw_err]
  7303 0000CA12 A1[18960100]        <1> 	mov	eax, [csftdf_df_cluster]
  7304 0000CA17 C3                  <1> 	retn
  7305                              <1> 
  7306                              <1> csftdf2_dealloc_mblock:
  7307 0000CA18 8B0D[10960100]      <1> 	mov	ecx, [csftdf_sf_mem_bsize] ; block size	
  7308 0000CA1E E86F9CFFFF          <1> 	call	deallocate_memory_block
  7309 0000CA23 B5FF                <1>         mov     ch, 0FFh ; (File was full loaded at memory)
  7310 0000CA25 EBE5                <1> 	jmp	short csftdf2_dealloc_retn
  7311                              <1> 
  7312                              <1> csftdf2_save_fs_file:
  7313                              <1> 	; 16/10/2016 (1Dh -> 18)
  7314                              <1> 	; temporary - (21/03/2016)
  7315 0000CA27 B812000000          <1> 	mov	eax, 18 ; write error
  7316 0000CA2C F9                  <1> 	stc
  7317 0000CA2D C3                  <1> 	retn
  7318                              <1> 
  7319                              <1> create_file:
  7320                              <1> 	; 16/10/2016
  7321                              <1> 	; 24/03/2016, 31/03/2016
  7322                              <1> 	; 20/03/2016, 21/03/2016, 23/03/2016
  7323                              <1> 	; 19/03/2016 (TRDOS 396 = TRDOS v2.0)
  7324                              <1> 	; 03/09/2011 (FILE.ASM, 'proc_create_file')
  7325                              <1> 	; 09/08/2010
  7326                              <1> 	;
  7327                              <1> 	; INPUT ->
  7328                              <1> 	; 	EAX = File Size
  7329                              <1> 	; 	ESI = ASCIIZ File Name
  7330                              <1> 	; 	CL = File Attributes 
  7331                              <1> 	;	EBX = FFFFFFFFh -> create empty file 
  7332                              <1> 	;			 (only for FAT fs) 
  7333                              <1> 	; OUTPUT ->
  7334                              <1> 	;     CF = 0 ->
  7335                              <1> 	;	EAX = New file's first cluster
  7336                              <1> 	; 	ESI = Logical Dos Drv Descr. Table Addr.
  7337                              <1> 	; 	EBX = offset CreateFile_Size
  7338                              <1> 	; 	ECX = Sectors per cluster (<256) 
  7339                              <1> 	; 	EDX = Directory entry index/number (<65536)
  7340                              <1> 	;     CF = 1 -> error code in AL
  7341                              <1> 
  7342                              <1> ;	test	cl, 18h (directory or volume name)
  7343                              <1> ;	jnz	short loc_createfile_access_denied
  7344 0000CA2E 80E107              <1> 	and	cl, 07h ; S, H, R
  7345 0000CA31 880D[54960100]      <1>         mov     [createfile_attrib], cl 
  7346                              <1> 
  7347 0000CA37 89D9                <1> 	mov	ecx, ebx
  7348 0000CA39 89F3                <1> 	mov	ebx, esi ; ASCIIZ File Name address
  7349 0000CA3B 29D2                <1> 	sub	edx, edx
  7350 0000CA3D 8A35[F68A0100]      <1>         mov     dh, [Current_Drv]
  7351 0000CA43 BE00010900          <1>         mov     esi, Logical_DOSDisks
  7352 0000CA48 01D6                <1> 	add	esi, edx
  7353                              <1> 
  7354 0000CA4A 8815[5F960100]      <1> 	mov	[createfile_UpdatePDir], dl ; 0 ; 31/03/2016 
  7355                              <1> 
  7356                              <1> 	; LD_DiskType = 0 for write protection (read only) 
  7357 0000CA50 807E0101            <1> 	cmp	byte [esi+LD_DiskType], 1 ; 0 = Invalid
  7358 0000CA54 730A                <1> 	jnb	short loc_createfile_check_file_sytem
  7359                              <1> 	; 16/10/2016 (TRDOS Error code: 30, disk write protected) 
  7360 0000CA56 B81E000000          <1> 	mov	eax, 30 ; 13h, MSDOS err : Disk write-protected 
  7361 0000CA5B 66BA0000            <1> 	mov	dx, 0
  7362                              <1> 	; err retn: EDX = 0, EBX = File name offset
  7363                              <1> 	; ESI -> Dos drive description table address	
  7364 0000CA5F C3                  <1> 	retn
  7365                              <1> 
  7366                              <1> ;loc_createfile_access_denied:
  7367                              <1> ;	mov	eax, 05h ; access denied (invalid attributes input)
  7368                              <1> ;	stc
  7369                              <1> ;	retn
  7370                              <1> 
  7371                              <1> loc_createfile_check_file_sytem:
  7372 0000CA60 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
  7373 0000CA64 730A                <1> 	jnb	short loc_createfile_chk_empty_FAT_file_sign1
  7374                              <1> 
  7375 0000CA66 A3[40960100]        <1> 	mov	[createfile_size], eax
  7376                              <1> 	; ESI = Logical Dos Drive Description Table address
  7377                              <1> 	; EBX = ASCIIZ File Name address
  7378 0000CA6B E9FE020000          <1> 	jmp	create_fs_file
  7379                              <1> 
  7380                              <1> loc_createfile_chk_empty_FAT_file_sign1:
  7381                              <1> 	; ECX = FFFFFFFFh -> create empty file if drive has FAT fs
  7382 0000CA70 41                  <1> 	inc	ecx
  7383 0000CA71 7506                <1> 	jnz	short loc_createfile_chk_empty_FAT_file_sign2
  7384 0000CA73 890D[40960100]      <1> 	mov	[createfile_size], ecx ; 0 ; empty file
  7385                              <1> 
  7386                              <1> loc_createfile_chk_empty_FAT_file_sign2:
  7387                              <1> 	; 23/03/2016
  7388 0000CA79 668B4E11            <1> 	mov	cx, [esi+LD_BPB+BytesPerSec]
  7389 0000CA7D 66890D[5C960100]    <1> 	mov	[createfile_BytesPerSec], cx
  7390                              <1> 	
  7391                              <1> 	; EBX = ASCIIZ File Name address
  7392 0000CA84 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+SecPerClust]
  7393 0000CA88 8815[55960100]      <1> 	mov	[createfile_SecPerClust], dl
  7394 0000CA8E 8B4E74              <1> 	mov	ecx, [esi+LD_FreeSectors]
  7395 0000CA91 39D1                <1> 	cmp	ecx, edx ; byte [createfile_SecPerClust]
  7396 0000CA93 7306                <1> 	jnb	short loc_create_fat_file
  7397                              <1> 	  
  7398                              <1> loc_createfile_insufficient_disk_space:
  7399 0000CA95 B827000000          <1> 	mov	eax, 27h
  7400                              <1> loc_createfile_gffc_retn:
  7401 0000CA9A C3                  <1> 	retn
  7402                              <1> 
  7403                              <1> loc_create_fat_file:
  7404 0000CA9B 891D[38960100]      <1> 	mov	[createfile_Name_Offset], ebx
  7405 0000CAA1 890D[3C960100]      <1> 	mov	[createfile_FreeSectors], ecx
  7406                              <1> 
  7407                              <1> loc_createfile_gffc_1:
  7408 0000CAA7 E821050000          <1> 	call	get_first_free_cluster
  7409 0000CAAC 72EC                <1> 	jc	short loc_createfile_gffc_retn
  7410                              <1> 
  7411 0000CAAE A3[44960100]        <1> 	mov	[createfile_FFCluster], eax
  7412                              <1> 
  7413                              <1> loc_createfile_locate_ffe_on_directory:
  7414                              <1> 	; Current directory fcluster <> Directory buffer cluster
  7415                              <1> 	; Current directory will be reloaded by
  7416                              <1> 	; 'locate_current_dir_file' procedure
  7417                              <1> 	;
  7418                              <1> 	; ESI = Logical Dos Drv Desc. Table Adress
  7419 0000CAB3 56                  <1> 	push	esi ; *
  7420 0000CAB4 31C0                <1> 	xor	eax, eax
  7421                              <1> 
  7422 0000CAB6 A3[12920100]        <1> 	mov	dword [FAT_ClusterCounter], eax ; 0
  7423                              <1> 	; 21/03/2016
  7424 0000CABB A2[5E960100]        <1> 	mov	byte [createfile_wfc], al ; 0 
  7425                              <1> 
  7426 0000CAC0 89C1                <1>  	mov	ecx, eax
  7427 0000CAC2 6649                <1> 	dec	cx ; FFFFh  
  7428                              <1> 	; CX = FFFFh -> find first deleted or free entry
  7429                              <1> 	; ESI would be ASCIIZ filename address if the call
  7430                              <1> 	; would not be for first free or deleted dir entry  
  7431 0000CAC4 E8D6E7FFFF          <1> 	call	locate_current_dir_file
  7432 0000CAC9 0F83EE000000        <1> 	jnc	loc_createfile_set_ff_dir_entry
  7433 0000CACF 5E                  <1> 	pop	esi ; *
  7434                              <1> 	 ; ESI = Logical DOS Drv. Description Table Address 
  7435 0000CAD0 83F802              <1> 	cmp	eax, 2
  7436 0000CAD3 7402                <1> 	je	short loc_createfile_add_new_cluster
  7437                              <1> loc_createfile_locate_file_stc_retn:
  7438 0000CAD5 F9                  <1> 	stc
  7439 0000CAD6 C3                  <1> 	retn
  7440                              <1> 
  7441                              <1> loc_createfile_add_new_cluster:
  7442 0000CAD7 803D[F58A0100]02    <1> 	cmp	byte [Current_FATType], 2
  7443                              <1> 	;cmp	byte [esi+LD_FATType], 2
  7444 0000CADE 770C                <1> 	ja	short loc_createfile_add_new_cluster_check_fsc
  7445 0000CAE0 803D[F48A0100]01    <1> 	cmp	byte [Current_Dir_Level], 1
  7446                              <1> 	;cmp	byte [esi+LD_CDirLevel], 1
  7447 0000CAE7 7303                <1> 	jnb	short loc_createfile_add_new_cluster_check_fsc
  7448                              <1> 	
  7449                              <1> 	;mov	eax, 12
  7450 0000CAE9 B00C                <1> 	mov	al, 12 ; No more files 
  7451                              <1> 
  7452                              <1> loc_createfile_anc_retn:
  7453 0000CAEB C3                  <1> 	retn
  7454                              <1> 
  7455                              <1> loc_createfile_add_new_cluster_check_fsc:
  7456 0000CAEC 8B0D[3C960100]      <1> 	mov	ecx, [createfile_FreeSectors]
  7457 0000CAF2 0FB605[55960100]    <1> 	movzx	eax, byte [createfile_SecPerClust]
  7458 0000CAF9 66D1E0              <1> 	shl	ax, 1 ; AX = 2 * AX
  7459 0000CAFC 39C1                <1> 	cmp	ecx, eax
  7460 0000CAFE 7295                <1>         jb	short loc_createfile_insufficient_disk_space
  7461                              <1> 
  7462                              <1> loc_createfile_add_new_subdir_cluster:
  7463 0000CB00 8B15[21920100]      <1> 	mov	edx, [DirBuff_Cluster]
  7464 0000CB06 8915[48960100]      <1> 	mov	[createfile_LastDirCluster], edx	
  7465                              <1> 
  7466 0000CB0C A1[44960100]        <1> 	mov	eax, [createfile_FFCluster]
  7467 0000CB11 E846040000          <1> 	call	load_FAT_sub_directory 
  7468 0000CB16 72D3                <1> 	jc	short loc_createfile_anc_retn
  7469                              <1> 
  7470                              <1> pass_createfile_add_new_subdir_cluster:
  7471                              <1> 	;movzx	eax, word [esi+LD_BPB+BytesPerSec]
  7472 0000CB18 0FB705[5C960100]    <1> 	movzx	eax, word [createfile_BytesPerSec] ; 23/03/2016
  7473 0000CB1F F7E1                <1> 	mul	ecx ; ecx = directory buffer sector count
  7474 0000CB21 89C1                <1> 	mov	ecx, eax
  7475 0000CB23 C1E902              <1> 	shr	ecx, 2 ; dword count
  7476 0000CB26 29C0                <1> 	sub	eax, eax ; 0
  7477 0000CB28 F3AB                <1> 	rep	stosd 
  7478                              <1> 	;
  7479 0000CB2A C605[1C920100]02    <1> 	mov	byte [DirBuff_ValidData], 2 
  7480 0000CB31 E890EFFFFF          <1> 	call	save_directory_buffer
  7481 0000CB36 72B3                <1> 	jc	short loc_createfile_anc_retn
  7482                              <1> 
  7483                              <1> loc_createfile_save_added_subdir_cluster:
  7484 0000CB38 A1[48960100]        <1> 	mov	eax, [createfile_LastDirCluster]
  7485 0000CB3D 8B0D[44960100]      <1> 	mov	ecx, [createfile_FFCluster]
  7486 0000CB43 E858050000          <1> 	call	update_cluster
  7487 0000CB48 7304                <1> 	jnc	short loc_createfile_save_fat_buffer_0
  7488 0000CB4A 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  7489 0000CB4C 751A                <1> 	jnz	short loc_createfile_save_fat_buffer_stc_retn
  7490                              <1> 
  7491                              <1> loc_createfile_save_fat_buffer_0:
  7492 0000CB4E A1[44960100]        <1> 	mov	eax, [createfile_FFCluster]
  7493 0000CB53 A3[48960100]        <1> 	mov	[createfile_LastDirCluster], eax
  7494 0000CB58 B9FFFFFF0F          <1> 	mov	ecx, 0FFFFFFFh ; 28 bit
  7495 0000CB5D E83E050000          <1> 	call	update_cluster
  7496 0000CB62 7306                <1> 	jnc	short loc_createfile_save_fat_buffer_1
  7497 0000CB64 09C0                <1> 	or	eax, eax ; Was it free cluster
  7498 0000CB66 7402                <1> 	jz	short loc_createfile_save_fat_buffer_1
  7499                              <1> 
  7500                              <1> loc_createfile_save_fat_buffer_stc_retn:
  7501 0000CB68 F9                  <1> 	stc
  7502                              <1> loc_createfile_save_fat_buffer_retn:
  7503                              <1> loc_createfile_gffc_2_stc_retn:
  7504 0000CB69 C3                  <1> 	retn
  7505                              <1> 
  7506                              <1> loc_createfile_save_fat_buffer_1:
  7507                              <1> 	; byte [FAT_BuffValidData] = 2 
  7508 0000CB6A E8EE070000          <1> 	call	save_fat_buffer
  7509 0000CB6F 72F8                <1> 	jc	short loc_createfile_save_fat_buffer_retn
  7510                              <1> 
  7511 0000CB71 803D[12920100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
  7512 0000CB78 7222                <1> 	jb	short loc_createfile_save_fat_buffer_2
  7513                              <1> 
  7514                              <1> 	; ESI = Logical DOS Drive Description Table address 
  7515 0000CB7A A1[12920100]        <1> 	mov	eax, [FAT_ClusterCounter]
  7516                              <1> 
  7517 0000CB7F C605[12920100]00    <1> 	mov	byte [FAT_ClusterCounter], 0 ; 21/03/2016
  7518                              <1> 
  7519 0000CB86 66BB01FF            <1> 	mov	bx, 0FF01h ; add free clusters 
  7520 0000CB8A E863080000          <1> 	call	calculate_fat_freespace
  7521                              <1> 
  7522                              <1> 	;inc	eax ; 0FFFFFFFFh -> 0 ; recalculation is needed!
  7523                              <1> 	;jnz	short loc_createfile_save_fat_buffer_2
  7524                              <1> 
  7525                              <1> 	; ecx > 0 -> Recalculation is needed
  7526 0000CB8F 09C9                <1> 	or	ecx, ecx 
  7527 0000CB91 7409                <1> 	jz	short loc_createfile_save_fat_buffer_2
  7528                              <1> 
  7529 0000CB93 66BB00FF            <1> 	mov	bx, 0FF00h ; ; recalculate free space
  7530 0000CB97 E856080000          <1> 	call	calculate_fat_freespace
  7531                              <1> 
  7532                              <1> loc_createfile_save_fat_buffer_2:
  7533                              <1> 	;call	update_parent_dir_lmdt
  7534                              <1> 
  7535                              <1> loc_createfile_gffc_2:
  7536 0000CB9C E82C040000          <1> 	call	get_first_free_cluster
  7537 0000CBA1 72C6                <1> 	jc	short loc_createfile_gffc_2_stc_retn
  7538                              <1> 
  7539 0000CBA3 A3[44960100]        <1> 	mov	[createfile_FFCluster], eax
  7540                              <1> 
  7541 0000CBA8 A1[48960100]        <1> 	mov	eax, [createfile_LastDirCluster]
  7542                              <1> 	
  7543 0000CBAD E8AA030000          <1> 	call	load_FAT_sub_directory 
  7544 0000CBB2 72B5                <1> 	jc	short loc_createfile_gffc_2_stc_retn
  7545                              <1> 
  7546 0000CBB4 BF00000800          <1> 	mov	edi, Directory_Buffer
  7547                              <1> 
  7548 0000CBB9 6629DB              <1> 	sub	bx, bx ; directory entry index/number = 0
  7549                              <1> 
  7550 0000CBBC 56                  <1> 	push	esi ; * ; 23/03/2016
  7551                              <1> 
  7552                              <1> loc_createfile_set_ff_dir_entry:
  7553 0000CBBD 66891D[56960100]    <1> 	mov	[createfile_DirIndex], bx
  7554                              <1> 
  7555                              <1>         ; EDI = Directory entry address
  7556 0000CBC4 8B35[38960100]      <1> 	mov	esi, [createfile_Name_Offset]
  7557 0000CBCA A1[44960100]        <1> 	mov	eax, [createfile_FFCluster]
  7558 0000CBCF A3[4C960100]        <1> 	mov	[createfile_Cluster], eax ; 24/03/2016
  7559 0000CBD4 B5FF                <1> 	mov	ch, 0FFh
  7560 0000CBD6 8A0D[54960100]      <1>         mov	cl, [createfile_attrib] ; file attributes
  7561                              <1> 	; CH > 0 -> File size is in [EBX]
  7562 0000CBDC BB[40960100]        <1> 	mov	ebx, createfile_size
  7563                              <1>   
  7564 0000CBE1 E803EEFFFF          <1> 	call	make_directory_entry
  7565                              <1> 	
  7566 0000CBE6 5E                  <1> 	pop	esi ; * ; ESI = Logical Dos Drv Desc. Table address
  7567                              <1> 
  7568 0000CBE7 C605[1C920100]02    <1> 	mov	byte [DirBuff_ValidData], 2 
  7569 0000CBEE E8D3EEFFFF          <1> 	call	save_directory_buffer
  7570 0000CBF3 7221                <1> 	jc	short loc_createfile_set_ff_dir_entry_retn
  7571                              <1> 
  7572 0000CBF5 C605[5F960100]01    <1> 	mov	byte [createfile_UpdatePDir], 1 ; 31/03/2016 
  7573                              <1> 
  7574                              <1> loc_createfile_get_set_write_file_cluster:
  7575 0000CBFC A1[40960100]        <1> 	mov	eax, [createfile_size]
  7576 0000CC01 09C0                <1> 	or	eax, eax
  7577 0000CC03 7570                <1> 	jnz	short loc_createfile_get_set_wfc_cont
  7578 0000CC05 40                  <1> 	inc	eax
  7579                              <1> 	; 23/03/2016
  7580 0000CC06 0FB61D[55960100]    <1> 	movzx	ebx, byte [createfile_SecPerClust]
  7581                              <1> 	;movzx	ecx, word [esi+LD_BPB+BytesPerSec] ; 512
  7582 0000CC0D 0FB70D[5C960100]    <1>         movzx   ecx, word [createfile_BytesPerSec] ; 512
  7583 0000CC14 EB7C                <1> 	jmp	loc_createfile_set_cluster_count 
  7584                              <1> 
  7585                              <1> loc_createfile_set_ff_dir_entry_retn:
  7586 0000CC16 C3                  <1> 	retn
  7587                              <1> 
  7588                              <1> loc_createfile_write_fcluster_to_disk:
  7589 0000CC17 034668              <1> 	add	eax, [esi+LD_DATABegin] ; convert to physical address
  7590 0000CC1A BB00000700          <1> 	mov	ebx, Cluster_Buffer
  7591                              <1> 	; ESI = Logical DOS Drv. Desc. Tbl. address
  7592                              <1> 	; EAX = Disk address
  7593                              <1> 	; EBX = Sector Buffer
  7594                              <1> 	; ECX = sectors per cluster
  7595 0000CC1F E88A5F0000          <1> 	call	disk_write
  7596 0000CC24 7211                <1> 	jc	short loc_createfile_dsk_wr_err
  7597                              <1> 
  7598                              <1> loc_createfile_update_fat_cluster:
  7599                              <1> 	; 21/03/2016	
  7600 0000CC26 803D[5E960100]00    <1> 	cmp	byte [createfile_wfc], 0 
  7601 0000CC2D 7712                <1> 	ja	short loc_createfile_update_fat_cluster_n1
  7602                              <1> 
  7603 0000CC2F FE05[5E960100]      <1> 	inc	byte [createfile_wfc] ; 1
  7604 0000CC35 EB24                <1> 	jmp	short loc_createfile_update_fat_cluster_n2
  7605                              <1> 
  7606                              <1> loc_createfile_dsk_wr_err:
  7607                              <1> 	; 16/10/2016 (1Dh -> 18)
  7608                              <1> 	; 23/03/2016
  7609 0000CC37 B812000000          <1> 	mov	eax, 18 ; Drive not ready or write error !
  7610 0000CC3C E9BD000000          <1> 	jmp	loc_createfile_stc_retn
  7611                              <1> 
  7612                              <1> loc_createfile_update_fat_cluster_n1:
  7613 0000CC41 A1[50960100]        <1> 	mov	eax, [createfile_PCluster]
  7614 0000CC46 8B0D[4C960100]      <1> 	mov	ecx, [createfile_Cluster]
  7615 0000CC4C E84F040000          <1> 	call	update_cluster
  7616 0000CC51 7308                <1> 	jnc	short loc_createfile_update_fat_cluster_n2
  7617 0000CC53 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  7618 0000CC55 0F85A3000000        <1> 	jnz	loc_createfile_stc_retn
  7619                              <1> 
  7620                              <1> loc_createfile_update_fat_cluster_n2:
  7621 0000CC5B A1[4C960100]        <1>         mov	eax, [createfile_Cluster]
  7622 0000CC60 B9FFFFFF0F          <1> 	mov	ecx, 0FFFFFFFh
  7623 0000CC65 E836040000          <1> 	call	update_cluster
  7624 0000CC6A 734E                <1> 	jnc	short loc_createfile_save_fat_buffer_3
  7625 0000CC6C 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  7626 0000CC6E 744A                <1> 	jz	short loc_createfile_save_fat_buffer_3
  7627                              <1> 
  7628                              <1> loc_createfile_upd_fat_fcluster_stc_retn:
  7629 0000CC70 E989000000          <1> 	jmp	loc_createfile_stc_retn
  7630                              <1> 
  7631                              <1> loc_createfile_get_set_wfc_cont:
  7632                              <1> 	;movzx	ecx, word [esi+LD_BPB+BytesPerSec] ; 512	
  7633 0000CC75 0FB70D[5C960100]    <1> 	movzx	ecx, word [createfile_BytesPerSec] ; 512
  7634 0000CC7C 01C8                <1> 	add	eax, ecx
  7635 0000CC7E 48                  <1> 	dec	eax  ; add eax, 511
  7636 0000CC7F 29D2                <1> 	sub	edx, edx
  7637 0000CC81 F7F1                <1> 	div	ecx
  7638 0000CC83 0FB61D[55960100]    <1> 	movzx	ebx, byte [createfile_SecPerClust]
  7639 0000CC8A 01D8                <1> 	add	eax, ebx
  7640 0000CC8C 48                  <1> 	dec	eax  ; add eax, SecPerClust - 1
  7641 0000CC8D 6631D2              <1> 	xor	dx, dx
  7642 0000CC90 F7F3                <1> 	div	ebx
  7643                              <1> 
  7644                              <1> loc_createfile_set_cluster_count:
  7645 0000CC92 A3[58960100]        <1> 	mov 	[createfile_CCount], eax
  7646                              <1> 	
  7647 0000CC97 BF00000700          <1> 	mov	edi, Cluster_Buffer
  7648 0000CC9C 89C8                <1> 	mov	eax, ecx ; Bytes per Sector
  7649 0000CC9E F7E3                <1> 	mul	ebx ; Sectors per Cluster 
  7650                              <1> 	; EAX = Bytes per Cluster
  7651 0000CCA0 89C1                <1> 	mov	ecx, eax
  7652 0000CCA2 C1E902              <1> 	shr	ecx, 2 ; dword count
  7653 0000CCA5 31C0                <1> 	xor	eax, eax
  7654 0000CCA7 F3AB                <1> 	rep	stosd ; clear cluster buffer
  7655                              <1> 
  7656 0000CCA9 A1[4C960100]        <1> 	mov	eax, [createfile_Cluster] ; 24/03/2016
  7657                              <1> 
  7658 0000CCAE 89D9                <1> 	mov	ecx, ebx
  7659                              <1> 
  7660                              <1> loc_createfile_get_set_wf_fclust_cont:
  7661 0000CCB0 83E802              <1> 	sub	eax, 2
  7662 0000CCB3 F7E1                <1> 	mul	ecx
  7663                              <1> 	; EAX = Logical DOS disk address (offset)
  7664 0000CCB5 E95DFFFFFF          <1>         jmp     loc_createfile_write_fcluster_to_disk
  7665                              <1> 
  7666                              <1> loc_createfile_save_fat_buffer_3:
  7667                              <1> 	; byte [FAT_BuffValidData] = 2
  7668 0000CCBA E89E060000          <1> 	call	save_fat_buffer
  7669 0000CCBF 723D                <1> 	jc	loc_createfile_stc_retn
  7670                              <1> 
  7671                              <1> 	; 21/03/2016
  7672 0000CCC1 803D[12920100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
  7673 0000CCC8 721B                <1> 	jb	short loc_createfile_save_fat_buffer_4
  7674                              <1> 
  7675                              <1> 	; ESI = Logical DOS Drive Description Table address 
  7676 0000CCCA A1[12920100]        <1> 	mov	eax, [FAT_ClusterCounter]
  7677 0000CCCF 66BB01FF            <1> 	mov	bx, 0FF01h ; add free clusters 
  7678 0000CCD3 E81A070000          <1> 	call	calculate_fat_freespace
  7679                              <1> 
  7680                              <1> 	;inc	eax ; 0FFFFFFFFh -> 0 ; recalculation is needed!
  7681                              <1> 	;jnz	short loc_createfile_save_fat_buffer_4
  7682                              <1> 
  7683                              <1> 	; ecx > 0 -> Recalculation is needed
  7684 0000CCD8 09C9                <1> 	or	ecx, ecx 
  7685 0000CCDA 7409                <1> 	jz	short loc_createfile_save_fat_buffer_4
  7686                              <1> 
  7687 0000CCDC 66BB00FF            <1> 	mov	bx, 0FF00h ; ; recalculate free space
  7688 0000CCE0 E80D070000          <1> 	call	calculate_fat_freespace
  7689                              <1> 
  7690                              <1> loc_createfile_save_fat_buffer_4:
  7691 0000CCE5 FF0D[58960100]      <1> 	dec	dword [createfile_CCount]
  7692                              <1> 	;jz	short loc_createfile_upd_dir_modif_date_time
  7693 0000CCEB 743F                <1> 	jz	short loc_createfile_stc_retn_cc ; 31/03/2016
  7694                              <1> 
  7695                              <1> loc_createfile_get_set_write_next_cluster:
  7696 0000CCED E8DB020000          <1> 	call	get_first_free_cluster
  7697 0000CCF2 720A                <1> 	jc	short loc_createfile_stc_retn
  7698                              <1> 
  7699                              <1> loc_createfile_get_set_write_next_cluster_1:
  7700 0000CCF4 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh
  7701 0000CCF7 7213                <1> 	jb	short loc_createfile_get_set_write_next_cluster_2
  7702                              <1> 
  7703                              <1> loc_createfile_wnc_insufficient_disk_space:	
  7704 0000CCF9 B827000000          <1> 	mov	eax, 27h ; Insufficient disk space
  7705                              <1> 
  7706                              <1> loc_createfile_stc_retn:
  7707 0000CCFE 803D[5E960100]01    <1> 	cmp	byte [createfile_wfc], 1
  7708 0000CD05 7324                <1> 	jnb	short loc_createfile_err_retn
  7709 0000CD07 C3                  <1> 	retn
  7710                              <1> 
  7711                              <1> loc_createfile_wnc_inv_format_retn:
  7712                              <1> 	;mov	eax, 28
  7713 0000CD08 B01C                <1> 	mov	al, 28 ; Invalid format
  7714 0000CD0A EBF2                <1> 	jmp	short loc_createfile_stc_retn
  7715                              <1> 	         
  7716                              <1> loc_createfile_get_set_write_next_cluster_2:
  7717 0000CD0C 83F802              <1> 	cmp	eax, 2
  7718 0000CD0F 72F7                <1> 	jb	short loc_createfile_wnc_inv_format_retn
  7719                              <1> 
  7720                              <1> loc_createfile_get_set_write_next_cluster_3:
  7721 0000CD11 8B0D[4C960100]      <1> 	mov	ecx, [createfile_Cluster]
  7722 0000CD17 A3[4C960100]        <1> 	mov	[createfile_Cluster], eax
  7723 0000CD1C 890D[50960100]      <1> 	mov	[createfile_PCluster], ecx
  7724 0000CD22 0FB60D[55960100]    <1> 	movzx	ecx, byte [createfile_SecPerClust]
  7725 0000CD29 EB85                <1> 	jmp	short loc_createfile_get_set_wf_fclust_cont
  7726                              <1> 
  7727                              <1> loc_createfile_err_retn:
  7728 0000CD2B F9                  <1> 	stc
  7729                              <1> 
  7730                              <1> ;loc_createfile_upd_dir_modif_date_time:
  7731                              <1> loc_createfile_stc_retn_cc: ; 31/03/2016
  7732 0000CD2C 9C                  <1> 	pushf	; cpu is here for an error return or completion 
  7733 0000CD2D 50                  <1> 	push	eax ; error code if cf = 1
  7734                              <1> 
  7735                              <1> 	;call	update_parent_dir_lmdt
  7736                              <1> 
  7737                              <1> ;loc_createfile_stc_retn_cc:
  7738 0000CD2E A1[12920100]        <1> 	mov	eax, [FAT_ClusterCounter]
  7739 0000CD33 09C0                <1> 	or	eax, eax
  7740 0000CD35 741A                <1> 	jz	short loc_createfile_stc_retn_pop_eax
  7741 0000CD37 8A3D[F68A0100]      <1> 	mov	bh, [Current_Drv]
  7742 0000CD3D B301                <1> 	mov	bl, 01h ; BL = 1 -> add clusters
  7743                              <1> 	; NOTE: EAX value will be added to Free Cluster Count
  7744                              <1> 	; (If EAX value is negative, Free Cluster Count will be decreased)
  7745 0000CD3F E8AE060000          <1>   	call	calculate_fat_freespace
  7746                              <1>         ; ESI = Logical DOS Drive Description Table Address 
  7747                              <1>         ;jc	short loc_createfile_stc_retn_pop_eax_cf
  7748 0000CD44 21C9                <1> 	and	ecx, ecx ; cx = 0 -> valid free sector count
  7749 0000CD46 7409                <1> 	jz	short loc_createfile_stc_retn_pop_eax
  7750                              <1> 
  7751                              <1> loc_createfile_stc_retn_recalc_FAT_freespace:
  7752 0000CD48 66BB00FF            <1> 	mov	bx, 0FF00h ; bh = 0FFh -> 
  7753                              <1> 	; ESI = Logical DOS Drv DT Addr
  7754                              <1> 	; BL = 0 -> Recalculate 
  7755 0000CD4C E8A1060000          <1> 	call	calculate_fat_freespace
  7756                              <1> 
  7757                              <1> loc_createfile_stc_retn_pop_eax:
  7758 0000CD51 58                  <1> 	pop	eax
  7759 0000CD52 9D                  <1> 	popf
  7760 0000CD53 7218                <1> 	jc	short loc_createfile_retn
  7761                              <1> 
  7762                              <1> loc_createfile_retn_fcluster:
  7763 0000CD55 A1[44960100]        <1> 	mov	eax, [createfile_FFCluster]
  7764 0000CD5A BB[40960100]        <1> 	mov	ebx, createfile_size
  7765                              <1> 	;movzx	ecx, byte [esi+LD_BPB+SecPerClust]
  7766 0000CD5F 0FB60D[55960100]    <1> 	movzx	ecx, byte [createfile_SecPerClust] ; 23/03/2016
  7767 0000CD66 0FB715[56960100]    <1> 	movzx	edx, word [createfile_DirIndex]
  7768                              <1> 
  7769                              <1> loc_createfile_retn:
  7770 0000CD6D C3                  <1> 	retn
  7771                              <1> 
  7772                              <1> create_fs_file:
  7773                              <1> 	; temporary (21/03/2016)
  7774 0000CD6E C3                  <1> 	retn
  7775                              <1> 
  7776                              <1> delete_fs_file:
  7777                              <1> 	; temporary (28/02/2016)
  7778 0000CD6F C3                  <1> 	retn
  7779                              <1> 
  7780                              <1> rename_fs_file_or_directory:
  7781 0000CD70 C3                  <1> 	retn
  7782                              <1> 
  7783                              <1> make_fs_directory:
  7784                              <1> 	; temporary (21/02/2016)
  7785 0000CD71 C3                  <1> 	retn
  7786                              <1> 
  7787                              <1> add_new_fs_section:
  7788                              <1> 	; temporary (11/03/2016)
  7789 0000CD72 C3                  <1> 	retn
  7790                              <1> 
  7791                              <1> delete_fs_directory_entry:
  7792                              <1> 	; temporary (11/03/2016)
  7793 0000CD73 C3                  <1> 	retn
  7794                              <1> 
  7795                              <1> csftdf2_read_fs_file_sectors:
  7796                              <1> 	; temporary (19/03/2016)
  7797 0000CD74 C3                  <1> 	retn
  7798                              <1> 
  7799                              <1> csftdf2_write_fs_file_sectors:
  7800                              <1> 	; temporary (19/03/2016)
  7801 0000CD75 C3                  <1> 	retn
  3091                                  %include 'trdosk5.s' ; 24/01/2016
  3092                              <1> ; ****************************************************************************
  3093                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - File System Procedures : trdosk5s
  3094                              <1> ; ----------------------------------------------------------------------------
  3095                              <1> ; Last Update: 23/10/2016
  3096                              <1> ; ----------------------------------------------------------------------------
  3097                              <1> ; Beginning: 24/01/2016
  3098                              <1> ; ----------------------------------------------------------------------------
  3099                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
  3100                              <1> ; ----------------------------------------------------------------------------
  3101                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
  3102                              <1> ; DRV_FAT.ASM (21/08/2011)
  3103                              <1> ; ****************************************************************************
  3104                              <1> ; DRV_FAT.ASM (c) 2005-2011 Erdogan TAN [ 07/07/2009 ] Last Update: 21/08/2011
  3105                              <1> 
  3106                              <1> get_next_cluster:
  3107                              <1> 	; 15/10/2016
  3108                              <1> 	; 23/03/2016
  3109                              <1> 	; 01/02/2016 (TRDOS 386 =  TRDOS v2.0)
  3110                              <1> 	; 05/07/2011
  3111                              <1> 	; 07/07/2009
  3112                              <1> 	; 2005
  3113                              <1> 	; INPUT ->
  3114                              <1> 	;	EAX = Cluster Number (32 bit)
  3115                              <1> 	;	ESI = Logical DOS Drive Parameters Table
  3116                              <1> 	; OUTPUT ->
  3117                              <1> 	;	cf = 0 -> No Error, EAX valid
  3118                              <1> 	;	cf = 1 & EAX = 0 -> End Of Cluster Chain
  3119                              <1> 	;	cf = 1 & EAX > 0 -> Error
  3120                              <1> 	;	ECX = Current/Previous cluster (if CF = 0)
  3121                              <1> 	;	EAX = Next Cluster Number (32 bit)
  3122                              <1> 	;
  3123                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
  3124                              <1> 
  3125 0000CD76 A3[06920100]        <1> 	mov	[FAT_CurrentCluster], eax
  3126                              <1> check_next_cluster_fat_type:
  3127 0000CD7B 29D2                <1> 	sub	edx, edx ; 0
  3128 0000CD7D 807E0302            <1>         cmp     byte [esi+LD_FATType], 2
  3129 0000CD81 7250                <1> 	jb	short get_FAT12_next_cluster
  3130 0000CD83 0F87AF000000        <1>         ja      get_FAT32_next_cluster
  3131                              <1> get_FAT16_next_cluster:
  3132 0000CD89 BB00030000          <1> 	mov	ebx, 300h ;768
  3133 0000CD8E F7F3                <1> 	div	ebx
  3134                              <1> 	; EAX = Count of 3 FAT sectors
  3135                              <1> 	; EDX = Cluster Offset (< 768)
  3136 0000CD90 66D1E2              <1> 	shl	dx, 1 ; Multiply by 2
  3137 0000CD93 89D3                <1> 	mov	ebx, edx ; Byte Offset
  3138 0000CD95 81C3001C0900        <1> 	add	ebx, FAT_Buffer
  3139 0000CD9B 66BA0300            <1> 	mov	dx, 3
  3140 0000CD9F F7E2                <1> 	mul	edx  
  3141                              <1> 	; EAX = FAT Sector (<= 256)
  3142                              <1> 	; EDX = 0
  3143 0000CDA1 8A0E                <1> 	mov	cl, [esi+LD_Name]
  3144 0000CDA3 803D[0A920100]00    <1> 	cmp	byte [FAT_BuffValidData], 0
  3145 0000CDAA 0F86CC000000        <1>         jna     load_FAT_sectors0
  3146 0000CDB0 3A0D[0B920100]      <1> 	cmp	cl, [FAT_BuffDrvName]
  3147 0000CDB6 0F85C0000000        <1>         jne     load_FAT_sectors0
  3148 0000CDBC 3B05[0E920100]      <1> 	cmp	eax, [FAT_BuffSector]
  3149 0000CDC2 0F85BA000000        <1>         jne     load_FAT_sectors1
  3150                              <1> 	;movzx	eax, word [ebx]
  3151 0000CDC8 668B03              <1> 	mov	ax, [ebx]
  3152                              <1> 	; 01/02/2016
  3153                              <1> 	; DRV_FAT.ASM (21/08/2011) had a FATal bug here !
  3154                              <1> 	; (cmp ah, 0Fh) ! (ax >= FF7h)
  3155                              <1> 	; (how can i do a such mistake!?)
  3156                              <1> 	;cmp	al, 0F7h
  3157                              <1> 	;jb	short loc_pass_gnc_FAT16_eoc_check
  3158                              <1> 	;cmp	ah, 0FFh
  3159                              <1> 	;jb	short loc_pass_gnc_FAT16_eoc_check
  3160 0000CDCB 6683F8F7            <1> 	cmp	ax, 0FFF7h
  3161 0000CDCF 725A                <1> 	jb	short loc_pass_gnc_FAT16_eoc_check
  3162                              <1> 	; ax >= FFF7h (cluster 0002h to FFF6h is valid, in use)
  3163 0000CDD1 EB56                <1> 	jmp	short loc_pass_gnc_FAT16_eoc_check_xor_eax
  3164                              <1> 
  3165                              <1> get_FAT12_next_cluster:
  3166 0000CDD3 BB00040000          <1> 	mov	ebx, 400h ;1024
  3167 0000CDD8 F7F3                <1> 	div	ebx
  3168                              <1> 	; EAX = Count of 3 FAT sectors
  3169                              <1> 	; EDX = Cluster Offset (< 1024)
  3170 0000CDDA 6650                <1> 	push	ax
  3171 0000CDDC 66B80300            <1> 	mov	ax, 3	
  3172 0000CDE0 66F7E2              <1> 	mul	dx    	; Multiply by 3
  3173 0000CDE3 66D1E8              <1> 	shr	ax, 1	; Divide by 2
  3174 0000CDE6 6689C3              <1>         mov	bx, ax 	; Byte Offset
  3175 0000CDE9 81C3001C0900        <1> 	add	ebx, FAT_Buffer
  3176 0000CDEF 6658                <1> 	pop	ax
  3177 0000CDF1 66BA0300            <1> 	mov	dx, 3
  3178 0000CDF5 F7E2                <1> 	mul	edx 
  3179                              <1> 	; EAX = FAT Sector (<= 12)
  3180                              <1> 	; EDX = 0
  3181 0000CDF7 8A0E                <1> 	mov	cl, [esi+LD_Name]
  3182 0000CDF9 803D[0A920100]00    <1> 	cmp	byte [FAT_BuffValidData], 0
  3183 0000CE00 767A                <1> 	jna	short load_FAT_sectors0
  3184 0000CE02 3A0D[0B920100]      <1> 	cmp	cl, [FAT_BuffDrvName]
  3185 0000CE08 7572                <1> 	jne	short load_FAT_sectors0
  3186 0000CE0A 3B05[0E920100]      <1> 	cmp	eax, [FAT_BuffSector]
  3187 0000CE10 7570                <1> 	jne	short load_FAT_sectors1
  3188 0000CE12 A1[06920100]        <1> 	mov	eax, [FAT_CurrentCluster]
  3189 0000CE17 66D1E8              <1> 	shr	ax, 1
  3190                              <1> 	;movzx	eax, word [ebx]
  3191 0000CE1A 668B03              <1> 	mov	ax, [ebx]
  3192 0000CE1D 7314                <1> 	jnc	short get_FAT12_nc_even
  3193 0000CE1F 66C1E804            <1> 	shr	ax, 4
  3194                              <1> loc_gnc_fat12_eoc_check:
  3195                              <1> 	;cmp	al, 0F7h
  3196                              <1> 	;jb	short loc_pass_gnc_FAT16_eoc_check
  3197                              <1> 	;cmp	ah, 0Fh
  3198                              <1> 	;jb	short loc_pass_gnc_FAT16_eoc_check
  3199 0000CE23 663DF70F            <1> 	cmp	ax, 0FF7h
  3200 0000CE27 7202                <1> 	jb	short loc_pass_gnc_FAT16_eoc_check
  3201                              <1> 	; ax >= FF7h (cluster 0002h to FF6h is valid, in use)
  3202                              <1> 
  3203                              <1> loc_pass_gnc_FAT16_eoc_check_xor_eax:
  3204 0000CE29 31C0                <1> 	xor	eax, eax ; 0
  3205                              <1> loc_pass_gnc_FAT16_eoc_check:
  3206                              <1> loc_pass_gnc_FAT32_eoc_check:
  3207 0000CE2B 8B0D[06920100]      <1> 	mov	ecx, [FAT_CurrentCluster]
  3208 0000CE31 F5                  <1> 	cmc
  3209 0000CE32 C3                  <1> 	retn
  3210                              <1> 
  3211                              <1> get_FAT12_nc_even:
  3212 0000CE33 80E40F              <1> 	and	ah, 0Fh
  3213 0000CE36 EBEB                <1> 	jmp	short loc_gnc_fat12_eoc_check
  3214                              <1> 
  3215                              <1> get_FAT32_next_cluster:
  3216 0000CE38 BB80010000          <1> 	mov	ebx, 180h ;384
  3217 0000CE3D F7F3                <1> 	div	ebx
  3218                              <1> 	; EAX = Count of 3 FAT sectors
  3219                              <1> 	; EDX = Cluster Offset (< 384)
  3220 0000CE3F 66C1E202            <1> 	shl	dx, 2	; Multiply by 4
  3221 0000CE43 89D3                <1> 	mov	ebx, edx ; Byte Offset
  3222 0000CE45 81C3001C0900        <1> 	add	ebx, FAT_Buffer
  3223 0000CE4B 66BA0300            <1> 	mov	dx, 3
  3224 0000CE4F F7E2                <1> 	mul	edx	
  3225                              <1>         ; EAX = FAT Sector (<= 2097152) ; (FFFFFF7h * 4) / 512
  3226                              <1> 	; 	for 32KB cluster size:
  3227                              <1> 	;	EAX <= 1024 = (4GB / 32KB) * 4) / 512 	
  3228                              <1> 	; EDX = 0
  3229 0000CE51 8A0E                <1> 	mov	cl, [esi+LD_Name]
  3230 0000CE53 803D[0A920100]00    <1> 	cmp	byte [FAT_BuffValidData], 0
  3231 0000CE5A 7620                <1> 	jna	short load_FAT_sectors0
  3232 0000CE5C 3A0D[0B920100]      <1> 	cmp	cl, [FAT_BuffDrvName]
  3233 0000CE62 7518                <1> 	jne	short load_FAT_sectors0
  3234 0000CE64 3B05[0E920100]      <1> 	cmp	eax, [FAT_BuffSector] ; 0, 3, 6, 9 ...
  3235 0000CE6A 7516                <1> 	jne	short load_FAT_sectors1
  3236 0000CE6C 8B03                <1> 	mov	eax, [ebx]
  3237 0000CE6E 25FFFFFF0F          <1>  	and	eax, 0FFFFFFFh ; 28 bit Cluster
  3238 0000CE73 3DF7FFFF0F          <1> 	cmp	eax, 0FFFFFF7h
  3239 0000CE78 72B1                <1> 	jb	short loc_pass_gnc_FAT32_eoc_check
  3240                              <1> 	; eax >= FFFFFF7h (cluster 0002h to FFFFFF6h is valid)
  3241 0000CE7A EBAD                <1> 	jmp	short loc_pass_gnc_FAT16_eoc_check_xor_eax
  3242                              <1> 
  3243                              <1> load_FAT_sectors0:
  3244 0000CE7C 880D[0B920100]      <1> 	mov	[FAT_BuffDrvName], cl
  3245                              <1> load_FAT_sectors1:
  3246 0000CE82 A3[0E920100]        <1> 	mov	[FAT_BuffSector], eax
  3247 0000CE87 89C3                <1> 	mov	ebx, eax
  3248 0000CE89 034660              <1>         add     eax, [esi+LD_FATBegin]
  3249 0000CE8C 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
  3250 0000CE90 7706                <1>         ja      short load_FAT_sectors3
  3251 0000CE92 0FB74E1C            <1> 	movzx	ecx, word [esi+LD_BPB+BPB_FATSz16]
  3252 0000CE96 EB03                <1> 	jmp	short load_FAT_sectors4
  3253                              <1> load_FAT_sectors3:
  3254 0000CE98 8B4E2A              <1> 	mov	ecx, [esi+LD_BPB+BPB_FATSz32]
  3255                              <1> load_FAT_sectors4:
  3256 0000CE9B 29D9                <1> 	sub	ecx, ebx ; [FAT_BuffSector]
  3257 0000CE9D 83F903              <1>         cmp     ecx, 3
  3258 0000CEA0 7605                <1>         jna     short load_FAT_sectors5
  3259 0000CEA2 B903000000          <1> 	mov	ecx, 3
  3260                              <1> load_FAT_sectors5:
  3261 0000CEA7 BB001C0900          <1> 	mov	ebx, FAT_Buffer
  3262 0000CEAC E80C5D0000          <1> 	call	disk_read
  3263 0000CEB1 730D                <1> 	jnc	short load_FAT_sectors_ok
  3264                              <1> 	; 15/10/2016 (15h -> 17)
  3265                              <1> 	; 23/03/2016 (15h)
  3266 0000CEB3 B811000000          <1> 	mov	eax, 17 ; Drive not ready or read error
  3267 0000CEB8 C605[0A920100]00    <1> 	mov	byte [FAT_BuffValidData], 0
  3268 0000CEBF C3                  <1> 	retn
  3269                              <1> load_FAT_sectors_ok:
  3270 0000CEC0 C605[0A920100]01    <1> 	mov	byte [FAT_BuffValidData], 1
  3271 0000CEC7 A1[06920100]        <1> 	mov	eax, [FAT_CurrentCluster]
  3272 0000CECC E9AAFEFFFF          <1>         jmp     check_next_cluster_fat_type
  3273                              <1> 
  3274                              <1> load_FAT_root_directory:
  3275                              <1> 	; 23/10/2016
  3276                              <1> 	; 15/10/2016
  3277                              <1> 	; 07/02/2016
  3278                              <1> 	; 02/02/2016
  3279                              <1> 	; 01/02/2016 (TRDOS 386 =  TRDOS v2.0)
  3280                              <1> 	; 21/05/2011
  3281                              <1> 	; 22/08/2009
  3282                              <1> 	;
  3283                              <1> 	; INPUT ->
  3284                              <1> 	;	ESI = Logical DOS Drive Description Table
  3285                              <1> 	; OUTPUT ->
  3286                              <1> 	;	cf = 1 -> Root directory could not be loaded
  3287                              <1> 	;	    EAX > 0 -> Error number
  3288                              <1> 	;	cf = 0 -> EAX = 0
  3289                              <1> 	;	ECX = Directory buffer size in sectors (CL)
  3290                              <1> 	;	EBX = Directory buffer address
  3291                              <1> 	; 	NOTE: DirBuffer_Size is in bytes ! (word)
  3292                              <1> 	;
  3293                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
  3294                              <1> 
  3295                              <1> 	; NOTE: Only for FAT12 and FAT16 file systems !
  3296                              <1> 	; (FAT32 fs root dir must be loaded as sub directory)
  3297                              <1> 
  3298 0000CED1 8A1E                <1> 	mov	bl, [esi+LD_Name]
  3299 0000CED3 8A7E03              <1> 	mov	bh, [esi+LD_FATType]
  3300                              <1> 
  3301                              <1> 	;mov	[DirBuff_DRV], bl
  3302                              <1> 	;mov	[DirBuff_FATType], bh
  3303 0000CED6 66891D[1A920100]    <1> 	mov	[DirBuff_DRV], bx
  3304                              <1> 	
  3305                              <1> 	;cmp	bh, 2
  3306                              <1> 	;ja	short load_FAT32_root_dir0 ; FAT32 root dir
  3307                              <1> 
  3308                              <1> load_FAT_root_dir0: ; 23/10/2016
  3309 0000CEDD 0FB75617            <1> 	movzx	edx, word [esi+LD_BPB+RootDirEnts]
  3310                              <1> 
  3311                              <1> 	;or	dx, dx ; 0 for FAT32 file systems
  3312                              <1> 	;jz	short load_FAT32_root_dir0 ; FAT32 root dir
  3313                              <1> 
  3314 0000CEE1 6681FA0002          <1> 	cmp	dx, 512 ; Number of Root Dir Entries
  3315 0000CEE6 7414                <1> 	je	short lrd_mov_ecx_32
  3316 0000CEE8 89D0                <1> 	mov	eax, edx
  3317                              <1> 	; 23/10/2016
  3318 0000CEEA 89C1                <1> 	mov	ecx, eax
  3319 0000CEEC 6683C10F            <1> 	add	cx, 15 ; round up 
  3320 0000CEF0 66C1E904            <1> 	shr	cx, 4  ; 16 entries per sector (512/32)
  3321                              <1> 	; ecx = Root directory size in sectors
  3322 0000CEF4 66C1E005            <1> 	shl	ax, 5 ; Root directory size in bytes
  3323 0000CEF8 664A                <1> 	dec	dx    ; Last entry number of root dir
  3324                              <1> 	; cx = Dir Buffer sector count             
  3325 0000CEFA EB0B                <1> 	jmp	short lrd_check_dir_buffer
  3326                              <1> 
  3327                              <1> lrd_mov_ecx_32:
  3328 0000CEFC B920000000          <1> 	mov	ecx, 32
  3329 0000CF01 664A                <1> 	dec	dx ; 511
  3330 0000CF03 66B80040            <1> 	mov	ax, 32*512 
  3331                              <1>  
  3332                              <1> lrd_check_dir_buffer:
  3333 0000CF07 29DB                <1> 	sub	ebx, ebx ; 0
  3334 0000CF09 881D[1C920100]      <1> 	mov	[DirBuff_ValidData], bl ; 0
  3335 0000CF0F 668915[1F920100]    <1> 	mov	[DirBuff_LastEntry], dx
  3336 0000CF16 891D[21920100]      <1> 	mov	[DirBuff_Cluster], ebx ; 0
  3337 0000CF1C 66A3[25920100]      <1> 	mov	[DirBuffer_Size], ax
  3338                              <1> 
  3339 0000CF22 8B4664              <1> 	mov	eax, [esi+LD_ROOTBegin]
  3340                              <1> read_directory:
  3341 0000CF25 BB00000800          <1> 	mov	ebx, Directory_Buffer
  3342 0000CF2A 51                  <1> 	push	ecx ; Directory buffer sector count
  3343 0000CF2B 53                  <1> 	push	ebx
  3344 0000CF2C E88C5C0000          <1> 	call	disk_read
  3345 0000CF31 5B                  <1> 	pop	ebx
  3346 0000CF32 720B                <1> 	jc	short load_DirBuff_error
  3347                              <1> 
  3348                              <1> validate_DirBuff_and_return:
  3349 0000CF34 59                  <1> 	pop	ecx ; Number of loaded sectors
  3350 0000CF35 C605[1C920100]01    <1> 	mov	byte [DirBuff_ValidData], 1
  3351 0000CF3C 31C0                <1> 	xor	eax, eax ; 0 = no error
  3352 0000CF3E C3                  <1> 	retn
  3353                              <1> 
  3354                              <1> load_DirBuff_error:
  3355 0000CF3F 89C8                <1> 	mov	eax, ecx ; remaining sectors
  3356 0000CF41 59                  <1> 	pop	ecx ; sector count
  3357 0000CF42 29C1                <1> 	sub	ecx, eax ; Number of loaded sectors
  3358                              <1> 	; 15/10/2016 (15h -> 17)
  3359 0000CF44 B811000000          <1> 	mov	eax, 17 ; DRV NOT READY OR READ ERROR !
  3360 0000CF49 F9                  <1> 	stc
  3361 0000CF4A C3                  <1>         retn
  3362                              <1> 
  3363                              <1> load_FAT32_root_directory:
  3364                              <1> 	; 02/02/2016 (TRDOS 386 =  TRDOS v2.0)
  3365                              <1> 	;
  3366                              <1> 	; INPUT ->
  3367                              <1> 	;	ESI = Logical DOS Drive Description Table
  3368                              <1> 	; OUTPUT ->
  3369                              <1> 	;	cf = 1 -> Root directory could not be loaded
  3370                              <1> 	;	    EAX > 0 -> Error number
  3371                              <1> 	;	cf = 0 -> EAX = 0
  3372                              <1> 	;	ECX = Directory buffer size in sectors (CL)
  3373                              <1> 	;	EBX = Directory buffer address
  3374                              <1> 	; 	NOTE: DirBuffer_Size is in bytes ! (word)
  3375                              <1> 	;
  3376                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
  3377                              <1> 
  3378                              <1> 
  3379 0000CF4B 8A1E                <1> 	mov	bl, [esi+LD_Name]
  3380 0000CF4D 8A7E03              <1> 	mov	bh, [esi+LD_FATType]
  3381                              <1> 
  3382                              <1> 	;mov	[DirBuff_DRV], bl
  3383                              <1> 	;mov	[DirBuff_FATType], bh
  3384 0000CF50 66891D[1A920100]    <1> 	mov	[DirBuff_DRV], bx
  3385                              <1> 
  3386                              <1> load_FAT32_root_dir0:
  3387 0000CF57 8B4632              <1> 	mov	eax, [esi+LD_BPB+FAT32_RootFClust]
  3388 0000CF5A EB0C                <1> 	jmp	short load_FAT_sub_dir0
  3389                              <1> 	
  3390                              <1> load_FAT_sub_directory:
  3391                              <1> 	; 01/02/2016 (TRDOS 386 =  TRDOS v2.0)
  3392                              <1> 	; 05/07/2011
  3393                              <1> 	; 23/08/2009
  3394                              <1> 	;
  3395                              <1> 	; INPUT ->
  3396                              <1> 	;	ESI = Logical DOS Drive Description Table
  3397                              <1> 	;	EAX = Cluster Number
  3398                              <1> 	; OUTPUT ->
  3399                              <1> 	;	cf = 1 -> Sub directory could not be loaded
  3400                              <1> 	;	    EAX > 0 -> Error number
  3401                              <1> 	;	cf = 0 -> EAX = 0
  3402                              <1> 	;	ECX = Directory buffer size in sectors (CL)
  3403                              <1> 	;	EBX = Directory buffer address
  3404                              <1> 	;
  3405                              <1> 	; 	NOTE: DirBuffer_Size is in bytes ! (word)
  3406                              <1> 	;
  3407                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
  3408                              <1> 
  3409 0000CF5C 8A1E                <1> 	mov	bl, [esi+LD_Name]
  3410 0000CF5E 8A7E03              <1> 	mov	bh, [esi+LD_FATType]
  3411                              <1> 
  3412                              <1> 	;mov	[DirBuff_DRV], bl
  3413                              <1> 	;mov	[DirBuff_FATType], bh
  3414 0000CF61 66891D[1A920100]    <1> 	mov	[DirBuff_DRV], bx
  3415                              <1> 
  3416                              <1> load_FAT_sub_dir0:
  3417 0000CF68 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
  3418                              <1> 
  3419 0000CF6C 882D[1C920100]      <1> 	mov	[DirBuff_ValidData], ch ; 0
  3420 0000CF72 A3[21920100]        <1> 	mov	[DirBuff_Cluster], eax
  3421                              <1> 
  3422 0000CF77 0FB74611            <1> 	movzx	eax, word [esi+LD_BPB+BytesPerSec]
  3423 0000CF7B F7E1                <1> 	mul	ecx
  3424 0000CF7D C1E805              <1> 	shr	eax, 5 ; directory entry count (dir size / 32)
  3425 0000CF80 6648                <1> 	dec	ax ; last entry
  3426 0000CF82 66A3[1F920100]      <1> 	mov	[DirBuff_LastEntry], ax
  3427                              <1> 
  3428 0000CF88 A1[21920100]        <1> 	mov	eax, [DirBuff_Cluster]
  3429 0000CF8D 83E802              <1> 	sub	eax, 2
  3430 0000CF90 F7E1                <1> 	mul	ecx
  3431 0000CF92 034668              <1> 	add	eax, [esi+LD_DATABegin]
  3432                              <1> 	; ecx = sector per cluster (dir buffer size = 32 sectors)
  3433 0000CF95 EB8E                <1> 	jmp	short read_directory
  3434                              <1> 
  3435                              <1> ; DRV_FS.ASM
  3436                              <1> 
  3437                              <1> load_current_FS_directory:
  3438 0000CF97 C3                  <1> 	retn
  3439                              <1> load_FS_root_directory:
  3440 0000CF98 C3                  <1> 	retn
  3441                              <1> load_FS_sub_directory:
  3442 0000CF99 C3                  <1> 	retn
  3443                              <1> 
  3444                              <1> read_cluster:
  3445                              <1> 	; 15/10/2016
  3446                              <1> 	; 18/03/2016
  3447                              <1> 	; 16/03/2016
  3448                              <1> 	; 17/02/2016
  3449                              <1> 	; 15/02/2016 (TRDOS 386 =  TRDOS v2.0)
  3450                              <1> 	;
  3451                              <1> 	; INPUT ->
  3452                              <1> 	;	EAX = Cluster Number (Sector index for SINGLIX FS)
  3453                              <1> 	;	ESI = Logical DOS Drive Description Table address
  3454                              <1> 	;	EBX = Cluster (File R/W) Buffer address (max. 64KB)
  3455                              <1> 	;	Only for SINGLIX FS:
  3456                              <1> 	;	EDX = File Number (The 1st FDT address) 
  3457                              <1> 	; OUTPUT ->
  3458                              <1> 	;	cf = 1 -> Cluster can not be loaded at the buffer
  3459                              <1> 	;	    EAX > 0 -> Error number
  3460                              <1> 	;	cf = 0 -> Cluster has been loaded at the buffer
  3461                              <1> 	;
  3462                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
  3463                              <1> 	
  3464 0000CF9A 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+BPB_SecPerClust] 
  3465                              <1> 	; CL = 1 = [esi+LD_FS_Reserved2] ; SectPerClust for Singlix FS
  3466                              <1> 
  3467                              <1> read_file_sectors: ; 16/03/2016
  3468 0000CF9E 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  3469 0000CFA2 761C                <1> 	jna	short read_fs_cluster
  3470                              <1> 
  3471                              <1> read_fat_file_sectors: ; 18/03/2016
  3472 0000CFA4 83E802              <1> 	sub	eax, 2 ; Beginning cluster number is always 2
  3473 0000CFA7 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+BPB_SecPerClust] ; 18/03/2016 
  3474 0000CFAB F7E2                <1> 	mul	edx
  3475 0000CFAD 034668              <1> 	add	eax, [esi+LD_DATABegin] ; absolute address of the cluster
  3476                              <1> 
  3477                              <1> 	; EAX = Disk sector address
  3478                              <1> 	; ECX = Sector count
  3479                              <1> 	; EBX = Buffer address
  3480                              <1> 	; (EDX = 0)
  3481                              <1> 	; ESI = Logical DOS drive description table address	
  3482                              <1> 
  3483 0000CFB0 E8085C0000          <1> 	call	disk_read
  3484 0000CFB5 7306                <1> 	jnc	short rclust_retn
  3485                              <1> 	
  3486                              <1> 	; 15/10/2016 (15h -> 17)
  3487 0000CFB7 B811000000          <1> 	mov	eax, 17 ; Drive not ready or read error !
  3488 0000CFBC C3                  <1> 	retn
  3489                              <1> 
  3490                              <1> rclust_retn:
  3491 0000CFBD 29C0                <1> 	sub	eax, eax ; 0
  3492 0000CFBF C3                  <1> 	retn
  3493                              <1> 
  3494                              <1> read_fs_cluster:
  3495                              <1> 	; 15/02/2016 (TRDOS 386 =  TRDOS v2.0)
  3496                              <1> 	; Singlix FS
  3497                              <1> 	
  3498                              <1> 	; EAX = Cluster number is sector index number of the file (eax)
  3499                              <1> 	
  3500                              <1> 	; EDX = File number is the first File Descriptor Table address 
  3501                              <1> 	;	of the file. (Absolute address of the FDT).
  3502                              <1> 	
  3503                              <1> 	; eax = sector index (0 for the first sector)
  3504                              <1> 	; edx = FDT0 address
  3505                              <1> 		; 64 KB buffer = 128 sectors (limit) 
  3506 0000CFC0 B980000000          <1> 	mov	ecx, 128 ; maximum count of sectors (before eof) 
  3507 0000CFC5 E801000000          <1> 	call	read_fs_sectors
  3508 0000CFCA C3                  <1> 	retn
  3509                              <1> 
  3510                              <1> read_fs_sectors:
  3511                              <1> 	; 15/02/2016 (TRDOS 386 =  TRDOS v2.0)
  3512 0000CFCB F9                  <1> 	stc
  3513 0000CFCC C3                  <1> 	retn
  3514                              <1> 
  3515                              <1> get_first_free_cluster:
  3516                              <1> 	; 02/03/2016
  3517                              <1> 	; 21/02/2016 (TRDOS 386 =  TRDOS v2.0)
  3518                              <1> 	; 26/10/2010 (DRV_FAT.ASM, 'proc_get_first_free_cluster')
  3519                              <1> 	; 10/07/2010
  3520                              <1> 	; INPUT ->
  3521                              <1> 	;	ESI = Logical DOS Drive Description Table address
  3522                              <1> 	; OUTPUT ->
  3523                              <1> 	;	cf = 1 -> Error code in AL (EAX)
  3524                              <1> 	;	cf = 0 -> 
  3525                              <1> 	;	  EAX = Cluster number 
  3526                              <1> 	;	  If EAX = FFFFFFFFh -> no free space
  3527                              <1> 	;	If the drive has FAT32 fs:
  3528                              <1> 	;	  EBX = FAT32 FSI sector buffer address (if > 0)
  3529                              <1> 
  3530 0000CFCD 8B4678              <1> 	mov	eax, [esi+LD_Clusters]
  3531 0000CFD0 40                  <1> 	inc	eax ; add eax, 1
  3532 0000CFD1 A3[A4940100]        <1> 	mov	[gffc_last_free_cluster], eax
  3533                              <1> 
  3534 0000CFD6 31DB                <1> 	xor	ebx, ebx ; 0 ; 02/03/2016
  3535                              <1> 
  3536 0000CFD8 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
  3537 0000CFDC 760E                <1> 	jna	short loc_gffc_get_first_fat_free_cluster0
  3538                              <1> 
  3539                              <1> loc_gffc_get_first_fat32_free_cluster:
  3540                              <1> 	; 02/03/2016
  3541 0000CFDE E844060000          <1> 	call	get_fat32_fsinfo_sector_parms
  3542 0000CFE3 7207                <1> 	jc	short loc_gffc_get_first_fat_free_cluster0 
  3543                              <1> 
  3544                              <1> loc_gffc_check_fsinfo_parms:
  3545                              <1> 	;;mov	ebx, DOSBootSectorBuff
  3546                              <1> 	;cmp	dword [ebx], 41615252h
  3547                              <1> 	;jne	short loc_gffc_fat32_fsinfo_err
  3548                              <1> 	;cmp	dword [ebx+484], 61417272h
  3549                              <1> 	;jne	short loc_gffc_fat32_fsinfo_err
  3550                              <1> 	;mov	eax, [ebx+492] ; FSI_Next_Free
  3551                              <1> 	;EAX = First free cluster 
  3552                              <1> 	;(from FAT32 FSInfo sector)
  3553 0000CFE5 89D0                <1> 	mov	eax, edx ; FSI_Next_Free (First Free Cluster)
  3554 0000CFE7 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh ; invalid (unknown) !
  3555 0000CFEA 7205                <1> 	jb	short loc_gffc_get_first_fat_free_cluster1
  3556                              <1> 
  3557                              <1> 	; Start from the 1st cluster of the FAT(32) file system
  3558                              <1> loc_gffc_get_first_fat_free_cluster0:
  3559 0000CFEC B802000000          <1> 	mov	eax, 2
  3560                              <1> 	;xor	edx, edx
  3561                              <1> 
  3562                              <1> loc_gffc_get_first_fat_free_cluster1:
  3563 0000CFF1 53                  <1> 	push	ebx ; 02/03/2016 
  3564                              <1> 
  3565                              <1> loc_gffc_get_first_fat_free_cluster2:   
  3566 0000CFF2 A3[A0940100]        <1> 	mov	[gffc_first_free_cluster], eax
  3567 0000CFF7 A3[9C940100]        <1> 	mov	[gffc_next_free_cluster], eax
  3568                              <1> 
  3569                              <1> 	; EBX = FAT32 FSINFO sector buffer address
  3570                              <1> 	; (EBX = 0, if the drive has not got FAT32 fs or
  3571                              <1> 	; FAT32 FSINFO sector buffer is invalid.)
  3572                              <1> 
  3573                              <1> loc_gffc_get_first_fat_free_cluster3:
  3574 0000CFFC E875FDFFFF          <1> 	call	get_next_cluster
  3575 0000D001 7307                <1> 	jnc	short loc_gffc_get_first_fat_free_cluster4
  3576 0000D003 09C0                <1> 	or	eax, eax
  3577 0000D005 740B                <1> 	jz	short loc_gffc_first_free_fat_cluster_next
  3578 0000D007 5B                  <1> 	pop	ebx ; 02/03/2016
  3579 0000D008 F5                  <1> 	cmc 	; stc
  3580 0000D009 C3                  <1> 	retn
  3581                              <1> 
  3582                              <1> loc_gffc_get_first_fat_free_cluster4:
  3583 0000D00A 21C0                <1> 	and	eax, eax ; next cluster value
  3584 0000D00C 7504                <1> 	jnz	short loc_gffc_first_free_fat_cluster_next
  3585 0000D00E 89C8                <1> 	mov	eax, ecx ; current (previous cluster) value
  3586 0000D010 EB22                <1> 	jmp	short loc_gffc_check_for_set
  3587                              <1>  
  3588                              <1> loc_gffc_first_free_fat_cluster_next:
  3589 0000D012 A1[9C940100]        <1> 	mov	eax, [gffc_next_free_cluster]
  3590 0000D017 3B05[A4940100]      <1> 	cmp	eax, [gffc_last_free_cluster]
  3591 0000D01D 7308                <1> 	jnb	short retn_stc_from_get_first_free_cluster
  3592                              <1> pass_gffc_last_cluster_eax_check:
  3593 0000D01F 40                  <1> 	inc	eax ; add eax, 1
  3594 0000D020 A3[9C940100]        <1> 	mov	[gffc_next_free_cluster], eax
  3595 0000D025 EBD5                <1> 	jmp	short loc_gffc_get_first_fat_free_cluster3
  3596                              <1> 
  3597                              <1> retn_stc_from_get_first_free_cluster:
  3598 0000D027 A1[A0940100]        <1> 	mov	eax, [gffc_first_free_cluster]
  3599 0000D02C 83F802              <1> 	cmp	eax, 2
  3600 0000D02F 7709                <1> 	ja	short loc_gffc_check_previous_clusters
  3601 0000D031 29C0                <1> 	sub	eax, eax
  3602 0000D033 48                  <1> 	dec	eax ; FFFFFFFFh
  3603                              <1> 
  3604                              <1> loc_gffc_check_for_set:
  3605                              <1> 	; 02/03/2016
  3606 0000D034 5B                  <1> 	pop	ebx
  3607                              <1> 
  3608                              <1> 	; EBX = FAT32 FSINFO sector buffer address
  3609                              <1> 	; (EBX = 0, if the drive has not got FAT32 fs or
  3610                              <1> 	; FAT32 FSINFO sector buffer is invalid.)
  3611                              <1> 
  3612 0000D035 09DB                <1> 	or	ebx, ebx
  3613 0000D037 750E                <1> 	jnz	short loc_gffc_set_ffree_fat32_cluster
  3614                              <1> 
  3615                              <1> 	;cmp	byte [esi+LD_FATType], 3
  3616                              <1> 	;jnb	short loc_gffc_set_ffree_fat32_cluster
  3617                              <1> 
  3618                              <1> 	;xor	ebx, ebx ; 0
  3619                              <1> 
  3620                              <1> loc_gffc_retn:
  3621 0000D039 C3                  <1> 	retn
  3622                              <1> 
  3623                              <1> loc_gffc_check_previous_clusters:
  3624 0000D03A 48                  <1> 	dec	eax ; sub eax, 1
  3625 0000D03B A3[A4940100]        <1> 	mov	[gffc_last_free_cluster], eax 
  3626 0000D040 B802000000          <1> 	mov	eax, 2
  3627                              <1> 	;xor	edx, edx
  3628 0000D045 EBAB                <1> 	jmp	short loc_gffc_get_first_fat_free_cluster2
  3629                              <1> 
  3630                              <1> loc_gffc_set_ffree_fat32_cluster:
  3631                              <1> 	;call	set_first_free_cluster
  3632                              <1> 	;retn
  3633                              <1> 	;jmp	short set_first_free_cluster	
  3634                              <1> 
  3635                              <1> set_first_free_cluster:
  3636                              <1> 	; 15/10/2016
  3637                              <1> 	; 23/03/2016
  3638                              <1> 	; 02/03/2016
  3639                              <1> 	; 29/02/2016
  3640                              <1> 	; 26/02/2016
  3641                              <1> 	; 21/02/2016 (TRDOS 386 =  TRDOS v2.0)
  3642                              <1> 	; 21/08/2011 (DRV_FAT.ASM, 'proc_set_first_free_cluster')
  3643                              <1> 	; 11/07/2010
  3644                              <1> 	; INPUT -> 
  3645                              <1> 	;	ESI = Logical DOS Drive Description Table address
  3646                              <1> 	;	EAX = First free cluster
  3647                              <1> 	;	EBX = FSINFO sector buffer address
  3648                              <1> 	;  	;;If EBX > 0, it is FSINFO sector buffer address
  3649                              <1> 	;	;;EBX = 0, if FSINFO sector is not loaded
  3650                              <1> 	; OUTPUT->
  3651                              <1> 	;	ESI = Logical DOS Drive Description Table address
  3652                              <1> 	;  	If EBX > 0, it is FSINFO sector buffer address
  3653                              <1> 	;	EBX = 0, if FSINFO sector could not be loaded
  3654                              <1> 	; 	CF = 1 -> Error code in AL (EAX)
  3655                              <1> 	;	CF = 0 -> first free cluster is successfully updated 
  3656                              <1> 
  3657                              <1> 	;cmp	byte [esi+LD_FATType], 3
  3658                              <1> 	;jb	short loc_sffc_invalid_drive
  3659                              <1> 
  3660                              <1> 	; Save First Free Cluster value for 'update_cluster'
  3661 0000D047 89463E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], eax ; First free Cluster	
  3662                              <1> 
  3663                              <1> 	;or	ebx, ebx
  3664                              <1> 	;jnz	short loc_sffc_read_fsinfo_sector
  3665                              <1> 
  3666 0000D04A 813B52526141        <1> 	cmp     dword [ebx], 41615252h
  3667 0000D050 7540                <1> 	jne	short loc_sffc_read_fsinfo_sector
  3668 0000D052 81BBE4010000727241- <1> 	cmp	dword [ebx+484], 61417272h
  3668 0000D05B 61                  <1>
  3669 0000D05C 7534                <1> 	jne	short loc_sffc_read_fsinfo_sector
  3670                              <1> 
  3671 0000D05E 3B83EC010000        <1> 	cmp	eax, [ebx+492]  ; FSI_Next_Free
  3672 0000D064 741F                <1> 	je	short loc_sffc_retn
  3673                              <1> 
  3674                              <1> loc_sffc_write_fsinfo_sector:
  3675                              <1> 	; EBX = FSINFO sector buffer
  3676                              <1> 	; [CFS_FAT32FSINFOSEC] is set in 'get_fat32_fsinfo_sector_parms'
  3677 0000D066 8983EC010000        <1> 	mov	[ebx+492], eax
  3678 0000D06C A1[B4940100]        <1> 	mov	eax, [CFS_FAT32FSINFOSEC] 
  3679 0000D071 B901000000          <1> 	mov	ecx, 1
  3680 0000D076 53                  <1> 	push	ebx
  3681 0000D077 E8325B0000          <1> 	call	disk_write
  3682 0000D07C 7208                <1> 	jc      short loc_sffc_read_fsinfo_sector_err1
  3683 0000D07E 5B                  <1> 	pop	ebx
  3684                              <1> 
  3685 0000D07F 8B83EC010000        <1> 	mov	eax, [ebx+492] ; First (Next) Free Cluster
  3686                              <1> 
  3687                              <1> loc_sffc_retn:
  3688 0000D085 C3                  <1> 	retn
  3689                              <1> 
  3690                              <1> ;loc_sffc_invalid_drive:
  3691                              <1> ;	mov	eax, 0Fh ; MSDOS Error : Invalid drive
  3692                              <1> ;	push	edx
  3693                              <1> 
  3694                              <1> loc_sffc_read_fsinfo_sector_err1:
  3695 0000D086 BB00000000          <1> 	mov	ebx, 0
  3696                              <1> 	; 15/10/2016 (1Dh -> 18)
  3697                              <1> 	; 23/03/2016 (1Dh)
  3698 0000D08B B812000000          <1> 	mov	eax, 18 ; Drive not ready or write error
  3699                              <1> 
  3700                              <1> loc_sffc_read_fsinfo_sector_err2:
  3701 0000D090 5A                  <1> 	pop	edx
  3702 0000D091 C3                  <1> 	retn
  3703                              <1> 	
  3704                              <1> loc_sffc_read_fsinfo_sector:
  3705 0000D092 50                  <1> 	push	eax
  3706                              <1> 
  3707 0000D093 E88F050000          <1> 	call	get_fat32_fsinfo_sector_parms
  3708 0000D098 72F6                <1> 	jc	short loc_sffc_read_fsinfo_sector_err2
  3709                              <1> 
  3710 0000D09A 58                  <1> 	pop	eax
  3711                              <1> 	; EDX = First (Next) Free Cluster value from FSINFO sector
  3712                              <1> 	; EAX = First Free Cluster value from 'get_next_cluster'
  3713                              <1> 	; (edx = old value)
  3714 0000D09B 39D0                <1> 	cmp	eax, edx ; First free Cluster (eax = new value) 
  3715 0000D09D 75C7                <1> 	jne	short loc_sffc_write_fsinfo_sector
  3716                              <1> 
  3717 0000D09F C3                  <1> 	retn	
  3718                              <1> 
  3719                              <1> update_cluster:
  3720                              <1> 	; 23/10/2016
  3721                              <1> 	; 23/03/2016
  3722                              <1> 	; 02/03/2016
  3723                              <1> 	; 01/03/2016
  3724                              <1> 	; 29/02/2016
  3725                              <1> 	; 27/02/2016
  3726                              <1> 	; 26/02/2016
  3727                              <1> 	; 22/02/2016 (TRDOS 386 =  TRDOS v2.0)
  3728                              <1> 	; 11/08/2011  
  3729                              <1> 	; 09/02/2005
  3730                              <1> 	; INPUT ->
  3731                              <1> 	;	EAX = Cluster Number
  3732                              <1> 	;	ECX = New Cluster Value
  3733                              <1> 	;	ESI = Logical Dos Drive Parameters Table
  3734                              <1> 	;
  3735                              <1> 	;	/// dword [FAT_ClusterCounter] ///
  3736                              <1> 	;
  3737                              <1> 	; OUTPUT ->
  3738                              <1> 	;	cf = 0 -> No Error, EAX is valid
  3739                              <1> 	;	cf = 1 & EAX = 0 -> End Of Cluster Chain
  3740                              <1> 	; 	cf = 1 & EAX > 0 -> Error
  3741                              <1> 	;		(ECX -> any value)
  3742                              <1> 	; 	EAX = Next Cluster
  3743                              <1> 	;	ECX = New Cluster Value
  3744                              <1> 	;
  3745                              <1> 	;	/// [FAT_ClusterCounter] is updated,
  3746                              <1> 	;	/// decreased when a free cluster is assigned,
  3747                              <1> 	;	/// increased if an assigned cluster is freed.	
  3748                              <1> 	;		
  3749                              <1> 	;
  3750                              <1> 	; (Modified registers: EAX, EBX, -ECX-, EDX)
  3751                              <1> 	
  3752 0000D0A0 A3[06920100]        <1> 	mov	[FAT_CurrentCluster], eax
  3753 0000D0A5 890D[A8940100]      <1> 	mov	[ClusterValue], ecx
  3754                              <1> 
  3755                              <1> loc_update_cluster_check_fat_buffer:
  3756 0000D0AB 8A1E                <1> 	mov	bl, [esi+LD_Name]
  3757 0000D0AD 381D[0B920100]      <1> 	cmp	[FAT_BuffDrvName], bl
  3758 0000D0B3 741A                <1> 	je	short loc_update_cluster_check_fat_type
  3759 0000D0B5 803D[0A920100]02    <1> 	cmp	byte [FAT_BuffValidData], 2
  3760 0000D0BC 0F84C2000000        <1>         je      loc_uc_save_fat_buffer
  3761                              <1> 
  3762                              <1> loc_uc_reset_fat_buffer_validation:
  3763 0000D0C2 C605[0A920100]00    <1> 	mov	byte [FAT_BuffValidData], 0
  3764                              <1> 
  3765                              <1> loc_uc_check_fat_type_reset_drvname:
  3766 0000D0C9 881D[0B920100]      <1> 	mov	[FAT_BuffDrvName], bl
  3767                              <1> 
  3768                              <1> loc_update_cluster_check_fat_type:
  3769 0000D0CF 29D2                <1> 	sub	edx, edx ; 26/02/2016
  3770 0000D0D1 8A5E03              <1> 	mov	bl, [esi+LD_FATType]
  3771 0000D0D4 83F802              <1> 	cmp	eax, 2
  3772 0000D0D7 0F82BE000000        <1>         jb      update_cluster_inv_data
  3773 0000D0DD 80FB02              <1> 	cmp	bl, 2 
  3774 0000D0E0 0F877A010000        <1>         ja      update_fat32_cluster
  3775                              <1> 	;cmp	bl, 1
  3776                              <1> 	;jb	short update_cluster_inv_data
  3777 0000D0E6 8B4E78              <1> 	mov	ecx, [esi+LD_Clusters]
  3778 0000D0E9 41                  <1> 	inc	ecx  
  3779 0000D0EA 890D[16920100]      <1> 	mov	[LastCluster], ecx
  3780 0000D0F0 39C8                <1> 	cmp	eax, ecx ; dword [LastCluster]
  3781 0000D0F2 0F87A6000000        <1>         ja      return_uc_fat_stc
  3782                              <1> 	; TRDOS v1 has a FATal bug here ! 
  3783                              <1> 		; or bl, bl ; cmp bl, 0
  3784                              <1> 		; jz short update_fat12_cluster
  3785                              <1> 	; !! It would destroy FAT12 floppy disk fs here !!
  3786                              <1> 	; ('A:' disks of TRDOS v1 operating system project
  3787                              <1> 	; had 'singlix fs', so, I could not differ this mistake
  3788                              <1> 	; on a drive 'A:')
  3789 0000D0F8 80FB01              <1> 	cmp	bl, 1 ; correct comparison is this !
  3790 0000D0FB 0F86A2000000        <1>         jna     update_fat12_cluster 
  3791                              <1> 
  3792                              <1> update_fat16_cluster:
  3793                              <1> pass_uc_fat16_errc:
  3794                              <1> 	;sub	edx, edx
  3795 0000D101 BB00030000          <1> 	mov	ebx, 300h ;768
  3796 0000D106 F7F3                <1> 	div	ebx
  3797                              <1> 	; EAX = Count of 3 FAT sectors
  3798                              <1> 	; DX = Cluster offset in FAT buffer
  3799 0000D108 6689D3              <1> 	mov	bx, dx  
  3800 0000D10B 66D1E3              <1> 	shl	bx, 1 ; Multiply by 2
  3801 0000D10E 66BA0300            <1> 	mov	dx, 3
  3802 0000D112 F7E2                <1> 	mul	edx  
  3803                              <1> 	; EAX = FAT Sector
  3804                              <1> 	; EDX = 0
  3805                              <1> 	; EBX = Byte offset in FAT buffer
  3806 0000D114 8A0D[0A920100]      <1> 	mov	cl, [FAT_BuffValidData]
  3807 0000D11A 80F902              <1> 	cmp	cl, 2
  3808 0000D11D 750A                <1> 	jne	short loc_uc_check_fat16_buff_sector_load
  3809                              <1> 
  3810                              <1> loc_uc_check_fat16_buff_sector_save:
  3811 0000D11F 3B05[0E920100]      <1> 	cmp	eax, [FAT_BuffSector]
  3812 0000D125 755D                <1> 	jne	short loc_uc_save_fat_buffer
  3813 0000D127 EB15                <1> 	jmp	short loc_update_fat16_cell
  3814                              <1> 
  3815                              <1> loc_uc_check_fat16_buff_sector_load:
  3816 0000D129 80F901              <1> 	cmp	cl, 1 ; byte [FAT_BuffValidData]
  3817 0000D12C 0F85FB010000        <1>         jne     loc_uc_load_fat_sectors
  3818 0000D132 3B05[0E920100]      <1> 	cmp	eax, [FAT_BuffSector]
  3819 0000D138 0F85EF010000        <1>         jne     loc_uc_load_fat_sectors
  3820                              <1> 
  3821                              <1> loc_update_fat16_cell:
  3822                              <1> loc_update_fat16_buffer:
  3823 0000D13E 81C3001C0900        <1> 	add	ebx, FAT_Buffer ; 26/02/2016
  3824                              <1> 	;movzx	eax, word [ebx]
  3825 0000D144 668B03              <1> 	mov	ax, [ebx]
  3826                              <1> 	; 01/03/2016
  3827 0000D147 89C2                <1> 	mov	edx, eax ; old value of the cluster
  3828 0000D149 A3[06920100]        <1> 	mov	[FAT_CurrentCluster], eax
  3829 0000D14E 8B0D[A8940100]      <1> 	mov	ecx, [ClusterValue] ; 32 bits
  3830 0000D154 66890B              <1> 	mov	[ebx], cx ; 16 bits !
  3831                              <1> 
  3832 0000D157 C605[0A920100]02    <1> 	mov	byte [FAT_BuffValidData], 2
  3833                              <1> 	
  3834 0000D15E 6683F802            <1> 	cmp	ax, 2
  3835 0000D162 723A                <1> 	jb	short return_uc_fat_stc
  3836 0000D164 3B05[16920100]      <1> 	cmp	eax, [LastCluster]
  3837 0000D16A 7732                <1> 	ja	short return_uc_fat_stc
  3838                              <1> 
  3839                              <1> loc_fat_buffer_updated:
  3840                              <1> 	; 01/03/2016
  3841 0000D16C F8                  <1> 	clc
  3842                              <1> loc_fat_buffer_stc_1:
  3843 0000D16D 9C                  <1> 	pushf
  3844 0000D16E 21C9                <1> 	and	ecx, ecx
  3845 0000D170 7506                <1> 	jnz	short loc_fat_buffer_updated_1
  3846                              <1> 
  3847                              <1> 	; 01/03/2016 
  3848                              <1> 	; new value of the cluster = 0 (free)
  3849                              <1> 	; increase free(d) cluster count
  3850 0000D172 FF05[12920100]      <1> 	inc	dword [FAT_ClusterCounter]
  3851                              <1> 
  3852                              <1> loc_fat_buffer_updated_1: ; new value of the cluster > 0
  3853 0000D178 09D2                <1> 	or	edx, edx ; 02/03/2016
  3854 0000D17A 7506                <1> 	jnz	short loc_fat_buffer_updated_2
  3855                              <1> 	; old value of the cluster = 0 (it was free cluster)
  3856                              <1> 	; decrease free(d) cluster count
  3857 0000D17C FF0D[12920100]      <1> 	dec	dword [FAT_ClusterCounter] ; it may be negative number
  3858                              <1> 
  3859                              <1> loc_fat_buffer_updated_2:
  3860 0000D182 9D                  <1> 	popf
  3861 0000D183 C3                  <1> 	retn
  3862                              <1> 
  3863                              <1> loc_uc_save_fat_buffer:
  3864                              <1> 	; byte [FAT_BuffValidData] = 2 
  3865 0000D184 E8D4010000          <1> 	call	save_fat_buffer
  3866 0000D189 0F8297010000        <1>         jc      loc_fat_sectors_rw_error2
  3867                              <1> 	;mov	byte [FAT_BuffValidData], 1
  3868 0000D18F A1[06920100]        <1> 	mov	eax, [FAT_CurrentCluster]
  3869                              <1> 	;mov	ecx, [ClusterValue]
  3870                              <1> 	;jmp	short loc_update_cluster_check_fat_buffer
  3871 0000D194 8A1E                <1> 	mov	bl, [esi+LD_Name] ; 01/03/2016
  3872 0000D196 E927FFFFFF          <1>         jmp     loc_uc_reset_fat_buffer_validation
  3873                              <1> 
  3874                              <1> update_cluster_inv_data:
  3875                              <1> 	;mov	eax, 0Dh
  3876 0000D19B B00D                <1> 	mov	al, 0Dh  ; Invalid Data
  3877 0000D19D C3                  <1> 	retn 
  3878                              <1> 
  3879                              <1> return_uc_fat_stc:
  3880                              <1> 	; 01/03/2016
  3881 0000D19E 31C0                <1> 	xor	eax, eax
  3882 0000D1A0 F9                  <1> 	stc
  3883 0000D1A1 EBCA                <1> 	jmp	short loc_fat_buffer_stc_1
  3884                              <1> 
  3885                              <1> update_fat12_cluster:
  3886                              <1> pass_uc_fat12_errc:
  3887                              <1> 	;sub	edx, edx
  3888 0000D1A3 BB00040000          <1> 	mov	ebx, 400h ;1024
  3889 0000D1A8 F7F3                <1> 	div	ebx
  3890                              <1> 	; EAX = Count of 3 FAT sectors
  3891                              <1> 	; DX = Cluster offset in FAT buffer
  3892 0000D1AA 66B90300            <1> 	mov	cx, 3
  3893 0000D1AE 6689C3              <1> 	mov	bx, ax
  3894 0000D1B1 6689C8              <1> 	mov	ax, cx ; 3
  3895 0000D1B4 66F7E2              <1> 	mul	dx     ; Multiply by 3
  3896 0000D1B7 66D1E8              <1> 	shr	ax, 1  ; Divide by 2
  3897 0000D1BA 6693                <1> 	xchg	bx, ax
  3898                              <1> 	; EAX = Count of 3 FAT sectors
  3899                              <1> 	; EBX = Byte Offset in FAT buffer   
  3900 0000D1BC 66F7E1              <1> 	mul	cx  ; 3 * AX
  3901                              <1> 	; EAX = FAT Beginning Sector
  3902                              <1> 	; EDX = 0
  3903 0000D1BF 8A0D[0A920100]      <1> 	mov	cl, [FAT_BuffValidData]
  3904                              <1> 	; TRDOS v1 has a FATal bug here ! 
  3905                              <1> 	; (it does not have 'cmp cl, 2' instruction here !
  3906                              <1> 	;  while 'jne' is existing !)
  3907 0000D1C5 80F902              <1> 	cmp	cl, 2 ; 2 = dirty buffer (must be written to disk)
  3908 0000D1C8 750A                <1> 	jne	short loc_uc_check_fat12_buff_sector_load
  3909                              <1> 
  3910                              <1> loc_uc_check_fat12_buff_sector_save:
  3911 0000D1CA 3B05[0E920100]      <1> 	cmp	eax, [FAT_BuffSector]
  3912 0000D1D0 75B2                <1>         jne     short loc_uc_save_fat_buffer
  3913 0000D1D2 EB15                <1> 	jmp	short loc_update_fat12_cell
  3914                              <1> 
  3915                              <1> loc_uc_check_fat12_buff_sector_load:
  3916 0000D1D4 80F901              <1> 	cmp	cl, 1 ; byte ptr [FAT_BuffValidData]
  3917 0000D1D7 0F8550010000        <1>         jne     loc_uc_load_fat_sectors
  3918 0000D1DD 3B05[0E920100]      <1> 	cmp	eax, [FAT_BuffSector]
  3919 0000D1E3 0F8544010000        <1>         jne     loc_uc_load_fat_sectors
  3920                              <1> 
  3921                              <1> loc_update_fat12_cell:
  3922 0000D1E9 81C3001C0900        <1> 	add	ebx, FAT_Buffer ; 26/02/2016
  3923 0000D1EF 668B0D[06920100]    <1> 	mov	cx, [FAT_CurrentCluster]
  3924 0000D1F6 66D1E9              <1> 	shr	cx, 1
  3925 0000D1F9 668B03              <1> 	mov	ax, [ebx]
  3926 0000D1FC 6689C2              <1> 	mov	dx, ax
  3927 0000D1FF 7344                <1> 	jnc	short uc_fat12_nc_even
  3928                              <1> 
  3929 0000D201 6683E00F            <1> 	and	ax, 0Fh
  3930 0000D205 8B0D[A8940100]      <1> 	mov	ecx, [ClusterValue] ; 32 bits
  3931 0000D20B 66C1E104            <1> 	shl	cx, 4
  3932 0000D20F 6609C1              <1> 	or	cx, ax
  3933 0000D212 6689D0              <1> 	mov	ax, dx
  3934 0000D215 66890B              <1> 	mov	[ebx], cx  ; 16 bits !
  3935 0000D218 66C1E804            <1> 	shr	ax, 4 ; al(bit4..7)+ah(bit0..7)
  3936                              <1> 
  3937                              <1> update_fat12_buffer:
  3938 0000D21C A3[06920100]        <1> 	mov	[FAT_CurrentCluster], eax
  3939 0000D221 89C2                <1> 	mov	edx, eax ; 01/03/2016
  3940 0000D223 C605[0A920100]02    <1> 	mov	byte [FAT_BuffValidData], 2
  3941 0000D22A 6683F802            <1> 	cmp	ax, 2
  3942 0000D22E 0F826AFFFFFF        <1>         jb      return_uc_fat_stc
  3943 0000D234 3B05[16920100]      <1> 	cmp	eax, [LastCluster]
  3944 0000D23A 0F875EFFFFFF        <1>         ja      return_uc_fat_stc
  3945 0000D240 E927FFFFFF          <1>         jmp     loc_fat_buffer_updated
  3946                              <1> 
  3947                              <1> uc_fat12_nc_even:
  3948 0000D245 662500F0            <1> 	and	ax, 0F000h
  3949 0000D249 8B0D[A8940100]      <1> 	mov	ecx, [ClusterValue] ; 32 bits
  3950 0000D24F 80E50F              <1> 	and	ch, 0Fh
  3951 0000D252 6609C1              <1> 	or	cx, ax
  3952 0000D255 6689D0              <1> 	mov	ax, dx
  3953 0000D258 66890B              <1> 	mov	[ebx], cx ; 16 bits !
  3954 0000D25B 80E40F              <1> 	and	ah, 0Fh ; al(bit0..7)+ah(bit0..3)
  3955 0000D25E EBBC                <1> 	jmp	short update_fat12_buffer
  3956                              <1> 
  3957                              <1> update_fat32_cluster:
  3958 0000D260 8B4E78              <1> 	mov	ecx, [esi+LD_Clusters]
  3959 0000D263 41                  <1> 	inc	ecx
  3960 0000D264 890D[16920100]      <1> 	mov	[LastCluster], ecx
  3961                              <1> 
  3962 0000D26A 39C8                <1> 	cmp	eax, ecx
  3963 0000D26C 0F872CFFFFFF        <1>         ja      return_uc_fat_stc
  3964                              <1> 
  3965                              <1> pass_uc_fat32_errc:
  3966                              <1> 	;sub	edx, edx
  3967 0000D272 BB80010000          <1> 	mov	ebx, 180h ;384
  3968 0000D277 F7F3                <1> 	div	ebx
  3969                              <1> 	; EAX = Count of 3 FAT sectors
  3970                              <1> 	; DX = Cluster offset in FAT buffer
  3971 0000D279 89D3                <1> 	mov	ebx, edx
  3972 0000D27B C1E302              <1> 	shl	ebx, 2 ; Multiply by 4
  3973 0000D27E BA03000000          <1> 	mov	edx, 3	
  3974 0000D283 F7E2                <1> 	mul	edx
  3975                              <1> 	; EBX = Cluster Offset in FAT buffer
  3976                              <1> 	; EAX = FAT Sector
  3977                              <1> 	; EDX = 0
  3978 0000D285 8A0D[0A920100]      <1> 	mov	cl, [FAT_BuffValidData]
  3979 0000D28B 80F902              <1> 	cmp	cl, 2
  3980 0000D28E 750E                <1> 	jne	short loc_uc_check_fat32_buff_sector_load
  3981                              <1> 
  3982                              <1> loc_uc_check_fat32_buff_sector_save:
  3983 0000D290 3B05[0E920100]      <1> 	cmp	eax, [FAT_BuffSector]
  3984 0000D296 0F85E8FEFFFF        <1>         jne     loc_uc_save_fat_buffer
  3985 0000D29C EB11                <1> 	jmp	short loc_update_fat32_cell
  3986                              <1> 
  3987                              <1> loc_uc_check_fat32_buff_sector_load:
  3988 0000D29E 80F901              <1> 	cmp	cl, 1 ; byte [FAT_BuffValidData]
  3989 0000D2A1 0F8586000000        <1>         jne     loc_uc_load_fat_sectors
  3990 0000D2A7 3B05[0E920100]      <1> 	cmp	eax, [FAT_BuffSector]
  3991 0000D2AD 757E                <1>         jne     loc_uc_load_fat_sectors
  3992                              <1> 
  3993                              <1> loc_update_fat32_cell:
  3994                              <1> loc_update_fat32_buffer:
  3995 0000D2AF 81C3001C0900        <1> 	add	ebx, FAT_Buffer ; 26/02/2016
  3996 0000D2B5 8B03                <1> 	mov	eax, [ebx]
  3997 0000D2B7 25FFFFFF0F          <1> 	and	eax, 0FFFFFFFh ; 28 bit cluster value
  3998                              <1> 	
  3999 0000D2BC 8B15[06920100]      <1> 	mov	edx, [FAT_CurrentCluster] ; 01/03/2016
  4000                              <1> 
  4001 0000D2C2 A3[06920100]        <1> 	mov 	[FAT_CurrentCluster], eax
  4002 0000D2C7 8B0D[A8940100]      <1> 	mov	ecx, [ClusterValue]
  4003 0000D2CD 890B                <1> 	mov	[ebx], ecx ; 29/02/2016 
  4004                              <1> 
  4005 0000D2CF C605[0A920100]02    <1> 	mov	byte [FAT_BuffValidData], 2
  4006                              <1> 
  4007                              <1> 	; 01/03/2016
  4008 0000D2D6 21C0                <1> 	and	eax, eax ; was it free cluster ?
  4009 0000D2D8 7514                <1> 	jnz	short loc_upd_fat32_c0
  4010                              <1> 
  4011                              <1> 	;or	ecx, ecx ; it will be left free ?!
  4012                              <1> 	;jz	short loc_upd_fat32_c3
  4013                              <1> 
  4014 0000D2DA 3B563E              <1> 	cmp	edx, [esi+LD_BPB+BPB_Reserved+4] ; First free cluster
  4015 0000D2DD 7520                <1> 	jne	short loc_upd_fat32_c3
  4016                              <1> 
  4017 0000D2DF 3B15[16920100]      <1> 	cmp	edx, [LastCluster]
  4018 0000D2E5 7207                <1> 	jb	short loc_upd_fat32_c0
  4019                              <1> 
  4020 0000D2E7 BA02000000          <1> 	mov	edx, 2 ; rewind !
  4021 0000D2EC EB0E                <1> 	jmp	short loc_upd_fat32_c2
  4022                              <1> 
  4023                              <1> loc_upd_fat32_c0:
  4024 0000D2EE FF463E              <1> 	inc	dword [esi+LD_BPB+BPB_Reserved+4] ; set it to next cluster		
  4025 0000D2F1 EB0C                <1> 	jmp	short loc_upd_fat32_c3
  4026                              <1> 
  4027                              <1> loc_upd_fat32_c1:
  4028 0000D2F3 09C9                <1> 	or	ecx, ecx ; will it be free cluster ?
  4029 0000D2F5 7508                <1> 	jnz	short loc_upd_fat32_c3
  4030                              <1> 
  4031 0000D2F7 3B563E              <1> 	cmp	edx, [esi+LD_BPB+BPB_Reserved+4] ; First free cluster
  4032 0000D2FA 7303                <1> 	jnb	short loc_upd_fat32_c3
  4033                              <1> 
  4034                              <1> loc_upd_fat32_c2:	
  4035 0000D2FC 89563E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], edx			
  4036                              <1> 
  4037                              <1> loc_upd_fat32_c3:
  4038 0000D2FF 89C2                <1> 	mov	edx, eax
  4039                              <1> 
  4040                              <1> loc_upd_fat32_c4:
  4041 0000D301 83F802              <1> 	cmp	eax, 2
  4042 0000D304 0F8294FEFFFF        <1>         jb      return_uc_fat_stc
  4043                              <1> 
  4044                              <1> pass_uc_fat32_c_zero_check_2:
  4045 0000D30A 3B05[16920100]      <1> 	cmp	eax, [LastCluster]
  4046 0000D310 0F8788FEFFFF        <1>         ja      return_uc_fat_stc
  4047                              <1> 	
  4048 0000D316 E951FEFFFF          <1> 	jmp     loc_fat_buffer_updated
  4049                              <1> 
  4050                              <1> loc_fat_sectors_rw_error1:
  4051                              <1> 	;mov	byte [FAT_BuffValidData], 0
  4052                              <1> 	; 23/10/2016 (15h -> 17)
  4053                              <1> 	; 23/03/2016
  4054 0000D31B B811000000          <1> 	mov	eax, 17 ; Drive not ready or read error
  4055 0000D320 8825[0A920100]      <1> 	mov	[FAT_BuffValidData], ah ; 0
  4056                              <1> 
  4057                              <1> loc_fat_sectors_rw_error2:
  4058                              <1> 	;mov	eax, error code
  4059                              <1> 	;mov	edx, 0
  4060 0000D326 8B0D[A8940100]      <1> 	mov	ecx, [ClusterValue]
  4061 0000D32C C3                  <1> 	retn
  4062                              <1> 
  4063                              <1> loc_uc_load_fat_sectors:
  4064 0000D32D A3[0E920100]        <1> 	mov	[FAT_BuffSector], eax
  4065                              <1> 
  4066                              <1> load_uc_fat_sectors_zero:
  4067 0000D332 034660              <1> 	add	eax, [esi+LD_FATBegin]
  4068 0000D335 BB001C0900          <1> 	mov	ebx, FAT_Buffer
  4069 0000D33A B903000000          <1> 	mov	ecx, 3
  4070 0000D33F E879580000          <1> 	call	disk_read
  4071 0000D344 72D5                <1> 	jc	short loc_fat_sectors_rw_error1
  4072                              <1> 
  4073 0000D346 C605[0A920100]01    <1>         mov     byte [FAT_BuffValidData], 1
  4074 0000D34D A1[06920100]        <1> 	mov 	eax, [FAT_CurrentCluster]
  4075 0000D352 8B0D[A8940100]      <1> 	mov	ecx, [ClusterValue]
  4076 0000D358 E972FDFFFF          <1>         jmp     loc_update_cluster_check_fat_type
  4077                              <1> 
  4078                              <1> save_fat_buffer:
  4079                              <1> 	; 15/10/2016
  4080                              <1> 	; 01/03/2016
  4081                              <1> 	; 22/02/2016 (TRDOS 386 =  TRDOS v2.0)
  4082                              <1> 	; 11/08/2011
  4083                              <1> 	; 09/02/2005 
  4084                              <1> 	; INPUT ->
  4085                              <1> 	;	None
  4086                              <1> 	; OUTPUT ->
  4087                              <1> 	;	cf = 0 -> OK.
  4088                              <1> 	;	cf = 1 -> error code in AL (EAX)
  4089                              <1> 	;
  4090                              <1> 	;	EBX = FAT_Buffer address
  4091                              <1> 	;
  4092                              <1> 	; (EAX, EDX, ECX will be modified)
  4093                              <1> 
  4094                              <1> 	;cmp	byte [FAT_BuffValidData], 2 
  4095                              <1> 	;je	short loc_save_fat_buff
  4096                              <1> 
  4097                              <1> ;loc_save_fat_buffer_retn:
  4098                              <1> ;	xor	eax, eax
  4099                              <1> ;	retn
  4100                              <1> 
  4101                              <1> loc_save_fat_buff:
  4102 0000D35D 31D2                <1> 	xor	edx, edx
  4103 0000D35F 8A35[0B920100]      <1> 	mov	dh, [FAT_BuffDrvName]
  4104 0000D365 80FE41              <1> 	cmp	dh, 'A'
  4105 0000D368 722E                <1> 	jb	short loc_save_fat_buffer_inv_data_retn
  4106 0000D36A 80EE41              <1> 	sub	dh, 'A'
  4107 0000D36D 56                  <1> 	push	esi ; *
  4108 0000D36E BE00010900          <1>         mov     esi, Logical_DOSDisks
  4109 0000D373 01D6                <1> 	add	esi, edx
  4110                              <1> 	
  4111 0000D375 8A5603              <1> 	mov	dl, [esi+LD_FATType]
  4112 0000D378 20D2                <1> 	and	dl, dl
  4113 0000D37A 741B                <1> 	jz	short loc_save_fat_buffer_inv_data_pop_retn 
  4114                              <1> 
  4115 0000D37C A1[0E920100]        <1> 	mov	eax, [FAT_BuffSector]
  4116 0000D381 80FA02              <1> 	cmp	dl, 2
  4117 0000D384 770A                <1> 	ja	short loc_save_fat32_buff
  4118                              <1> 
  4119                              <1> loc_save_fat_12_16_buff:
  4120                              <1> 	; 01/03/2016
  4121                              <1> 	; TRDOS v1 has a FATal bug here!
  4122                              <1> 	; Correct code: mov dx, word ptr [FAT_BuffSector]+2
  4123                              <1> 	; (DX:AX in TRDOS v1 -> EAX in TRDOS v2)
  4124                              <1> 	;
  4125 0000D386 0FB74E1C            <1> 	movzx	ecx, word [esi+LD_BPB+FATSecs] 
  4126 0000D38A 29C1                <1> 	sub	ecx, eax
  4127                              <1> 	; TRDOS v1 has a bug here... ('pop esi' was forgotten!)
  4128                              <1> 	;jna	short loc_save_fat_buffer_inv_data_retn ; wrong addr!
  4129 0000D38C 7609                <1> 	jna	short loc_save_fat_buffer_inv_data_pop_retn ; correct addr.
  4130 0000D38E EB15                <1> 	jmp	short loc_save_fat_buffer_check_rs3
  4131                              <1> 
  4132                              <1> loc_save_fat32_buff:
  4133 0000D390 8B4E2A              <1> 	mov	ecx, [esi+LD_BPB+FAT32_FAT_Size]
  4134 0000D393 29C1                <1> 	sub	ecx, eax
  4135 0000D395 770E                <1> 	ja	short loc_save_fat_buffer_check_rs3
  4136                              <1> 
  4137                              <1> loc_save_fat_buffer_inv_data_pop_retn:
  4138 0000D397 5E                  <1> 	pop	esi ; *
  4139                              <1> loc_save_fat_buffer_inv_data_retn:
  4140 0000D398 B80D000000          <1> 	mov	eax, 0Dh ; Invalid DATA
  4141 0000D39D C3                  <1> 	retn
  4142                              <1> 
  4143                              <1> loc_save_fat_buff_remain_sectors_3:
  4144 0000D39E B903000000          <1> 	mov	ecx, 3
  4145 0000D3A3 EB05                <1> 	jmp	short loc_save_fat_buff_continue
  4146                              <1> 
  4147                              <1> loc_save_fat_buffer_check_rs3:
  4148 0000D3A5 83F903              <1> 	cmp	ecx, 3
  4149 0000D3A8 77F4                <1> 	ja	short loc_save_fat_buff_remain_sectors_3
  4150                              <1> 
  4151                              <1> loc_save_fat_buff_continue:
  4152 0000D3AA BB001C0900          <1> 	mov	ebx, FAT_Buffer
  4153 0000D3AF 034660              <1> 	add	eax, [esi+LD_FATBegin]
  4154 0000D3B2 51                  <1> 	push	ecx
  4155 0000D3B3 E8F6570000          <1> 	call	disk_write
  4156 0000D3B8 59                  <1> 	pop	ecx
  4157 0000D3B9 722B                <1> 	jc	short loc_save_FAT_buff_write_err
  4158                              <1> 	
  4159 0000D3BB 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
  4160 0000D3BF 7605                <1> 	jna	short loc_calc_2nd_fat12_16_addr
  4161                              <1> 
  4162                              <1> loc_calc_2nd_fat32_addr:
  4163 0000D3C1 8B462A              <1> 	mov	eax, [esi+LD_BPB+FAT32_FAT_Size]
  4164 0000D3C4 EB04                <1> 	jmp	short loc_calc_2nd_fat_addr
  4165                              <1> 
  4166                              <1> loc_calc_2nd_fat12_16_addr:
  4167 0000D3C6 0FB7461C            <1> 	movzx	eax, word [esi+LD_BPB+FATSecs]
  4168                              <1> 
  4169                              <1> loc_calc_2nd_fat_addr:
  4170 0000D3CA 034660              <1> 	add	eax, [esi+LD_FATBegin]
  4171 0000D3CD 0305[0E920100]      <1> 	add	eax, [FAT_BuffSector]
  4172 0000D3D3 BB001C0900          <1> 	mov	ebx, FAT_Buffer
  4173                              <1> 	; ecx = 1 to 3
  4174 0000D3D8 E8D1570000          <1> 	call	disk_write
  4175 0000D3DD 7207                <1> 	jc	short loc_save_FAT_buff_write_err
  4176                              <1>  	; Valid  buffer (1 = valid but do not save)
  4177 0000D3DF C605[0A920100]01    <1> 	mov	byte [FAT_BuffValidData], 1
  4178                              <1> 
  4179                              <1> loc_save_FAT_buff_write_err:
  4180 0000D3E6 5E                  <1> 	pop	esi ; *
  4181 0000D3E7 BB001C0900          <1> 	mov	ebx, FAT_Buffer
  4182                              <1> 	; 15/10/2016 (1Dh -> 18)
  4183                              <1> 	; 23/03/2016 (1Dh)
  4184 0000D3EC B812000000          <1> 	mov	eax, 18 ; Drive not ready or write error
  4185 0000D3F1 C3                  <1> 	retn
  4186                              <1> 
  4187                              <1> calculate_fat_freespace:
  4188                              <1> 	; 23/03/2016
  4189                              <1> 	; 02/03/2016
  4190                              <1> 	; 01/03/2016
  4191                              <1> 	; 29/02/2016
  4192                              <1> 	; 22/02/2016 (TRDOS 386 =  TRDOS v2.0)
  4193                              <1> 	; 30/04/2011
  4194                              <1> 	; 03/04/2010
  4195                              <1> 	; 2005
  4196                              <1> 	; INPUT ->
  4197                              <1> 	;	EAX = Cluster count to be added or subtracted
  4198                              <1> 	; 	If BH = FFh, ESI = TR-DOS Logical Drive Description Table
  4199                              <1> 	; 	If BH < FFh, BH = TR-DOS Logical Drive Number
  4200                              <1> 	; 	BL: 
  4201                              <1> 	;	0 = Calculate, 1 = Add, 2 = Subtract, 3 = Get (Not Set/Calc)
  4202                              <1> 	; OUTPUT ->
  4203                              <1> 	;	EAX = Free Space in sectors
  4204                              <1> 	;	ESI = Logical Dos Drive Description Table address
  4205                              <1> 	;	BH = Logical Dos Drive Number (same with input value of BH)
  4206                              <1> 	;	BL = Type of operation (same with input value of BL)
  4207                              <1> 	;	ECX = 0 -> valid
  4208                              <1> 	;	ECX > 0 -> error or invalid
  4209                              <1> 	;	If EAX = FFFFFFFFh, it is 're-calculation needed'
  4210                              <1> 	;			          sign due to r/w error   
  4211                              <1> 
  4212 0000D3F2 66891D[AE940100]    <1> 	mov	[CFS_OPType], bx
  4213 0000D3F9 A3[B0940100]        <1> 	mov	[CFS_CC], eax
  4214                              <1> 	
  4215 0000D3FE 80FFFF              <1> 	cmp	bh, 0FFh
  4216 0000D401 740B                <1> 	je	short pass_calculate_freespace_get_drive_dt_offset
  4217                              <1> 
  4218                              <1> loc_calculate_freespace_get_drive_dt_offset:     
  4219 0000D403 31C0                <1> 	xor	eax, eax
  4220 0000D405 88FC                <1>         mov     ah, bh
  4221 0000D407 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  4222 0000D40C 01C6                <1>         add     esi, eax
  4223                              <1> 
  4224                              <1> pass_calculate_freespace_get_drive_dt_offset:
  4225 0000D40E 08DB                <1> 	or	bl, bl
  4226 0000D410 7435                <1> 	jz	short loc_reset_fcc
  4227                              <1> 	
  4228                              <1> loc_get_free_sectors:
  4229 0000D412 8B4674              <1> 	mov	eax, [esi+LD_FreeSectors]
  4230                              <1> 
  4231                              <1> 	;xor	ecx, ecx
  4232                              <1> 	;dec	ecx ; 0FFFFFFFFh
  4233                              <1> 	;cmp	eax, ecx ; 29/02/2016
  4234                              <1> 	;je	short loc_get_free_sectors_retn ; recalculation is needed!
  4235                              <1> 	
  4236                              <1> 	; 23/03/2016
  4237 0000D415 8B4E70              <1> 	mov	ecx, [esi+LD_TotalSectors]
  4238 0000D418 39C1                <1> 	cmp	ecx, eax ; Total sectors must be greater than Free sectors !
  4239 0000D41A 7707                <1> 	ja	short loc_get_free_sectors_check_optype
  4240                              <1> 	
  4241 0000D41C 31C0                <1> 	xor	eax, eax
  4242 0000D41E 48                  <1> 	dec	eax ; 0FFFFFFFFh  ; recalculation is needed!
  4243 0000D41F 894674              <1> 	mov	[esi+LD_FreeSectors], eax ; reset (for recalculation)
  4244                              <1> 		
  4245                              <1> loc_get_free_sectors_retn:
  4246 0000D422 C3                  <1> 	retn
  4247                              <1> 	
  4248                              <1> loc_get_free_sectors_check_optype:
  4249 0000D423 80FB03              <1> 	cmp	bl, 3
  4250 0000D426 7203                <1> 	jb	short loc_set_fcc
  4251                              <1> 
  4252 0000D428 29C9                <1> 	sub	ecx, ecx ; 0
  4253                              <1> 
  4254 0000D42A C3                  <1> 	retn	
  4255                              <1> 
  4256                              <1> loc_set_fcc:
  4257 0000D42B 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
  4258 0000D42F 0F87DF000000        <1>         ja      loc_update_FAT32_fs_info_fcc
  4259                              <1> 
  4260                              <1> 	;mov	eax, [esi+LD_FreeSectors]
  4261 0000D435 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
  4262 0000D439 29D2                <1> 	sub	edx, edx
  4263 0000D43B F7F1                <1> 	div	ecx
  4264                              <1> 	;or	dx, dx 
  4265                              <1> 	;	; DX -> Remain sectors < SecPerClust
  4266                              <1> 	;	; DX > 0 -> invalid free sector count
  4267                              <1> 	;jnz	short loc_reset_fcc 
  4268                              <1> 
  4269                              <1> ;pass_set_fcc_div32:
  4270 0000D43D A3[27920100]        <1> 	mov	[FreeClusterCount], eax
  4271 0000D442 E988000000          <1>         jmp     loc_set_free_sectors_FAT12_FAT16
  4272                              <1> 
  4273                              <1> loc_reset_fcc:
  4274 0000D447 31C0                <1> 	xor	eax, eax
  4275 0000D449 A3[27920100]        <1> 	mov	[FreeClusterCount], eax ; 0
  4276 0000D44E 8B5678              <1> 	mov	edx, [esi+LD_Clusters]
  4277 0000D451 42                  <1> 	inc	edx
  4278 0000D452 8915[16920100]      <1> 	mov	[LastCluster], edx
  4279                              <1> 
  4280 0000D458 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
  4281 0000D45C 7647                <1> 	jna	short loc_count_free_fat_clusters_0  
  4282                              <1> 
  4283 0000D45E 48                  <1> 	dec	eax ; FFFFFFFFh
  4284 0000D45F A3[B8940100]        <1> 	mov	[CFS_FAT32FC], eax
  4285                              <1> 
  4286                              <1> 	; 29/02/2016
  4287 0000D464 89463A              <1> 	mov	[esi+LD_BPB+BPB_Reserved], eax ; reset
  4288 0000D467 89463E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], eax ; reset
  4289                              <1> 	
  4290 0000D46A B802000000          <1> 	mov 	eax, 2
  4291                              <1> 
  4292                              <1> loc_count_fc_next_cluster_0:
  4293 0000D46F 50                  <1> 	push	eax
  4294 0000D470 E801F9FFFF          <1> 	call	get_next_cluster
  4295 0000D475 7310                <1> 	jnc	short loc_check_fat32_ff_cluster
  4296 0000D477 09C0                <1> 	or	eax, eax
  4297 0000D479 741E                <1> 	jz	short pass_inc_cfs_fcc_0
  4298                              <1> 
  4299                              <1> loc_put_fcc_unknown_sign:
  4300 0000D47B 58                  <1> 	pop	eax
  4301                              <1> 	; "Free count is Unknown" sign
  4302                              <1> 	;mov	dword [FreeClusterCount], 0FFFFFFFFh
  4303                              <1> 
  4304                              <1> 	; 29/02/2016
  4305                              <1> 	; Save Free Cluster Count value in FAT32 'BPB_Reserved' area
  4306                              <1> 	;mov	[esi+LD_BPB+BPB_Reserved], 0FFFFFFFFh ; unknown!
  4307 0000D47C 8B15[B8940100]      <1> 	mov	edx, [CFS_FAT32FC] ; First Free Cluster
  4308                              <1> 	; Save First Free Cluster value in FAT32 'BPB_Reserved+4' area
  4309 0000D482 89563E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], edx
  4310                              <1> 	
  4311 0000D485 EB7D                <1>         jmp     loc_put_fcc_invalid_sign
  4312                              <1> 
  4313                              <1> loc_check_fat32_ff_cluster:
  4314 0000D487 09C0                <1> 	or	eax, eax
  4315 0000D489 750E                <1> 	jnz	short pass_inc_cfs_fcc_0
  4316 0000D48B 58                  <1> 	pop	eax
  4317 0000D48C A3[B8940100]        <1> 	mov	[CFS_FAT32FC], eax
  4318                              <1> 	;mov	dword [FreeClusterCount], 1
  4319 0000D491 FF05[27920100]      <1> 	inc	dword [FreeClusterCount]
  4320 0000D497 EB27                <1> 	jmp	short pass_inc_cfs_fcc_1
  4321                              <1> 
  4322                              <1> pass_inc_cfs_fcc_0:
  4323 0000D499 58                  <1> 	pop	eax
  4324                              <1> 
  4325                              <1> pass_inc_cfs_fcc_0c:
  4326 0000D49A 40                  <1> 	inc	eax ; add eax, 1
  4327 0000D49B 3B05[16920100]      <1> 	cmp	eax, [LastCluster]
  4328 0000D4A1 76CC                <1> 	jna 	short loc_count_fc_next_cluster_0
  4329 0000D4A3 EB6F                <1> 	jmp	short loc_update_FAT32_fs_info_fcc
  4330                              <1> 
  4331                              <1> loc_count_free_fat_clusters_0:
  4332                              <1> 	;mov	eax, 2
  4333 0000D4A5 B002                <1> 	mov	al, 2
  4334                              <1> 
  4335                              <1> loc_count_fc_next_cluster:
  4336 0000D4A7 50                  <1> 	push	eax
  4337 0000D4A8 E8C9F8FFFF          <1> 	call	get_next_cluster
  4338 0000D4AD 720C                <1> 	jc	short loc_count_fcc_stc
  4339                              <1> 
  4340                              <1> loc_count_free_clusters_1:
  4341 0000D4AF 21C0                <1> 	and	eax, eax
  4342 0000D4B1 750C                <1> 	jnz	short pass_inc_cfs_fcc
  4343                              <1> 
  4344 0000D4B3 FF05[27920100]      <1> 	inc	dword [FreeClusterCount]
  4345 0000D4B9 EB04                <1> 	jmp	short pass_inc_cfs_fcc
  4346                              <1> 
  4347                              <1> loc_count_fcc_stc:
  4348 0000D4BB 09C0                <1> 	or	eax, eax
  4349 0000D4BD 75BC                <1> 	jnz	short loc_put_fcc_unknown_sign ; 29/02/2016
  4350                              <1> 
  4351                              <1> pass_inc_cfs_fcc:
  4352 0000D4BF 58                  <1> 	pop	eax
  4353                              <1> 
  4354                              <1> pass_inc_cfs_fcc_1:
  4355 0000D4C0 40                  <1> 	inc	eax ; add eax, 1
  4356 0000D4C1 3B05[16920100]      <1> 	cmp	eax, [LastCluster]
  4357 0000D4C7 76DE                <1> 	jna	short loc_count_fc_next_cluster
  4358                              <1> 
  4359                              <1> loc_set_free_sectors:
  4360 0000D4C9 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
  4361 0000D4CD 7745                <1> 	ja	short loc_update_FAT32_fs_info_fcc
  4362                              <1> 
  4363                              <1> loc_set_free_sectors_FAT12_FAT16:
  4364 0000D4CF 803D[AE940100]00    <1> 	cmp	byte [CFS_OPType], 0
  4365 0000D4D6 761C                <1> 	jna	short pass_FAT_add_sub_fcc
  4366 0000D4D8 A1[B0940100]        <1> 	mov	eax, [CFS_CC]
  4367 0000D4DD 803D[AE940100]01    <1> 	cmp	byte [CFS_OPType], 1
  4368 0000D4E4 7708                <1> 	ja	short pass_FAT_add_fcc
  4369 0000D4E6 0105[27920100]      <1> 	add 	[FreeClusterCount], eax
  4370 0000D4EC EB06                <1> 	jmp	short pass_FAT_add_sub_fcc
  4371                              <1> 
  4372                              <1> pass_FAT_add_fcc:
  4373 0000D4EE 2905[27920100]      <1> 	sub	[FreeClusterCount], eax
  4374                              <1> 
  4375                              <1> pass_FAT_add_sub_fcc:
  4376 0000D4F4 0FB64613            <1> 	movzx	eax, byte [esi+LD_BPB+SecPerClust]
  4377 0000D4F8 8B15[27920100]      <1> 	mov	edx, [FreeClusterCount]
  4378 0000D4FE F7E2                <1> 	mul	edx
  4379                              <1> 
  4380 0000D500 31C9                <1> 	xor	ecx, ecx 
  4381 0000D502 EB05                <1> 	jmp	short loc_cfs_retn_params
  4382                              <1> 
  4383                              <1> loc_put_fcc_invalid_sign:
  4384 0000D504 29C0                <1>        	sub	eax, eax ; 0
  4385 0000D506 48                  <1> 	dec	eax ; FFFFFFFFh
  4386                              <1> loc_fat32_ffc_recalc_needed:
  4387 0000D507 89C1                <1> 	mov	ecx, eax
  4388                              <1> 
  4389                              <1> loc_cfs_retn_params:
  4390 0000D509 894674              <1> 	mov 	[esi+LD_FreeSectors], eax
  4391 0000D50C 0FB71D[AE940100]    <1> 	movzx	ebx, word [CFS_OPType]
  4392 0000D513 C3                  <1> 	retn
  4393                              <1> 
  4394                              <1> loc_update_FAT32_fs_info_fcc:
  4395                              <1> loc_check_fcc_FSINFO_op:
  4396                              <1> 	; 29/02/2016
  4397                              <1> 	; EAX = Free cluster count (before this update) ; value from disk
  4398                              <1> 	; EDX = First Free Cluster (before this update) ; value from disk
  4399 0000D514 803D[AE940100]01    <1> 	cmp	byte [CFS_OPType], 1
  4400 0000D51B 7221                <1> 	jb	short loc_cfs_FAT32_get_rcalc_parms ; 0 = recalculated
  4401 0000D51D 7406                <1> 	je	short loc_check_fcc_FSINFO_op1 ; 1 = add
  4402                              <1> loc_check_fcc_FSINFO_op2: ; subtract
  4403 0000D51F F71D[B0940100]      <1> 	neg	dword [CFS_CC] ; prepare to subtract ; 2 = sub (add negative)
  4404                              <1> loc_check_fcc_FSINFO_op1:
  4405                              <1> 	; 01/03/2016
  4406 0000D525 31D2                <1> 	xor	edx, edx ; 0
  4407 0000D527 4A                  <1> 	dec	edx ; 0FFFFFFFFh
  4408 0000D528 8B463A              <1> 	mov	eax, [esi+LD_BPB+BPB_Reserved]
  4409 0000D52B 39D0                <1> 	cmp	eax, edx
  4410 0000D52D 73D5                <1> 	jnb	short loc_put_fcc_invalid_sign
  4411 0000D52F 0305[B0940100]      <1>         add     eax, [CFS_CC] ; free cluster count on disk + current count
  4412 0000D535 72CD                <1> 	jc	short loc_put_fcc_invalid_sign
  4413                              <1> 	
  4414 0000D537 A3[27920100]        <1> 	mov	[FreeClusterCount], eax
  4415 0000D53C EB0E                <1> 	jmp	short loc_cfs_write_FSINFO_sector
  4416                              <1> 
  4417                              <1> loc_cfs_FAT32_get_rcalc_parms:
  4418 0000D53E 8B15[B8940100]      <1> 	mov	edx, [CFS_FAT32FC]
  4419 0000D544 A1[27920100]        <1> 	mov	eax, [FreeClusterCount]
  4420 0000D549 89563E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], edx ; First Free Cluster
  4421                              <1> loc_cfs_write_FSINFO_sector:
  4422 0000D54C 89463A              <1> 	mov	[esi+LD_BPB+BPB_Reserved], eax ; Free cluster count
  4423                              <1> 	; 01/03/2016
  4424 0000D54F E8AA000000          <1> 	call	set_fat32_fsinfo_sector_parms
  4425 0000D554 72AE                <1>         jc      short loc_put_fcc_invalid_sign
  4426                              <1> 
  4427                              <1> loc_set_FAT32_free_sectors:
  4428                              <1> 	; 29/02/2016
  4429                              <1> 	;mov	eax, [FreeClusterCount]
  4430                              <1> 	;mov	ecx, eax
  4431                              <1> 	;cmp	eax, 0FFFFFFFFh ; Invalid !
  4432                              <1> 	;je	short loc_cfs_retn_params
  4433                              <1> 	;
  4434 0000D556 8B0D[27920100]      <1> 	mov	ecx, [FreeClusterCount]
  4435 0000D55C 0FB64613            <1> 	movzx	eax, byte [esi+LD_BPB+SecPerClust]
  4436 0000D560 F7E1                <1> 	mul	ecx
  4437                              <1> 	; 29/02/2016
  4438 0000D562 31C9                <1> 	xor	ecx, ecx ; 0
  4439 0000D564 09D2                <1> 	or	edx, edx ; 0 ?
  4440 0000D566 759C                <1>         jnz     loc_put_fcc_invalid_sign
  4441 0000D568 394670              <1> 	cmp	[esi+LD_TotalSectors], eax ; Volume size in sectors
  4442 0000D56B 7697                <1>         jna     short loc_put_fcc_invalid_sign
  4443                              <1> 	;
  4444                              <1> loc_set_FAT32_free_sectors_ok:
  4445 0000D56D 31D2                <1> 	xor	edx, edx ; 0
  4446 0000D56F EB98                <1>         jmp     short loc_cfs_retn_params 
  4447                              <1> 	;
  4448                              <1> 
  4449                              <1> get_last_cluster:
  4450                              <1> 	; 22/10/2016
  4451                              <1> 	; 27/02/2016 (TRDOS 386 =  TRDOS v2.0)
  4452                              <1> 	; 12/06/2010 (DRV_FAT.ASM, 'proc_get_last_custer')
  4453                              <1> 	; 06/06/2010
  4454                              <1> 	; INPUT ->
  4455                              <1> 	;	EAX = First Cluster Number
  4456                              <1> 	; 	ESI = Logical Dos Drive Parameters Table
  4457                              <1> 	; OUTPUT ->
  4458                              <1> 	;	cf = 0 -> No Error, EAX is valid
  4459                              <1> 	;	cf = 1 -> EAX > 0 -> Error
  4460                              <1> 	;	EAX = Last Cluster Number
  4461                              <1> 	;       ECX = Previous Cluster -just before the last cluster-
  4462                              <1> 	;       ; 22/10/2016
  4463                              <1> 	;	[glc_index] = cluster index number of the last cluster	
  4464                              <1> 	;
  4465                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
  4466                              <1> 
  4467 0000D571 89C1                <1> 	mov	ecx, eax
  4468                              <1> 
  4469 0000D573 C705[C0940100]FFFF- <1> 	mov	dword [glc_index], 0FFFFFFFFh ; 22/10/2016	
  4469 0000D57B FFFF                <1>
  4470                              <1> 
  4471                              <1> loc_glc_get_next_cluster_1:
  4472 0000D57D 890D[BC940100]      <1> 	mov	[glc_prevcluster], ecx
  4473                              <1>  	; 22/10/2016
  4474 0000D583 FF05[C0940100]      <1> 	inc	dword [glc_index]
  4475                              <1> 
  4476                              <1> loc_glc_get_next_cluster_2:
  4477 0000D589 E8E8F7FFFF          <1> 	call	get_next_cluster
  4478                              <1> 	; ecx = current/previous cluster 
  4479                              <1> 	; eax = next/last cluster
  4480 0000D58E 73ED                <1> 	jnc	short loc_glc_get_next_cluster_1
  4481                              <1> 
  4482 0000D590 09C0                <1> 	or	eax, eax
  4483 0000D592 7509                <1> 	jnz	short loc_glc_stc_retn
  4484                              <1> 
  4485                              <1> 	; ecx = previous cluster
  4486 0000D594 89C8                <1>         mov	eax, ecx
  4487                              <1> 
  4488                              <1> 	; previous cluster becomes last cluster (ecx -> eax)
  4489                              <1> 	; previous of previous cluster becomes previous cluster (ecx)
  4490                              <1> 
  4491                              <1> loc_glc_prev_cluster_retn:
  4492 0000D596 8B0D[BC940100]      <1> 	mov	ecx, [glc_prevcluster] 
  4493 0000D59C C3                  <1> 	retn
  4494                              <1> 
  4495                              <1> loc_glc_stc_retn:
  4496 0000D59D F5                  <1> 	cmc	;stc
  4497 0000D59E EBF6                <1>         jmp	short loc_glc_prev_cluster_retn
  4498                              <1> 
  4499                              <1> truncate_cluster_chain:
  4500                              <1> 	; 01/03/2016
  4501                              <1> 	; 28/02/2016 (TRDOS 386 =  TRDOS v2.0)
  4502                              <1> 	; 22/01/2011 (DRV_FAT.ASM, 'proc_truncate_cluster_chain')
  4503                              <1> 	; 11/09/2010
  4504                              <1> 	; INPUT ->
  4505                              <1> 	;	ESI = Logical dos drive description table address
  4506                              <1> 	;	EAX = First cluster to be truncated/unlinked 
  4507                              <1> 	; OUTPUT ->
  4508                              <1> 	;	ESI = Logical dos drive description table address
  4509                              <1> 	; 	ECX = Count of truncated/removed clusters
  4510                              <1> 	; 	CF = 0 -> EAX = Free sectors
  4511                              <1> 	; 	CF = 1 -> Error code in EAX (AL)
  4512                              <1> 
  4513                              <1> 	; NOTE: This procedure does not update lm date&time ! 
  4514                              <1> 
  4515                              <1> loc_truncate_cc:	
  4516 0000D5A0 31C9                <1> 	xor	ecx, ecx ; mov ecx, 0
  4517                              <1> 	;mov	byte [FAT_BuffValidData], 0
  4518 0000D5A2 890D[12920100]      <1> 	mov	[FAT_ClusterCounter], ecx ; 0 ; reset
  4519                              <1> 
  4520                              <1> loc_tcc_unlink_clusters:
  4521 0000D5A8 E8F3FAFFFF          <1> 	call	update_cluster
  4522                              <1> 	; EAX = Next Cluster
  4523                              <1> 	; ECX = Cluster Value
  4524                              <1> 	; Note:
  4525                              <1> 	; Returns count of unlinked clusters in
  4526                              <1> 	; dword ptr FAT_ClusterCounter
  4527 0000D5AD 73F9                <1> 	jnc short loc_tcc_unlink_clusters
  4528                              <1> 
  4529                              <1> pass_tcc_unlink_clusters:
  4530 0000D5AF A2[C7940100]        <1> 	mov	byte [TCC_FATErr], al
  4531 0000D5B4 803D[0A920100]02    <1> 	cmp	byte [FAT_BuffValidData], 2
  4532 0000D5BB 750E                <1> 	jne	short loc_tcc_calculate_FAT_freespace
  4533 0000D5BD E89BFDFFFF          <1> 	call	save_fat_buffer
  4534 0000D5C2 7307                <1> 	jnc	short loc_tcc_calculate_FAT_freespace
  4535 0000D5C4 A2[C7940100]        <1> 	mov	byte [TCC_FATErr], al ; Error
  4536                              <1> 	;mov	byte [FAT_BuffValidData], 0
  4537                              <1> 
  4538                              <1> 	; 01/03/2016
  4539 0000D5C9 EB12                <1> 	jmp	short loc_tcc_recalculate_FAT_freespace
  4540                              <1> 
  4541                              <1> loc_tcc_calculate_FAT_freespace:
  4542 0000D5CB A1[12920100]        <1> 	mov	eax, [FAT_ClusterCounter] ; signed (+-) number
  4543 0000D5D0 66BB01FF            <1> 	mov	bx, 0FF01h ; BH = FFh -> ESI = Dos drv desc. table
  4544                              <1> 			   ; BL = 1 -> add cluster
  4545 0000D5D4 E819FEFFFF          <1> 	call	calculate_fat_freespace
  4546 0000D5D9 21C9                <1> 	and	ecx, ecx ; cx = 0 -> valid free sector count
  4547 0000D5DB 7409                <1> 	jz	short pass_truncate_cc_recalc_FAT_freespace
  4548                              <1> 
  4549                              <1> loc_tcc_recalculate_FAT_freespace:
  4550 0000D5DD 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate !
  4551 0000D5E1 E80CFEFFFF          <1> 	call	calculate_fat_freespace
  4552                              <1>               
  4553                              <1> loc_tcc_calculate_FAT_freespace_err:
  4554                              <1> pass_truncate_cc_recalc_FAT_freespace:
  4555 0000D5E6 8B0D[12920100]      <1> 	mov	ecx, [FAT_ClusterCounter]
  4556                              <1> 
  4557 0000D5EC 803D[C7940100]00    <1> 	cmp	byte [TCC_FATErr], 0
  4558 0000D5F3 7608                <1> 	jna	short loc_tcc_unlink_clusters_retn
  4559                              <1> 
  4560                              <1> loc_tcc_unlink_clusters_error:
  4561 0000D5F5 0FB605[C7940100]    <1> 	movzx	eax, byte [TCC_FATErr]
  4562 0000D5FC F9                  <1> 	stc
  4563                              <1> loc_tcc_unlink_clusters_retn:
  4564 0000D5FD C3                  <1> 	retn
  4565                              <1> 
  4566                              <1> set_fat32_fsinfo_sector_parms:
  4567                              <1> 	; 15/10/2016
  4568                              <1> 	; 23/03/2016
  4569                              <1> 	; 29/02/2016 (TRDOS 386 =  TRDOS v2.0)
  4570                              <1> 	; INPUT ->
  4571                              <1> 	;	ESI = Logical dos drive description table address
  4572                              <1> 	;	[esi+LD_BPB+BPB_Reserved] = Free Cluster Count
  4573                              <1> 	;	[esi+LD_BPB+BPB_Reserved+4] = First Free Cluster 
  4574                              <1> 	; OUTPUT ->
  4575                              <1> 	;	ESI = Logical dos drive description table address
  4576                              <1> 	; 	CF = 0 -> OK..
  4577                              <1> 	; 	CF = 1 -> Error code in EAX (AL)
  4578                              <1> 	;
  4579                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX)
  4580                              <1> 
  4581 0000D5FE E824000000          <1> 	call	get_fat32_fsinfo_sector_parms
  4582 0000D603 7221                <1> 	jc	short update_fat32_fsinfo_sector_retn
  4583                              <1> 
  4584 0000D605 8B463A              <1> 	mov	eax, [esi+LD_BPB+BPB_Reserved] ; Free Cluster Count
  4585 0000D608 8B563E              <1> 	mov	edx, [esi+LD_BPB+BPB_Reserved+4] ; First free Cluster	
  4586                              <1> 
  4587                              <1>         ;mov	ebx, DOSBootSectorBuff
  4588 0000D60B 8983E8010000        <1> 	mov	[ebx+488], eax
  4589 0000D611 8993EC010000        <1> 	mov	[ebx+492], edx	
  4590                              <1> 
  4591 0000D617 A1[B4940100]        <1> 	mov	eax, [CFS_FAT32FSINFOSEC]
  4592 0000D61C B901000000          <1> 	mov	ecx, 1
  4593 0000D621 E888550000          <1> 	call	disk_write
  4594                              <1> 	;jnc     short update_fat32_fsinfo_sector_retn
  4595                              <1> 
  4596                              <1> 	; 15/10/2016 (1Dh -> 18)
  4597                              <1> 	; 23/03/2016 (1Dh)
  4598                              <1> 	;mov	eax, 18 ; Drive not ready or write error
  4599                              <1> 
  4600                              <1> update_fat32_fsinfo_sector_retn:
  4601 0000D626 C3                  <1> 	retn
  4602                              <1> 
  4603                              <1> get_fat32_fsinfo_sector_parms:
  4604                              <1> 	; 15/10/2016
  4605                              <1> 	; 23/03/2016
  4606                              <1> 	; 01/03/2016
  4607                              <1> 	; 29/02/2016 (TRDOS 386 =  TRDOS v2.0)
  4608                              <1> 	; INPUT ->
  4609                              <1> 	;	ESI = Logical dos drive description table address
  4610                              <1> 	; OUTPUT ->
  4611                              <1> 	;	ESI = Logical dos drive description table address
  4612                              <1> 	;	EBX = FSINFO sector buffer address (DOSBootSectorBuff)	
  4613                              <1> 	;	CF = 0 -> OK..
  4614                              <1> 	;	   EAX = FsInfo sector address
  4615                              <1> 	;	   ECX = Free cluster count
  4616                              <1> 	;	   EDX = First free cluster 	
  4617                              <1> 	;	CF = 1 -> Error code in AL (EAX)
  4618                              <1> 	;	   EBX = 0
  4619                              <1> 	;	
  4620                              <1> 	;	[CFS_FAT32FSINFOSEC] = FAT32 FSINFO sector address
  4621                              <1>         ;
  4622                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX)
  4623                              <1> 
  4624 0000D627 0FB74636            <1> 	movzx	eax, word [esi+LD_BPB+FAT32_FSInfoSec]
  4625 0000D62B 03466C              <1> 	add	eax, [esi+LD_StartSector]
  4626 0000D62E A3[B4940100]        <1> 	mov	[CFS_FAT32FSINFOSEC], eax
  4627                              <1> 	
  4628 0000D633 BB[06900100]        <1>         mov     ebx, DOSBootSectorBuff
  4629 0000D638 B901000000          <1> 	mov	ecx, 1
  4630 0000D63D E87B550000          <1> 	call	disk_read
  4631 0000D642 7232                <1> 	jc	short loc_read_FAT32_fsinfo_sec_err
  4632                              <1> 
  4633 0000D644 BB[06900100]        <1> 	mov	ebx, DOSBootSectorBuff
  4634                              <1> 
  4635 0000D649 813B52526141        <1> 	cmp	dword [ebx], 41615252h
  4636 0000D64F 751E                <1> 	jne	short loc_read_FAT32_fsinfo_sec_stc
  4637                              <1> 
  4638 0000D651 81BBE4010000727241- <1> 	cmp	dword [ebx+484], 61417272h
  4638 0000D65A 61                  <1>
  4639 0000D65B 7512                <1> 	jne	short loc_read_FAT32_fsinfo_sec_stc
  4640                              <1> 
  4641 0000D65D A1[B4940100]        <1> 	mov	eax, [CFS_FAT32FSINFOSEC]
  4642 0000D662 8B8BE8010000        <1> 	mov	ecx, [ebx+488] ; free cluster count
  4643 0000D668 8B93EC010000        <1> 	mov	edx, [ebx+492] ; first (next) free cluster	
  4644                              <1> 
  4645 0000D66E C3                  <1> 	retn
  4646                              <1> 
  4647                              <1> loc_read_FAT32_fsinfo_sec_stc: 
  4648                              <1> 	; 15/10/2016 (0Bh -> 28)
  4649 0000D66F B81C000000          <1> 	mov	eax, 28 ; Invalid format!
  4650 0000D674 EB05                <1> 	jmp	short loc_read_FAT32_fsinfo_sec_stc_retn
  4651                              <1> 
  4652                              <1> loc_read_FAT32_fsinfo_sec_err:
  4653                              <1> 	; 15/10/2016 (15h -> 17)
  4654                              <1> 	; 23/03/2016 (15h)
  4655 0000D676 B811000000          <1> 	mov	eax, 17 ; Drive not ready or read error
  4656                              <1> 
  4657                              <1> loc_read_FAT32_fsinfo_sec_stc_retn:
  4658 0000D67B 29DB                <1> 	sub	ebx, ebx ; 0
  4659 0000D67D F9                  <1> 	stc
  4660 0000D67E C3                  <1> 	retn
  4661                              <1> 
  4662                              <1> add_new_cluster:
  4663                              <1> 	; 15/10/2016
  4664                              <1> 	; 16/05/2016
  4665                              <1> 	; 18/03/2016, 24/03/2016
  4666                              <1> 	; 11/03/2016 (TRDOS 386 =  TRDOS v2.0)
  4667                              <1> 	; 30/07/2011 (DRV_FAT.ASM)
  4668                              <1> 	; 11/09/2010
  4669                              <1> 	; INPUT ->
  4670                              <1> 	;	ESI = Logical dos drv desc. table address
  4671                              <1> 	;	EAX = Last cluster
  4672                              <1> 	; OUTPUT ->
  4673                              <1> 	;	ESI = Logical dos drv desc. table address
  4674                              <1> 	;	EAX = New Last cluster (next cluster)
  4675                              <1> 	;	cf = 1 -> error code in EAX (AL)
  4676                              <1> 	;	cf = 1 -> DX = sectors per cluster
  4677                              <1> 	;	ECX = Free sectors
  4678                              <1> 	; NOTE:
  4679                              <1> 	; This procedure does not update lm date&time !
  4680                              <1> 	;
  4681                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX, EDI)
  4682                              <1> 	;
  4683                              <1> 
  4684 0000D67F A3[E4950100]        <1> 	mov	[FAT_anc_LCluster], eax
  4685                              <1> 	
  4686 0000D684 E844F9FFFF          <1> 	call	get_first_free_cluster
  4687 0000D689 720B                <1> 	jc	short loc_add_new_cluster_retn
  4688                              <1> 	; EAX >= 2 and EAX < FFFFFFFFh is valid
  4689                              <1> 
  4690 0000D68B 89C2                <1> 	mov	edx, eax
  4691                              <1> 
  4692 0000D68D 42                  <1> 	inc	edx
  4693                              <1> 	;jnz	short loc_add_new_cluster_check_ffc_eax
  4694 0000D68E 7516                <1> 	jnz	short loc_add_new_cluster_save_fcc
  4695                              <1> 
  4696                              <1> loc_add_new_cluster_no_disk_space_retn:
  4697 0000D690 B827000000          <1> 	mov	eax, 27h ; MSDOS err => insufficient disk space
  4698                              <1> loc_add_new_cluster_stc_retn:
  4699 0000D695 F9                  <1> 	stc
  4700                              <1> loc_add_new_cluster_retn:
  4701 0000D696 0FB65E13            <1> 	movzx	ebx, byte [esi+LD_BPB+SecPerClust]
  4702 0000D69A 8B4E74              <1> 	mov	ecx, [esi+LD_FreeSectors]
  4703                              <1> 	;xor	edx, edx
  4704                              <1> 	;stc
  4705 0000D69D C3                  <1> 	retn
  4706                              <1> 
  4707                              <1> loc_anc_invalid_format_stc_retn:
  4708 0000D69E F9                  <1> 	stc
  4709                              <1> loc_add_new_cluster_invalid_format_retn:
  4710                              <1> 	; 15/10/2016 (0Bh -> 28)
  4711 0000D69F B81C000000          <1> 	mov	eax, 28 ; Invalid format
  4712 0000D6A4 EBF0                <1> 	jmp	short loc_add_new_cluster_retn 
  4713                              <1> 
  4714                              <1> ;loc_add_new_cluster_check_ffc_eax:
  4715                              <1> ;	cmp	eax, 2
  4716                              <1> ;	jb	short loc_add_new_cluster_invalid_format_retn
  4717                              <1> 
  4718                              <1> loc_add_new_cluster_save_fcc:  
  4719 0000D6A6 A3[E8950100]        <1> 	mov	[FAT_anc_FFCluster], eax
  4720                              <1> 
  4721 0000D6AB 83E802              <1> 	sub	eax, 2
  4722 0000D6AE 0FB65E13            <1>         movzx   ebx, byte [esi+LD_BPB+SecPerClust]
  4723 0000D6B2 F7E3                <1> 	mul	ebx
  4724 0000D6B4 09D2                <1> 	or	edx, edx
  4725 0000D6B6 75E6                <1> 	jnz	short loc_anc_invalid_format_stc_retn
  4726                              <1> 
  4727                              <1> loc_add_new_cluster_allocate_cluster:
  4728                              <1> 	; 18/03/2016
  4729 0000D6B8 92                  <1> 	xchg	edx, eax ; eax = 0
  4730                              <1> 	; 16/05/2016
  4731                              <1> 	;cmp	[ClusterBuffer_Valid], al ; 0
  4732                              <1> 	;jna	short loc_anc_clear_cluster_buffer
  4733                              <1> 	;; 'copy' command, 
  4734                              <1> 	;; writing destination file clust after reading source file clust
  4735                              <1> 	;mov	[ClusterBuffer_Valid], al ; 0 ; reset
  4736                              <1> 	;jmp	short loc_add_new_cluster_write_nc_to_disk
  4737                              <1> 
  4738                              <1> loc_anc_clear_cluster_buffer:
  4739                              <1> 	; 11/03/2016
  4740                              <1> 	; Clear buffer
  4741 0000D6B9 BF00000700          <1> 	mov	edi, Cluster_Buffer ; 70000h (for current TRDOS 386 version)
  4742 0000D6BE 89D9                <1> 	mov	ecx, ebx ; sector count
  4743 0000D6C0 C1E107              <1> 	shl	ecx, 7 ; 1 sector = 512 bytes -> 128 double words
  4744                              <1> 	;xor	eax, eax ; 0
  4745 0000D6C3 F3AB                <1> 	rep	stosd
  4746                              <1> 
  4747                              <1> loc_add_new_cluster_write_nc_to_disk:
  4748                              <1> 	; 11/03/2016
  4749                              <1> 	;xchg	eax, edx ; edx = 0, eax = sector offset
  4750 0000D6C5 89D0                <1> 	mov	eax, edx
  4751 0000D6C7 034668              <1>         add     eax, [esi+LD_DATABegin]
  4752 0000D6CA 72D3                <1> 	jc	short loc_add_new_cluster_invalid_format_retn 
  4753                              <1> 		
  4754 0000D6CC 89D9                <1> 	mov	ecx, ebx ; ECX = sectors per cluster (<256)
  4755 0000D6CE BB00000700          <1> 	mov	ebx, Cluster_Buffer
  4756 0000D6D3 E8D6540000          <1> 	call	disk_write
  4757 0000D6D8 7307                <1> 	jnc	short loc_add_new_cluster_update_fat_nlc
  4758                              <1> 	
  4759                              <1> 	; 15/10/2016 (1Dh -> 18)
  4760 0000D6DA B812000000          <1> 	mov	eax, 18 ; Write Error
  4761 0000D6DF EBB4                <1> 	jmp	short loc_add_new_cluster_stc_retn
  4762                              <1> 
  4763                              <1> loc_add_new_cluster_update_fat_nlc:
  4764 0000D6E1 A1[E8950100]        <1> 	mov	eax, [FAT_anc_FFCluster]
  4765 0000D6E6 31C9                <1> 	xor	ecx, ecx
  4766 0000D6E8 890D[12920100]      <1> 	mov	[FAT_ClusterCounter], ecx ; 0 ; reset
  4767 0000D6EE 49                  <1> 	dec	ecx ; 0FFFFFFFFh
  4768 0000D6EF E8ACF9FFFF          <1> 	call	update_cluster
  4769 0000D6F4 7304                <1> 	jnc	short loc_add_new_cluster_update_fat_plc
  4770 0000D6F6 09C0                <1> 	or	eax, eax ;EAX = 0 -> cluster value is 0 or eocc
  4771 0000D6F8 759B                <1> 	jnz	short loc_add_new_cluster_stc_retn
  4772                              <1> 
  4773                              <1> loc_add_new_cluster_update_fat_plc:
  4774 0000D6FA A1[E4950100]        <1> 	mov	eax, [FAT_anc_LCluster]
  4775 0000D6FF 8B0D[E8950100]      <1> 	mov	ecx, [FAT_anc_FFCluster]
  4776 0000D705 E896F9FFFF          <1> 	call	update_cluster
  4777 0000D70A 7314                <1> 	jnc	short loc_add_new_cluster_save_fat_buffer
  4778 0000D70C 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  4779 0000D70E 7410                <1> 	jz	short loc_add_new_cluster_save_fat_buffer
  4780                              <1> 
  4781                              <1> loc_anc_save_fat_buffer_err_retn:
  4782                              <1> 	;cmp	byte [FAT_ClusterCounter], 1
  4783                              <1> 	;jb	short loc_add_new_cluster_retn
  4784                              <1> 
  4785 0000D710 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate free space (BL = 0)
  4786                              <1> 			   ; (BH = FFh -> Use ESI as Drv Param. Tbl.)
  4787 0000D714 50                  <1> 	push	eax
  4788 0000D715 E8D8FCFFFF          <1> 	call	calculate_fat_freespace
  4789 0000D71A 58                  <1> 	pop	eax
  4790 0000D71B E975FFFFFF          <1>         jmp     loc_add_new_cluster_stc_retn
  4791                              <1> 
  4792                              <1> loc_add_new_cluster_save_fat_buffer:
  4793                              <1> 	;cmp	byte [FAT_BuffValidData], 2
  4794                              <1> 	;jne	short loc_add_new_cluster_calc_FAT_freespace 
  4795                              <1> 	;Byte [FAT_BuffValidData] =  2 
  4796 0000D720 E838FCFFFF          <1> 	call	save_fat_buffer
  4797 0000D725 72E9                <1> 	jc	short loc_anc_save_fat_buffer_err_retn
  4798                              <1> 
  4799                              <1> loc_add_new_cluster_calc_FAT_freespace:
  4800                              <1> 	;mov	eax, 1 ; Only one Cluster
  4801 0000D727 A1[12920100]        <1> 	mov	eax, [FAT_ClusterCounter]
  4802 0000D72C 66BB01FF            <1> 	mov	bx, 0FF01h ; BH = FFh -> ESI -> Dos drv desc. table
  4803                              <1> 		; BL = 1 -> add cluster
  4804 0000D730 B301                <1> 	mov	bl, 01h ; BL = 1 -> add clusters
  4805                              <1> 	; NOTE: EAX value will be added to Free Cluster Count
  4806                              <1> 	; (Free Cluster Count is decreased when EAX value is negative)
  4807 0000D732 E8BBFCFFFF          <1>         call    calculate_fat_freespace
  4808                              <1> 	;ECX = 0 -> no error, ECX > 0 -> error or invalid return
  4809 0000D737 21C9                <1> 	and	ecx, ecx ; ECX = 0 -> valid free sector count
  4810 0000D739 7409                <1> 	jz	short loc_add_new_cluster_return_cluster_number
  4811                              <1> 
  4812                              <1> loc_add_new_cluster_recalc_FAT_freespace:
  4813 0000D73B 66BB00FF            <1> 	mov	bx, 0FF00h  ; recalculate free space
  4814 0000D73F E8AEFCFFFF          <1>         call    calculate_fat_freespace
  4815                              <1> 	; cf = 0
  4816                              <1> loc_add_new_cluster_return_cluster_number:
  4817 0000D744 89C1                <1> 	mov	ecx, eax ; Free sector count
  4818 0000D746 A1[E8950100]        <1> 	mov	eax, [FAT_anc_FFCluster]
  4819 0000D74B 0FB65E13            <1> 	movzx	ebx, byte [esi+LD_BPB+SecPerClust]
  4820                              <1> 	;mov	edi, Cluster_Buffer
  4821 0000D74F 31D2                <1> 	xor	edx, edx
  4822 0000D751 C3                  <1>         retn
  4823                              <1> 
  4824                              <1> write_cluster:
  4825                              <1> 	; 15/10/2016
  4826                              <1> 	; 21/03/2016 (TRDOS 386 =  TRDOS v2.0)
  4827                              <1> 	;
  4828                              <1> 	; INPUT ->
  4829                              <1> 	;	EAX = Cluster Number (Sector index for SINGLIX FS)
  4830                              <1> 	;	ESI = Logical DOS Drive Description Table address
  4831                              <1> 	;	EBX = Cluster (File R/W) Buffer address (max. 64KB)
  4832                              <1> 	;	Only for SINGLIX FS:
  4833                              <1> 	;	EDX = File Number (The 1st FDT address) 
  4834                              <1> 	; OUTPUT ->
  4835                              <1> 	;	cf = 1 -> Cluster can not be written onto disk
  4836                              <1> 	;	    EAX > 0 -> Error number
  4837                              <1> 	;	cf = 0 -> Cluster has been written successfully
  4838                              <1> 	;
  4839                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
  4840                              <1> 	
  4841 0000D752 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+BPB_SecPerClust] 
  4842                              <1> 	; CL = 1 = [esi+LD_FS_Reserved2] ; SectPerClust for Singlix FS
  4843                              <1> 
  4844                              <1> write_file_sectors: ; 16/03/2016
  4845 0000D756 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  4846 0000D75A 761C                <1> 	jna	short write_fs_cluster
  4847                              <1> 
  4848                              <1> write_fat_file_sectors: 
  4849 0000D75C 83E802              <1> 	sub	eax, 2 ; Beginning cluster number is always 2
  4850 0000D75F 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+BPB_SecPerClust] ; 18/03/2016 
  4851 0000D763 F7E2                <1> 	mul	edx
  4852 0000D765 034668              <1> 	add	eax, [esi+LD_DATABegin] ; absolute address of the cluster
  4853                              <1> 
  4854                              <1> 	; EAX = Disk sector address
  4855                              <1> 	; ECX = Sector count
  4856                              <1> 	; EBX = Buffer address
  4857                              <1> 	; (EDX = 0)
  4858                              <1> 	; ESI = Logical DOS drive description table address	
  4859                              <1> 
  4860 0000D768 E841540000          <1> 	call	disk_write
  4861 0000D76D 7306                <1> 	jnc	short wclust_retn
  4862                              <1> 	
  4863                              <1> 	; 15/10/2016 (1Dh -> 18)
  4864 0000D76F B812000000          <1> 	mov	eax, 18 ; Drive not ready or write error !
  4865 0000D774 C3                  <1> 	retn
  4866                              <1> 
  4867                              <1> wclust_retn:
  4868 0000D775 29C0                <1> 	sub	eax, eax ; 0
  4869 0000D777 C3                  <1> 	retn
  4870                              <1> 
  4871                              <1> write_fs_cluster:
  4872                              <1> 	; 21/03/2016 (TRDOS 386 =  TRDOS v2.0)
  4873                              <1> 	; Singlix FS
  4874                              <1> 	
  4875                              <1> 	; EAX = Cluster number is sector index number of the file (eax)
  4876                              <1> 	
  4877                              <1> 	; EDX = File number is the first File Descriptor Table address 
  4878                              <1> 	;	of the file. (Absolute address of the FDT).
  4879                              <1> 	
  4880                              <1> 	; eax = sector index (0 for the first sector)
  4881                              <1> 	; edx = FDT0 address
  4882                              <1> 		; 64 KB buffer = 128 sectors (limit) 
  4883 0000D778 B980000000          <1> 	mov	ecx, 128 ; maximum count of sectors (before eof) 
  4884 0000D77D E801000000          <1> 	call	write_fs_sectors
  4885 0000D782 C3                  <1> 	retn
  4886                              <1> 
  4887                              <1> write_fs_sectors:
  4888                              <1> 	; 21/03/2016 (TRDOS 386 =  TRDOS v2.0)
  4889 0000D783 F9                  <1> 	stc
  4890 0000D784 C3                  <1> 	retn
  4891                              <1> 
  4892                              <1> get_cluster_by_index:
  4893                              <1> 	; 29/04/2016 (TRDOS 386 =  TRDOS v2.0)
  4894                              <1> 	; INPUT ->
  4895                              <1> 	; 	EAX = Beginning cluster
  4896                              <1> 	; 	EDX = Sector index in disk/file section
  4897                              <1> 	;	      (Only for SINGLIX file system!)
  4898                              <1> 	; 	ECX = Cluster sequence number after the beginning cluster
  4899                              <1> 	; 	ESI = Logical DOS Drive Description Table address
  4900                              <1> 	; OUTPUT ->
  4901                              <1> 	;	EAX = Cluster number 
  4902                              <1> 	;	cf = 1 -> Error code in AL (EAX)
  4903                              <1> 	;
  4904                              <1> 	;(Modified registers: EAX, ECX, EBX, EDX)
  4905                              <1> 	;	
  4906 0000D785 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
  4907 0000D789 721E                <1>         jb      short get_fs_section_by_index 
  4908                              <1> 
  4909 0000D78B 3B4E78              <1> 	cmp	ecx, [esi+LD_Clusters]
  4910 0000D78E 7207                <1> 	jb	short gcbi_1
  4911                              <1> gcbi_0:
  4912 0000D790 F9                  <1> 	stc
  4913 0000D791 B823000000          <1> 	mov	eax, 23h ; Cluster not available ! 
  4914                              <1> 			 ; MSDOS error code: FCB unavailable
  4915 0000D796 C3                  <1> 	retn
  4916                              <1> gcbi_1:
  4917 0000D797 51                  <1> 	push	ecx
  4918 0000D798 E8D9F5FFFF          <1> 	call	get_next_cluster
  4919 0000D79D 59                  <1> 	pop	ecx
  4920 0000D79E 7203                <1> 	jc	short gcbi_3
  4921 0000D7A0 E2F5                <1> 	loop	gcbi_1
  4922                              <1> gcbi_2:
  4923 0000D7A2 C3                  <1> 	retn
  4924                              <1> gcbi_3:
  4925 0000D7A3 09C0                <1> 	or	eax, eax
  4926 0000D7A5 74E9                <1> 	jz	short gcbi_0
  4927 0000D7A7 F5                  <1> 	cmc 	; stc
  4928 0000D7A8 C3                  <1> 	retn
  4929                              <1> 
  4930                              <1> get_fs_section_by_index:
  4931                              <1> 	; 29/04/2016 (TRDOS 386 =  TRDOS v2.0)
  4932                              <1> 	; INPUT ->
  4933                              <1> 	; 	EAX = Beginning FDT number/address
  4934                              <1> 	; 	EDX = Sector index in disk/file section
  4935                              <1> 	; 	ECX = Sector sequence number after the beginning FDT
  4936                              <1> 	; 	ESI = Logical DOS Drive Description Table address
  4937                              <1> 	; OUTPUT ->
  4938                              <1> 	; 	EAX = FDT number/address
  4939                              <1> 	; 	EDX = Sector index of the section (0,1,2,3,4...)
  4940                              <1> 	;	cf = 1 -> Error code in AL (EAX)
  4941                              <1> 	;
  4942                              <1> 	;(Modified registers: EAX, ECX, EBX, EDX)
  4943                              <1> 	;
  4944 0000D7A9 B8FFFFFFFF          <1> 	mov	eax, 0FFFFFFFFh
  4945 0000D7AE C3                  <1> 	retn
  4946                              <1> 
  4947                              <1> get_last_section:
  4948                              <1> 	; 22/10/2016 (TRDOS 386 =  TRDOS v2.0)	
  4949                              <1> 	; INPUT ->
  4950                              <1> 	; 	EAX = (The 1st) FDT number/address
  4951                              <1> 	; 	ESI = Logical DOS Drive Description Table address
  4952                              <1> 	; OUTPUT ->
  4953                              <1> 	; 	EAX = FDT number/address of the last section
  4954                              <1> 	; 	EDX = Last sector of the section (0,1,2,3,4...)
  4955                              <1> 	;	[glc_index] = sector index number of the last sector
  4956                              <1> 	;		      (for file, not for the last section)  	
  4957                              <1> 	;		   	
  4958                              <1> 	;	cf = 1 -> Error code in AL (EAX)
  4959                              <1> 	;
  4960                              <1> 	;(Modified registers: EAX, ECX, EBX, EDX)
  4961                              <1> 	;
  4962 0000D7AF B800000000          <1> 	mov	eax, 0
  4963 0000D7B4 BA00000000          <1> 	mov	edx, 0
  4964 0000D7B9 C3                  <1> 	retn
  3092                                  %include 'trdosk6.s' ; 24/01/2016
  3093                              <1> ; ****************************************************************************
  3094                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.3) - MAIN PROGRAM : trdosk6.s
  3095                              <1> ; ----------------------------------------------------------------------------
  3096                              <1> ; Last Update: 06/03/2021
  3097                              <1> ; ----------------------------------------------------------------------------
  3098                              <1> ; Beginning: 24/01/2016
  3099                              <1> ; ----------------------------------------------------------------------------
  3100                              <1> ; Assembler: NASM version 2.15 t(trdos386.s)
  3101                              <1> ; ----------------------------------------------------------------------------
  3102                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
  3103                              <1> ; u1.s (27/17/2015), u2.s (03/01/2016)
  3104                              <1> ; ****************************************************************************
  3105                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
  3106                              <1> ; TRDOS2.ASM (09/11/2011)
  3107                              <1> ; ----------------------------------------------------------------------------
  3108                              <1> ; INT_21H.ASM (c) 2009-2011 Erdogan TAN  [14/11/2009] Last Update: 08/11/2011
  3109                              <1> 
  3110                              <1> sysent: ; < enter to system call >
  3111                              <1> 	; 17/03/2017
  3112                              <1> 	; 03/03/2017
  3113                              <1> 	; 19/02/2017
  3114                              <1> 	; 13/01/2017
  3115                              <1> 	; 06/06/2016
  3116                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  3117                              <1> 	; 16/04/2015 - 19/10/2015 (Retro UNIX 386 v1)
  3118                              <1> 	; 10/04/2013 - 18/01/2014 (Retro UNIX 8086 v1)
  3119                              <1> 	;
  3120                              <1> 	; 'unkni' or 'sysent' is sytem entry from various traps. 
  3121                              <1> 	; The trap type is determined and an indirect jump is made to 
  3122                              <1> 	; the appropriate system call handler. If there is a trap inside
  3123                              <1> 	; the system a jump to panic is made. All user registers are saved 
  3124                              <1> 	; and u.sp points to the end of the users stack. The sys (trap)
  3125                              <1> 	; instructor is decoded to get the the system code part (see
  3126                              <1> 	; trap instruction in the PDP-11 handbook) and from this 
  3127                              <1> 	; the indirect jump address is calculated. If a bad system call is
  3128                              <1> 	; made, i.e., the limits of the jump table are exceeded, 'badsys'
  3129                              <1> 	; is called. If the call is legitimate control passes to the
  3130                              <1> 	; appropriate system routine.
  3131                              <1> 	;
  3132                              <1> 	; Calling sequence:
  3133                              <1> 	;	Through a trap caused by any sys call outside the system.
  3134                              <1> 	; Arguments:
  3135                              <1> 	;	Arguments of particular system call.	
  3136                              <1> 	; ...............................................................
  3137                              <1> 	;	
  3138                              <1> 	; Retro UNIX 8086 v1 modification: 
  3139                              <1> 	;       System call number is in EAX register.
  3140                              <1> 	;
  3141                              <1> 	;       Other parameters are in EDX, EBX, ECX, ESI, EDI, EBP
  3142                              <1> 	;	registers depending of function details.
  3143                              <1>   	;
  3144                              <1> 	; 16/04/2015
  3145 0000D7BA 368925[5C030300]    <1>         mov     [ss:u.sp], esp ; Kernel stack points to return address
  3146                              <1> 
  3147                              <1> 	; save user registers
  3148 0000D7C1 1E                  <1> 	push	ds
  3149 0000D7C2 06                  <1> 	push	es
  3150 0000D7C3 0FA0                <1> 	push	fs
  3151 0000D7C5 0FA8                <1> 	push	gs
  3152 0000D7C7 60                  <1> 	pushad  ; eax, ecx, edx, ebx, esp -before pushad-, ebp, esi, edi
  3153                              <1> 	;
  3154                              <1> 	; ESPACE = [ss:u.sp] - esp ; 4*12 = 48 ; 17/09/2015 ; 06/06/2016
  3155                              <1> 	; 	(ESPACE is size of space in kernel stack 
  3156                              <1> 	;	for saving/restoring user registers.)
  3157                              <1> 	;
  3158 0000D7C8 50                  <1> 	push	eax ; 01/07/2015
  3159 0000D7C9 66B81000            <1> 	mov     ax, KDATA
  3160 0000D7CD 8ED8                <1>         mov     ds, ax
  3161 0000D7CF 8EC0                <1>         mov     es, ax
  3162 0000D7D1 8EE0                <1>         mov     fs, ax
  3163 0000D7D3 8EE8                <1>         mov     gs, ax
  3164 0000D7D5 A1[308A0100]        <1> 	mov	eax, [k_page_dir]
  3165 0000D7DA 0F22D8              <1> 	mov	cr3, eax
  3166 0000D7DD 58                  <1> 	pop	eax ; 01/07/2015
  3167                              <1> 	; 19/10/2015
  3168 0000D7DE FC                  <1> 	cld
  3169                              <1> 	;
  3170 0000D7DF FE05[5B030300]      <1> 	inc	byte [sysflg]
  3171                              <1> 		; incb sysflg / indicate a system routine is in progress
  3172 0000D7E5 FB                  <1>         sti 	; 18/01/2014
  3173 0000D7E6 0F85DF9DFFFF        <1> 	jnz     panic ; 24/05/2013
  3174                              <1> 		; beq 1f
  3175                              <1> 		; jmp panic ; / called if trap inside system
  3176                              <1> ;1:
  3177                              <1> 	; 17/03/2017
  3178 0000D7EC 80642438FE          <1> 	and	byte [esp+ESPACE+8], ~1 ; clear carry flag
  3179                              <1> 
  3180                              <1> 	; 16/04/2015
  3181 0000D7F1 A3[64030300]        <1> 	mov	[u.r0], eax
  3182 0000D7F6 8925[60030300]      <1> 	mov	[u.usp], esp ; kernel stack points to user's registers
  3183                              <1> 
  3184                              <1> 	; 13/01/2017 (TRDOS 386 Feaure only !)
  3185 0000D7FC 803D[D4030300]00    <1> 	cmp	byte [u.t_lock], 0 ; timer interrupt lock ?
  3186 0000D803 0F879D010000        <1> 	ja	sysrele		   ; yes, sys release only !!!
  3187                              <1> 
  3188                              <1> 		; mov $s.syst+2,clockp
  3189                              <1> 		; mov r0,-(sp) / save user registers 
  3190                              <1> 		; mov sp,u.r0 / pointer to bottom of users stack 
  3191                              <1> 			   ; / in u.r0
  3192                              <1> 		; mov r1,-(sp)
  3193                              <1> 		; mov r2,-(sp)
  3194                              <1> 		; mov r3,-(sp)
  3195                              <1> 		; mov r4,-(sp)
  3196                              <1> 		; mov r5,-(sp)
  3197                              <1> 		; mov ac,-(sp) / "accumulator" register for extended
  3198                              <1> 		             ; / arithmetic unit
  3199                              <1> 		; mov mq,-(sp) / "multiplier quotient" register for the
  3200                              <1> 		             ; / extended arithmetic unit
  3201                              <1> 		; mov sc,-(sp) / "step count" register for the extended
  3202                              <1> 		             ; / arithmetic unit
  3203                              <1> 		; mov sp,u.sp / u.sp points to top of users stack
  3204                              <1> 		; mov 18.(sp),r0 / store pc in r0
  3205                              <1> 		; mov -(r0),r0 / sys inst in r0      10400xxx
  3206                              <1> 		; sub $sys,r0 / get xxx code
  3207 0000D809 C1E002              <1> 	shl	eax, 2
  3208                              <1> 		; asl r0 / multiply by 2 to jump indirect in bytes
  3209 0000D80C 3DB8000000          <1> 	cmp	eax, end_of_syscalls - syscalls
  3210                              <1> 		; cmp r0,$2f-1f / limit of table (35) exceeded
  3211                              <1> 	;jnb	short badsys
  3212                              <1> 		; bhis badsys / yes, bad system call
  3213 0000D811 F5                  <1> 	cmc
  3214 0000D812 9C                  <1> 	pushf	
  3215 0000D813 50                  <1> 	push	eax
  3216 0000D814 8B2D[5C030300]      <1>  	mov 	ebp, [u.sp] ; Kernel stack at the beginning of sys call
  3217 0000D81A B0FE                <1> 	mov	al, 0FEh ; 11111110b
  3218 0000D81C 1400                <1> 	adc	al, 0 ; al = al + cf
  3219 0000D81E 204508              <1> 	and	[ebp+8], al ; flags (reset carry flag)
  3220                              <1> 		; bic $341,20.(sp) / set users processor priority to 0 
  3221                              <1> 				 ; / and clear carry bit
  3222 0000D821 5D                  <1> 	pop	ebp ; eax
  3223 0000D822 9D                  <1> 	popf
  3224 0000D823 0F8208020000        <1>         jc      badsys
  3225 0000D829 A1[64030300]        <1> 	mov	eax, [u.r0]
  3226                              <1> 	; system call registers: EAX, EDX, ECX, EBX, ESI, EDI
  3227 0000D82E FFA5[34D80000]      <1> 	jmp	dword [ebp+syscalls]
  3228                              <1> 		; jmp *1f(r0) / jump indirect thru table of addresses
  3229                              <1> 		            ; / to proper system routine.
  3230                              <1> syscalls: ; 1:
  3231                              <1> 	; 31/12/2017
  3232                              <1> 	; 28/02/2017
  3233                              <1> 	; 20/02/2017
  3234                              <1> 	; 19/02/2017
  3235                              <1> 	; 15/10/2016
  3236                              <1> 	; 20/05/2016
  3237                              <1> 	; 19/05/2016
  3238                              <1> 	; 16/05/2016
  3239                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  3240                              <1> 	; 21/09/2015
  3241                              <1> 	; 01/07/2015
  3242                              <1> 	; 16/04/2015 (32 bit address modification) 
  3243 0000D834 [A81A0100]          <1> 	dd sysver	; 0 ; Get TRDOS 386 version number (v2.0)	
  3244 0000D838 [93DA0000]          <1> 	dd sysexit 	; 1
  3245 0000D83C [68DC0000]          <1> 	dd sysfork 	; 2
  3246 0000D840 [9BE00000]          <1> 	dd sysread 	; 3
  3247 0000D844 [BAE00000]          <1> 	dd syswrite 	; 4
  3248 0000D848 [51DE0000]          <1> 	dd sysopen 	; 5
  3249 0000D84C [72E00000]          <1> 	dd sysclose 	; 6
  3250 0000D850 [EADB0000]          <1> 	dd syswait 	; 7
  3251 0000D854 [80DD0000]          <1> 	dd syscreat 	; 8
  3252 0000D858 [FC280100]          <1> 	dd sysrename	; 9  ; TRDOS 386, Rename File (31/12/2017)
  3253 0000D85C [77240100]          <1> 	dd sysdelete	; 10 ; TRDOS 386, Delete File (29/12/2017)
  3254 0000D860 [450E0100]          <1> 	dd sysexec 	; 11
  3255 0000D864 [A1250100]          <1> 	dd syschdir 	; 12
  3256 0000D868 [66270100]          <1> 	dd systime 	; 13 ; TRDOS 386, Get Sys Date&Time (30/12/2017)
  3257 0000D86C [34E00000]          <1> 	dd sysmkdir 	; 14
  3258 0000D870 [D5250100]          <1> 	dd syschmod 	; 15 ; TRDOS 386, Change Attributes (30/12/2017) 
  3259 0000D874 [DE240100]          <1> 	dd sysrmdir 	; 16 ; TRDOS 386, Remove Directory (29/12/2017)
  3260 0000D878 [20110100]          <1> 	dd sysbreak 	; 17
  3261 0000D87C [BB260100]          <1> 	dd sysdrive 	; 18 ; TRDOS 386, Get/Set Current Drv (30/12/2017) 
  3262 0000D880 [61110100]          <1> 	dd sysseek 	; 19
  3263 0000D884 [73110100]          <1> 	dd systell 	; 20
  3264 0000D888 [1D2A0100]          <1> 	dd sysmem 	; 21 ; TRDOS 386, Get Total&Free Mem (31/12/2017)
  3265 0000D88C [532A0100]          <1> 	dd sysprompt 	; 22 ; TRDOS 386, Change Cmd Prompt (31/12/2017)
  3266 0000D890 [952A0100]          <1> 	dd syspath 	; 23 ; TRDOS 386, Get/Set Run Path (31/12/2017)
  3267 0000D894 [022B0100]          <1> 	dd sysenv 	; 24 ; TRDOS 386, Get/Set Env Vars (31/12/2017)
  3268 0000D898 [E7270100]          <1> 	dd sysstime 	; 25 ; TRDOS 386, Set Sys Date&Time (30/12/2017)
  3269 0000D89C [D9110100]          <1> 	dd sysquit 	; 26
  3270 0000D8A0 [CD110100]          <1> 	dd sysintr 	; 27
  3271 0000D8A4 [0A270100]          <1> 	dd sysdir 	; 28 ; TRDOS 386, Get Curr Drive&Dir (30/12/2017) 
  3272 0000D8A8 [51E10000]          <1> 	dd sysemt 	; 29
  3273 0000D8AC [45270100]          <1> 	dd sysldrvt	; 30 ; TRDOS 386, Get Logical DOS DDT (30/12/2017)
  3274 0000D8B0 [02E30000]          <1> 	dd sysvideo 	; 31 ; TRDOS 386 Video Functions (16/05/2016)
  3275 0000D8B4 [CC340100]          <1> 	dd sysaudio 	; 32 ; TRDOS 386 Audio Functions (16/05/2016)
  3276 0000D8B8 [6AE10000]          <1> 	dd systimer 	; 33 ; TRDOS 386 Timer Functions (18/05/2016)
  3277 0000D8BC [1A120100]          <1> 	dd syssleep 	; 34 ; Retro UNIX 8086 v1 feature only !
  3278                              <1> 			     ; 11/06/2014
  3279 0000D8C0 [49120100]          <1> 	dd sysmsg	; 35 ; Retro UNIX 386 v1 feature only !
  3280                              <1> 			     ; 01/07/2015
  3281 0000D8C4 [66130100]          <1> 	dd sysgeterr	; 36 ; Retro UNIX 386 v1 feature only !
  3282                              <1> 			     ; 21/09/2015 - get last error number
  3283 0000D8C8 [4E240100]          <1> 	dd sysfpstat	; 37 ; TRDOS 386 FPU state option (28/02/2017)
  3284 0000D8CC [B71A0100]          <1> 	dd syspri 	; 38 ; change priority - TRDOS 386 (20/05/2016)
  3285 0000D8D0 [A6D90000]          <1> 	dd sysrele	; 39 ; TRDOS 386 (19/05/2016) (0 -> 39)
  3286 0000D8D4 [EA1B0100]          <1> 	dd sysfff	; 40 ; Find First File - TRDOS 386 (15/10/2016)
  3287 0000D8D8 [C91C0100]          <1> 	dd sysfnf	; 41 ; Find Next File - TRDOS 386 (15/10/2016)
  3288 0000D8DC [39230100]          <1> 	dd sysalloc	; 42 ; Allocate contiguous memory block/pages
  3289                              <1> 			     ; TRDOS 386 (19/02/2017) DMA buff fuctions		
  3290 0000D8E0 [F7230100]          <1> 	dd sysdalloc	; 43 ; Deallocate contiguous memory block/pages
  3291                              <1> 			     ; TRDOS 386 (19/02/2017) DMA buff fuctions
  3292 0000D8E4 [32240100]          <1> 	dd syscalbac	; 44 ; IRQ Callback and Signal Response Byte
  3293                              <1> 			     ; service setup - TRDOS 386 (20/02/2017)
  3294                              <1> 			     ; 28/08/2017 (20/08/2017)	
  3295 0000D8E8 [5D3D0100]          <1> 	dd sysdma	; 45 ; TRDOS 386 - (ISA) DMA service
  3296                              <1> 	
  3297                              <1> end_of_syscalls:
  3298                              <1> 
  3299                              <1> error:
  3300                              <1> 	; 18/05/2016
  3301                              <1> 	; 13/05/2016
  3302                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  3303                              <1> 	; 16/04/2015 - 17/09/2015 (Retro UNIX 386 v1)
  3304                              <1> 	; 10/04/2013 - 07/08/2013 (Retro UNIX 8086 v1)
  3305                              <1> 	;
  3306                              <1> 	; 'error' merely sets the error bit off the processor status (c-bit)
  3307                              <1> 	; then falls right into the 'sysret', 'sysrele' return sequence.
  3308                              <1> 	;
  3309                              <1> 	; INPUTS -> none
  3310                              <1> 	; OUTPUTS ->
  3311                              <1> 	;	processor status - carry (c) bit is set (means error)
  3312                              <1> 	;
  3313                              <1> 	; 26/05/2013 (Stack pointer must be reset here! 
  3314                              <1> 	; 	      Because, jumps to error procedure
  3315                              <1> 	;	      disrupts push-pop nesting balance)
  3316                              <1> 	;
  3317 0000D8EC 8B2D[5C030300]      <1> 	mov	ebp, [u.sp] ; interrupt (system call) return (iretd) address
  3318 0000D8F2 804D0801            <1> 	or	byte [ebp+8], 1  ; set carry bit of flags register
  3319                              <1> 				 ; (system call will return with cf = 1)
  3320                              <1> 		; bis $1,20.(r1) / set c bit in processor status word below
  3321                              <1> 		               ; / users stack
  3322                              <1> 	; 17/09/2015
  3323 0000D8F6 83ED30              <1> 	sub	ebp, ESPACE ; 48 ; total size of stack frame ('sysdefs.inc')
  3324                              <1> 				 ; for saving/restoring user registers	
  3325                              <1> 	;cmp	ebp, [u.usp]
  3326                              <1> 	;je	short err0	
  3327 0000D8F9 892D[60030300]      <1> 	mov	[u.usp], ebp
  3328                              <1> ;err0:
  3329                              <1> 	; 01/09/2015
  3330 0000D8FF 8B25[60030300]      <1> 	mov	esp, [u.usp] 	    ; Retro Unix 8086 v1 modification!
  3331                              <1> 				    ; 10/04/2013
  3332                              <1> 				    ; (If an I/O error occurs during disk I/O,
  3333                              <1> 				    ; related procedures will jump to 'error'
  3334                              <1> 				    ; procedure directly without returning to 
  3335                              <1> 				    ; the caller procedure. So, stack pointer
  3336                              <1>                                     ; must be restored here.)
  3337                              <1> 	; 13/05/2016
  3338                              <1> 	; NOTE: (The last) error code is in 'u.error', it can be retrieved by
  3339                              <1> 	;	'get last error' system call later. 	
  3340                              <1> 
  3341                              <1> 	; 03/09/2015 - 09/06/2015 - 07/08/2013
  3342 0000D905 C605[C6030300]00    <1> 	mov 	byte [u.kcall], 0 ; namei_r, mkdir_w reset
  3343                              <1> 
  3344                              <1> sysret: ; < return from system call>
  3345                              <1> 	; 01/03/2017
  3346                              <1> 	; 28/02/2017
  3347                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  3348                              <1> 	; 16/04/2015 - 10/09/2015 (Retro UNIX 386 v1)
  3349                              <1> 	; 10/04/2013 - 23/02/2014 (Retro UNIX 8086 v1)
  3350                              <1> 	;
  3351                              <1> 	; 'sysret' first checks to see if process is about to be 
  3352                              <1> 	; terminated (u.bsys). If it is, 'sysexit' is called.
  3353                              <1> 	; If not, following happens:	 
  3354                              <1> 	; 	1) The user's stack pointer is restored.
  3355                              <1> 	;	2) r1=0 and 'iget' is called to see if last mentioned
  3356                              <1> 	;	   i-node has been modified. If it has, it is written out
  3357                              <1> 	;	   via 'ppoke'.
  3358                              <1> 	;	3) If the super block has been modified, it is written out
  3359                              <1> 	;	   via 'ppoke'.				
  3360                              <1> 	;	4) If the dismountable file system's super block has been
  3361                              <1> 	;	   modified, it is written out to the specified device
  3362                              <1> 	;	   via 'ppoke'.
  3363                              <1> 	;	5) A check is made if user's time quantum (uquant) ran out
  3364                              <1> 	;	   during his execution. If so, 'tswap' is called to give
  3365                              <1> 	;	   another user a chance to run.
  3366                              <1> 	;	6) 'sysret' now goes into 'sysrele'. 
  3367                              <1> 	;	    (See 'sysrele' for conclusion.)		
  3368                              <1> 	;
  3369                              <1> 	; Calling sequence:
  3370                              <1> 	;	jump table or 'br sysret'
  3371                              <1> 	; Arguments: 
  3372                              <1> 	;	-	
  3373                              <1> 	; ...............................................................
  3374                              <1> 	;	
  3375                              <1> 	; ((AX=r1 for 'iget' input))
  3376                              <1> 	;	
  3377 0000D90C 31C0                <1> 	xor	eax, eax ; 28/02/2017
  3378                              <1> sysret0: ; 29/07/2015 (eax = 0, jump from sysexec)
  3379 0000D90E FEC0                <1> 	inc	al ; 04/05/2013
  3380 0000D910 3805[B2030300]      <1> 	cmp	[u.bsys], al ; 1
  3381                              <1> 		; tstb u.bsys / is a process about to be terminated because
  3382 0000D916 0F8377010000        <1>         jnb     sysexit ; 04/05/2013
  3383                              <1> 		; bne sysexit / of an error? yes, go to sysexit
  3384                              <1> 	;mov	esp, [u.usp] ; 24/05/2013 (that is not needed here)
  3385                              <1> 		; mov u.sp,sp / no point stack to users stack
  3386 0000D91C FEC8                <1> 	dec 	al ; mov ax, 0
  3387                              <1> 		; clr r1 / zero r1 to check last mentioned i-node
  3388 0000D91E E88A520000          <1> 	call	iget
  3389                              <1> 		; jsr r0,iget / if last mentioned i-node has been modified
  3390                              <1> 		            ; / it is written out
  3391                              <1> 	; 10/01/2017
  3392                              <1> 	; 09/01/2017
  3393                              <1> ;sysrele: ; < release >
  3394                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  3395                              <1> 	; 16/04/2015 - 14/10/2015 (Retro UNIX 386 v1)
  3396                              <1> 	; 10/04/2013 - 07/03/2014 (Retro UNIX 8086 v1)
  3397                              <1> 	;
  3398                              <1> 	; 'sysrele' first calls 'tswap' if the time quantum for a user is
  3399                              <1> 	;  zero (see 'sysret'). It then restores the user's registers and
  3400                              <1> 	; turns off the system flag. It then checked to see if there is
  3401                              <1> 	; an interrupt from the user by calling 'isintr'. If there is, 
  3402                              <1> 	; the output gets flashed (see isintr) and interrupt action is
  3403                              <1> 	; taken by a branch to 'intract'. If there is no interrupt from
  3404                              <1> 	; the user, a rti is made.
  3405                              <1> 	;
  3406                              <1> 	; Calling sequence:
  3407                              <1> 	;	Fall through a 'bne' in 'sysret' & ?
  3408                              <1> 	; Arguments:
  3409                              <1> 	;	-	
  3410                              <1> 	; ...............................................................
  3411                              <1> 	;	
  3412                              <1> 	; 23/02/2014 (swapret)
  3413                              <1> 	; 22/09/2013
  3414                              <1> sysrel0: ;1:
  3415 0000D923 803D[A8030300]00    <1> 	cmp	byte [u.quant], 0 ; 16/05/2013
  3416                              <1> 		; tstb uquant / is the time quantum 0?
  3417 0000D92A 7705                <1>         ja      short swapret
  3418                              <1> 		; bne 1f / no, don't swap it out
  3419                              <1> sysrelease: ; 07/12/2013 (jump from 'clock')
  3420 0000D92C E83F400000          <1> 	call	tswap
  3421                              <1> 		; jsr r0,tswap / yes, swap it out
  3422                              <1> 	
  3423                              <1> ; Retro Unix 8086 v1 feature: return from 'swap' to 'swapret' address.
  3424                              <1> swapret: ;1:
  3425                              <1> 	; 10/09/2015
  3426                              <1> 	; 01/09/2015
  3427                              <1> 	; 14/05/2015
  3428                              <1> 	; 16/04/2015 (Retro UNIX 386 v1 - 32 bit, pm modifications)
  3429                              <1> 	; 26/05/2013 (Retro UNIX 8086 v1)
  3430                              <1> 	; cli
  3431                              <1> 	; 24/07/2015
  3432                              <1> 	;
  3433                              <1> 	;; 'esp' must be already equal to '[u.usp]' here ! 
  3434                              <1> 	;; mov	esp, [u.usp]
  3435                              <1> 
  3436                              <1> 	; 22/09/2013
  3437 0000D931 E877520000          <1> 	call	isintr
  3438                              <1> 	; 20/10/2013
  3439 0000D936 7405                <1> 	jz	short sysrel1
  3440 0000D938 E83F010000          <1> 	call	intract
  3441                              <1> 		; jsr r0,isintr / is there an interrupt from the user
  3442                              <1> 		;     br intract / yes, output gets flushed, take interrupt
  3443                              <1> 		               ; / action
  3444                              <1> sysrel1:
  3445 0000D93D FA                  <1> 	cli	; 14/10/2015
  3446                              <1> sysrel2:
  3447                              <1> 	; 28/02/2017
  3448                              <1> 	; Check if there is a (delayed) callback for current user/process
  3449 0000D93E A0[D7030300]        <1> 	mov	al, [u.irqwait]
  3450 0000D943 240F                <1> 	and	al, 0Fh ; is there a waiting IRQ callback service ?
  3451 0000D945 7444                <1> 	jz	short sysrel8 ; no
  3452                              <1> 
  3453                              <1> 	; Set return to IRQ callback service and return from the service
  3454 0000D947 0FB6D8              <1> 	movzx	ebx, al
  3455 0000D94A 883D[D7030300]      <1> 	mov 	[u.irqwait], bh ; 0 ; reset
  3456 0000D950 8A9B[F8490100]      <1> 	mov	bl, [ebx+IRQenum] ; (available) IRQ index +1 (1 to 9)
  3457                              <1> 	; 01/03/2017
  3458 0000D956 FECB                <1> 	dec	bl ; IRQ index number, 0 to 8
  3459 0000D958 7831                <1> 	js	short sysrel8 ; 0 -> FFh (not in use!?) 
  3460                              <1> 	;
  3461 0000D95A A0[B3030300]        <1> 	mov 	al, [u.uno] ; current process (user) number 
  3462 0000D95F 3883[629C0100]      <1> 	cmp	[ebx+IRQ.owner], al
  3463 0000D965 7524                <1> 	jne	short sysrel8 ; it is not the current user/process !?
  3464 0000D967 F683[749C0100]01    <1> 	test	byte [ebx+IRQ.method], 1 ; callback ?
  3465 0000D96E 741B                <1> 	jz	short sysrel8 ; not a callback method !?
  3466                              <1> 
  3467 0000D970 8B93[869C0100]      <1> 	mov	edx, [ebx+IRQ.addr] ; IRQ callback service address (virtual)
  3468 0000D976 C605[D8030300]01    <1> 	mov	byte [u.r_lock], 1 ; IRQ callback service in progress flag
  3469                              <1> 
  3470 0000D97D E896400000          <1> 	call	wswap ; save user's registers & status 
  3471                              <1> 		      ;	(for return from IRQ callback service)
  3472                              <1> 
  3473 0000D982 8B2D[5C030300]      <1> 	mov	ebp, [u.sp]; kernel's stack, points to EIP (user)
  3474 0000D988 895500              <1> 	mov	[ebp], edx ; IRQ call back service address
  3475                              <1> sysrel8:
  3476 0000D98B FE0D[5B030300]      <1> 	dec	byte [sysflg]
  3477                              <1> 		; decb sysflg / turn system flag off
  3478                              <1> 	
  3479 0000D991 A1[B8030300]        <1> 	mov	eax, [u.pgdir]	
  3480 0000D996 0F22D8              <1> 	mov	cr3, eax  ; 1st PDE points to Kernel Page Table 0 (1st 4 MB)
  3481                              <1> 			  ; (others are different than kernel page tables) 
  3482                              <1> 	; 10/09/2015
  3483 0000D999 61                  <1> 	popad ; edi, esi, ebp, temp (icrement esp by 4), ebx, edx, ecx, eax
  3484                              <1> 		; mov (sp)+,sc / restore user registers
  3485                              <1> 		; mov (sp)+,mq
  3486                              <1> 		; mov (sp)+,ac
  3487                              <1> 		; mov (sp)+,r5
  3488                              <1> 		; mov (sp)+,r4
  3489                              <1> 		; mov (sp)+,r3
  3490                              <1> 		; mov (sp)+,r2
  3491                              <1> 	;
  3492 0000D99A A1[64030300]        <1> 	mov	eax, [u.r0]  ; ((return value in EAX))
  3493 0000D99F 0FA9                <1> 	pop	gs
  3494 0000D9A1 0FA1                <1> 	pop	fs
  3495 0000D9A3 07                  <1> 	pop	es
  3496 0000D9A4 1F                  <1> 	pop	ds
  3497                              <1> 	;or	word [esp+8], 200h ; 22/01/2017 ; force enabling interrupts
  3498 0000D9A5 CF                  <1> 	iretd	
  3499                              <1> 		; rti / no, return from interrupt
  3500                              <1> 
  3501                              <1> sysrele:
  3502                              <1> 	; 24/03/2017
  3503                              <1> 	; 28/02/2017
  3504                              <1> 	; 27/02/2017
  3505                              <1> 	; 29/01/2017
  3506                              <1> 	; 14/01/2017
  3507                              <1> 	; 13/01/2017
  3508                              <1> 	; 09/01/2017, 10/01/2017, 12/01/2017
  3509                              <1> 	; Major modification for TRDOS 386 (CallBack return)
  3510                              <1> 	;
  3511                              <1> 	; 'sysrele' system call restores previously saved
  3512                              <1> 	; registers and addresses of the process
  3513                              <1> 	; (Main purpose -in TRDOS 386- is to return from
  3514                              <1> 	; timer callback service routine in ring 3 -user mode-.)
  3515                              <1> 	;
  3516                              <1> 	; check if the process is in timer callback phase
  3517 0000D9A6 803D[D4030300]00    <1> 	cmp	byte [u.t_lock], 0 ; TIMER INT LOCK
  3518                              <1> 	;je	short sysrel0 ; classic (Retro UNIX 386 type) sysrele
  3519 0000D9AD 7734                <1> 	ja	short sysrel3
  3520                              <1> 	; 27/02/2017
  3521 0000D9AF 803D[D8030300]00    <1> 	cmp	byte [u.r_lock], 0 ; IRQ callback lock	
  3522 0000D9B6 0F8667FFFFFF        <1> 	jna	sysrel0 ; classic sysrele ; 24/03/2017
  3523 0000D9BC E859000000          <1> 	call	sysrel7
  3524 0000D9C1 803D[D8030300]00    <1> 	cmp	byte [u.r_lock], 0 ; IRQ callback service lock
  3525 0000D9C8 7628                <1> 	jna	short sysrel4
  3526 0000D9CA C605[D8030300]00    <1> 	mov	byte [u.r_lock], 0 ; reset
  3527                              <1> 	;mov	byte [u.irqwait], 0 ; reset ; 28/02/2017
  3528 0000D9D1 A0[D9030300]        <1> 	mov	al, [u.r_mode]
  3529 0000D9D6 08C0                <1> 	or	al, al
  3530 0000D9D8 7518                <1> 	jnz	short sysrel4
  3531 0000D9DA FEC8                <1> 	dec	al
  3532 0000D9DC A2[D9030300]        <1> 	mov	[u.r_mode], al ; 0FFh ; not necessary !?
  3533 0000D9E1 EB32                <1> 	jmp	short sysrel6		
  3534                              <1> sysrel3:
  3535                              <1> 	; 27/02/2017
  3536 0000D9E3 E832000000          <1> 	call	sysrel7
  3537                              <1> 	; 14/01/2017
  3538 0000D9E8 28C0                <1> 	sub	al, al
  3539 0000D9EA 3805[D4030300]      <1> 	cmp	[u.t_lock], al ; 0 ; TIMER INT LOCK
  3540 0000D9F0 770E                <1> 	ja	short sysrel5 ; yes
  3541                              <1> sysrel4:
  3542                              <1> 	; 29/01/2017
  3543 0000D9F2 8B44241C            <1> 	mov	eax, [esp+28] ; eax
  3544 0000D9F6 A3[64030300]        <1> 	mov	[u.r0], eax
  3545 0000D9FB E93EFFFFFF          <1> 	jmp	sysrel2
  3546                              <1> sysrel5:
  3547 0000DA00 A2[D4030300]        <1> 	mov	[u.t_lock], al ; 0 ; reset
  3548 0000DA05 A0[D5030300]        <1> 	mov	al, [u.t_mode]
  3549 0000DA0A 20C0                <1> 	and	al, al
  3550                              <1> 	;jnz	short sysrel2 ; 0FFh ; user mode
  3551 0000DA0C 75E4                <1> 	jnz	short sysrel4 ; 29/01/2017
  3552 0000DA0E FEC8                <1> 	dec	al
  3553 0000DA10 A2[D5030300]        <1> 	mov	[u.t_mode], al ; 0FFh ; not necessary !?
  3554                              <1> sysrel6:
  3555                              <1> 	; cpu will continue from the interrupted sytem call addr
  3556 0000DA15 61                  <1> 	popad		; edi, esi, ebp, esp, ebx, edx, ecx, eax
  3557 0000DA16 83C410              <1> 	add	esp, 16	; pass segment segisters: ds, es, fs, gs		
  3558 0000DA19 CF                  <1> 	iretd		; eip, cs, eflags
  3559                              <1> 
  3560                              <1> sysrel7:
  3561 0000DA1A 0FB61D[B3030300]    <1> 	movzx	ebx, byte [u.uno] ; current process number
  3562 0000DA21 66C1E302            <1> 	shl	bx, 2
  3563                              <1> 	;cmp	[ebx+p.tcb-4], eax ; 0 ; is there callback address ?
  3564                              <1> 	;jna	short sysrel0 
  3565                              <1> 	; yes, reset callback address then restore process registers 
  3566                              <1> 	;mov	[ebx+p.tcb-4], eax ; 0 ; reset
  3567 0000DA25 8B83[BC000300]      <1> 	mov     eax, [ebx+p.upage-4] ; UPAGE address
  3568 0000DA2B FA                  <1> 	cli	; disable interrupts till 'iretd'
  3569 0000DA2C E91F400000          <1> 	jmp	rswap ; restore process 'u' structure
  3570                              <1>  
  3571                              <1> badsys:
  3572                              <1> 	; 25/12/2016
  3573                              <1> 	; 18/04/2016 (TRDOS 386 = TRDOS v2.0)
  3574                              <1> 	; 17/04/2011 (TRDOS v1.0, 'IFC.ASM')
  3575                              <1> 	; 03/02/2011 ('trdos_ifc_routine')
  3576                              <1> 	;
  3577                              <1> 	; 16/04/2015 (Retro UNIX 386 v1, 'badsys')
  3578                              <1> 	; (EIP, EAX values will be shown on screen with error message)
  3579                              <1> 	; (EIP = 'CD 40h' instruction address -INT 40h-)
  3580                              <1> 	; (EAX = Function number)  
  3581                              <1> 	;
  3582 0000DA31 FE05[B2030300]      <1> 	inc	byte [u.bsys]
  3583                              <1> 	;
  3584 0000DA37 8B1D[5C030300]      <1> 	mov	ebx, [u.sp] ; esp at the beginning of 'sysent'
  3585 0000DA3D 8B03                <1> 	mov	eax, [ebx] ; EIP (return address, not 'INT 30h' address)
  3586 0000DA3F 83E802              <1> 	sub	eax, 2 ; CDh, ##h
  3587 0000DA42 E8CE68FFFF          <1> 	call	dwordtohex
  3588 0000DA47 8915[D1470100]      <1> 	mov	[eip_str], edx
  3589 0000DA4D A3[D5470100]        <1> 	mov	[eip_str+4], eax
  3590 0000DA52 A1[64030300]        <1> 	mov	eax, [u.r0]
  3591 0000DA57 E8B968FFFF          <1> 	call	dwordtohex
  3592 0000DA5C 8915[C0470100]      <1> 	mov	[eax_str], edx
  3593 0000DA62 A3[C4470100]        <1> 	mov	[eax_str+4], eax
  3594                              <1> 
  3595 0000DA67 66C705[B5470100]34- <1> 	mov	word [int_num_str], SYSCALL_INT_NUM ; 25/12/2016
  3595 0000DA6F 30                  <1>
  3596                              <1> 
  3597 0000DA70 BE[87470100]        <1> 	mov	esi, ifc_msg ; "invalid funtion call !" msg (trdosk9.s)
  3598 0000DA75 E8EB9AFFFF          <1> 	call	print_msg
  3599                              <1> 
  3600 0000DA7A EB17                <1> 	jmp	sysexit
  3601                              <1> 
  3602                              <1> intract: ; / interrupt action
  3603                              <1> 	; 14/10/2015
  3604                              <1> 	; 16/04/2015 (Retro UNIX 386 v1 - Beginning)
  3605                              <1> 	; 09/05/2013 - 07/12/2013 (Retro UNIX 8086 v1)
  3606                              <1> 	;
  3607                              <1> 	; Retro UNIX 8086 v1 modification !
  3608                              <1> 	; (Process/task switching and quit routine by using
  3609                              <1> 	; Retro UNIX 8086 v1 keyboard interrupt output.))
  3610                              <1> 	;
  3611                              <1> 	; input -> 'u.quit'  (also value of 'u.intr' > 0)
  3612                              <1> 	; output -> If value of 'u.quit' = FFFFh ('ctrl+brk' sign)
  3613                              <1> 	;		'intract' will jump to 'sysexit'.
  3614                              <1> 	;	    Intract will return to the caller 
  3615                              <1> 	;		if value of 'u.quit' <> FFFFh. 	 
  3616                              <1> 	; 14/10/2015
  3617 0000DA7C FB                  <1> 	sti
  3618                              <1> 	; 07/12/2013	
  3619 0000DA7D 66FF05[AC030300]    <1> 	inc 	word [u.quit]
  3620 0000DA84 7408                <1> 	jz	short intrct0 ; FFFFh -> 0
  3621 0000DA86 66FF0D[AC030300]    <1> 	dec	word [u.quit]
  3622                              <1> 	; 16/04/2015
  3623 0000DA8D C3                  <1> 	retn
  3624                              <1> intrct0:	
  3625 0000DA8E 58                  <1> 	pop	eax ; call intract -> retn
  3626                              <1> 	;
  3627 0000DA8F 31C0                <1> 	xor 	eax, eax
  3628 0000DA91 FEC0                <1> 	inc	al  ; mov ax, 1
  3629                              <1> ;;;
  3630                              <1> 	; UNIX v1 original 'intract' routine... 
  3631                              <1> 	; / interrupt action
  3632                              <1> 		;cmp *(sp),$rti / are you in a clock interrupt?
  3633                              <1> 		; bne 1f / no, 1f
  3634                              <1> 		; cmp (sp)+,(sp)+ / pop clock pointer
  3635                              <1> 	; 1: / now in user area
  3636                              <1> 		; mov r1,-(sp) / save r1
  3637                              <1> 		; mov u.ttyp,r1 
  3638                              <1> 			; / pointer to tty buffer in control-to r1
  3639                              <1> 		; cmpb 6(r1),$177
  3640                              <1> 			; / is the interrupt char equal to "del"
  3641                              <1> 		; beq 1f / yes, 1f
  3642                              <1> 		; clrb 6(r1) 
  3643                              <1> 		        ; / no, clear the byte 
  3644                              <1> 			; / (must be a quit character)
  3645                              <1> 		; mov (sp)+,r1 / restore r1
  3646                              <1> 		; clr u.quit / clear quit flag
  3647                              <1> 		; bis $20,2(sp) 
  3648                              <1> 		    	; / set trace for quit (sets t bit of 
  3649                              <1> 			; / ps-trace trap)
  3650                              <1> 		; rti   ;  / return from interrupt
  3651                              <1> 	; 1: / interrupt char = del
  3652                              <1> 		; clrb 6(r1) / clear the interrupt byte 
  3653                              <1> 			   ; / in the buffer
  3654                              <1> 		; mov (sp)+,r1 / restore r1
  3655                              <1> 		; cmp u.intr,$core / should control be 
  3656                              <1> 				; / transferred to loc core?
  3657                              <1> 		; blo 1f
  3658                              <1> 		; jmp *u.intr / user to do rti yes, 
  3659                              <1> 				; / transfer to loc core
  3660                              <1> 	; 1:
  3661                              <1> 		; sys 1 / exit
  3662                              <1> 
  3663                              <1> sysexit: ; <terminate process>
  3664                              <1> 	; 14/11/2017
  3665                              <1> 	; 27/05/2017
  3666                              <1> 	; 10/04/2017
  3667                              <1> 	; 26/02/2017, 28/02/2017
  3668                              <1> 	; 02/01/2017, 23/01/2017
  3669                              <1> 	; 06/06/2016, 10/06/2016
  3670                              <1> 	; 19/05/2016, 23/05/2016
  3671                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  3672                              <1> 	; 16/04/2015 - 01/09/2015 (Retro UNIX 386 v1)
  3673                              <1> 	; 19/04/2013 - 14/02/2014 (Retro UNIX 8086 v1)
  3674                              <1> 	;
  3675                              <1> 	; 'sysexit' terminates a process. First each file that
  3676                              <1> 	; the process has opened is closed by 'flose'. The process
  3677                              <1> 	; status is then set to unused. The 'p.pid' table is then
  3678                              <1> 	; searched to find children of the dying process. If any of
  3679                              <1> 	; children are zombies (died by not waited for), they are
  3680                              <1> 	; set free. The 'p.pid' table is then searched to find the
  3681                              <1> 	; dying process's parent. When the parent is found, it is
  3682                              <1> 	; checked to see if it is free or it is a zombie. If it is
  3683                              <1> 	; one of these, the dying process just dies. If it is waiting
  3684                              <1> 	; for a child process to die, it notified that it doesn't 
  3685                              <1> 	; have to wait anymore by setting it's status from 2 to 1
  3686                              <1> 	; (waiting to active). It is awakened and put on runq by
  3687                              <1> 	; 'putlu'. The dying process enters a zombie state in which
  3688                              <1> 	; it will never be run again but stays around until a 'wait'
  3689                              <1> 	; is completed by it's parent process. If the parent is not
  3690                              <1> 	; found, process just dies. This means 'swap' is called with
  3691                              <1> 	; 'u.uno=0'. What this does is the 'wswap' is not called
  3692                              <1> 	; to write out the process and 'rswap' reads the new process
  3693                              <1> 	; over the one that dies..i.e., the dying process is 
  3694                              <1> 	; overwritten and destroyed.	
  3695                              <1>  	;
  3696                              <1> 	; Calling sequence:
  3697                              <1> 	;	sysexit or conditional branch.
  3698                              <1> 	; Arguments:
  3699                              <1> 	;	-	
  3700                              <1> 	; ...............................................................
  3701                              <1> 	;	
  3702                              <1> 	; Retro UNIX 8086 v1 modification: 
  3703                              <1> 	;       System call number (=1) is in EAX register.
  3704                              <1> 	;
  3705                              <1> 	;       Other parameters are in EDX, EBX, ECX, ESI, EDI, EBP
  3706                              <1> 	;       registers depending of function details.
  3707                              <1> 	;
  3708                              <1> 	; ('swap' procedure is mostly different than original UNIX v1.)
  3709                              <1> 	;
  3710                              <1> ; / terminate process
  3711                              <1> 	; AX = 1
  3712 0000DA93 6648                <1> 	dec 	ax ; 0
  3713 0000DA95 66A3[AA030300]      <1> 	mov	[u.intr], ax ; 0
  3714                              <1> 		; clr u.intr / clear interrupt control word
  3715                              <1> 		; clr r1 / clear r1
  3716                              <1> sysexit_0:
  3717                              <1> 	; 23/01/2017
  3718                              <1> 	; 02/01/2017
  3719                              <1> 	; 10/06/2016
  3720                              <1> 	; 06/06/2016
  3721                              <1> 	; 23/05/2016
  3722                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
  3723                              <1> 	; Check and stop/clear timer event(s) of this (dying) process
  3724                              <1> 	; if there is.
  3725                              <1> 
  3726                              <1> 	; 02/01/2017 
  3727 0000DA9B FA                  <1> 	cli	; disable interrupts
  3728                              <1> 	; 23/01/2017 - reset timer frequency (to 18.2Hz)
  3729 0000DA9C B036                <1> 	mov	al, 00110110b ; 36h
  3730 0000DA9E E643                <1>  	out	43h, al
  3731 0000DAA0 28C0                <1> 	sub	al, al ; 0
  3732 0000DAA2 E640                <1> 	out	40h, al ; LB
  3733 0000DAA4 E640                <1> 	out	40h, al ; HB
  3734                              <1>  	; 
  3735 0000DAA6 0FB61D[B3030300]    <1> 	movzx	ebx, byte [u.uno]
  3736                              <1> 	;mov	bl, [u.uno] ; process number of dying process
  3737 0000DAAD 3883[FF000300]      <1> 	cmp	byte [ebx+p.timer-1], al ; 0
  3738 0000DAB3 763A                <1> 	jna	short sysexit_12 ; no timer events for this process
  3739 0000DAB5 8883[FF000300]      <1> 	mov	byte [ebx+p.timer-1], al ; 0 ; reset
  3740                              <1> 	;mov	al, [timer_events]
  3741                              <1> 	;or	al, al
  3742                              <1>  	;jz	short sysexit_12 ; no timer events
  3743                              <1> 	;mov	cl, al
  3744 0000DABB 8A0D[C3960100]      <1> 	mov	cl, [timer_events] ; 14/11/2017
  3745                              <1> 	;cli	; disable interrupts 
  3746 0000DAC1 B410                <1> 	mov	ah, 16 ; number of available timer events
  3747 0000DAC3 BE[60040300]        <1> 	mov	esi, timer_set ; beginning address of timer events
  3748                              <1> sysexit_7:
  3749 0000DAC8 8A06                <1> 	mov	al, [esi] ; process number (of timer event)
  3750 0000DACA 38D8                <1> 	cmp	al, bl ; process number comparison
  3751 0000DACC 7411                <1> 	je	short sysexit_10
  3752 0000DACE 20C0                <1> 	and	al, al
  3753 0000DAD0 7404                <1> 	jz	short sysexit_9
  3754                              <1> sysexit_8:
  3755 0000DAD2 FEC9                <1> 	dec	cl
  3756 0000DAD4 7416                <1> 	jz	short sysexit_11
  3757                              <1> sysexit_9:
  3758 0000DAD6 FECC                <1> 	dec	ah
  3759 0000DAD8 7415                <1> 	jz	short sysexit_12
  3760 0000DADA 83C610              <1> 	add	esi, 16
  3761 0000DADD EBE9                <1> 	jmp	short sysexit_7
  3762                              <1> 
  3763                              <1> sysexit_10:
  3764                              <1> 	;mov	byte [esi], 0
  3765 0000DADF 66C7060000          <1> 	mov	word [esi], 0
  3766                              <1> 	;mov	dword [esi+12], 0
  3767                              <1> 	;
  3768 0000DAE4 FE0D[C3960100]      <1> 	dec	byte [timer_events] ; 02/01/2017
  3769                              <1> 	;
  3770 0000DAEA EBE6                <1> 	jmp	short sysexit_8
  3771                              <1> 
  3772                              <1> sysexit_11:
  3773 0000DAEC 6629C0              <1> 	sub	ax, ax ; 0 ; 26/02/2017
  3774                              <1> sysexit_12:
  3775                              <1> 	; 26/02/2017 (Unlink IRQ callbacks belong to the user)
  3776 0000DAEF 803D[D6030300]00    <1> 	cmp	byte [u.irqc], 0 ; Count of IRQ callbacks
  3777 0000DAF6 7E2E                <1> 	jng	short sysexit_16 ; zero or invalid
  3778                              <1> 	; 28/02/2017
  3779                              <1> 	; clear IRQ callback flags (for 'sysrele' and 'sysret')
  3780 0000DAF8 A2[D7030300]        <1> 	mov	[u.irqwait], al ; 0 ; force to clear waiting flag
  3781 0000DAFD A2[D8030300]        <1> 	mov	[u.r_lock], al ; 0 ; force to clear busy flag
  3782 0000DB02 BE[629C0100]        <1> 	mov	esi, IRQ.owner
  3783                              <1> sysexit_13:	
  3784 0000DB07 AC                  <1> 	lodsb
  3785 0000DB08 3A05[B3030300]      <1> 	cmp	al, [u.uno] ; owner = current user ?
  3786 0000DB0E 750C                <1> 	jne	short sysexit_14
  3787 0000DB10 C646FF00            <1> 	mov	byte [esi-1], 0 ; owner = 0 : Free
  3788 0000DB14 FE0D[D6030300]      <1> 	dec	byte [u.irqc]
  3789 0000DB1A 7408                <1> 	jz	short sysexit_15
  3790                              <1> sysexit_14:
  3791 0000DB1C 81FE[6A9C0100]      <1> 	cmp	esi, IRQ.owner + 8 ; the last IRQ index number ?
  3792 0000DB22 76E3                <1> 	jna	short sysexit_13 ; no
  3793                              <1> sysexit_15:
  3794 0000DB24 30C0                <1> 	xor	al, al ; 0
  3795                              <1> sysexit_16: ; 2:
  3796 0000DB26 FB                  <1> 	sti	; enable interrupts 
  3797                              <1> 	;
  3798                              <1> 	; AX = 0
  3799                              <1> sysexit_1: ; 1:
  3800                              <1> 	; AX = File descriptor
  3801                              <1> 		; / r1 has file descriptor (index to u.fp list)
  3802                              <1> 		; / Search the whole list
  3803 0000DB27 E811350000          <1> 	call	fclose
  3804                              <1> 		; jsr r0,fclose / close all files the process opened
  3805                              <1> 	;; ignore error return
  3806                              <1> 		; br .+2 / ignore error return
  3807                              <1> 	;inc	ax
  3808 0000DB2C FEC0                <1> 	inc	al
  3809                              <1> 		; inc r1 / increment file descriptor
  3810                              <1> 	;cmp	ax, 10
  3811 0000DB2E 3C0A                <1> 	cmp	al, 10
  3812                              <1> 		; cmp r1,$10. / end of u.fp list?
  3813 0000DB30 72F5                <1> 	jb	short sysexit_1
  3814                              <1> 		; blt 1b / no, go back
  3815                              <1> 	;movzx	ebx, byte [u.uno]
  3816 0000DB32 8A1D[B3030300]      <1> 	mov	bl, [u.uno] ; 02/01/2017
  3817                              <1> 		; movb	u.uno,r1 / yes, move dying process's number to r1
  3818 0000DB38 88A3[AF000300]      <1> 	mov	[ebx+p.stat-1], ah ; 0, SFREE
  3819                              <1> 		; clrb p.stat-1(r1) / free the process
  3820                              <1> 	; 10/04/2017
  3821 0000DB3E 381D[D99C0100]      <1> 	cmp	[audio_user], bl
  3822 0000DB44 7518                <1> 	jne	short sysexit_17
  3823                              <1> 	; reset audio device (current) owner and 'initializated' flag
  3824 0000DB46 883D[D99C0100]      <1> 	mov	[audio_user], bh ; 0
  3825                              <1> 	; 27/05/2017
  3826 0000DB4C 8B0D[C49C0100]      <1> 	mov	ecx,  [audio_buffer]
  3827 0000DB52 09C9                <1> 	or	ecx, ecx
  3828 0000DB54 7408                <1> 	jz	short sysexit_17
  3829                              <1> 	; 'deallocate_user_pages' is not necessary in sysexit !!!
  3830                              <1> 	;push	ebx
  3831                              <1> 	;mov	ebx, ecx
  3832                              <1> 	;mov	ecx, [audio_buff_size]
  3833                              <1> 	;call	deallocate_user_pages
  3834                              <1> 	;; (Modified Registers -> EAX, EDX, ESI, EDI, EBX, ECX, EBP)
  3835 0000DB56 29C9                <1> 	sub	ecx, ecx
  3836 0000DB58 890D[C49C0100]      <1> 	mov	[audio_buffer], ecx ; 0
  3837                              <1> 	;pop	ebx
  3838                              <1> sysexit_17:
  3839                              <1> 	;shl	bx, 1
  3840 0000DB5E D0E3                <1> 	shl	bl, 1
  3841                              <1> 		; asl r1 / use r1 for index into the below tables
  3842 0000DB60 668B8B[1E000300]    <1> 	mov	cx, [ebx+p.pid-2]
  3843                              <1> 		; mov p.pid-2(r1),r3 / move dying process's name to r3
  3844 0000DB67 668B93[3E000300]    <1> 	mov	dx, [ebx+p.ppid-2]
  3845                              <1> 		; mov p.ppid-2(r1),r4 / move its parents name to r4
  3846                              <1> 	; xor 	bx, bx ; 0
  3847 0000DB6E 30DB                <1> 	xor	bl, bl ; 0
  3848                              <1> 		; clr r2
  3849 0000DB70 31F6                <1> 	xor	esi, esi ; 0
  3850                              <1> 		; clr r5 / initialize reg
  3851                              <1> sysexit_2: ; 1:
  3852                              <1> 	        ; / find children of this dying process, 
  3853                              <1> 		; / if they are zombies, free them
  3854                              <1> 	;add	bx, 2
  3855 0000DB72 80C302              <1> 	add	bl, 2
  3856                              <1> 		; add $2,r2 / search parent process table 
  3857                              <1> 		          ; / for dying process's name
  3858 0000DB75 66398B[3E000300]    <1> 	cmp	[ebx+p.ppid-2], cx
  3859                              <1> 		; cmp p.ppid-2(r2),r3 / found it?
  3860 0000DB7C 7513                <1> 	jne	short sysexit_4
  3861                              <1> 		; bne 3f / no
  3862                              <1> 	;shr	bx, 1
  3863 0000DB7E D0EB                <1> 	shr	bl, 1
  3864                              <1> 		; asr r2 / yes, it is a parent
  3865 0000DB80 80BB[AF000300]03    <1> 	cmp	byte [ebx+p.stat-1], 3 ; SZOMB
  3866                              <1> 		; cmpb p.stat-1(r2),$3 / is the child of this 
  3867                              <1> 				     ; / dying process a zombie
  3868 0000DB87 7506                <1> 	jne	short sysexit_3 
  3869                              <1> 		; bne 2f / no
  3870 0000DB89 88A3[AF000300]      <1> 	mov	[ebx+p.stat-1], ah ; 0, SFREE
  3871                              <1> 		; clrb p.stat-1(r2) / yes, free the child process
  3872                              <1> sysexit_3: ; 2:
  3873                              <1> 	;shr	bx, 1
  3874 0000DB8F D0E3                <1> 	shl	bl, 1
  3875                              <1> 		; asl r2
  3876                              <1> sysexit_4: ; 3:
  3877                              <1> 		; / search the process name table 
  3878                              <1> 		; / for the dying process's parent
  3879 0000DB91 663993[1E000300]    <1> 	cmp	[ebx+p.pid-2], dx
  3880                              <1> 		; cmp p.pid-2(r2),r4 / found it?
  3881 0000DB98 7502                <1> 	jne	short sysexit_5
  3882                              <1> 		; bne 3f / no
  3883 0000DB9A 89DE                <1> 	mov	esi, ebx
  3884                              <1> 		; mov r2,r5 / yes, put index to p.pid table (parents
  3885                              <1> 		          ; / process # x2) in r5
  3886                              <1> sysexit_5: ; 3:
  3887                              <1> 	;cmp	bx, nproc + nproc
  3888 0000DB9C 80FB20              <1> 	cmp	bl, nproc + nproc
  3889                              <1> 		; cmp r2,$nproc+nproc / has whole table been searched?
  3890 0000DB9F 72D1                <1> 	jb	short sysexit_2
  3891                              <1> 		; blt 1b / no, go back
  3892                              <1> 		; mov r5,r1 / yes, r1 now has parents process # x2
  3893 0000DBA1 21F6                <1> 	and	esi, esi ; r5=r1
  3894 0000DBA3 7436                <1> 	jz	short sysexit_6
  3895                              <1> 		; beq 2f / no parent has been found. 
  3896                              <1> 		       ; / The process just dies
  3897 0000DBA5 66D1EE              <1> 	shr	si, 1
  3898                              <1> 		; asr r1 / set up index to p.stat
  3899 0000DBA8 8A86[AF000300]      <1> 	mov	al, [esi+p.stat-1]
  3900                              <1> 		; movb p.stat-1(r1),r2 / move status of parent to r2
  3901 0000DBAE 20C0                <1> 	and	al, al
  3902 0000DBB0 7429                <1> 	jz	short sysexit_6
  3903                              <1> 		; beq 2f / if its been freed, 2f
  3904 0000DBB2 3C03                <1> 	cmp	al, 3
  3905                              <1> 		; cmp r2,$3 / is parent a zombie?
  3906 0000DBB4 7425                <1> 	je	short sysexit_6
  3907                              <1> 		; beq 2f / yes, 2f
  3908                              <1> 	; BH = 0
  3909 0000DBB6 8A1D[B3030300]      <1> 	mov	bl, [u.uno]
  3910                              <1> 		; movb u.uno,r3 / move dying process's number to r3
  3911 0000DBBC C683[AF000300]03    <1> 	mov	byte [ebx+p.stat-1], 3  ; SZOMB
  3912                              <1> 		; movb $3,p.stat-1(r3) / make the process a zombie
  3913 0000DBC3 3C01                <1> 	cmp	al, 1 ; SRUN
  3914 0000DBC5 7414                <1> 	je	short sysexit_6
  3915                              <1> 	;cmp	al, 2
  3916                              <1> 		; cmp r2,$2 / is the parent waiting for 
  3917                              <1> 			  ; / this child to die
  3918                              <1> 	;jne	short sysexit_6	
  3919                              <1> 		; bne 2f / yes, notify parent not to wait any more
  3920                              <1> 	; p.stat = 2 --> waiting
  3921                              <1> 	; p.stat = 4 --> sleeping
  3922 0000DBC7 C686[AF000300]01    <1> 	mov	byte [esi+p.stat-1], 1 ; SRUN
  3923                              <1> 	;dec	byte [esi+p.stat-1]
  3924                              <1> 		; decb	p.stat-1(r1) / awaken it by putting it (parent)
  3925 0000DBCE 6689F0              <1> 	mov	ax, si ; r1  (process number in AL)
  3926                              <1> 	; 
  3927                              <1> 	;mov	ebx, runq + 4
  3928                              <1> 		; mov $runq+4,r2 / on the runq
  3929 0000DBD1 BB[54030300]        <1> 	mov	ebx, runq+2 ; normal run queue ; 02/01/2017
  3930 0000DBD6 E8AD3E0000          <1> 	call	putlu
  3931                              <1> 		; jsr r0, putlu
  3932                              <1> sysexit_6: 
  3933                              <1> 		; / the process dies
  3934 0000DBDB C605[B3030300]00    <1> 	mov	byte [u.uno], 0
  3935                              <1> 		; clrb u.uno / put zero as the process number, 
  3936                              <1> 	           ; / so "swap" will
  3937 0000DBE2 E8A33D0000          <1> 	call	swap
  3938                              <1> 		; jsr r0,swap / overwrite process with another process
  3939                              <1> hlt_sys:
  3940                              <1> 	;sti
  3941                              <1> hlts0:
  3942 0000DBE7 F4                  <1> 	hlt
  3943 0000DBE8 EBFD                <1> 	jmp	short hlts0
  3944                              <1> 		; 0 / and thereby kill it; halt?
  3945                              <1> 
  3946                              <1> syswait: ; < wait for a processs to die >
  3947                              <1> 	; 17/09/2015
  3948                              <1> 	; 02/09/2015
  3949                              <1> 	; 01/09/2015
  3950                              <1> 	; 16/04/2015 (Retro UNIX 386 v1 - Beginning)
  3951                              <1> 	; 24/05/2013 - 05/02/2014 (Retro UNIX 8086 v1)
  3952                              <1> 	;
  3953                              <1> 	; 'syswait' waits for a process die. 
  3954                              <1> 	; It works in following way:
  3955                              <1> 	;    1) From the parent process number, the parent's 
  3956                              <1> 	; 	process name is found. The p.ppid table of parent
  3957                              <1> 	;	names is then searched for this process name.
  3958                              <1> 	;	If a match occurs, r2 contains child's process
  3959                              <1> 	;	number. The child status is checked to see if it is
  3960                              <1> 	;	a zombie, i.e; dead but not waited for (p.stat=3)
  3961                              <1> 	;	If it is, the child process is freed and it's name
  3962                              <1> 	;	is put in (u.r0). A return is then made via 'sysret'.
  3963                              <1> 	;	If the child is not a zombie, nothing happens and
  3964                              <1> 	;	the search goes on through the p.ppid table until
  3965                              <1> 	;	all processes are checked or a zombie is found.
  3966                              <1> 	;    2) If no zombies are found, a check is made to see if
  3967                              <1> 	;	there are any children at all. If there are none,
  3968                              <1> 	;	an error return is made. If there are, the parent's
  3969                              <1> 	;	status is set to 2 (waiting for child to die),
  3970                              <1> 	;	the parent is swapped out, and a branch to 'syswait'
  3971                              <1> 	;	is made to wait on the next process.
  3972                              <1> 	;
  3973                              <1> 	; Calling sequence:
  3974                              <1> 	;	?
  3975                              <1> 	; Arguments:
  3976                              <1> 	;	-
  3977                              <1> 	; Inputs: - 
  3978                              <1> 	; Outputs: if zombie found, it's name put in u.r0.	
  3979                              <1> 	; ...............................................................
  3980                              <1> 	;				
  3981                              <1> 	
  3982                              <1> ; / wait for a process to die
  3983                              <1> 
  3984                              <1> syswait_0:
  3985 0000DBEA 0FB61D[B3030300]    <1> 	movzx	ebx, byte [u.uno] ; 01/09/2015
  3986                              <1> 		; movb u.uno,r1 / put parents process number in r1
  3987 0000DBF1 D0E3                <1> 	shl	bl, 1
  3988                              <1> 	;shl	bx, 1
  3989                              <1> 		; asl r1 / x2 to get index into p.pid table
  3990 0000DBF3 668B83[1E000300]    <1> 	mov	ax, [ebx+p.pid-2]
  3991                              <1> 		; mov p.pid-2(r1),r1 / get the name of this process
  3992 0000DBFA 31F6                <1> 	xor	esi, esi
  3993                              <1> 		; clr r2
  3994 0000DBFC 31C9                <1> 	xor	ecx, ecx ; 30/10/2013
  3995                              <1> 	;xor 	cl, cl
  3996                              <1> 		; clr r3 / initialize reg 3
  3997                              <1> syswait_1: ; 1:
  3998 0000DBFE 6683C602            <1> 	add	si, 2
  3999                              <1> 		; add $2,r2 / use r2 for index into p.ppid table
  4000                              <1> 			  ; / search table of parent processes 
  4001                              <1> 			  ; / for this process name
  4002 0000DC02 663B86[3E000300]    <1> 	cmp	ax, [esi+p.ppid-2]
  4003                              <1> 		; cmp p.ppid-2(r2),r1 / r2 will contain the childs 
  4004                              <1> 			            ; / process number
  4005 0000DC09 7535                <1> 	jne	short syswait_3
  4006                              <1> 		;bne 3f / branch if no match of parent process name
  4007                              <1> 	;inc	cx
  4008 0000DC0B FEC1                <1> 	inc	cl
  4009                              <1> 		;inc r3 / yes, a match, r3 indicates number of children
  4010 0000DC0D 66D1EE              <1> 	shr	si, 1
  4011                              <1> 		; asr r2 / r2/2 to get index to p.stat table
  4012                              <1> 	; The possible states ('p.stat' values) of a process are:
  4013                              <1> 	;	0 = free or unused
  4014                              <1> 	;	1 = active
  4015                              <1> 	;	2 = waiting for a child process to die
  4016                              <1> 	;	3 = terminated, but not yet waited for (zombie).	
  4017 0000DC10 80BE[AF000300]03    <1> 	cmp	byte [esi+p.stat-1], 3 ; SZOMB, 05/02/2014
  4018                              <1> 		; cmpb p.stat-1(r2),$3 / is the child process a zombie?
  4019 0000DC17 7524                <1> 	jne	short syswait_2
  4020                              <1> 		; bne 2f / no, skip it
  4021 0000DC19 88BE[AF000300]      <1> 	mov	[esi+p.stat-1], bh ; 0
  4022                              <1> 		; clrb p.stat-1(r2) / yes, free it
  4023 0000DC1F 66D1E6              <1> 	shl	si, 1
  4024                              <1> 		; asl r2 / r2x2 to get index into p.pid table
  4025 0000DC22 0FB786[1E000300]    <1> 	movzx	eax, word [esi+p.pid-2]
  4026 0000DC29 A3[64030300]        <1> 	mov	[u.r0], eax
  4027                              <1> 		; mov p.pid-2(r2),*u.r0 
  4028                              <1> 			      ; / put childs process name in (u.r0)
  4029                              <1> 	;
  4030                              <1> 	; Retro UNIX 386 v1 modification ! (17/09/2015)
  4031                              <1> 	;
  4032                              <1> 	; Parent process ID -p.ppid- field (of the child process)
  4033                              <1> 	; must be cleared in order to prevent infinitive 'syswait'
  4034                              <1> 	; system call loop from the application/program if it calls
  4035                              <1> 	; 'syswait' again (mistakenly) while there is not a zombie
  4036                              <1> 	; or running child process to wait. ('forktest.s', 17/09/2015)
  4037                              <1> 	;
  4038                              <1> 	; Note: syswait will return with error if there is not a
  4039                              <1> 	;       zombie or running process to wait.	
  4040                              <1> 	;
  4041 0000DC2E 6629C0              <1> 	sub	ax, ax
  4042 0000DC31 668986[3E000300]    <1> 	mov 	[esi+p.ppid-2], ax ; 0 ; 17/09/2015
  4043 0000DC38 E9D1FCFFFF          <1> 	jmp	sysret0 ; ax = 0
  4044                              <1> 	;
  4045                              <1> 	;jmp	sysret
  4046                              <1> 		; br sysret1 / return cause child is dead
  4047                              <1> syswait_2: ; 2:
  4048 0000DC3D 66D1E6              <1> 	shl	si, 1
  4049                              <1> 		; asl r2 / r2x2 to get index into p.ppid table
  4050                              <1> syswait_3: ; 3:
  4051 0000DC40 6683FE20            <1> 	cmp	si, nproc+nproc
  4052                              <1> 		; cmp r2,$nproc+nproc / have all processes been checked?
  4053 0000DC44 72B8                <1> 	jb	short syswait_1
  4054                              <1> 		; blt 1b / no, continue search
  4055                              <1> 	;and	cx, cx
  4056 0000DC46 20C9                <1> 	and	cl, cl
  4057                              <1> 		; tst r3 / one gets here if there are no children 
  4058                              <1> 		       ; / or children that are still active
  4059                              <1> 	; 30/10/2013
  4060 0000DC48 750B                <1> 	jnz	short syswait_4
  4061                              <1> 	;jz	error
  4062                              <1> 		; beq error1 / there are no children, error
  4063 0000DC4A 890D[64030300]      <1> 	mov	[u.r0], ecx ; 0
  4064 0000DC50 E997FCFFFF          <1> 	jmp	error
  4065                              <1> syswait_4:
  4066 0000DC55 8A1D[B3030300]      <1> 	mov	bl, [u.uno]
  4067                              <1> 		; movb u.uno,r1 / there are children so put 
  4068                              <1> 			      ; / parent process number in r1
  4069 0000DC5B FE83[AF000300]      <1> 	inc	byte [ebx+p.stat-1] ; 2, SWAIT, 05/02/2014
  4070                              <1> 		; incb p.stat-1(r1) / it is waiting for 
  4071                              <1> 				  ; / other children to die
  4072                              <1> 	; 04/11/2013
  4073 0000DC61 E8243D0000          <1> 	call	swap
  4074                              <1> 		; jsr r0,swap / swap it out, because it's waiting
  4075 0000DC66 EB82                <1> 	jmp	syswait_0
  4076                              <1> 		; br syswait / wait on next process
  4077                              <1> 
  4078                              <1> sysfork: ; < create a new process >
  4079                              <1> 	; 02/01/2017 (TRDOS 386 modification)
  4080                              <1> 	; 04/09/2015, 18/05/2015
  4081                              <1> 	; 28/08/2015, 01/09/2015, 02/09/2015
  4082                              <1> 	; 09/05/2015, 10/05/2015, 14/05/2015
  4083                              <1> 	; 06/05/2015 (Retro UNIX 386 v1 - Beginning)
  4084                              <1> 	; 24/05/2013 - 14/02/2014 (Retro UNIX 8086 v1)
  4085                              <1> 	;
  4086                              <1> 	; 'sysfork' creates a new process. This process is referred
  4087                              <1> 	; to as the child process. This new process core image is
  4088                              <1> 	; a copy of that of the caller of 'sysfork'. The only
  4089                              <1> 	; distinction is the return location and the fact that (u.r0)
  4090                              <1> 	; in the old process (parent) contains the process id (p.pid)
  4091                              <1> 	; of the new process (child). This id is used by 'syswait'.
  4092                              <1> 	; 'sysfork' works in the following manner: 	
  4093                              <1> 	;    1) The process status table (p.stat) is searched to find
  4094                              <1> 	;	a process number that is unused. If none are found
  4095                              <1> 	;	an error occurs.
  4096                              <1> 	;    2) when one is found, it becomes the child process number
  4097                              <1> 	;	and it's status (p.stat) is set to active.
  4098                              <1> 	;    3) If the parent had a control tty, the interrupt 
  4099                              <1> 	;	character in that tty buffer is cleared.
  4100                              <1> 	;    4) The child process is put on the lowest priority run 
  4101                              <1> 	;	queue via 'putlu'.
  4102                              <1> 	;    5) A new process name is gotten from 'mpid' (actually 
  4103                              <1> 	;	it is a unique number) and is put in the child's unique
  4104                              <1> 	;	identifier; process id (p.pid).
  4105                              <1> 	;    6) The process name of the parent is then obtained and
  4106                              <1> 	;	placed in the unique identifier of the parent process
  4107                              <1> 	;	name is then put in 'u.r0'.	
  4108                              <1> 	;    7) The child process is then written out on disk by
  4109                              <1> 	;	'wswap',i.e., the parent process is copied onto disk
  4110                              <1> 	;	and the child is born. (The child process is written 
  4111                              <1> 	;	out on disk/drum with 'u.uno' being the child process
  4112                              <1> 	;	number.)
  4113                              <1> 	;    8) The parent process number is then restored to 'u.uno'.
  4114                              <1> 	;    9) The child process name is put in 'u.r0'.
  4115                              <1> 	;   10) The pc on the stack sp + 18 is incremented by 2 to
  4116                              <1> 	;	create the return address for the parent process.
  4117                              <1> 	;   11) The 'u.fp' list as then searched to see what files
  4118                              <1> 	;	the parent has opened. For each file the parent has
  4119                              <1> 	;	opened, the corresponding 'fsp' entry must be updated
  4120                              <1> 	;	to indicate that the child process also has opened
  4121                              <1> 	;	the file. A branch to 'sysret' is then made.	 			 				
  4122                              <1> 	;
  4123                              <1> 	; Calling sequence:
  4124                              <1> 	;	from shell ?
  4125                              <1> 	; Arguments:
  4126                              <1> 	;	-
  4127                              <1> 	; Inputs: -
  4128                              <1> 	; Outputs: *u.r0 - child process name
  4129                              <1> 	; ...............................................................
  4130                              <1> 	;	
  4131                              <1> 	; Retro UNIX 8086 v1 modification: 
  4132                              <1> 	;	AX = r0 = PID (>0) (at the return of 'sysfork')
  4133                              <1> 	;	= process id of child a parent process returns
  4134                              <1> 	;	= process id of parent when a child process returns
  4135                              <1> 	;
  4136                              <1> 	;       In original UNIX v1, sysfork is called and returns as
  4137                              <1> 	;	in following manner: (with an example: c library, fork)
  4138                              <1> 	;	
  4139                              <1> 	;	1:
  4140                              <1> 	;		sys	fork
  4141                              <1> 	;			br 1f  / child process returns here
  4142                              <1> 	;		bes	2f     / parent process returns here
  4143                              <1> 	;		/ pid of new process in r0
  4144                              <1> 	;		rts	pc
  4145                              <1> 	;	2: / parent process condionally branches here
  4146                              <1> 	;		mov	$-1,r0 / pid = -1 means error return
  4147                              <1> 	;		rts	pc
  4148                              <1> 	;
  4149                              <1> 	;	1: / child process brances here
  4150                              <1> 	;		clr	r0   / pid = 0 in child process
  4151                              <1> 	;		rts	pc
  4152                              <1> 	;
  4153                              <1> 	;	In UNIX v7x86 (386) by Robert Nordier (1999)
  4154                              <1> 	;		// pid = fork();
  4155                              <1> 	;		//
  4156                              <1> 	;		// pid == 0 in child process; 
  4157                              <1> 	;		// pid == -1 means error return
  4158                              <1> 	;		// in child, 
  4159                              <1> 	;		//	parents id is in par_uid if needed
  4160                              <1> 	;		
  4161                              <1> 	;		_fork:
  4162                              <1> 	;			mov	$.fork,eax
  4163                              <1> 	;			int	$0x30
  4164                              <1> 	;			jmp	1f
  4165                              <1> 	;			jnc	2f
  4166                              <1> 	;			jmp	cerror
  4167                              <1> 	;		1:
  4168                              <1> 	;			mov	eax,_par_uid
  4169                              <1> 	;			xor	eax,eax
  4170                              <1> 	;		2:
  4171                              <1> 	;			ret
  4172                              <1> 	;
  4173                              <1> 	;	In Retro UNIX 8086 v1,
  4174                              <1> 	;	'sysfork' returns in following manner:
  4175                              <1> 	;	
  4176                              <1> 	;		mov	ax, sys_fork
  4177                              <1> 	;		mov	bx, offset @f ; routine for child
  4178                              <1> 	;		int	20h
  4179                              <1> 	;		jc	error
  4180                              <1> 	;		
  4181                              <1> 	;	; Routine for parent process here (just after 'jc')
  4182                              <1> 	;		mov	word ptr [pid_of_child], ax
  4183                              <1> 	;		jmp	next_routine_for_parent	
  4184                              <1> 	;
  4185                              <1> 	;	@@: ; routine for child process here				
  4186                              <1> 	;		....	
  4187                              <1> 	;	NOTE: 'sysfork' returns to specified offset
  4188                              <1> 	;	       for child process by using BX input.
  4189                              <1> 	;	      (at first, parent process will return then 
  4190                              <1> 	;	      child process will return -after swapped in-
  4191                              <1> 	;	      'syswait' is needed in parent process
  4192                              <1> 	;	      if return from child process will be waited for.)
  4193                              <1> 	;	  				
  4194                              <1> 	
  4195                              <1> ; / create a new process
  4196                              <1> 	; EBX = return address for child process 
  4197                              <1> 	     ; (Retro UNIX 8086 v1 modification !)
  4198 0000DC68 31F6                <1> 	xor 	esi, esi
  4199                              <1> 		; clr r1
  4200                              <1> sysfork_1: ; 1: / search p.stat table for unused process number
  4201 0000DC6A 46                  <1> 	inc	esi
  4202                              <1> 		; inc r1
  4203 0000DC6B 80BE[AF000300]00    <1> 	cmp	byte [esi+p.stat-1], 0 ; SFREE, 05/02/2014
  4204                              <1> 		; tstb p.stat-1(r1) / is process active, unused, dead
  4205 0000DC72 760B                <1> 	jna	short sysfork_2	
  4206                              <1> 		; beq 1f / it's unused so branch
  4207 0000DC74 6683FE10            <1> 	cmp	si, nproc
  4208                              <1> 		; cmp r1,$nproc / all processes checked
  4209 0000DC78 72F0                <1> 	jb	short sysfork_1
  4210                              <1> 		; blt 1b / no, branch back
  4211                              <1> 	;
  4212                              <1> 	; Retro UNIX 8086 v1. modification:
  4213                              <1> 	;	Parent process returns from 'sysfork' to address 
  4214                              <1> 	;	which is just after 'sysfork' system call in parent
  4215                              <1> 	;	process. Child process returns to address which is put
  4216                              <1> 	;	in BX register by parent process for 'sysfork'. 
  4217                              <1> 	;
  4218                              <1> 		;add $2,18.(sp) / add 2 to pc when trap occured, points
  4219                              <1> 		             ; / to old process return
  4220                              <1> 		; br error1 / no room for a new process
  4221 0000DC7A E96DFCFFFF          <1> 	jmp	error
  4222                              <1> sysfork_2: ; 1:
  4223 0000DC7F E8577FFFFF          <1> 	call	allocate_page
  4224 0000DC84 0F8262FCFFFF        <1> 	jc	error
  4225 0000DC8A 50                  <1> 	push	eax   ; UPAGE (user structure page) address
  4226                              <1> 	; Retro UNIX 386 v1 modification!
  4227 0000DC8B E85A81FFFF          <1> 	call	duplicate_page_dir
  4228                              <1> 		; EAX = New page directory 
  4229 0000DC90 730B                <1> 	jnc	short sysfork_3
  4230 0000DC92 58                  <1> 	pop	eax   ; UPAGE (user structure page) address
  4231 0000DC93 E82181FFFF          <1> 	call 	deallocate_page
  4232 0000DC98 E94FFCFFFF          <1> 	jmp	error
  4233                              <1> sysfork_3:
  4234                              <1> 	; Retro UNIX 386 v1 modification !
  4235 0000DC9D 56                  <1> 	push	esi
  4236 0000DC9E E8753D0000          <1> 	call	wswap ; save current user (u) structure, user registers
  4237                              <1> 		      ; and interrupt return components (for IRET)
  4238 0000DCA3 8705[B8030300]      <1> 	xchg	eax, [u.pgdir] ; page directory of the child process
  4239 0000DCA9 A3[BC030300]        <1> 	mov	[u.ppgdir], eax ; page directory of the parent process
  4240 0000DCAE 5E                  <1> 	pop	esi
  4241 0000DCAF 58                  <1> 	pop	eax   ; UPAGE (user structure page) address
  4242                              <1> 		; [u.usp] = esp
  4243 0000DCB0 89F7                <1> 	mov	edi, esi
  4244 0000DCB2 66C1E702            <1> 	shl	di, 2
  4245 0000DCB6 8987[BC000300]      <1> 	mov	[edi+p.upage-4], eax ; memory page for 'user' struct
  4246 0000DCBC A3[B4030300]        <1> 	mov	[u.upage], eax ; memory page for 'user' struct (child)
  4247                              <1> 	; 28/08/2015
  4248 0000DCC1 0FB605[B3030300]    <1> 	movzx	eax, byte [u.uno] ; parent process number
  4249                              <1> 		; movb u.uno,-(sp) / save parent process number
  4250 0000DCC8 89C7                <1> 	mov	edi, eax
  4251 0000DCCA 50                  <1>         push	eax ; ** 
  4252 0000DCCB 8A87[7F000300]      <1> 	mov     al, [edi+p.ttyc-1] ; console tty (parent)
  4253                              <1> 	; 18/09/2015
  4254                              <1> 	;mov     [esi+p.ttyc-1], al ; set child's console tty
  4255                              <1> 	;mov     [esi+p.waitc-1], ah ; 0 ; reset child's wait channel
  4256 0000DCD1 668986[7F000300]    <1> 	mov     [esi+p.ttyc-1], ax ; al - set child's console tty
  4257                              <1> 				   ; ah - reset child's wait channel	
  4258 0000DCD8 89F0                <1> 	mov	eax, esi
  4259 0000DCDA A2[B3030300]        <1> 	mov	[u.uno], al ; child process number
  4260                              <1> 		;movb r1,u.uno / set child process number to r1
  4261 0000DCDF FE86[AF000300]      <1>         inc     byte [esi+p.stat-1] ; 1, SRUN, 05/02/2014
  4262                              <1> 		; incb p.stat-1(r1) / set p.stat entry for child 
  4263                              <1> 				; / process to active status
  4264                              <1> 		; mov u.ttyp,r2 / put pointer to parent process' 
  4265                              <1> 			      ; / control tty buffer in r2
  4266                              <1>                 ; beq 2f / branch, if no such tty assigned
  4267                              <1> 		; clrb 6(r2) / clear interrupt character in tty buffer
  4268                              <1> 	; 2:
  4269 0000DCE5 53                  <1> 	push	ebx  ; * return address for the child process
  4270                              <1> 		     ; * Retro UNIX 8086 v1 feature only !	
  4271                              <1> 	; (Retro UNIX 8086 v1 modification!)
  4272                              <1> 		; mov $runq+4,r2
  4273 0000DCE6 BB[54030300]        <1> 	mov	ebx, runq+2 ; normal run queue ; 02/01/2017  
  4274 0000DCEB E8983D0000          <1> 	call	putlu
  4275                              <1>  		; jsr r0,putlu / put child process on lowest priority 
  4276                              <1> 			   ; / run queue
  4277 0000DCF0 66D1E6              <1> 	shl	si, 1
  4278                              <1> 		; asl r1 / multiply r1 by 2 to get index 
  4279                              <1> 		       ; / into p.pid table
  4280 0000DCF3 66FF05[4E030300]    <1> 	inc	word [mpid]
  4281                              <1> 		; inc mpid / increment m.pid; get a new process name
  4282 0000DCFA 66A1[4E030300]      <1> 	mov	ax, [mpid]
  4283 0000DD00 668986[1E000300]    <1> 	mov	[esi+p.pid-2], ax
  4284                              <1> 		;mov mpid,p.pid-2(r1) / put new process name 
  4285                              <1> 				    ; / in child process' name slot
  4286 0000DD07 5A                  <1> 	pop	edx  ; * return address for the child process
  4287                              <1> 		     ; * Retro UNIX 8086 v1 feature only !	
  4288 0000DD08 5B                  <1>   	pop	ebx  ; **
  4289                              <1> 	;mov	ebx, [esp] ; ** parent process number
  4290                              <1> 		; movb (sp),r2 / put parent process number in r2
  4291 0000DD09 66D1E3              <1> 	shl 	bx, 1
  4292                              <1> 		;asl r2 / multiply by 2 to get index into below tables
  4293                              <1> 	;movzx eax, word [ebx+p.pid-2]
  4294 0000DD0C 668B83[1E000300]    <1> 	mov	ax, [ebx+p.pid-2]
  4295                              <1> 		; mov p.pid-2(r2),r2 / get process name of parent
  4296                              <1> 				   ; / process
  4297 0000DD13 668986[3E000300]    <1> 	mov	[esi+p.ppid-2], ax
  4298                              <1> 		; mov r2,p.ppid-2(r1) / put parent process name 
  4299                              <1> 			  ; / in parent process slot for child
  4300 0000DD1A A3[64030300]        <1> 	mov	[u.r0], eax	
  4301                              <1> 		; mov r2,*u.r0 / put parent process name on stack 
  4302                              <1> 			     ; / at location where r0 was saved
  4303 0000DD1F 8B2D[5C030300]      <1> 	mov 	ebp, [u.sp] ; points to return address (EIP for IRET)
  4304 0000DD25 895500              <1> 	mov	[ebp], edx ; *, CS:EIP -> EIP
  4305                              <1> 			   ; * return address for the child process
  4306                              <1> 		; mov $sysret1,-(sp) /
  4307                              <1> 		; mov sp,u.usp / contents of sp at the time when 
  4308                              <1> 			      ; / user is swapped out
  4309                              <1> 		; mov $sstack,sp / point sp to swapping stack space
  4310                              <1> 	; 04/09/2015 - 01/09/2015
  4311                              <1> 	; [u.usp] = esp
  4312 0000DD28 68[0CD90000]        <1> 	push	sysret ; ***
  4313 0000DD2D 8925[60030300]      <1> 	mov	[u.usp], esp ; points to 'sysret' address (***)
  4314                              <1> 			     ; (for child process)	
  4315 0000DD33 31C0                <1> 	xor 	eax, eax
  4316 0000DD35 66A3[94030300]      <1> 	mov 	[u.ttyp], ax ; 0
  4317                              <1> 	;
  4318 0000DD3B E8D83C0000          <1> 	call	wswap ; Retro UNIX 8086 v1 modification !
  4319                              <1> 		;jsr r0,wswap / put child process out on drum
  4320                              <1> 		;jsr r0,unpack / unpack user stack
  4321                              <1> 		;mov u.usp,sp / restore user stack pointer
  4322                              <1> 		; tst (sp)+ / bump stack pointer
  4323                              <1> 	; Retro UNIX 386 v1 modification !
  4324 0000DD40 58                  <1> 	pop	eax ; ***
  4325 0000DD41 66D1E3              <1> 	shl	bx, 1
  4326 0000DD44 8B83[BC000300]      <1> 	mov     eax, [ebx+p.upage-4] ; UPAGE address ; 14/05/2015
  4327 0000DD4A E8013D0000          <1> 	call	rswap ; restore parent process 'u' structure, 
  4328                              <1> 		      ; registers and return address (for IRET)
  4329                              <1> 		;movb (sp)+,u.uno / put parent process number in u.uno
  4330 0000DD4F 0FB705[4E030300]    <1>         movzx   eax, word [mpid]
  4331 0000DD56 A3[64030300]        <1> 	mov	[u.r0], eax
  4332                              <1> 		; mov mpid,*u.r0 / put child process name on stack 
  4333                              <1> 			       ; / where r0 was saved
  4334                              <1> 		; add $2,18.(sp) / add 2 to pc on stack; gives parent
  4335                              <1> 			          ; / process return
  4336                              <1> 	;xor	ebx, ebx
  4337 0000DD5B 31F6                <1> 	xor     esi, esi
  4338                              <1> 		;clr r1
  4339                              <1> sysfork_4: ; 1: / search u.fp list to find the files 
  4340                              <1> 	      ; / opened by the parent process
  4341                              <1> 	; 01/09/2015
  4342                              <1> 	;xor	bh, bh
  4343                              <1> 	;mov 	bl, [esi+u.fp]
  4344 0000DD5D 8A86[6A030300]      <1> 	mov 	al, [esi+u.fp]
  4345                              <1> 		; movb u.fp(r1),r2 / get an open file for this process
  4346                              <1>         ;or      bl, bl
  4347 0000DD63 08C0                <1> 	or	al, al
  4348 0000DD65 740D                <1> 	jz	short sysfork_5	
  4349                              <1> 		; beq 2f / file has not been opened by parent, 
  4350                              <1> 		       ; / so branch
  4351 0000DD67 B40A                <1> 	mov	ah, 10 ; Retro UNIX 386 v1 fsp structure size = 10 bytes
  4352 0000DD69 F6E4                <1> 	mul	ah
  4353                              <1> 	;movzx	ebx, ax
  4354 0000DD6B 6689C3              <1> 	mov	bx, ax
  4355                              <1> 	;shl     bx, 3
  4356                              <1> 		; asl r2 / multiply by 8
  4357                              <1>        		; asl r2 / to get index into fsp table
  4358                              <1>        		; asl r2
  4359 0000DD6E FE83[4E010300]      <1>   	inc     byte [ebx+fsp-2]
  4360                              <1> 		; incb fsp-2(r2) / increment number of processes
  4361                              <1> 			     ; / using file, because child will now be
  4362                              <1> 			     ; / using this file
  4363                              <1> sysfork_5: ; 2:
  4364 0000DD74 46                  <1>         inc     esi
  4365                              <1> 		; inc r1 / get next open file
  4366 0000DD75 6683FE0A            <1>         cmp     si, 10
  4367                              <1> 		; cmp r1,$10. / 10. files is the maximum number which
  4368                              <1> 			  ; / can be opened
  4369 0000DD79 72E2                <1> 	jb	short sysfork_4	
  4370                              <1> 		; blt 1b / check next entry
  4371 0000DD7B E98CFBFFFF          <1> 	jmp	sysret
  4372                              <1> 		; br sysret1
  4373                              <1> 
  4374                              <1> syscreat: ; < create file >
  4375                              <1> 	; 13/11/2017
  4376                              <1> 	; 27/10/2016
  4377                              <1> 	; 25/10/2016, 26/10/2016
  4378                              <1> 	; 15/10/2016, 16/10/2016, 17/10/2016
  4379                              <1> 	; 10/10/2016 (TRDOS 386 = TRDOS v2.0) 
  4380                              <1> 	;	     -derived from INT_21H.ASM-
  4381                              <1> 	;            ("loc_INT21h_create_file")
  4382                              <1>         ; 	10/07/2011 (12/03/2011)
  4383                              <1>         ;	INT 21h Function AH = 3Ch
  4384                              <1>         ;	Create File
  4385                              <1>         ;	INPUT
  4386                              <1>         ;	   CX = Attributes
  4387                              <1>         ;          DS:DX= Address of zero terminaned path name
  4388                              <1>         ;
  4389                              <1> 	; 27/12/2015 (Retro UNIX 386 v1.1)
  4390                              <1> 	; 14/05/2015 (Retro UNIX 386 v1 - Beginning)
  4391                              <1> 	; 27/05/2013 (Retro UNIX 8086 v1)
  4392                              <1> 	;
  4393                              <1> 	; 'syscreat' called with two arguments; name and mode.
  4394                              <1> 	; u.namep points to name of the file and mode is put
  4395                              <1> 	; on the stack. 'namei' is called to get i-number of the file.		
  4396                              <1> 	; If the file aready exists, it's mode and owner remain 
  4397                              <1> 	; unchanged, but it is truncated to zero length. If the file
  4398                              <1> 	; did not exist, an i-node is created with the new mode via
  4399                              <1> 	; 'maknod' whether or not the file already existed, it is
  4400                              <1> 	; open for writing. The fsp table is then searched for a free
  4401                              <1> 	; entry. When a free entry is found, proper data is placed
  4402                              <1> 	; in it and the number of this entry is put in the u.fp list.
  4403                              <1> 	; The index to the u.fp (also know as the file descriptor)
  4404                              <1> 	; is put in the user's r0. 			
  4405                              <1> 	;
  4406                              <1> 	; Calling sequence:
  4407                              <1> 	;	syscreate; name; mode
  4408                              <1> 	; Arguments:
  4409                              <1> 	;	name - name of the file to be created
  4410                              <1> 	;	mode - mode of the file to be created
  4411                              <1> 	; Inputs: (arguments)
  4412                              <1> 	; Outputs: *u.r0 - index to u.fp list 
  4413                              <1> 	;		   (the file descriptor of new file)
  4414                              <1> 	; ...............................................................
  4415                              <1> 	;				
  4416                              <1> 	; Retro UNIX 8086 v1 modification: 
  4417                              <1> 	;       'syscreate' system call has two arguments; so,
  4418                              <1> 	;	* 1st argument, name is pointed to by BX register
  4419                              <1> 	;	* 2nd argument, mode is in CX register
  4420                              <1> 	;
  4421                              <1> 	;	AX register (will be restored via 'u.r0') will return
  4422                              <1> 	;	to the user with the file descriptor/number 
  4423                              <1> 	;	(index to u.fp list).
  4424                              <1> 	;
  4425                              <1> 	;call	arg2
  4426                              <1> 	; * name - 'u.namep' points to address of file/path name
  4427                              <1> 	;          in the user's program segment ('u.segmnt')
  4428                              <1> 	;          with offset in BX register (as sysopen argument 1).
  4429                              <1> 	; * mode - sysopen argument 2 is in CX register 
  4430                              <1> 	;          which is on top of stack.
  4431                              <1> 	;
  4432                              <1> 	; TRDOS 386 (10/10/2016)
  4433                              <1> 	;	
  4434                              <1>         ; INPUT ->
  4435                              <1>         ;	   CL = File Attributes
  4436                              <1> 	;     	      bit 0 (1) - Read only file (R)
  4437                              <1> 	;             bit 1 (1) - Hidden file (H)
  4438                              <1>         ;             bit 2 (1) - System file (R)
  4439                              <1> 	;             bit 3 (1) - Volume label/name (V)
  4440                              <1>         ;             bit 4 (1) - Subdirectory (D)
  4441                              <1> 	;	      bit 5 (1) - File has been archived (A)	 	
  4442                              <1>         ;          EBX = Pointer to filename (ASCIIZ) -path-
  4443                              <1> 	;	
  4444                              <1> 	; OUTPUT ->
  4445                              <1> 	;          eax = File/Device Handle/Number (index) (AL)
  4446                              <1> 	;          cf = 1 -> Error code in AL
  4447                              <1> 	;
  4448                              <1> 	; Modified Registers: EAX (at the return of system call)
  4449                              <1> 	;  
  4450                              <1> 	; Note: If the file is existing and it has not any one
  4451                              <1> 	;	of S,H,R,V,D attributes, it will be truncated 
  4452                              <1> 	;	to zero length; otherwise, access error will be 
  4453                              <1> 	;	returned. 
  4454                              <1> 
  4455                              <1> sysmkdir_0:
  4456 0000DD80 F6C108              <1> 	test	cl, 08h ; Volume name 
  4457 0000DD83 740A                <1> 	jz	short syscreat_0
  4458                              <1> 
  4459                              <1> 	; Volume name or long name creation
  4460                              <1> 	; is not permitted (in TRDOS 386)!
  4461 0000DD85 B80B000000          <1> 	mov	eax, ERR_FILE_ACCESS  ; 11 ; 'permission denied !'
  4462 0000DD8A E926020000          <1>         jmp	sysopen_dev_err
  4463                              <1> 
  4464                              <1> syscreat_0:
  4465                              <1>         ;mov	[u.namep], ebx
  4466 0000DD8F 51                  <1> 	push	ecx
  4467 0000DD90 89DE                <1> 	mov	esi, ebx
  4468                              <1> 	; file name is forced, change directory as temporary
  4469                              <1> 	;mov	ax, 1
  4470                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset ; 17/10/2016
  4471                              <1> 	;call	set_working_path 
  4472 0000DD92 E849520000          <1> 	call	set_working_path_x ; 17/10/2016	
  4473 0000DD97 0F82D7000000        <1> 	jc	syscreat_err
  4474                              <1> 
  4475                              <1> 	; 16/10/2016
  4476 0000DD9D 803D[E7960100]00    <1> 	cmp	byte [SWP_inv_fname], 0
  4477 0000DDA4 776C                <1> 	ja	short  syscreat_inv_fname ; invalid file name !
  4478                              <1> 
  4479                              <1> 	; Here, we have a valid path and also a valid file name
  4480                              <1> 	; (Working dir has been changed if the path
  4481                              <1> 	;  -file name string- had contained a dir name.)
  4482                              <1> 
  4483 0000DDA6 6631C0              <1> 	xor	ax, ax 
  4484                              <1> 	;mov	esi, FindFile_Name
  4485 0000DDA9 E8E3B6FFFF          <1> 	call	find_first_file
  4486 0000DDAE 59                  <1> 	pop	ecx
  4487                              <1> 		; ESI = Directory Entry (FindFile_DirEntry) Location
  4488                              <1> 		; EDI = Directory Buffer Directory Entry Location
  4489                              <1> 		; EAX = File Size
  4490                              <1> 		;  BL = Attributes of The File/Directory
  4491                              <1> 		;  BH = Long Name Yes/No Status (>0 is YES)
  4492                              <1> 		;  DX > 0 : Ambiguous filename chars are used
  4493 0000DDAF 7269                <1> 	jc	short syscreat_1 ; file not found (the good!) 
  4494                              <1> 				 ; or another error (the bad') 
  4495                              <1> 
  4496                              <1> 	; (& the uggly!) truncate file to zero length before open
  4497                              <1> 
  4498                              <1> 	;'*' and '?' already checked at 'set_working_path' stage
  4499                              <1> 	;and	dx, dx
  4500                              <1> 	;jnz	short sysmkdir_err ; permission denied 
  4501                              <1> 				   ; invalid filename chars
  4502                              <1> 
  4503                              <1> 	;test	cl, 10h ; subdirectory ?
  4504                              <1> 	;jnz	short sysmkdir_err	
  4505                              <1> 
  4506                              <1> 	; BL = File Attributes:	
  4507                              <1> 	;     	      bit 0 (1) - Read only file (R)
  4508                              <1> 	;             bit 1 (1) - Hidden file (H)
  4509                              <1>         ;             bit 2 (1) - System file (R)
  4510                              <1> 	;             bit 3 (1) - Volume label/name (V)
  4511                              <1>         ;             bit 4 (1) - Subdirectory (D)
  4512                              <1> 	;	      bit 5 (1) - File has been archived	 	
  4513                              <1> 
  4514                              <1> 	; * existing directory must not be truncated
  4515                              <1> 	;   (we don't know it is empty or not, at this stage) 
  4516                              <1> 	; * existing volume name (or a long name) can not be
  4517                              <1> 	;   re-created or truncated by 'syscreat' 	
  4518                              <1> 	; * A file with S, H, R attributes must not be truncated
  4519                              <1> 	;   (change attributes to normal, if you need truncate it)
  4520                              <1> 
  4521 0000DDB1 F6C31F              <1> 	test	bl, 00011111b  ; check attributes of existing file
  4522 0000DDB4 754E                <1> 	jnz	short sysmkdir_err
  4523                              <1> 
  4524                              <1> 	;; normal file, OK to continue...
  4525                              <1> 
  4526                              <1> 	; ESI = FindFile_DirEntry
  4527 0000DDB6 668B4614            <1> 	mov	ax, [esi+DirEntry_FstClusHI] ; 20
  4528 0000DDBA C1E010              <1> 	shl	eax, 16 ; 13/11/2017
  4529 0000DDBD 668B461A            <1> 	mov	ax, [esi+DirEntry_FstClusLO] ; 26 
  4530                              <1> 	; EAX = First cluster to be truncated/unlinked
  4531 0000DDC1 57                  <1> 	push	edi
  4532 0000DDC2 51                  <1> 	push	ecx
  4533 0000DDC3 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  4534 0000DDC8 29C9                <1> 	sub	ecx, ecx
  4535 0000DDCA 8A2D[F68A0100]      <1> 	mov	ch, [Current_Drv]
  4536 0000DDD0 01CE                <1> 	add	esi, ecx
  4537                              <1> 	; ESI = Logical dos drive description table address
  4538 0000DDD2 E8C9F7FFFF          <1> 	call	truncate_cluster_chain
  4539 0000DDD7 59                  <1> 	pop	ecx
  4540 0000DDD8 5F                  <1> 	pop	edi
  4541 0000DDD9 7230                <1> 	jc	short syscreate_truncate_err
  4542                              <1> 
  4543                              <1> 	; 26/10/2016
  4544                              <1> 	; EDI = Directory entry address in directory buffer
  4545                              <1> 	; Update directory entry
  4546 0000DDDB E848DCFFFF          <1> 	call	convert_current_date_time
  4547                              <1> 	; OUTPUT -> DX = Date in dos dir entry format
  4548                              <1>         ; 	    AX = Time in dos dir entry format	
  4549 0000DDE0 66894716            <1> 	mov	[edi+DirEntry_WrtTime], ax
  4550 0000DDE4 66895718            <1> 	mov	[edi+DirEntry_WrtDate], dx	
  4551 0000DDE8 66895712            <1> 	mov	[edi+DirEntry_LastAccDate], dx
  4552 0000DDEC 31C0                <1> 	xor	eax, eax ; file size = 0 
  4553 0000DDEE 89471C              <1> 	mov	[edi+DirEntry_FileSize], eax ; 0
  4554 0000DDF1 C605[1C920100]02    <1> 	mov	byte [DirBuff_ValidData], 2 ; data changed sign	
  4555 0000DDF8 BE[E8930100]        <1> 	mov	esi, FindFile_DirEntry
  4556 0000DDFD B201                <1> 	mov	dl, 1 ; open file for writing
  4557 0000DDFF E9AA000000          <1> 	jmp	sysopen_2
  4558                              <1> 
  4559                              <1> sysmkdir_err:
  4560                              <1> 	; 1 = write, 2 = read & write, >2 = invalid
  4561 0000DE04 B80B000000          <1>         mov	eax, ERR_FILE_ACCESS  ; 11 ; 'permission denied !'
  4562 0000DE09 EB73                <1>         jmp	short sysopen_err
  4563                              <1> 
  4564                              <1> syscreate_truncate_err:
  4565 0000DE0B B812000000          <1> 	mov	eax, ERR_DRV_WRITE ; 18 ; 'disk write error !'
  4566 0000DE10 EB6C                <1>         jmp	short sysopen_err
  4567                              <1> 
  4568                              <1> syscreat_inv_fname:  ; invalid file name chars 
  4569                              <1> 	; 16/10/2016
  4570 0000DE12 B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME  ; 26 ; invalid file name chars 
  4571 0000DE17 59                  <1> 	pop	ecx
  4572 0000DE18 EB64                <1> 	jmp	sysopen_err
  4573                              <1> 
  4574                              <1> syscreat_1:
  4575                              <1> 	; Error code in EAX
  4576 0000DE1A 3C02                <1>         cmp	al, 02h ; 'File not found' error
  4577 0000DE1C 7560                <1>         jne	sysopen_err
  4578                              <1> 
  4579 0000DE1E F6C110              <1> 	test	cl, 10h ; Directory
  4580 0000DE21 0F852C020000        <1> 	jnz	sysmkdir_2
  4581                              <1> 
  4582                              <1> syscreat_2:
  4583 0000DE27 BE[D8930100]        <1> 	mov	esi, FindFile_Name 
  4584                              <1>         ;xor	edx, edx
  4585 0000DE2C 31C0                <1>         xor	eax, eax ; File Size  = 0
  4586 0000DE2E 31DB                <1> 	xor	ebx, ebx
  4587 0000DE30 4B                  <1> 	dec 	ebx ; FFFFFFFFh -> create empty file 
  4588                              <1> 	            ;              (only for FAT fs) 
  4589                              <1> 	; CL = File Attributes
  4590 0000DE31 E8F8EBFFFF          <1> 	call	create_file
  4591 0000DE36 7246                <1> 	jc	sysopen_err
  4592                              <1> 		; EAX = New file's first cluster
  4593                              <1> 		; ESI = Logical Dos Drv Descr. Table Addr.
  4594                              <1> 		; EBX = offset CreateFile_Size
  4595                              <1> 		; ECX = Sectors per cluster (<256) 
  4596                              <1> 		; EDX = Directory entry index/number (<65536)
  4597                              <1> 	; 26/10/2016
  4598                              <1> 	;mov	esi, Directory_Buffer
  4599                              <1> 	;shl	dx, 5 ; *32
  4600                              <1> 	;add	esi, edx
  4601                              <1> 	;; esi = directory entry address in directory buffer
  4602                              <1> 
  4603                              <1> 	; Here, directory entry has been created but last
  4604                              <1> 	; modification date & time of the parent dir has not
  4605                              <1> 	; been updated, yet! 
  4606                              <1> 	; (Note: Directory and FAT buffers have been updated...)
  4607                              <1>  	
  4608 0000DE38 E824DDFFFF          <1> 	call	update_parent_dir_lmdt ; now, it is OK too!
  4609                              <1> 
  4610                              <1> 	; 25/10/2016
  4611 0000DE3D 66B80018            <1> 	mov	ax, 1800h
  4612 0000DE41 BE[D8930100]        <1> 	mov	esi, FindFile_Name
  4613 0000DE46 E846B6FFFF          <1> 	call	find_first_file
  4614 0000DE4B 7231                <1> 	jc	short sysopen_err
  4615                              <1> 
  4616                              <1> 	; Only possible error after here is 
  4617                              <1> 	; "too many open files !" error.
  4618                              <1> 	;
  4619                              <1> 	; If "syscreat" will return with that error,
  4620                              <1> 	; (the file has been created but it could not be opened)
  4621                              <1> 	; the user must retry to open this file again
  4622                              <1> 	; or must close another file before using 
  4623                              <1> 	; "sysopen" system call.
  4624                              <1> 
  4625 0000DE4D B201                <1> 	mov	dl, 1 ; open file for writing
  4626                              <1> 	; ESI = Directory Entry (FindFile_DirEntry) Location
  4627                              <1> 	; EAX = File Size (= 0)
  4628 0000DE4F EB5D                <1> 	jmp	short sysopen_2
  4629                              <1> 
  4630                              <1> sysopen: ;<open file>
  4631                              <1> 	; 26/10/2016
  4632                              <1> 	; 24/10/2016
  4633                              <1> 	; 17/10/2016
  4634                              <1> 	; 15/10/2016
  4635                              <1> 	; 06/10/2016, 07/10/2016, 08/10/2016
  4636                              <1> 	; 05/10/2016 (TRDOS 386 = TRDOS v2.0) 
  4637                              <1> 	;	     -derived from INT_21H.ASM-
  4638                              <1> 	;            ("loc_INT21h_open_file")
  4639                              <1>         ; 	26/02/2011 
  4640                              <1>         ;	INT 21h Function AH = 3Dh
  4641                              <1>         ;	Open File
  4642                              <1>         ;	INPUT
  4643                              <1>         ;	   AL= File Access Value
  4644                              <1> 	;     	     0- Open for reading
  4645                              <1> 	;            1- Open for writing
  4646                              <1>         ;            2- Open for reading and writing
  4647                              <1>         ;          DS:DX= Pointer to filename (ASCIIZ)
  4648                              <1>         ;
  4649                              <1> 	; 14/05/2015 (Retro UNIX 386 v1 - Beginning)
  4650                              <1> 	; 22/05/2013 - 27/05/2013 (Retro UNIX 8086 v1)
  4651                              <1> 	;
  4652                              <1> 	; 'sysopen' opens a file in following manner:
  4653                              <1> 	;    1) The second argument in a sysopen says whether to
  4654                              <1> 	;	open the file ro read (0) or write (>0).
  4655                              <1> 	;    2) I-node of the particular file is obtained via 'namei'.
  4656                              <1> 	;    3) The file is opened by 'iopen'.
  4657                              <1> 	;    4) Next housekeeping is performed on the fsp table
  4658                              <1> 	;	and the user's open file list - u.fp.
  4659                              <1> 	;	a) u.fp and fsp are scanned for the next available slot.
  4660                              <1> 	;	b) An entry for the file is created in the fsp table.
  4661                              <1> 	;	c) The number of this entry is put on u.fp list.
  4662                              <1> 	;	d) The file descriptor index to u.fp list is pointed
  4663                              <1> 	;	   to by u.r0.
  4664                              <1> 	;
  4665                              <1> 	; Calling sequence:
  4666                              <1> 	;	sysopen; name; mode
  4667                              <1> 	; Arguments:
  4668                              <1> 	;	name - file name or path name
  4669                              <1> 	;	mode - 0 to open for reading
  4670                              <1> 	;	       1 to open for writing
  4671                              <1> 	; Inputs: (arguments)
  4672                              <1> 	; Outputs: *u.r0 - index to u.fp list (the file descriptor)
  4673                              <1> 	;		  is put into r0's location on the stack.	
  4674                              <1> 	; ...............................................................
  4675                              <1> 	;				
  4676                              <1> 	; Retro UNIX 8086 v1 modification: 
  4677                              <1> 	;       'sysopen' system call has two arguments; so,
  4678                              <1> 	;	* 1st argument, name is pointed to by BX register
  4679                              <1> 	;	* 2nd argument, mode is in CX register
  4680                              <1> 	;
  4681                              <1> 	;	AX register (will be restored via 'u.r0') will return
  4682                              <1> 	;	to the user with the file descriptor/number 
  4683                              <1> 	;	(index to u.fp list).
  4684                              <1> 	;
  4685                              <1> 	;call	arg2
  4686                              <1> 	; * name - 'u.namep' points to address of file/path name
  4687                              <1> 	;          in the user's program segment ('u.segmnt')
  4688                              <1> 	;          with offset in BX register (as sysopen argument 1).
  4689                              <1> 	; * mode - sysopen argument 2 is in CX register 
  4690                              <1> 	;          which is on top of stack.
  4691                              <1> 	;
  4692                              <1> 	; jsr r0,arg2 / get sys args into u.namep and on stack
  4693                              <1> 	;
  4694                              <1>        	; system call registers: ebx, ecx (through 'sysenter')
  4695                              <1> 	;
  4696                              <1> 	; TRDOS 386 (05/10/2016)
  4697                              <1> 	;	
  4698                              <1>         ; INPUT ->
  4699                              <1>         ;	   CL = File Access Value (Open Mode)
  4700                              <1> 	;     	      0 - Open file for reading
  4701                              <1> 	;             1 - Open file for writing
  4702                              <1>         ;             2 - Open device for reading
  4703                              <1> 	;	      3 - Open device for writing
  4704                              <1>         ;          EBX = Pointer to filename/devicename (ASCIIZ)
  4705                              <1> 	; OUTPUT ->
  4706                              <1> 	;          eax = File/Device Handle/Number (index) (AL)
  4707                              <1> 	;          cf = 1 -> Error code in AL
  4708                              <1> 	;
  4709                              <1> 	; Modified Registers: EAX (at the return of system call)
  4710                              <1> 	;  
  4711                              <1> 
  4712 0000DE51 80F901              <1> 	cmp	cl, 1 ; read file (0), write file (1)
  4713 0000DE54 7614                <1> 	jna	short sysopen_0
  4714                              <1> 
  4715 0000DE56 80F903              <1> 	cmp	cl, 3
  4716 0000DE59 0F8640010000        <1> 	jna	sysopen_device
  4717                              <1> 
  4718                              <1> 	; Invalid access code
  4719 0000DE5F B817000000          <1> 	mov	eax, ERR_INV_PARAMETER
  4720 0000DE64 0F874B010000        <1> 	ja	sysopen_dev_err
  4721                              <1> 
  4722                              <1> sysopen_0:
  4723                              <1> 	;mov	[u.namep], ebx
  4724 0000DE6A 51                  <1> 	push	ecx
  4725 0000DE6B 89DE                <1> 	mov	esi, ebx
  4726                              <1> 	; file name is forced, change directory as temporary
  4727                              <1> 	;mov	ax, 1
  4728                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset ; 17/10/2016
  4729                              <1> 	;call	set_working_path 
  4730 0000DE6D E86E510000          <1> 	call	set_working_path_x ; 17/10/2016	
  4731 0000DE72 731E                <1> 	jnc	short sysopen_1
  4732                              <1> 
  4733                              <1> syscreat_err: ; ecx = file attributes (for 'syscreat')
  4734 0000DE74 59                  <1> 	pop	ecx ; open mode  
  4735 0000DE75 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
  4736 0000DE77 7505                <1> 	jnz	short sysopen_err
  4737                              <1> 	; eax = 0
  4738 0000DE79 B80C000000          <1> 	mov	eax, ERR_DIR_NOT_FOUND ; Directory not found !
  4739                              <1> sysopen_err:
  4740 0000DE7E A3[64030300]        <1> 	mov	[u.r0], eax
  4741 0000DE83 A3[C8030300]        <1> 	mov	[u.error], eax
  4742 0000DE88 E828520000          <1> 	call 	reset_working_path
  4743 0000DE8D E95AFAFFFF          <1> 	jmp	error
  4744                              <1> 
  4745                              <1> sysopen_1:
  4746                              <1> 	;mov	esi, FindFile_Name
  4747 0000DE92 66B80018            <1>         mov	ax, 1800h ; Only files 
  4748 0000DE96 E8F6B5FFFF          <1> 	call	find_first_file
  4749 0000DE9B 5A                  <1> 	pop	edx
  4750 0000DE9C 72E0                <1> 	jc	short sysopen_err ; eax = 2 (File not found !)
  4751                              <1> 
  4752                              <1> 	; check_open_file_attr_access_code
  4753                              <1> 
  4754 0000DE9E F6C307              <1>         test	bl, 7  ; system, hidden, readonly 
  4755 0000DEA1 740B                <1>         jz	short sysopen_2
  4756                              <1> 
  4757 0000DEA3 20D2                <1> 	and	dl, dl ; 0 = read mode
  4758 0000DEA5 7407                <1> 	jz	short sysopen_2
  4759                              <1> 
  4760                              <1> 	; 1 = write, 2 = read & write, >2 = invalid
  4761 0000DEA7 B80B000000          <1>         mov	eax, ERR_FILE_ACCESS  ; 11 = 'permission denied !'
  4762 0000DEAC EBD0                <1>         jmp	short sysopen_err
  4763                              <1> 
  4764                              <1> sysopen_2:
  4765                              <1> 	; esi = Directory Entry (FindFile_DirEntry) Location
  4766 0000DEAE 89F3                <1> 	mov	ebx, esi
  4767 0000DEB0 31F6                <1>         xor     esi, esi ; 0
  4768 0000DEB2 31FF                <1>         xor     edi, edi ; 0
  4769                              <1> sysopen_3: ; scan the list of entries in fsp table
  4770 0000DEB4 80BE[6A030300]00    <1>         cmp     byte [esi+u.fp], 0
  4771 0000DEBB 760F                <1>         jna     short sysopen_4 ; empty slot
  4772 0000DEBD 6646                <1>         inc     si
  4773 0000DEBF 6683FE0A            <1>         cmp     si, 10
  4774 0000DEC3 72EF                <1> 	jb	short sysopen_3
  4775                              <1> toomanyf:
  4776 0000DEC5 B80D000000          <1> 	mov	eax, ERR_TOO_MANY_FILES ; too many open files !
  4777 0000DECA EBB2                <1> 	jmp	short sysopen_err
  4778                              <1> 
  4779                              <1> sysopen_4: 
  4780 0000DECC 80BF[569A0100]00    <1>         cmp     byte [edi+OF_MODE], 0 ; Scan open files table 
  4781 0000DED3 760A                <1> 	jna     short sysopen_5
  4782 0000DED5 6647                <1> 	inc	di
  4783 0000DED7 6683FF0A            <1> 	cmp     di, OPENFILES ; max. number of open files (=10)
  4784 0000DEDB 72EF                <1> 	jb	short sysopen_4
  4785 0000DEDD EBE6                <1> 	jmp	short toomanyf
  4786                              <1> 
  4787                              <1> sysopen_5:
  4788 0000DEDF FEC2                <1> 	inc	dl
  4789 0000DEE1 8897[569A0100]      <1>         mov     [edi+OF_MODE], dl
  4790 0000DEE7 8A15[96930100]      <1> 	mov	dl, [FindFile_Drv]
  4791 0000DEED 8897[4C9A0100]      <1>         mov     [edi+OF_DRIVE], dl ; Logical DOS drive number
  4792 0000DEF3 66C1E702            <1> 	shl	di, 2 ; *4 (dword offset)
  4793                              <1> 
  4794 0000DEF7 8987[9C9A0100]      <1> 	mov	[edi+OF_SIZE], eax ; File size in bytes
  4795                              <1> 
  4796 0000DEFD 668B4314            <1>         mov 	ax, [ebx+DirEntry_FstClusHI]
  4797 0000DF01 C1E010              <1> 	shl	eax, 16
  4798 0000DF04 668B431A            <1> 	mov 	ax, [ebx+DirEntry_FstClusLO]
  4799 0000DF08 8987[249A0100]      <1> 	mov     [edi+OF_FCLUSTER], eax ; First cluster
  4800 0000DF0E 8987[3C9B0100]      <1> 	mov     [edi+OF_CCLUSTER], eax ; Current cluster
  4801                              <1> 
  4802 0000DF14 31DB                <1>         xor	ebx, ebx
  4803 0000DF16 899F[749A0100]      <1>         mov     [edi+OF_POINTER], ebx ; offset pointer (0)
  4804 0000DF1C 899F[649B0100]      <1>         mov     [edi+OF_CCINDEX], ebx ; cluster index (0)
  4805                              <1> 
  4806 0000DF22 A1[08940100]        <1> 	mov	eax, [FindFile_DirFirstCluster]
  4807 0000DF27 8987[C49A0100]      <1> 	mov	[edi+OF_DIRFCLUSTER], eax
  4808                              <1> 
  4809 0000DF2D A1[0C940100]        <1> 	mov	eax, [FindFile_DirCluster]
  4810 0000DF32 8987[EC9A0100]      <1> 	mov	[edi+OF_DIRCLUSTER], eax
  4811                              <1> 
  4812                              <1> 	; Get (& Save) Volume ID 
  4813                              <1> 	; Important for files of removable drives
  4814                              <1> 	; (In order to check the drive has same volume/disk)
  4815 0000DF38 88D7                <1> 	mov	bh, dl
  4816 0000DF3A 81C300010900        <1>         add	ebx, Logical_DOSDisks
  4817 0000DF40 8A4303              <1>         mov	al, [ebx+LD_FATType]
  4818 0000DF43 3C01                <1>         cmp	al, 1
  4819 0000DF45 7209                <1>         jb	short sysopen_6_fs
  4820 0000DF47 3C02                <1>         cmp	al, 2
  4821 0000DF49 770A                <1>         ja	short sysopen_6_fat32
  4822                              <1> sysopen_6_fat:
  4823 0000DF4B 8B432D              <1>         mov	eax, [ebx+LD_BPB+VolumeID]
  4824 0000DF4E EB08                <1>         jmp	short sysopen_7
  4825                              <1> sysopen_6_fs:
  4826 0000DF50 8B4328              <1>         mov	eax, [ebx+LD_FS_VolumeSerial]
  4827 0000DF53 EB03                <1>         jmp	short sysopen_7
  4828                              <1> sysopen_6_fat32:
  4829 0000DF55 8B4349              <1>         mov	eax, [ebx+LD_BPB+FAT32_VolID]
  4830                              <1> sysopen_7:
  4831 0000DF58 A3[EC8A0100]        <1>         mov	[Current_VolSerial], eax
  4832                              <1> 
  4833 0000DF5D 8987[149B0100]      <1> 	mov	[edi+OF_VOLUMEID], eax
  4834                              <1> 
  4835                              <1> 	; 24/10/2016
  4836 0000DF63 66D1EF              <1> 	shr	di, 1 ; 4/2, word offset
  4837 0000DF66 668B1D[10940100]    <1> 	mov	bx, [FindFile_DirEntryNumber]
  4838 0000DF6D 66899F[8C9B0100]    <1> 	mov	[edi+OF_DIRENTRY], bx
  4839                              <1> 
  4840 0000DF74 31D2                <1> 	xor	edx, edx
  4841                              <1> 	;shr	di, 2 ; /4 (byte offset)
  4842 0000DF76 66D1EF              <1> 	shr	di, 1 ; 2/2, byte offset
  4843 0000DF79 8897[6A9A0100]      <1> 	mov	byte [edi+OF_OPENCOUNT], dl ; 0
  4844 0000DF7F 8897[609A0100]      <1> 	mov	byte [edi+OF_STATUS], dl ; 0
  4845                              <1> 
  4846 0000DF85 89FB                <1> 	mov	ebx, edi
  4847 0000DF87 FEC3                <1> 	inc	bl
  4848                              <1> 
  4849 0000DF89 889E[6A030300]      <1>         mov     [esi+u.fp], bl ; Open File Entry Number
  4850 0000DF8F 8935[64030300]      <1> 	mov     [u.r0], esi ; move index to u.fp list 
  4851                              <1> 			    ; into eax on stack
  4852                              <1> 
  4853 0000DF95 E81B510000          <1>         call 	reset_working_path
  4854                              <1>         
  4855 0000DF9A E96DF9FFFF          <1> 	jmp	sysret
  4856                              <1> 
  4857                              <1> 	; (Retro UNIX 386 v1.0)
  4858                              <1> 	; 'fsp' table (10 bytes/entry)
  4859                              <1> 	; bit 15				   bit 0
  4860                              <1> 	; ---|-------------------------------------------
  4861                              <1> 	; r/w|		i-number of open file
  4862                              <1> 	; ---|-------------------------------------------
  4863                              <1> 	;		   device number
  4864                              <1> 	; -----------------------------------------------
  4865                              <1> 	; offset pointer, r/w pointer to file (bit 0-15)
  4866                              <1> 	; -----------------------------------------------
  4867                              <1> 	; offset pointer, r/w pointer to file (bit 16-31)
  4868                              <1> 	; ----------------------|------------------------
  4869                              <1> 	;  flag that says file 	| number of processes
  4870                              <1> 	;   has been deleted	| that have file open 
  4871                              <1> 	; ----------------------|------------------------
  4872                              <1> 
  4873                              <1> sysopen_device:
  4874                              <1> 	; 15/10/2016
  4875                              <1> 	; 08/10/2016
  4876                              <1> 	; 07/10/2016 (TRDOS 386 = TRDOS v2.0)
  4877 0000DF9F 51                  <1> 	push	ecx ; open mode
  4878 0000DFA0 89E5                <1> 	mov	ebp, esp
  4879 0000DFA2 B910000000          <1> 	mov	ecx, 16 ; transfer length = 16 bytes 
  4880 0000DFA7 29CC                <1> 	sub	esp, ecx
  4881 0000DFA9 89E7                <1> 	mov	edi, esp ; destination address 
  4882 0000DFAB 89DE                <1> 	mov 	esi, ebx ; dev name in user's memory space
  4883 0000DFAD E8FC3B0000          <1> 	call	transfer_from_user_buffer
  4884 0000DFB2 7310                <1> 	jnc	short sysopen_dev_0
  4885                              <1> 	; eax = ERR_OUT_OF_MEMORY = 4 = ERR_MINOR_IM
  4886 0000DFB4 59                  <1> 	pop	ecx
  4887                              <1> sysopen_dev_err:
  4888 0000DFB5 A3[64030300]        <1> 	mov	[u.r0], eax
  4889 0000DFBA A3[C8030300]        <1> 	mov	[u.error], eax
  4890 0000DFBF E928F9FFFF          <1> 	jmp	error
  4891                              <1> sysopen_dev_0:
  4892 0000DFC4 89FE                <1> 	mov	esi, edi ; Device name addr (max. 16 bytes, ASCIIZ) 
  4893                              <1> 			 ; for example: "tty, TTY, /dev/tty"
  4894 0000DFC6 E890530000          <1> 	call	get_device_number
  4895 0000DFCB 89EC                <1> 	mov	esp, ebp
  4896 0000DFCD 59                  <1> 	pop	ecx
  4897 0000DFCE 7307                <1> 	jnc	short sysopen_dev_1
  4898 0000DFD0 B818000000          <1> 	mov	eax, ERR_INV_DEV_NAME ; 24 ; 'invalid device name !'
  4899 0000DFD5 EBDE                <1> 	jmp	short sysopen_dev_err
  4900                              <1> sysopen_dev_1:
  4901                              <1> 	; eax = Device Number (AL)
  4902                              <1> 	;  cl = Open mode (2 = device read, 3 = device write)
  4903 0000DFD7 31DB                <1>         xor     ebx, ebx ; 0
  4904                              <1> sysopen_dev_2: ; scan the list of entries
  4905 0000DFD9 389B[6A030300]      <1>         cmp     [ebx+u.fp], bl ; 0
  4906 0000DFDF 760E                <1>         jna     short sysopen_dev_3 ; empty slot
  4907 0000DFE1 FEC3                <1>         inc     bl
  4908 0000DFE3 80FB0A              <1>         cmp     bl, 10
  4909 0000DFE6 72F1                <1> 	jb	short sysopen_dev_2
  4910                              <1> 	;
  4911 0000DFE8 B80D000000          <1> 	mov	eax, ERR_TOO_MANY_FILES ; too many open files !
  4912 0000DFED EBC6                <1> 	jmp	short sysopen_dev_err
  4913                              <1> sysopen_dev_3:
  4914 0000DFEF 891D[64030300]      <1> 	mov 	[u.r0], ebx ; File/Device index/handle/descriptor
  4915                              <1> 	; eax = device number (entry offset)
  4916 0000DFF5 8AA8[E8970100]      <1> 	mov	ch, [eax+DEV_ACCESS] ; bit 0 = accessable by users
  4917                              <1> 				     ; bit 1 = read access perm
  4918                              <1> 				     ; bit 2 = write access perm
  4919                              <1> 				     ; bit 3 = IOCTL permit to users
  4920                              <1> 				     ; bit 4 = block device if set
  4921                              <1> 				     ; bit 5 = 16 bit or 1024 byte
  4922                              <1> 				     ; bit 6 = 32 bit or 2048 byte
  4923                              <1> 				     ; bit 7 = installable device drv
  4924 0000DFFB F6C501              <1> 	test 	ch, 1 ; accessable by normal users (except root)
  4925 0000DFFE 7510                <1> 	jnz	short sysopen_dev_4 ; yes, permission has been given
  4926 0000E000 803D[B0030300]00    <1> 	cmp	byte [u.uid], 0 ; root?
  4927 0000E007 7607                <1> 	jna	short sysopen_dev_4 ; superuser can open all devices
  4928                              <1> sysopen_dev_perm_err:
  4929 0000E009 B80B000000          <1> 	mov	eax, ERR_DEV_ACCESS  ; 11 = 'permission denied !'
  4930 0000E00E EBA5                <1> 	jmp	short sysopen_dev_err
  4931                              <1> sysopen_dev_4:
  4932 0000E010 D0ED                <1> 	shr	ch, 1 ; result: 1 = read, 2 = write, 3 = r & w 
  4933 0000E012 FEC9                <1> 	dec	cl  ; result: 1 = read, 2 = write
  4934 0000E014 84E9                <1> 	test	cl, ch
  4935 0000E016 74F1                <1> 	jz	short sysopen_dev_perm_err 
  4936                              <1> 
  4937 0000E018 D0E5                <1> 	shl	ch, 1 ; bit 0 = 0
  4938                              <1> 	; eax = device number (entry offset)
  4939 0000E01A E858540000          <1> 	call	device_open
  4940 0000E01F 72E8                <1> 	jc	short sysopen_dev_perm_err 
  4941                              <1> 
  4942                              <1> 	; eax = device number (entry offset)
  4943 0000E021 0C80                <1> 	or	al, 80h ; set device bit (set bit 7 to 1)
  4944 0000E023 8B1D[64030300]      <1> 	mov	ebx, [u.r0]
  4945 0000E029 8883[6A030300]      <1> 	mov	[ebx+u.fp], al	; bit 7 (=1) points to device	
  4946                              <1> 	
  4947 0000E02F E9D8F8FFFF          <1> 	jmp	sysret
  4948                              <1> 
  4949                              <1> sysmkdir: ; < make directory >
  4950                              <1> 	; 15/10/2016
  4951                              <1> 	; 10/10/2016 (TRDOS 386 = TRDOS v2.0) 
  4952                              <1> 	;	     -derived from INT_21H.ASM-
  4953                              <1> 	;            ("loc_INT21h_create_file")
  4954                              <1>         ; 	10/07/2011 (12/03/2011)
  4955                              <1>         ;	INT 21h Function AH = 3Ch
  4956                              <1>         ;	Create File
  4957                              <1>         ;	INPUT
  4958                              <1>         ;	   CX = Attributes
  4959                              <1>         ;          DS:DX= Address of zero terminaned path name
  4960                              <1>         ;
  4961                              <1>         ;
  4962                              <1> 	; 14/05/2015 (Retro UNIX 386 v1 - Beginning)
  4963                              <1> 	; 27/05/2013 - 02/08/2013 (Retro UNIX 8086 v1)
  4964                              <1> 	;
  4965                              <1> 	; 'sysmkdir' creates an empty directory whose name is
  4966                              <1> 	; pointed to by arg 1. The mode of the directory is arg 2.	
  4967                              <1> 	; The special entries '.' and '..' are not present.
  4968                              <1> 	; Errors are indicated if the directory already exists or		
  4969                              <1> 	; user is not the super user. 
  4970                              <1> 	;
  4971                              <1> 	; Calling sequence:
  4972                              <1> 	;	sysmkdir; name; mode
  4973                              <1> 	; Arguments:
  4974                              <1> 	;	name - points to the name of the directory
  4975                              <1> 	;	mode - mode of the directory
  4976                              <1> 	; Inputs: (arguments)
  4977                              <1> 	; Outputs: -
  4978                              <1> 	;    (sets 'directory' flag to 1; 
  4979                              <1> 	;    'set user id on execution' and 'executable' flags to 0)
  4980                              <1> 	; ...............................................................
  4981                              <1> 	;				
  4982                              <1> 	; Retro UNIX 8086 v1 modification: 
  4983                              <1> 	;       'sysmkdir' system call has two arguments; so,
  4984                              <1> 	;	* 1st argument, name is pointed to by BX register
  4985                              <1> 	;	* 2nd argument, mode is in CX register
  4986                              <1> 	;
  4987                              <1> 	; TRDOS 386 (10/10/2016)
  4988                              <1> 	;	
  4989                              <1>         ; INPUT ->
  4990                              <1>         ;	   CL = Directory Attributes
  4991                              <1> 	;     	      bit 0 (1) - Read only file/dir (R)
  4992                              <1> 	;             bit 1 (1) - Hidden file/dir (H)
  4993                              <1>         ;             bit 2 (1) - System file/dir (R)
  4994                              <1> 	;             bit 3 (1) - Volume label/name (V)
  4995                              <1>         ;             bit 4 (1) - Subdirectory (D)
  4996                              <1> 	;	      bit 5 (1) - File/Dir has been archived (A)
  4997                              <1> 	;	   CX = 0 -> create normal directory	 	
  4998                              <1>         ;          EBX = Pointer to directory name (ASCIIZ) -path-
  4999                              <1> 	;	
  5000                              <1> 	; OUTPUT ->
  5001                              <1> 	;          eax = First cluster of the new directory
  5002                              <1> 	;          cf = 1 -> Error code in AL
  5003                              <1> 	;
  5004                              <1> 	; Modified Registers: EAX (at the return of system call)
  5005                              <1> 	;  
  5006                              <1> 	; Note: If the file or directory is existing
  5007                              <1> 	;	an access error will be returned. 
  5008                              <1> 
  5009 0000E034 6621C9              <1> 	and	cx, cx ; if cx = 0 -> create a normal subdir
  5010 0000E037 7413                <1> 	jz	short sysmkdir_1
  5011                              <1> 
  5012 0000E039 F6C110              <1> 	test	cl, 10h ; if dir flags set, also use other flags
  5013 0000E03C 0F853EFDFFFF        <1> 	jnz	sysmkdir_0 ; jump to head of 'syscreat'
  5014                              <1> 
  5015                              <1> 	; CX has wrong flags
  5016 0000E042 B817000000          <1> 	mov 	eax, ERR_INV_FLAGS
  5017 0000E047 E969FFFFFF          <1> 	jmp	sysopen_dev_err
  5018                              <1> 
  5019                              <1> sysmkdir_1:
  5020 0000E04C B110                <1> 	mov	cl, 10h ; set subdir flag and reset other flags
  5021 0000E04E E92DFDFFFF          <1> 	jmp	sysmkdir_0 ; jump to head of 'syscreat'
  5022                              <1> sysmkdir_2: 
  5023                              <1> 	; jump from 'syscreat' ; from 'syscreat_1'
  5024                              <1> 	;  CL = Directory attributes/flags  
  5025 0000E053 BE[D8930100]        <1> 	mov	esi, FindFile_Name 
  5026 0000E058 E804D7FFFF          <1> 	call	make_sub_directory
  5027 0000E05D 0F821BFEFFFF        <1> 	jc	sysopen_err       ; NOTE: Old type (TRDOS 8086)
  5028                              <1> 				  ; error codes must be modified
  5029                              <1> 				  ; for next TRDOS 386 versions
  5030                              <1> 				  ; (10/10/2016)
  5031                              <1> 				  ; Old (MSDOS type)
  5032                              <1> 				  ; error codes (2011):
  5033                              <1> 				  ;  2 = file not found
  5034                              <1> 				  ;  3 = directory not found
  5035                              <1> 				  ;  5 = access denied
  5036                              <1> 				  ; 12 = no more files
  5037                              <1> 			          ; 19 = disk write protected   
  5038                              <1> 				  ; 39 = insufficient disk space
  5039                              <1> 				  ; 'sysdefs.s' ; 10/10/2016  	
  5040                              <1> 	
  5041 0000E063 A3[64030300]        <1> 	mov	[u.r0], eax ; New sub dir's first cluster
  5042                              <1> 
  5043 0000E068 E848500000          <1>         call 	reset_working_path
  5044                              <1> 
  5045 0000E06D E99AF8FFFF          <1> 	jmp	sysret	
  5046                              <1> 
  5047                              <1> sysclose: ;<close file>
  5048                              <1> 	; 06/10/2016 (TRDOS 386 = TRDOS v2.0) 
  5049                              <1> 	;
  5050                              <1> 	; 14/05/2015 (Retro UNIX 386 v1 - Beginning)
  5051                              <1> 	; 22/05/2013 - 26/05/2013 (Retro UNIX 8086 v1)
  5052                              <1> 	;
  5053                              <1> 	; 'sysclose', given a file descriptor in 'u.r0', closes the
  5054                              <1> 	; associated file. The file descriptor (index to 'u.fp' list)
  5055                              <1> 	; is put in r1 and 'fclose' is called.
  5056                              <1> 	;
  5057                              <1> 	; Calling sequence:
  5058                              <1> 	;	sysclose
  5059                              <1> 	; Arguments:
  5060                              <1> 	;	-  
  5061                              <1> 	; Inputs: *u.r0 - file descriptor
  5062                              <1> 	; Outputs: -
  5063                              <1> 	; ...............................................................
  5064                              <1> 	;				
  5065                              <1> 	; Retro UNIX 8086 v1 modification:
  5066                              <1> 	;	 The user/application program puts file descriptor
  5067                              <1> 	;        in BX register as 'sysclose' system call argument.
  5068                              <1> 	; 	 (argument transfer method 1)
  5069                              <1> 
  5070                              <1> 	; TRDOS 386 (06/10/2016)
  5071                              <1> 	;	
  5072                              <1>         ; INPUT ->
  5073                              <1>         ;	   EBX = File Handle/Number (file index) (AL)
  5074                              <1> 	; OUTPUT ->
  5075                              <1> 	;          cf = 0 -> EAX = 0
  5076                              <1> 	;          cf = 1 -> Error code in EAX (ERR_FILE_NOT_OPEN)
  5077                              <1> 	;
  5078                              <1> 	; Modified Registers: EAX (at the return of system call)
  5079                              <1> 	;  
  5080                              <1> 
  5081 0000E072 89D8                <1> 	mov 	eax, ebx
  5082 0000E074 31DB                <1> 	xor	ebx, ebx	
  5083 0000E076 891D[64030300]      <1> 	mov	[u.r0], ebx ; 0  ; return value of EAX
  5084 0000E07C E8BC2F0000          <1> 	call 	fclose
  5085 0000E081 0F8385F8FFFF        <1> 	jnc	sysret
  5086 0000E087 B80A000000          <1> 	mov	eax, ERR_FILE_NOT_OPEN ; file not open !
  5087 0000E08C A3[C8030300]        <1> 	mov	[u.error], eax ;
  5088 0000E091 A3[64030300]        <1> 	mov	[u.r0], eax ; ! invalid handle !
  5089 0000E096 E951F8FFFF          <1> 	jmp	error
  5090                              <1> 
  5091                              <1> sysread: ; < read from file >
  5092                              <1> 	; 11/10/2016 (TRDOS 386 = TRDOS v2.0) 
  5093                              <1> 	;	     -derived from INT_21H.ASM-
  5094                              <1> 	;            ("loc_INT21h_read_file")
  5095                              <1>         ; 	13/03/2011 (05/03/2011)
  5096                              <1>         ;	INT 21h Function AH = 3Fh
  5097                              <1>         ;	Read from a File
  5098                              <1>         ;	INPUT
  5099                              <1> 	;	   BX = File Handle
  5100                              <1>         ;	   CX = Number of bytes to read
  5101                              <1>         ;          DS:DX= Buffer address
  5102                              <1>         ;
  5103                              <1> 	; Note: TRDOS 386 'sysread' has been derived from 
  5104                              <1> 	;	Retro UNIX 386 v1 'sysread', except a few 
  5105                              <1> 	;	code modifications.
  5106                              <1> 	;
  5107                              <1> 	; 13/05/2015 (Retro UNIX 386 v1)
  5108                              <1> 	; 11/05/2015 (Retro UNIX 386 v1 - Beginning)
  5109                              <1> 	; 23/05/2013 (Retro UNIX 8086 v1)
  5110                              <1> 	;
  5111                              <1> 	; 'sysread' is given a buffer to read into and the number of
  5112                              <1> 	; characters to be read. If finds the file from the file
  5113                              <1> 	; descriptor located in *u.r0 (r0). This file descriptor
  5114                              <1> 	; is returned from a successful open call (sysopen).
  5115                              <1> 	; The i-number of file is obtained via 'rw1' and the data
  5116                              <1> 	; is read into core via 'readi'.
  5117                              <1> 	;
  5118                              <1> 	; Calling sequence:
  5119                              <1> 	;	sysread; buffer; nchars
  5120                              <1> 	; Arguments:
  5121                              <1> 	;	buffer - location of contiguous bytes where 
  5122                              <1> 	;		 input will be placed.
  5123                              <1> 	;	nchars - number of bytes or characters to be read.
  5124                              <1> 	; Inputs: *u.r0 - file descriptor (& arguments)
  5125                              <1> 	; Outputs: *u.r0 - number of bytes read.	
  5126                              <1> 	; ...............................................................
  5127                              <1> 	;				
  5128                              <1> 	; Retro UNIX 8086 v1 modification: 
  5129                              <1> 	;       'sysread' system call has three arguments; so,
  5130                              <1> 	;	* 1st argument, file descriptor is in BX register
  5131                              <1> 	;	* 2nd argument, buffer address/offset in CX register
  5132                              <1> 	;	* 3rd argument, number of bytes is in DX register
  5133                              <1> 	;
  5134                              <1> 	;	AX register (will be restored via 'u.r0') will return
  5135                              <1> 	;	to the user with number of bytes read. 
  5136                              <1> 	;
  5137                              <1> 	; TRDOS 386 (05/10/2016)
  5138                              <1> 	;	
  5139                              <1>         ; INPUT ->
  5140                              <1>         ;	   EBX = File handle (descriptor/index)
  5141                              <1> 	;	   ECX = Buffer address		
  5142                              <1>         ;          EDX = Number of bytes
  5143                              <1> 	; OUTPUT ->
  5144                              <1> 	;          EAX = Number of bytes have been read
  5145                              <1> 	;          cf = 1 -> Error code in AL
  5146                              <1> 	;
  5147                              <1> 	; Modified Registers: EAX (at the return of system call)
  5148                              <1> 	; 
  5149                              <1> 
  5150                              <1> 	; EBX = File descriptor
  5151 0000E09B E8EB2F0000          <1> 	call	getf1 
  5152 0000E0A0 7277                <1> 	jc	short device_read ; read data from device
  5153                              <1> 	; EAX = First cluster of the file
  5154                              <1> 
  5155 0000E0A2 E83F000000          <1> 	call	rw1
  5156 0000E0A7 730A                <1> 	jnc	short sysread_0
  5157                              <1> 
  5158 0000E0A9 A3[64030300]        <1> 	mov	[u.r0], eax ; error code
  5159 0000E0AE E939F8FFFF          <1> 	jmp	error
  5160                              <1> 	 
  5161                              <1> sysread_0:
  5162 0000E0B3 E8E2350000          <1> 	call	readi
  5163 0000E0B8 EB1D                <1> 	jmp	short rw0
  5164                              <1> 
  5165                              <1> syswrite: ; < write to file >
  5166                              <1> 	; 23/10/2016
  5167                              <1> 	; 11/10/2016 (TRDOS 386 = TRDOS v2.0) 
  5168                              <1> 	;	     -derived from INT_21H.ASM-
  5169                              <1> 	;            ("loc_INT21h_write_file")
  5170                              <1>         ; 	13/03/2011 (05/03/2011)
  5171                              <1>         ;	INT 21h Function AH = 40h
  5172                              <1>         ;	Write to a File
  5173                              <1>         ;	INPUT
  5174                              <1> 	;	   BX = File Handle
  5175                              <1>         ;	   CX = Number of bytes to write
  5176                              <1>         ;          DS:DX= Buffer address
  5177                              <1>         ;
  5178                              <1> 	; Note: TRDOS 386 'sysrwrite' has been derived from 
  5179                              <1> 	;	Retro UNIX 386 v1 'syswrite', except a few 
  5180                              <1> 	;	code modifications.
  5181                              <1> 	;
  5182                              <1> 
  5183                              <1> 	; 13/05/2015 (Retro UNIX 386 v1)
  5184                              <1> 	; 11/05/2015 (Retro UNIX 386 v1 - Beginning)
  5185                              <1> 	; 23/05/2013 (Retro UNIX 8086 v1)
  5186                              <1> 	;
  5187                              <1> 	; 'syswrite' is given a buffer to write onto an output file
  5188                              <1> 	; and the number of characters to write. If finds the file
  5189                              <1> 	; from the file descriptor located in *u.r0 (r0). This file 
  5190                              <1> 	; descriptor is returned from a successful open or create call
  5191                              <1> 	; (sysopen or syscreat). The i-number of file is obtained via
  5192                              <1> 	; 'rw1' and buffer is written on the output file via 'write'.
  5193                              <1> 	;
  5194                              <1> 	; Calling sequence:
  5195                              <1> 	;	syswrite; buffer; nchars
  5196                              <1> 	; Arguments:
  5197                              <1> 	;	buffer - location of contiguous bytes to be writtten.
  5198                              <1> 	;	nchars - number of characters to be written.
  5199                              <1> 	; Inputs: *u.r0 - file descriptor (& arguments)
  5200                              <1> 	; Outputs: *u.r0 - number of bytes written.	
  5201                              <1> 	; ...............................................................
  5202                              <1> 	;				
  5203                              <1> 	; Retro UNIX 8086 v1 modification: 
  5204                              <1> 	;       'syswrite' system call has three arguments; so,
  5205                              <1> 	;	* 1st argument, file descriptor is in BX register
  5206                              <1> 	;	* 2nd argument, buffer address/offset in CX register
  5207                              <1> 	;	* 3rd argument, number of bytes is in DX register
  5208                              <1> 	;
  5209                              <1> 	;	AX register (will be restored via 'u.r0') will return
  5210                              <1> 	;	to the user with number of bytes written. 
  5211                              <1> 	;
  5212                              <1> 	; INPUT ->
  5213                              <1>         ;	   EBX = File handle (descriptor/index)
  5214                              <1> 	;	   ECX = Buffer address		
  5215                              <1>         ;          EDX = Number of bytes
  5216                              <1> 	; OUTPUT ->
  5217                              <1> 	;          EAX = Number of bytes have been written
  5218                              <1> 	;          cf = 1 -> Error code in AL
  5219                              <1> 	;
  5220                              <1> 	; Modified Registers: EAX (at the return of system call)
  5221                              <1> 	;  
  5222                              <1> 
  5223                              <1> 	; EBX = File descriptor
  5224 0000E0BA E8CC2F0000          <1> 	call	getf1 
  5225 0000E0BF 7274                <1> 	jc	short device_write ; write data to device
  5226                              <1> 	; EAX = First cluster of the file
  5227                              <1> 	; EBX = File number  (Open file number) ; 23/10/2016
  5228                              <1> 
  5229 0000E0C1 E820000000          <1> 	call	rw1
  5230 0000E0C6 730A                <1> 	jnc	short syswrite_0
  5231 0000E0C8 A3[64030300]        <1> 	mov	[u.r0], eax ; error code
  5232 0000E0CD E91AF8FFFF          <1> 	jmp	error
  5233                              <1> 	 
  5234                              <1> syswrite_0:
  5235 0000E0D2 E8EF3C0000          <1> 	call	writei
  5236                              <1> rw0: ; 1:
  5237 0000E0D7 A1[8C030300]        <1>         mov	eax, [u.nread]
  5238 0000E0DC A3[64030300]        <1> 	mov	[u.r0], eax
  5239 0000E0E1 E926F8FFFF          <1> 	jmp	sysret
  5240                              <1> 
  5241                              <1> rw1:	
  5242                              <1> 	; 11/10/2016 (TRDOS 386 = TRDOS v2.0) 
  5243                              <1> 	; 14/05/2015 (Retro UNIX 386 v1)
  5244                              <1> 	; 11/05/2015 (Retro UNIX 386 v1 - Beginning)
  5245                              <1> 	; 23/05/2013 - 24/05/2013 (Retro UNIX 8086 v1)
  5246                              <1> 	; System call registers: ebx, ecx, edx (through 'sysenter')
  5247                              <1> 	;
  5248                              <1> 	; EBX = File descriptor
  5249                              <1> 	;call	getf1 ; calling point in 'getf' from 'rw1'
  5250                              <1> 	;jc	short device_rw ; read/write data from/to device
  5251                              <1> 	; EAX = First cluster of the file
  5252                              <1> 
  5253 0000E0E6 83F802              <1> 	cmp 	eax, 2
  5254 0000E0E9 7217                <1> 	jb	short rw2
  5255                              <1> 	;
  5256 0000E0EB 890D[84030300]      <1> 	mov	[u.base], ecx 	; buffer address/offset 
  5257                              <1> 				;(in the user's virtual memory space)
  5258 0000E0F1 8915[88030300]      <1> 	mov	[u.count], edx 
  5259                              <1> 
  5260 0000E0F7 C705[C8030300]0000- <1>         mov     dword [u.error], 0 ; reset the last error code
  5260 0000E0FF 0000                <1>
  5261 0000E101 C3                  <1> 	retn
  5262                              <1> 
  5263                              <1> rw2:
  5264 0000E102 B80A000000          <1> 	mov	eax, ERR_FILE_NOT_OPEN ; file not open !
  5265 0000E107 A3[C8030300]        <1> 	mov	dword [u.error], eax
  5266 0000E10C C3                  <1> 	retn
  5267                              <1> rw3: 
  5268 0000E10D B80B000000          <1> 	mov	eax, ERR_FILE_ACCESS ; permission denied !
  5269 0000E112 A3[C8030300]        <1> 	mov	dword [u.error], eax
  5270 0000E117 F9                  <1> 	stc
  5271 0000E118 C3                  <1> 	retn
  5272                              <1> 
  5273                              <1> device_read:
  5274                              <1> 	; 11/10/2016 (TRDOS 386 = TRDOS v2.0)
  5275                              <1> 	; cl = DEV_OPENMODE ; open mode
  5276                              <1> 	; ch = DEV_ACCESS   ; access flags   
  5277                              <1> 	; al = DEV_DRIVER   ; device number (eax)
  5278                              <1> 
  5279 0000E119 F6C101              <1> 	test	cl, 1 ; 1 = read, 2 = write, 3 = read&write
  5280 0000E11C 74EF                <1> 	jz	short rw3
  5281                              <1> 
  5282 0000E11E 89C3                <1> 	mov	ebx, eax
  5283 0000E120 66C1E302            <1> 	shl	bx, 2 ; *4
  5284                              <1> 
  5285 0000E124 F6C580              <1> 	test	ch, 80h ; bit 7, installable device driver flag
  5286 0000E127 7406                <1> 	jz	short d_read_2 ; Kernel device
  5287                              <1> 	; installable device
  5288                              <1> d_read_1:
  5289 0000E129 FFA3[A4970100]      <1>         jmp	dword [ebx+IDEV_RADDR-4]
  5290                              <1> d_read_2:
  5291 0000E12F FFA3[40490100]      <1> 	jmp	dword [ebx+KDEV_RADDR-4]
  5292                              <1> 
  5293                              <1> device_write:
  5294                              <1> 	; 11/10/2016 (TRDOS 386 = TRDOS v2.0)
  5295                              <1> 	; cl = DEV_OPENMODE ; open mode
  5296                              <1> 	; ch = DEV_ACCESS   ; access flags   
  5297                              <1> 	; al = DEV_DRIVER   ; device number (eax)
  5298                              <1> 
  5299 0000E135 F6C102              <1> 	test	cl, 2 ; 1 = read, 2 = write, 3 = read&write
  5300 0000E138 74D3                <1> 	jz	short rw3	
  5301                              <1> 
  5302 0000E13A 89C3                <1> 	mov	ebx, eax
  5303 0000E13C 66C1E302            <1> 	shl	bx, 2 ; *4
  5304                              <1> 
  5305 0000E140 F6C580              <1> 	test	ch, 80h ; bit 7, installable device driver flag
  5306 0000E143 7406                <1> 	jz	short d_write_2 ; Kernel device
  5307                              <1> 	; installable device
  5308                              <1> d_write_1:
  5309 0000E145 FFA3[C4970100]      <1>         jmp	dword [ebx+IDEV_WADDR-4]
  5310                              <1> d_write_2:
  5311 0000E14B FFA3[90490100]      <1> 	jmp	dword [ebx+KDEV_WADDR-4]
  5312                              <1> 
  5313                              <1> 
  5314                              <1> sysemt: ; enable (or disable) multi tasking -time sharing-
  5315                              <1> 	;
  5316                              <1> 	; 23/05/2016 - TRDOS 386 (TRDOS v2.0)
  5317                              <1> 	; 14/05/2015 (Retro UNIX 386 v1)
  5318                              <1> 	; 10/12/2013 - 20/04/2014 (Retro UNIX 8086 v1)
  5319                              <1> 	;
  5320                              <1> 	; Retro UNIX 8086 v1 modification: 
  5321                              <1> 	;	'Enable Multi Tasking'  system call instead 
  5322                              <1> 	;	of 'Emulator Trap' in original UNIX v1 for PDP-11.
  5323                              <1> 	;
  5324                              <1> 	; Retro UNIX 8086 v1 feature only!
  5325                              <1> 	;	Using purpose: Kernel will start without time-out
  5326                              <1> 	;	(internal clock/timer) functionality.
  5327                              <1> 	;	Then etc/init will enable clock/timer for
  5328                              <1> 	;	multi tasking. 
  5329                              <1> 	;
  5330                              <1> 	; INPUT ->
  5331                              <1> 	;	BL = 0 -> disable multi tasking
  5332                              <1> 	;	BL > 1 -> enable multi tasking (time sharing) 
  5333                              <1> 	; OUTPUT ->
  5334                              <1> 	;	none	
  5335                              <1> 	;
  5336                              <1> 	;  Note: Multi tasking is disabled during system
  5337                              <1> 	;	 initialization, it must be enabled by using
  5338                              <1> 	;	 this system call. (Otherwise, running proces 
  5339                              <1> 	;	 will not be changed by another process within
  5340                              <1> 	;	 run time sequence/schedule, if running process
  5341                              <1> 	;	 will not 'release' itself. Only 'wakeup' procedure
  5342                              <1> 	;	 for waiting processes and programmed timer events
  5343                              <1> 	;	 for other processes can change running process 
  5344                              <1> 	;	 while multi tasking is disabled.) ** 23/05/2016 **
  5345                              <1> 
  5346 0000E151 803D[B0030300]00    <1> 	cmp	byte [u.uid], 0 ; root ?
  5347                              <1> 	;ja	error
  5348 0000E158 0F87D3F8FFFF        <1> 	ja	badsys ; 14/05/2015
  5349                              <1> 	;
  5350 0000E15E FA                  <1> 	cli
  5351 0000E15F 881D[C2960100]      <1> 	mov	[multi_tasking], bl ; 0 to disable, >0 to enable
  5352 0000E165 E9A2F7FFFF          <1> 	jmp	sysret
  5353                              <1> 
  5354                              <1> systimer:
  5355                              <1> 	; 02/01/2017
  5356                              <1> 	; 21/12/2016
  5357                              <1> 	; 19/12/2016
  5358                              <1> 	; 10/12/2016 (callback)
  5359                              <1> 	; 10/06/2016
  5360                              <1> 	; 07/06/2016
  5361                              <1> 	; 06/06/2016
  5362                              <1> 	; 21/05/2016
  5363                              <1> 	; 19/05/2016
  5364                              <1> 	; 18/05/2016 - TRDOS 386 (TRDOS v2.0)
  5365                              <1> 	; (TRDOS 386 feature only!)
  5366                              <1> 	;
  5367                              <1> 	; (start or stop timer event(s))	
  5368                              <1> 	;
  5369                              <1> 	; INPUT ->
  5370                              <1> 	;	BL = Signal return byte (response byte)
  5371                              <1> 	;	     (Any requested value between 0 and 255)
  5372                              <1> 	;	     (Kernel will put it at the requested address)    	
  5373                              <1> 	;	BH = Time count unit
  5374                              <1> 	;	     0 = Stop timer event
  5375                              <1> 	;	     1 = 18.2 ticks per second
  5376                              <1> 	;	     2 = 10 milliseconds  		
  5377                              <1> 	;	     3 = 1 second (for real time clock interrupt) 	 
  5378                              <1> 	;	     4 = time/tick count in current time count unit
  5379                              <1> 	;	    // 10/12/2016			
  5380                              <1> 	;	    80h = Stop timer event (callback method)
  5381                              <1> 	;	    81h = 18.2 ticks per second, callback method
  5382                              <1> 	;	    82h = 10 milliseconds, callback method 	
  5383                              <1> 	;	    83h = 1 second (for RTC int), callback method 	
  5384                              <1> 	;	    84h = current time count unit, callback method
  5385                              <1> 	;
  5386                              <1> 	;	    Note: Only 03h or 83h will set real time clock
  5387                              <1> 	;		  (RTC) events (Others are for PIT events)! 	
  5388                              <1> 	;	
  5389                              <1> 	;	NOTE: If callback (user service) method is used,
  5390                              <1> 	;	    EDX will point to the return address (of service
  5391                              <1> 	;	    procedure) in user's space instead of signal 
  5392                              <1> 	;	    response byte address. (TRDOS 386 kernel will
  5393                              <1> 	;	    direct the cpu to that address -in user's space-
  5394                              <1> 	;	    at the return of system call or interrupt 
  5395                              <1> 	;	    just after the adjusted count/time is elapsed.)
  5396                              <1> 	;	    User's sevice routine must be ended with a
  5397                              <1> 	;	    'iret'. Normal return addresses from system 
  5398                              <1> 	;	    calls or and interrupts will be kept same except
  5399                              <1> 	;	    the timer returns. 			
  5400                              <1>      	;
  5401                              <1> 	;	BH = 0 -> Stop timer event
  5402                              <1> 	;	BL = Timer event number (1 to 255) if BH = 0     	
  5403                              <1> 	;	     If BL = 0, all timer events (which are belongs
  5404                              <1> 	;	      to running process) will be stopped 		    
  5405                              <1> 	;	ECX = Time/Tick count (depending on time count unit)
  5406                              <1> 	;	EDX = Signal return (Response) byte address
  5407                              <1> 	;	      (virtual address in user's memory space)
  5408                              <1> 	; OUTPUT ->
  5409                              <1> 	;	AL = Timer event number	(1 to 255) (max. value = 16)
  5410                              <1> 	;	IF BH Input = 0 & CF = 0 & AL = 0 -> 
  5411                              <1> 	;	     timer event(s) has/have been stopped/finished
  5412                              <1> 	;	CF = 1 & AL = 0 -> no timer setting space to set
  5413                              <1> 	;	CF = 1 & AL > 0 -> timer count unit is not usable
  5414                              <1> 	;
  5415                              <1> 	;	NOTE: To modify a time count for a user function,
  5416                              <1> 	;	      at first, current timer event must be stopped
  5417                              <1> 	;	      then a new timer event (which is related with
  5418                              <1> 	;	      same user function) must be started.
  5419                              <1> 	;		
  5420                              <1> 	;	      Signal return (response) byte may be used for 
  5421                              <1> 	;	      several purposes. Kernel will put this value 
  5422                              <1> 	;	      to requested address during timer interrupt,
  5423                              <1> 	;	      program/user can check this value to understand
  5424                              <1> 	;	      which event has been occurred and what is changed.
  5425                              <1> 	;	      (Multi timer events can share same signal address)
  5426                              <1> 	;	
  5427                              <1> 	;	NOTE: If the process is running while the time count
  5428                              <1> 	;	      is reached, kernel will put signal return (response)
  5429                              <1> 	;	      byte value at requested address during timer
  5430                              <1> 	;	      interrupt and the process will continue to run.
  5431                              <1> 	;	      Program/process must call (jump to) it's timer event
  5432                              <1> 	;	      function as required, for checking the timer event
  5433                              <1> 	;	      status via signal return (response) byte address. 
  5434                              <1> 	;
  5435                              <1> 	;	      If the process is not running (waiting or sleeping
  5436                              <1> 	;	      or released) while the time count is reached,
  5437                              <1> 	;	      it is restarted from where it left, to ensure
  5438                              <1> 	;	      proper multi media (video, audio, clock, timer)
  5439                              <1> 	;	      functionality.
  5440                              <1> 	;
  5441                              <1> 	;	      (It is better to use 'syswait' or 'syssleep',
  5442                              <1> 	;	      or 'sysrele' system call just after the timer
  5443                              <1> 	;	      function. Otherwise, timer events may block other
  5444                              <1> 	;	      processes which are not using timer events.)  	 		 			 		 	
  5445                              <1> 	;	     	      		 			
  5446                              <1> 	; Timer Event Structure: (max. 16 timer events, 16*16 bytes)
  5447                              <1> 	;       Owner:	        resb 1 ; 0 = free
  5448                              <1> 	;		  	       ;>0 = process number (u.uno)
  5449                              <1> 	;	Calback:	resb 1 ; 1 = callback, 0 = response byte
  5450                              <1> 	;	Interrupt:      resb 1 ; 0 = Timer interrupt (or none)
  5451                              <1> 	;		   	       ; 1 = Real Time Clock interrupt 
  5452                              <1> 	;	Response:       resb 1 ; 0 to 255, signal return value
  5453                              <1> 	;	Count Limit:	resd 1 ; count of ticks (total/set)
  5454                              <1> 	;	Current Count: 	resd 1 ; count of ticks (current)
  5455                              <1> 	;	Response Addr:  resd 1 ; response byte (pointer) address
  5456                              <1> 	;
  5457                              <1> 
  5458                              <1> 	; 19/12/2016 (timer callback)
  5459 0000E16A C605[009C0100]00    <1> 	mov	byte [tcallback], 0 
  5460 0000E171 C605[019C0100]00    <1> 	mov	byte [trtc], 0
  5461 0000E178 C705[D0030300]0000- <1> 	mov	dword [u.tcb], 0 ; this is not necessary...
  5461 0000E180 0000                <1>
  5462                              <1> 
  5463 0000E182 80FF80              <1> 	cmp	bh, 80h
  5464 0000E185 7225                <1> 	jb	short systimer_cb2
  5465 0000E187 7704                <1> 	ja	short systimer_cb0
  5466                              <1> 
  5467 0000E189 31D2                <1> 	xor	edx, edx ; 0, reset callback address
  5468 0000E18B EB0B                <1> 	jmp	short systimer_cb1
  5469                              <1> 
  5470                              <1> systimer_cb0:
  5471 0000E18D 80FF84              <1> 	cmp	bh, 84h	
  5472 0000E190 7764                <1> 	ja	short systimer_5 ;  undefined, error
  5473                              <1> 
  5474                              <1> 	;mov	byte [tcallback], 1 ; 19/12/2016
  5475 0000E192 FE05[009C0100]      <1> 	inc	byte [tcallback]
  5476                              <1> 
  5477                              <1> systimer_cb1:
  5478 0000E198 0FB635[B3030300]    <1> 	movzx	esi, byte [u.uno] ; process number
  5479 0000E19F 66C1E602            <1> 	shl	si, 2	
  5480 0000E1A3 8996[0C010300]      <1> 	mov	[esi+p.tcb-4], edx ; set process timer callback address
  5481                              <1> 				   ; (overwrite prev value if it is set!)
  5482 0000E1A9 80E77F              <1> 	and	bh, 7Fh
  5483                              <1> 
  5484                              <1> systimer_cb2:
  5485 0000E1AC 80FF02              <1> 	cmp	bh, 2
  5486 0000E1AF 7445                <1>         je      short systimer_5  ; only 18.2 ticks per second is usable
  5487                              <1> 				  ; 10 milliseconds (100 Hertz) timer 
  5488                              <1> 				  ; will be set later (18/05/2016)
  5489 0000E1B1 774B                <1>         ja      short systimer_6 
  5490                              <1> 
  5491 0000E1B3 20FF                <1> 	and	bh, bh
  5492 0000E1B5 0F84BA000000        <1>         jz      systimer_9        ; stop timer event(s)
  5493                              <1> 
  5494                              <1> 	; bh = 1 (timer interrupt, 18.2 Hz, IBM PC/AT ROMBIOS default)
  5495                              <1> 
  5496                              <1> systimer_19:
  5497 0000E1BB B00A                <1> 	mov	al, 10 ; (*)
  5498                              <1> 
  5499                              <1> systimer_0:
  5500 0000E1BD B710                <1> 	mov	bh, 16
  5501                              <1> 	;
  5502 0000E1BF 383D[C3960100]      <1> 	cmp	[timer_events], bh ; 16 ; 07/06/2016
  5503 0000E1C5 7319                <1> 	jnb 	short systimer_3  ; max. 16 timer events
  5504                              <1> 	;
  5505 0000E1C7 50                  <1> 	push	eax ; (*)
  5506                              <1> 
  5507 0000E1C8 BF[60040300]        <1> 	mov	edi, timer_set  ; beginning address of timer events
  5508                              <1> 				; setting space
  5509 0000E1CD 30C0                <1> 	xor	al, al ; 0
  5510                              <1> systimer_1:
  5511 0000E1CF FEC0                <1> 	inc	al
  5512 0000E1D1 803F00              <1> 	cmp	byte [edi], 0 	; is it free space ?
  5513 0000E1D4 7639                <1> 	jna	short systimer_7 ; yes
  5514 0000E1D6 FECF                <1> 	dec	bh
  5515 0000E1D8 7405                <1> 	jz	short systimer_2
  5516 0000E1DA 83C710              <1> 	add	edi, 16
  5517 0000E1DD EBF0                <1> 	jmp	short  systimer_1 ; next event space
  5518                              <1> 
  5519                              <1> systimer_2:
  5520 0000E1DF 58                  <1> 	pop	eax ; (*) discard
  5521                              <1> systimer_3:
  5522 0000E1E0 C605[64030300]00    <1> 	mov	byte [u.r0], 0
  5523                              <1> systimer_4:
  5524 0000E1E7 C705[C8030300]1B00- <1>         mov     dword [u.error], ERR_MISC
  5524 0000E1EF 0000                <1>
  5525                              <1>                                 ; one of miscellaneous/other errors
  5526 0000E1F1 E9F6F6FFFF          <1> 	jmp	error ; cf -> 1
  5527                              <1> 
  5528                              <1> systimer_5:
  5529 0000E1F6 883D[64030300]      <1> 	mov	[u.r0], bh ; Time count unit (=2 or >3)
  5530 0000E1FC EBE9                <1> 	jmp	short systimer_4 ; 07/06/2016
  5531                              <1> 
  5532                              <1> systimer_6:
  5533 0000E1FE 80FF04              <1> 	cmp	bh, 4
  5534 0000E201 77F3                <1>         ja      short systimer_5  ; undefined time count unit
  5535                              <1> 	;jb	short systimer_16	
  5536                              <1> 
  5537                              <1> 	;mov	al, 1	; default (use current timer unit)
  5538                              <1> 			; countdown value is in ECX ! 
  5539                              <1> 			; max. value of ecx = 4294967296/10
  5540                              <1>         ;jmp    short systimer_0
  5541                              <1> 	;jmp	short systimer_19	
  5542 0000E203 74B6                <1> 	je	short systimer_19
  5543                              <1> 
  5544                              <1> systimer_16:
  5545                              <1> 	; bh = 3
  5546                              <1> 	; timer event via real time clock interrupt
  5547                              <1> 	; interrupt/update frequency: 1 Hz (1 tick per second)
  5548                              <1> 	
  5549 0000E205 B0B6                <1> 	mov	al, 182 ; (*) ; 18.2 * 10
  5550 0000E207 FE05[019C0100]      <1> 	inc	byte [trtc] ; timer event via real time clock
  5551 0000E20D EBAE                <1>         jmp     short systimer_0
  5552                              <1> 
  5553                              <1> systimer_7:
  5554 0000E20F A2[64030300]        <1> 	mov	[u.r0], al ; timer event number
  5555                              <1> 	;
  5556                              <1> 	; edi = address of empty timer event area
  5557 0000E214 A0[B3030300]        <1> 	mov	al, [u.uno]
  5558 0000E219 FA                  <1> 	cli 	; disable interrupts 
  5559 0000E21A AA                  <1> 	stosb	; process number
  5560 0000E21B A0[009C0100]        <1> 	mov	al, [tcallback] ; timer callback flag
  5561 0000E220 AA                  <1> 	stosb 	; 1= callback method, 0= signal response byte method
  5562 0000E221 A0[019C0100]        <1> 	mov	al, [trtc] ; timer interrupt type
  5563 0000E226 AA                  <1> 	stosb	; 1= real time clock, 0= programmable interval timer
  5564 0000E227 88D8                <1> 	mov	al, bl ; Signal return (Response) value
  5565 0000E229 AA                  <1> 	stosb   ; response byte
  5566 0000E22A 58                  <1> 	pop	eax ; (*) ; 10 or 182
  5567 0000E22B 89D3                <1> 	mov	ebx, edx ; virtual address for response/signal byte
  5568 0000E22D F7E1                <1> 	mul	ecx
  5569                              <1> 	; (eax = 10 * count of 18.2 Hz timer ticks)
  5570                              <1> 	; (count down step = 10)
  5571 0000E22F AB                  <1> 	stosd  ; count limit (reset value)
  5572 0000E230 AB                  <1> 	stosd  ; current count value
  5573                              <1> 
  5574                              <1> 	; 19/12/2016
  5575 0000E231 803D[009C0100]00    <1> 	cmp	byte [tcallback], 0 ; timer callback method ?
  5576 0000E238 7604                <1> 	jna	short systimer_17 ; no	
  5577 0000E23A 89D8                <1> 	mov	eax, ebx ; virtual address for callback routine 
  5578 0000E23C EB0D                <1> 	jmp	short systimer_18
  5579                              <1> 
  5580                              <1> systimer_17: ; signal response byte method
  5581                              <1> 	; ebx = virtual address
  5582                              <1> 	; [u.pgdir] = page directory's physical address
  5583                              <1> 	; 20/02/2017
  5584 0000E23E FE05[029C0100]      <1> 	inc	 byte [no_page_swap] ; 1 
  5585                              <1> 			; Do not add this page to swap queue
  5586                              <1> 			; and remove it from swap queue if it is
  5587                              <1> 			; on the queue.
  5588 0000E244 E8A780FFFF          <1> 	call	get_physical_addr
  5589 0000E249 721A                <1> 	jc	short systimer_8 ; 07/06/2016
  5590                              <1> 	; eax = physical address of the virtual address in user's space
  5591                              <1> systimer_18:
  5592 0000E24B AB                  <1> 	stosd	; response addr (physical) or callback addr (virtual)
  5593 0000E24C FE05[C3960100]      <1> 	inc	byte [timer_events] ; 07/06/201
  5594                              <1> 	; 02/01/2017
  5595 0000E252 0FB605[B3030300]    <1> 	movzx	eax, byte [u.uno]
  5596 0000E259 FE80[FF000300]      <1> 	inc	byte [eax+p.timer-1]	
  5597                              <1> 	;
  5598 0000E25F FB                  <1> 	sti 	; enable interrupts
  5599 0000E260 E9A7F6FFFF          <1> 	jmp	sysret
  5600                              <1> 
  5601                              <1> systimer_8:
  5602                              <1> 	; 10/06/2016
  5603                              <1> 	; 07/06/2016
  5604 0000E265 28C0                <1> 	sub	al, al ; 0
  5605 0000E267 8847F4              <1> 	mov	[edi-12], al ; clear process number (free timer event)
  5606                              <1> 	;mov	dword [edi], eax ; 0
  5607 0000E26A FB                  <1> 	sti
  5608 0000E26B A2[64030300]        <1> 	mov	[u.r0], al ; 0
  5609 0000E270 E977F6FFFF          <1> 	jmp	error
  5610                              <1> 
  5611                              <1> systimer_9:
  5612                              <1> 	; 10/06/2016
  5613                              <1> 	; 07/06/2016
  5614 0000E275 28C0                <1> 	sub	al, al
  5615 0000E277 A2[64030300]        <1> 	mov	byte [u.r0], al ; 0
  5616 0000E27C 3805[C3960100]      <1> 	cmp     byte [timer_events], al ;  0
  5617 0000E282 7631                <1> 	jna	short systimer_12
  5618                              <1> 
  5619                              <1> 	; Note: ecx and edx are undefined here
  5620                              <1> 	;	(for stop timer function)
  5621                              <1> 
  5622 0000E284 BE[60040300]        <1> 	mov	esi, timer_set  ; beginning address of timer events
  5623                              <1> 				; setting space	 
  5624 0000E289 A0[B3030300]        <1> 	mov	al, [u.uno]
  5625                              <1> 	
  5626 0000E28E B710                <1> 	mov	bh, 16
  5627                              <1> 
  5628 0000E290 08DB                <1> 	or	bl, bl
  5629 0000E292 7544                <1> 	jnz	short systimer_15
  5630                              <1> 
  5631                              <1> 	; clear timer event areas belong to current process
  5632                              <1> 	; (for stopping all timer events belong to current process) 
  5633 0000E294 FA                  <1> 	cli 	; disable interrupts
  5634                              <1> systimer_10:
  5635                              <1> 	; 10/06/2016
  5636                              <1> 	; 07/06/2016 	
  5637 0000E295 8A26                <1> 	mov	ah, [esi]
  5638 0000E297 08E4                <1> 	or	ah, ah ; 0 ?
  5639 0000E299 7411                <1> 	jz	short systimer_11
  5640 0000E29B 38C4                <1> 	cmp	ah, al ; is the process number (owner) same ?
  5641 0000E29D 750D                <1>         jne     short systimer_11 ; no
  5642                              <1> 
  5643                              <1> 	;mov	byte [esi], 0
  5644 0000E29F 66C7060000          <1> 	mov	word [esi], 0 ; clear
  5645                              <1> 	;mov	dword [esi+12], 0 ; clear
  5646                              <1> 
  5647 0000E2A4 FE0D[C3960100]      <1> 	dec	byte [timer_events]
  5648 0000E2AA 7409                <1> 	jz	short systimer_12
  5649                              <1> 
  5650                              <1> systimer_11:
  5651 0000E2AC FECF                <1> 	dec	bh
  5652 0000E2AE 7405                <1> 	jz	short systimer_12
  5653 0000E2B0 83C610              <1> 	add	esi, 16
  5654 0000E2B3 EBE0                <1> 	jmp	short systimer_10
  5655                              <1> 
  5656                              <1> systimer_12:
  5657 0000E2B5 0FB635[B3030300]    <1> 	movzx	esi, byte [u.uno]
  5658 0000E2BC 08DB                <1> 	or	bl, bl ; all timer events or one timer event ?
  5659 0000E2BE 740C                <1> 	jz	short systimer_13
  5660 0000E2C0 8A9E[FF000300]      <1> 	mov	bl, [esi+p.timer-1]
  5661 0000E2C6 20DB                <1> 	and	bl, bl	; previous number of timer events for the process
  5662 0000E2C8 7408                <1> 	jz	short systimer_14
  5663 0000E2CA FECB                <1> 	dec	bl  ; previous number of timer events for the process - 1
  5664                              <1> systimer_13:
  5665 0000E2CC 889E[FF000300]      <1> 	mov	[esi+p.timer-1], bl ; 0 ; no timer events for process
  5666                              <1> systimer_14:
  5667 0000E2D2 FB                  <1> 	sti	; enable interrupts
  5668 0000E2D3 E934F6FFFF          <1> 	jmp	sysret
  5669                              <1> 
  5670                              <1> systimer_15:
  5671 0000E2D8 38FB                <1> 	cmp	bl, bh ; 16
  5672 0000E2DA 0F8707FFFFFF        <1>         ja      systimer_4      ; max. 16 timer events !
  5673                              <1> 	;
  5674 0000E2E0 88DA                <1> 	mov	dl, bl
  5675 0000E2E2 FECA                <1> 	dec	dl  ; 16 -> 15 ... 1 -> 0 
  5676 0000E2E4 C0E204              <1> 	shl	dl, 4 ; * 16
  5677 0000E2E7 0FB6FA              <1> 	movzx	edi, dl
  5678 0000E2EA 01F7                <1> 	add	edi, esi ; timer_set 
  5679                              <1> 	
  5680 0000E2EC 3A07                <1> 	cmp	al, [edi] ; process number
  5681 0000E2EE 0F85F3FEFFFF        <1>         jne     systimer_4
  5682                              <1> 	
  5683                              <1> 	; same process ID
  5684 0000E2F4 FA                  <1> 	cli	; disable interrupts
  5685                              <1>  	; 10/06/2016 ; 02/01/2017
  5686                              <1> 	;mov	byte [edi], 0 
  5687 0000E2F5 66C7070000          <1> 	mov	word [edi], 0 ; clear
  5688                              <1> 	;mov	dword [edi+12], 0 ; clear
  5689 0000E2FA FE0D[C3960100]      <1> 	dec	byte [timer_events]
  5690 0000E300 EBB3                <1> 	jmp	short systimer_12
  5691                              <1> 
  5692                              <1> sysvideo: ; VIDEO DATA TRANSFER FUNCTIONS
  5693                              <1> 	; 06/03/2021
  5694                              <1> 	; 02/03/2021
  5695                              <1> 	; 28/02/2021
  5696                              <1> 	; 27/02/2021
  5697                              <1> 	; 26/02/2021
  5698                              <1> 	; 25/02/2021
  5699                              <1> 	; 21/02/2021, 22/02/2021, 23/02/2021
  5700                              <1> 	; 15/02/2021, 16/02/2021, 18/02/2021
  5701                              <1> 	; 10/02/2021, 11/02/2021, 12/02/2021
  5702                              <1> 	; 07/02/2021, 08/02/2021
  5703                              <1> 	; 01/02/2021, 02/02/2021, 05/02/2021
  5704                              <1> 	; 29/01/2021, 30/01/2021, 31/01/2021
  5705                              <1> 	; 23/01/2021, 24/01/2021, 28/01/2021
  5706                              <1> 	; 18/01/2021, 19/01/2021, 22/01/2021
  5707                              <1> 	; 04/01/2021, 10/01/2021, 11/01/2021
  5708                              <1> 	; 01/01/2021, 02/01/2021, 03/01/2021
  5709                              <1> 	; 28/12/2020, 29/12/2020, 30/12/2020
  5710                              <1> 	; 25/12/2020, 26/12/2020
  5711                              <1> 	; 21/12/2020, 23/12/2020
  5712                              <1> 	; 12/12/2020, 14/12/2020
  5713                              <1> 	; 10/12/2020, 11/12/2020
  5714                              <1> 	; 03/12/2020, 04/12/2020
  5715                              <1> 	; 22/11/2020, 23/11/2020
  5716                              <1> 	; 21/11/2020 (TRDOS 386 v2.0.3)
  5717                              <1> 	; 12/05/2017
  5718                              <1> 	; 11/07/2016
  5719                              <1> 	; 13/06/2016
  5720                              <1> 	; 16/05/2016 - TRDOS 386 (TRDOS v2.0)
  5721                              <1> 	;
  5722                              <1> 	; VIDEO DATA TRANSFER FUNCTIONS:
  5723                              <1> 	;
  5724                              <1> 	; Inputs:
  5725                              <1> 	;		; 07/02/2021
  5726                              <1> 	;	BH = 0 = VIDEO BIOS Mode 3, tty/text mode data transfers
  5727                              <1> 	;	     BL = 
  5728                              <1> 	;		Bits 0&1, Transfer direction
  5729                              <1> 	;	     	 	0 - System to system
  5730                              <1> 	;			1 - User to system
  5731                              <1> 	;			2 - System to user
  5732                              <1> 	;			3 - Exhange (Swap) - 28/01/2021
  5733                              <1> 	;		Bits 2, Transfer Type
  5734                              <1> 	;			0 - Display page (complete) transfer
  5735                              <1> 	;	     		1 - Display page window (col,row) transfer
  5736                              <1> 	;		; 28/01/2021
  5737                              <1> 	;		Bits 3..7 - Reserved, undefined (must be 0)
  5738                              <1> 	;	        ; 28/01/2021	
  5739                              <1> 	;	     /// BL = 0 -> System to system (display page) transfer
  5740                              <1> 	;		 CL = Source page (0FFh = current video page)
  5741                              <1> 	;		 DL = Destination page (0FFh = current video page)
  5742                              <1> 	;		 (Note: Nothing to do if src & dest are same page)
  5743                              <1> 	;	     /// BL = 1&2 -> user to system & system to user transfer
  5744                              <1> 	;		 ECX = User's buffer address
  5745                              <1> 	;		 DL = Video page (0FFh = current video page)
  5746                              <1> 	;	     /// BL = 3 -> exchange (swap) display page ; 28/01/2021
  5747                              <1> 	;		 ECX = User's buffer address
  5748                              <1> 	;		 DL = Video page (0FFh = current video page)
  5749                              <1> 	;		 EDI = Swap address in user's memory (must be > 0)
  5750                              <1> 	;	     /// BL = 5&6&7 -> user to system, system to user transfer 
  5751                              <1> 	;		(system window is in current/active display page)
  5752                              <1> 	;		 ESI = User's buffer address
  5753                              <1> 	;		 ECX Low 16 bits = Top left column (X1 position)
  5754                              <1> 	;		 ECX High 16 bits = Top row (Y1 position)
  5755                              <1> 	;		 EDX Low 16 bits = Bottom right column (X2 position)
  5756                              <1> 	;		 EDX High 16 bits = Bottom row (Y2 position)
  5757                              <1>         ;                If BL = 5 or BL bit 0 & bit 1 are 1 ; 28/01/2021
  5758                              <1> 	;		 EDI = Swap address (in user's memory space)
  5759                              <1> 	;		 (If swap address > 0, previous content of the window
  5760                              <1> 	;		 will be saved into swap area in user's memory space)
  5761                              <1> 	;	     /// BL = 4 -> system to system transfer
  5762                              <1> 	;		 ESI = System's source buffer (video page) address
  5763                              <1> 	;		 ECX Low 16 bits = Top left column (X1 position)
  5764                              <1> 	;		 ECX High 16 bits = Top row (Y1 position)
  5765                              <1> 	;		 EDX Low 16 bits = Bottom right column (X2 position)
  5766                              <1> 	;		 EDX High 16 bits = Bottom row (Y2 position)
  5767                              <1> 	;		 EDI = System's destination buffer (video page) addr
  5768                              <1> 	;
  5769                              <1> 	;		; 06/02/2021
  5770                              <1> 	;		; 05/02/2021
  5771                              <1> 	;		; 01/02/2021, 02/02/2021
  5772                              <1> 	;		; 30/01/2021, 31/02/2021
  5773                              <1> 	;		; 29/01/2021 (major modification)
  5774                              <1> 	;		; 23/11/2020 (major modification)
  5775                              <1> 	;		; 22/11/2020 (bugfixes and extensions)
  5776                              <1> 	;	BH = 1 = VGA Graphics (0A0000h) data transfers
  5777                              <1> 	;		BL bit 7
  5778                              <1> 	;		   resolution (screen width) option
  5779                              <1> 	;		   0 = 320 pixels
  5780                              <1> 	;		   1 = 640 pixels
  5781                              <1> 	;		.. followings are same with SVGA transfer function
  5782                              <1> 	;		BL bit 6
  5783                              <1> 	;		   direction option
  5784                              <1> 	;		   0 = user to system (video memory)
  5785                              <1> 	;		   1 = system to user
  5786                              <1> 	;		BL bit 5
  5787                              <1> 	;		   masked/direct (non-masked) operations
  5788                              <1> 	;		   1 = masked, 0 = non-masked (direct)
  5789                              <1> 	;		BL bit 4
  5790                              <1> 	;		   page/window option
  5791                              <1> 	;		   1 = window, 0 = display page (screen)
  5792                              <1> 	;		BL bit 0 to 3 (pixel operation types)
  5793                              <1> 	;		   0 = Copy pixels (colors) ((mask color))
  5794                              <1> 	;		   1 = Change (New, Fill) color
  5795                              <1> 	;		   2 = Add color
  5796                              <1> 	;		   3 = Sub color
  5797                              <1> 	;		   4 = OR color
  5798                              <1> 	;		   5 = AND color
  5799                              <1> 	;		   6 = XOR color
  5800                              <1> 	;		   7 = NOT color
  5801                              <1> 	;		   8 = NEG color
  5802                              <1> 	;		   9 = INC color
  5803                              <1> 	;		  10 = DEC color
  5804                              <1> 	;		  11 = Mix (Average) colors
  5805                              <1> 	;		  12 = Replace pixel colors
  5806                              <1> 	;		  13 = Copy pixel block(s)
  5807                              <1> 	;		  14 = Write line(s)
  5808                              <1> 	;		  15 = Write character (font)
  5809                              <1> 	;
  5810                              <1> 	;	   Input Registers for pixel operations:
  5811                              <1> 	;		 Same with LFB data transfer function below
  5812                              <1> 	;
  5813                              <1> 	;		; 25/02/2021		
  5814                              <1> 	;		; 05/02/2021, 06/02/2021
  5815                              <1> 	;		; 01/02/2021, 02/02/2021
  5816                              <1> 	;		; 30/01/2021, 31/02/2021
  5817                              <1> 	; 		; 29/01/2021 (major modification)
  5818                              <1> 	;		; 23/11/2020 (major modification)
  5819                              <1> 	;		; 22/11/2020 (bugfixes and extensions)
  5820                              <1> 	;	BH = 2 = Super VGA, LINEAR FRAME BUFFER data transfers
  5821                              <1> 	;		BL bit 7
  5822                              <1> 	;		   unused (invalid), must be 0
  5823                              <1> 	;		BL bit 6
  5824                              <1> 	;		   direction option
  5825                              <1> 	;		   0 = user to system (video memory)
  5826                              <1> 	;		   1 = system to user
  5827                              <1> 	;		BL bit 5
  5828                              <1> 	;		   masked/direct (non-masked) operations
  5829                              <1> 	;		   1 = masked, 0 = non-masked (direct)
  5830                              <1> 	;		BL bit 4
  5831                              <1> 	;		   page/window option
  5832                              <1> 	;		   1 = window, 0 = display page (screen)
  5833                              <1> 	;		BL bit 0 to 3 (pixel operation types)
  5834                              <1> 	;		   0 = Copy pixels (colors) ((mask color))
  5835                              <1> 	;		   1 = Change (New, Fill) color
  5836                              <1> 	;		   2 = Add color
  5837                              <1> 	;		   3 = Sub color
  5838                              <1> 	;		   4 = OR color
  5839                              <1> 	;		   5 = AND color
  5840                              <1> 	;		   6 = XOR color
  5841                              <1> 	;		   7 = NOT color
  5842                              <1> 	;		   8 = NEG color
  5843                              <1> 	;		   9 = INC color
  5844                              <1> 	;		  10 = DEC color
  5845                              <1> 	;		  11 = Mix (Average) colors
  5846                              <1> 	;		  12 = Replace pixel colors
  5847                              <1> 	;		  13 = Copy pixel block(s)
  5848                              <1> 	;		  14 = Write line(s)
  5849                              <1> 	;		  15 = Write character (font)
  5850                              <1> 	;
  5851                              <1> 	;	   Note: If HW of EBX > 0, it is VESA VBE mode number
  5852                              <1> 	;		 otherwise, function will be applied
  5853                              <1> 	;		 to current (VESA VBE) video mode.
  5854                              <1> 	;		
  5855                              <1> 	;	   Input Registers for pixel operations:
  5856                              <1> 	;		-- user to system & system to system --
  5857                              <1> 	;		-- (BL = 0 to 0Fh) -- non-masked, screen --
  5858                              <1> 	;		-- (BL = 10h to 1Fh) -- non-masked, window --
  5859                              <1> 	;		-- (BL = 20h to 2Fh) -- masked, screen --
  5860                              <1> 	;		-- (BL = 30h to 3Fh) -- masked, window --
  5861                              <1> 	;		(*) window, (**) masked (***) sys to sys
  5862                              <1> 	;		for BL bit 0 to 3
  5863                              <1> 	;		00h: COPY PIXELS
  5864                              <1> 	;		  If BL bit 4 = 0 ; 21/02/2021
  5865                              <1> 	;		     full screen copy	
  5866                              <1>    	;		     ECX & EDX will not be used
  5867                              <1> 	;		    (user buffer must fit to display page)	  	
  5868                              <1> 	;		  If BL bit 4 = 1 ; 21/02/2021		
  5869                              <1> 	;		    ECX = start position (row, column) (*)
  5870                              <1> 	;			  (HW = row, CX = column)
  5871                              <1> 	;		    EDX = size (rows, colums) (*)
  5872                              <1> 	;			  (HW = rows, DX = columns)
  5873                              <1> 	;		          (0 -> invalid)
  5874                              <1> 	;		          (1 -> horizontal or vertical line)
  5875                              <1> 	;		    ESI = user's buffer address
  5876                              <1> 	;		    EDI = mask color (**) ; 25/02/2021
  5877                              <1> 	;			  (this color will be excluded)
  5878                              <1> 	;		01h: CHANGE PIXEL COLORS
  5879                              <1> 	;		02h: ADD PIXEL COLORS
  5880                              <1> 	;		03h: SUB PIXEL COLORS
  5881                              <1> 	;		04h: OR PIXEL COLORS
  5882                              <1> 	;		05h: AND PIXEL COLORS
  5883                              <1> 	;		06h: XOR PIXEL COLORS
  5884                              <1> 	;		0Bh: MIX PIXEL COLORS
  5885                              <1> 	;		     CL = color (8 bit, 256 colors)
  5886                              <1> 	;		    ECX = color (16 bit and true colors)
  5887                              <1> 	;		    EDX = start position (row, column) (*)
  5888                              <1> 	;			 (HW = row, DX = column)
  5889                              <1> 	;		    ESI = size (rows, colums) (*)
  5890                              <1> 	;			  (HW = rows, SI = columns)
  5891                              <1> 	;		    EDI = mask color (**) ; 25/02/2021
  5892                              <1> 	;			  (this color will be excluded)
  5893                              <1> 	;		07h: NOT PIXEL COLORS
  5894                              <1> 	;		08h: NEG PIXEL COLORS
  5895                              <1> 	;		09h: INC PIXEL COLORS
  5896                              <1> 	;		0Ah: DEC PIXEL COLORS
  5897                              <1> 	;		    ECX = start position (row, column) (*)
  5898                              <1> 	;			  (HW = row, CX = column)
  5899                              <1> 	;		    EDX = size (rows, colums) (*)
  5900                              <1> 	;			  (HW = rows, DX = columns)
  5901                              <1> 	;		          (0 -> invalid)
  5902                              <1> 	;		          (1 -> horizontal or vertical line)
  5903                              <1> 	;		    EDI = mask color (**) ; 25/02/2021
  5904                              <1> 	;			  (this color will be excluded)
  5905                              <1> 	;		0Ch: REPLACE PIXEL COLORS
  5906                              <1> 	;		     CL = current color (8 bit, 256 colors)
  5907                              <1> 	;		    ECX = current color (16 bit and true colors)
  5908                              <1> 	;		     DL = new color (8 bit, 256 colors)
  5909                              <1> 	;		    EDX = new color (16 bit and true colors)
  5910                              <1> 	;		    ESI = start position (row, column) (*)
  5911                              <1> 	;			  (HW = row, SI = column)
  5912                              <1> 	;		    EDI = size (rows, colums) (*)
  5913                              <1> 	;			  (HW = rows, DI = columns)
  5914                              <1> 	;		0Dh: COPY PIXEL BLOCK(S) -full screen-
  5915                              <1> 	;		   -If BL bit 5 is 0-
  5916                              <1> 	;		    ECX = start position (row, column) (*)
  5917                              <1> 	;			  (HW = row, CX = column)
  5918                              <1> 	;		    EDX = size (rows, colums) (*)
  5919                              <1> 	;			  (HW = rows, DX = columns)
  5920                              <1> 	;		          (0 -> invalid)
  5921                              <1> 	;		          (1 -> horizontal or vertical line)
  5922                              <1> 	;		    ESI = destination (row, column) (***)
  5923                              <1> 	;		   -If BL bit 5 is 1-
  5924                              <1> 	;	               CL = color (8 bit, 256 colors)
  5925                              <1> 	;		      ECX = color (16 bit and true colors)
  5926                              <1> 	;	   	      EDX = count of blocks (not bytes)
  5927                              <1> 	;			    (limit: 2048 blocks)
  5928                              <1> 	;		      ESI = user's buffer address 
  5929                              <1> 	;			  contains 64 bits block data
  5930                              <1> 	;			  BLOCK ADDRESS - (row, col), dword
  5931                              <1> 	;			  (first 32 bits)
  5932                              <1> 	;			  BLOCK SIZE - (rows, cols), dword
  5933                              <1> 	;			  (second 32 bits)
  5934                              <1> 	;		; 10/02/2021
  5935                              <1> 	;		0Eh: WRITE LINE(s) -full screen- 
  5936                              <1> 	;		   -If BL bit 5 is 0-	
  5937                              <1> 	; 		    CL = color (8 bit, 256 colors)
  5938                              <1> 	; 		   ECX = color (16 bit and true colors)
  5939                              <1> 	; 		    DX = low 12 bits - size (length)
  5940                              <1> 	;			 high 4 bits - direction or type
  5941                              <1> 	;			     0 - Horizontal line
  5942                              <1> 	;			     1 - Vertical line
  5943                              <1> 	;			   > 1 - undefined, invalid
  5944                              <1> 	; 		   ESI = start position (row, column)
  5945                              <1> 	;			 (HW = row, SI = column)
  5946                              <1> 	;		   -If BL bit 5 is 1-
  5947                              <1> 	;		     CL = color (8 bit, 256 colors)
  5948                              <1> 	;		    ECX = color (16 bit and true colors)
  5949                              <1> 	;		     DX = number of lines (in user buffer)
  5950                              <1> 	;			   (limit: 2048 lines)	
  5951                              <1> 	;		    ESI = user's buffer
  5952                              <1> 	;		          contains 64 bit data for lines
  5953                              <1> 	;			   START POINT: 32 bit (row, col)
  5954                              <1> 	;			   LENGTH: 32 bit
  5955                              <1> 	;			   high 16 bits - 0
  5956                              <1> 	;			   bit 0-11 - length
  5957                              <1> 	;			   bit 12-15 - type (length)
  5958                              <1> 	;		0Fh: WRITE CHARACTER (FONT)
  5959                              <1> 	;		     CL = char's color (8 bit, 256 colors)
  5960                              <1> 	;		    ECX = char's color (16 bit and true colors)
  5961                              <1> 	;		     DL = Character's ASCII code
  5962                              <1> 	;		     DH bit 0 -> font height
  5963                              <1> 	;			  0 -> 8x16 character font
  5964                              <1> 	;			  1 -> 8x8 character font
  5965                              <1> 	;		     DH bit 1 & 2 -> scale	
  5966                              <1> 	;			  0 = 1/1 (8 pixels per char row)
  5967                              <1> 	;			  1 = 2/1 (16 pixels per char row)
  5968                              <1> 	;			  2 = 3/1 (24 pixels per char row)
  5969                              <1> 	;			  3 = 4/1 (32 pixels per char row) 
  5970                              <1> 	;		     DH bit 6 -> [ufont] option (1 = use [ufont])
  5971                              <1> 	;		     If DH bit 7 = 1
  5972                              <1> 	;			 USER FONT (from user buffer)
  5973                              <1> 	;			    DL = 0 -> 8x8 (width: 1 byte per row)
  5974                              <1> 	;			    DL = 1 -> 8x16
  5975                              <1> 	;			    DL = 2 -> 16x16 (width: 2 bytes)
  5976                              <1> 	;			    DL = 3 -> 16x32
  5977                              <1> 	;			    DL = 4 -> 24x24 (width: 3 bytes)
  5978                              <1> 	;			    DL = 5 -> 24x48
  5979                              <1> 	;			    DL = 6 -> 32x32 (width: 4 bytes)
  5980                              <1> 	;			    DL = 7 -> 32x64
  5981                              <1> 	;			    DL > 7 -> invalid (unused)
  5982                              <1> 	;			 EDI = user's font buffer address
  5983                              <1> 	;			    (NOTE: byte order is as row0,row1,row2..)
  5984                              <1> 	; 		    ESI = start position (row, column) (*)
  5985                              <1> 	;			     (HW = row, SI = column)
  5986                              <1> 	;
  5987                              <1> 	;		-- system to user --
  5988                              <1> 	;		   BL (bit 0 to 7) 
  5989                              <1> 	;	 	40h: COPY PIXELS (full screen, display page)
  5990                              <1> 	;		    EDI = user's buffer address
  5991                              <1> 	;		41h: COPY PIXELS (window)
  5992                              <1> 	;		    ECX = start position (row, column) (*)
  5993                              <1> 	;			  (HW = row, CX = column)
  5994                              <1> 	;		    EDX = size (rows, colums) (*)
  5995                              <1> 	;			  (HW = rows, DX = columns)
  5996                              <1> 	;		          (<=1 -> horizontal or vertical line)
  5997                              <1> 	;		    EDI = user's buffer address
  5998                              <1> 	;
  5999                              <1> 	;		Example: (29/01/2021)
  6000                              <1> 	;		    ecx = 00400064h (start at row 64, column 100) 
  6001                              <1> 	;		    edx = 00320048h (size: 50 rows, 72 columns)
  6002                              <1> 	;				    (end at row 114, column 172)
  6003                              <1> 	;		    If video memory starts at 0A0000h
  6004                              <1> 	;		    and if resolution is 320x200 (256 colors) ..
  6005                              <1> 	;		    window start offset: (64*320)+100 = 20580
  6006                              <1> 	;		    window size: 16072 bytes (pixels) 
  6007                              <1> 	;		    window end offset: 20580+16072 = 36652
  6008                              <1> 	;		    window start address: 0A0000h+564h = 0A5064h
  6009                              <1> 	; Outputs:
  6010                              <1> 	;	EAX = transfer/byte count
  6011                              <1> 	;
  6012                              <1> 	;	NOTE: If the source or destination address passes out of
  6013                              <1> 	;	video pages (display memory limits), data will not be transferred
  6014                              <1> 	;	and EAX will return as 0.
  6015                              <1> 	;
  6016                              <1> 	; 08/02/2021
  6017                              <1> 	; 07/02/2021	
  6018                              <1> 	; 04/01/2021
  6019                              <1> 	; PIXEL READ/WRITE (in current/active video mode)
  6020                              <1> 	;
  6021                              <1> 	;	BH = 3 = Read/Write pixel(s) -for all graphics modes-
  6022                              <1> 	;	     BL = 
  6023                              <1> 	;		0 = Read pixel
  6024                              <1> 	;		1 = Write pixel
  6025                              <1> 	;	     	2 = swap pixel colors
  6026                              <1> 	;		3 = mix pixel colors
  6027                              <1> 	;	     29/01/2021	
  6028                              <1> 	;		4 = read pixels from user defined positions 
  6029                              <1> 	;		5 = write single color pixels to user defined positions
  6030                              <1> 	;		6 = write multi color pixels to user defined positions 
  6031                              <1> 	; 
  6032                              <1> 	;	      > 6 = invalid/unimplemented	
  6033                              <1> 	;	
  6034                              <1> 	;	     .. for BL = 0 to 5		
  6035                              <1> 	;	     CL = color for writing pixel(s) or
  6036                              <1>  	;	     ECX = color for writing pixel(s) in true color modes
  6037                              <1> 	;
  6038                              <1> 	;	     EDX = Offset from start of video memory (0A0000h)
  6039                              <1> 	;		   or start of linear frame buffer
  6040                              <1> 	;
  6041                              <1> 	;	     07/02/2021	
  6042                              <1> 	;	     .. for BL = 4
  6043                              <1> 	;	     EDI = user's destination buffer address for pixel colors 	
  6044                              <1> 	;	     29/01/2021
  6045                              <1> 	;	     .. for BL = 4 & 5		
  6046                              <1> 	;	     ESI = user's source buffer address for BL = 4 & 5
  6047                              <1> 	;	     (buffer contains dword offset positions for pixels)
  6048                              <1> 	;	     EDX = number of pixels
  6049                              <1> 	;	     .. for BL = 6	 		
  6050                              <1> 	;	     ESI = user's buffer address for BL = 6
  6051                              <1> 	;	     (buffer contains dword offset position and dword color
  6052                              <1> 	;	      value for each pixel)
  6053                              <1> 	;	     EDX = number of pixels  
  6054                              <1> 	;	
  6055                              <1> 	; Note:
  6056                              <1> 	;	Pixel read/write will be performed in current video mode. 
  6057                              <1> 	;	If [CRT_MODE] < 0FFh, 0A0000h will be used 
  6058                              <1> 	;	   as video memory and limit will be 65536
  6059                              <1> 	;	   (new/mix pixel color will be in CL)  	
  6060                              <1> 	;	if [CRT_MODE] = 0FFh (VESA VBE video mode)
  6061                              <1> 	;	   LFB base address will be used as video memory
  6062                              <1> 	;	   and limit will be video page size
  6063                              <1> 	;	   (new/mix pixel color will be in CL)  
  6064                              <1> 	;
  6065                              <1> 	; Outputs:
  6066                              <1> 	;	EAX = pixel color (according to BL and ECX input)
  6067                              <1> 	;	EAX = 0 (pixel color is 0 or there is an error)
  6068                              <1> 	;	     (BL will return as 0FFh if there is an error)
  6069                              <1> 	;	; 29/01/2021 	
  6070                              <1> 	;	EAX = number of pixels (for BL input = 4&5&6)
  6071                              <1> 	;
  6072                              <1> 	; DIRECT (STANDARD VGA/CGA) DISPLAY MEMORY ACCESS FUNCTIONS:
  6073                              <1> 	;
  6074                              <1> 	;	BH = 4 = CGA direct video memory (0B8000h, 32K) access
  6075                              <1> 	;		Page directory & page tables of the user's
  6076                              <1> 	;		program will be updated to direct access to
  6077                              <1> 	;		0B8000h (32K) video (CGA, color) memory; if
  6078                              <1> 	;		there is not a permission conflict or lock!  
  6079                              <1> 	;	        (User's program/process will have permission to
  6080                              <1> 	;		access locked display memory if the owner is
  6081                              <1> 	;		it's parent.)
  6082                              <1>         ;
  6083                              <1> 	;	    Screen width = 320	
  6084                              <1> 	;
  6085                              <1> 	;	BH = 5 = VGA direct video memory (0A0000h, 64K) access
  6086                              <1> 	;		Page directory & page tables of the user's
  6087                              <1> 	;		program will be updated to direct access to
  6088                              <1> 	;		0A0000h (64K) video (VGA) memory; if there is not
  6089                              <1> 	;		a permission conflict or lock!  
  6090                              <1> 	;	        (User's program/process will have permission to
  6091                              <1> 	;		access locked display memory if the owner is
  6092                              <1> 	;		it's parent.)
  6093                              <1> 	;	
  6094                              <1> 	;	    ; 23/11/2020		
  6095                              <1> 	;	    Screen width options = 320, 640, 800 
  6096                              <1> 	;			
  6097                              <1> 	; Outputs:
  6098                              <1> 	;	EAX = Display memory address for direct access
  6099                              <1> 	;	      0A0000h for VGA, 0B8000h for CGA	
  6100                              <1> 	;	(Display memory size: 32K for CGA, 64K for VGA)
  6101                              <1> 	; 	EAX = 0 if display page access permission has been denied.
  6102                              <1> 	;	      (Locked!) 	
  6103                              <1> 	;	      	 	
  6104                              <1> 	; LINEAR FRAME BUFFER ACCESS FUNCTIONS:
  6105                              <1> 	;
  6106                              <1> 	;	BH = 6 = Linear Frame Buffer direct video memory access
  6107                              <1> 	;
  6108                              <1> 	;		Page directory & page tables of the user's
  6109                              <1> 	;		program will be updated to direct access to
  6110                              <1> 	;		the configured LFB (Linear Frame Buffer) address,
  6111                              <1> 	;		if there is not a permission conflict or lock!  
  6112                              <1> 	;	        (User's program/process will have permission to
  6113                              <1> 	;		access locked display memory if the owner is
  6114                              <1> 	;		it's parent.)
  6115                              <1> 	;
  6116                              <1> 	;	   ; 10/12/2020
  6117                              <1> 	;	   BL = 0FFh -> Direct LFB access for current video mode
  6118                              <1> 	;	   BL = XXh < 0FFh -> Direct LFB access
  6119                              <1> 	; 			      for VESA video mode 1XXh	
  6120                              <1> 	;		
  6121                              <1> 	;		Return: EAX = Linear Frame Buffer address
  6122                              <1> 	;			(EAX = 0 -> error)
  6123                              <1> 	;		     If EAX > 0
  6124                              <1> 	;			EDX = Frame Buffer Size in bytes
  6125                              <1> 	;		         BH = Requested Video Mode - 100h
  6126                              <1> 	;		              (VESA VBE video modes)	
  6127                              <1> 	;		         BL = bits per pixel
  6128                              <1> 	;			      8 = 256 colors, 8
  6129                              <1> 	;		             16 = 65536 colors, 5-6(G)-5 
  6130                              <1> 	;		             24 = RGB, 16M colors, 8-8-8
  6131                              <1> 	;		             32 = RGB + alpha bytes, 8-8-8-8
  6132                              <1> 	;		     If BH = 0FFh
  6133                              <1> 	;		        BL = VGA/CGA video mode (also EAX = 0)
  6134                              <1> 	;
  6135                              <1> 	;		** Function will return with EAX = 0 if the mode
  6136                              <1> 	;		is not a valid VESA VBE video mode as 1??h ** 	
  6137                              <1> 	;
  6138                              <1> 	;		ECX = Pixel resolution
  6139                              <1> 	;		      CX = Width (320, 640, 800, 1024, 1366, 1920)
  6140                              <1> 	;		      High 16 bits of ECX = Height 
  6141                              <1> 	;
  6142                              <1> 	; 	23/11/2020
  6143                              <1> 	; ***	GET VIDEO MODE & LINEAR FRAME BUFFER INFO   
  6144                              <1> 	;	(This function -7- also is used for VGA and CGA modes)
  6145                              <1> 	; 	
  6146                              <1> 	;	BH = 7 = Get Linear Frame Buffer info
  6147                              <1> 	;
  6148                              <1> 	;	   ; 22/01/2021	
  6149                              <1> 	;	   ; 10/12/2020
  6150                              <1> 	;	   BL = any -not used- (22/01/2021)
  6151                              <1> 	;	
  6152                              <1> 	;		Return:
  6153                              <1> 	;		EAX = Frame Buffer Address (0 = is not in use)
  6154                              <1> 	;		EDX = Frame Buffer Size in bytes
  6155                              <1> 	;		 BH = Current Video Mode - 100h  ; 22/01/2021
  6156                              <1> 	;		     (VESA VBE video modes)	
  6157                              <1> 	;		 BL = bits per pixel
  6158                              <1> 	;			8 = 256 colors, 8
  6159                              <1> 	;		       16 = 65536 colors, 5-6(G)-5 
  6160                              <1> 	;		       24 = RGB, 16M colors, 8-8-8
  6161                              <1> 	;		       32 = RGB + alpha bytes, 8-8-8-8
  6162                              <1> 	;		If BH = 0FFh
  6163                              <1> 	;		   BL = VGA/CGA video mode (also EAX = 0)
  6164                              <1> 	;
  6165                              <1> 	;		Note:	
  6166                              <1> 	;		Alpha byte will be used as virtual color index.
  6167                              <1> 	;		(32 bit pixel colors.. byte 0,1,2 rgb and 3 alpha)
  6168                              <1> 	;
  6169                              <1> 	;		** Function will return with EAX = 0 if the mode
  6170                              <1> 	;		is not a valid VESA VBE video mode as 1??h ** 	
  6171                              <1> 	;
  6172                              <1> 	;		ECX = Pixel resolution
  6173                              <1> 	;		      CX = Width (320, 640, 800, 1024, 1366, 1920)
  6174                              <1> 	;		      High 16 bits of ECX = Height  
  6175                              <1> 	;
  6176                              <1> 	;	NOTE: Each process will have it's own frame buffer
  6177                              <1> 	;	      address and resolution parameters in 'u' area.
  6178                              <1> 	;	      Then, if the current frame buffer & resolution
  6179                              <1> 	;	      is different, frame buffer r/w functions
  6180                              <1> 	;	      will use scale factor to convert process's
  6181                              <1>         ;             pixel coordinates to actual screen coordinates.
  6182                              <1> 	;	      resolution -> dimensional scale
  6183                              <1> 	;	      color size -> color scale
  6184                              <1> 	;	     * RGB (TRUE) colors to 256 colors conversion:
  6185                              <1>         ;             TRUE Colors -> 8,8,8 (R,G,B; byte 0 is R)
  6186                              <1> 	;	      256 colors -> 2,2,2,2 (R,G,B,L; bit 0&1 is R)
  6187                              <1> 	; 		  bit 6&7 -> luminosity base level (0,1,2,3)
  6188                              <1> 	;		  bit 4&5 -> blue level (0,1,2,3)
  6189                              <1> 	;		  bit 2%3 -> green level (0,1,2,3)
  6190                              <1> 	;		  bit 0&1 -> red level (0,1,2,3)
  6191                              <1> 	;	      Example: total red level : luminosity + red level
  6192                              <1> 	;	      Luminosity base level: 0 -> 16
  6193                              <1> 	;		 		     1 -> 32
  6194                              <1> 	;				     2 -> 64
  6195                              <1> 	;				     3 -> 128
  6196                              <1> 	;	      Color level:	
  6197                              <1> 	;				    0 -> 0
  6198                              <1> 	;				    1 -> luminosity level
  6199                              <1> 	;				    2 -> luminosity level + 64
  6200                              <1> 	;				    3 -> 255
  6201                              <1> 	;	     Luminosity base level = min (R,G,B)
  6202                              <1> 	;			if it is <16, it will be set to 16
  6203                              <1> 	;	     Color levels: Color values are fixed to (nearest) 
  6204                              <1> 	;		   one of all possible set level (step) values
  6205                              <1> 	;		   (according to luminosity base level); then
  6206                              <1> 	;		   color levels are set to R-L, G-L, B-L.
  6207                              <1> 	;	 For example: If luminosity base level is 32
  6208                              <1> 	;		  all possible set values are 0, 32, 96, 255.
  6209                              <1> 	;
  6210                              <1> 	;	    * RGB (TRUE) colors to 16 colors conversion:
  6211                              <1> 	;	    16 colors: R,B,G,L bits (4 bits)
  6212                              <1> 	;	    	   If any one of R,G,B >= 128 L = 1	
  6213                              <1>  	;		   If max. value of (R,G,B) >= 32, it is 1
  6214                              <1> 	;		      else all color bits (R&G&B&L) are 0
  6215                              <1> 	;		   If the second value >= max. value / 2
  6216                              <1> 	;		      it is 1
  6217                              <1> 	;		   If third value value >= max. value / 2
  6218                              <1> 	;		      it is 1
  6219                              <1> 	;	    Example: R = 132, G = 64, B = 78
  6220                              <1> 	;		     L = 1, R = 1
  6221                              <1> 	;		     G < 66 --> G = 0
  6222                              <1> 	;		     B >= 66 --> B = 1
  6223                              <1> 	;
  6224                              <1> 	; 10/12/2020
  6225                              <1> 	; SET VIDEO MODE (& RETURN LFB INFO for VESA VBE VIDEO MODES)
  6226                              <1> 	;	
  6227                              <1> 	;	BH = 8 = Set Video Mode
  6228                              <1> 	;		
  6229                              <1> 	;		BL = Requested Video Mode (method)
  6230                              <1> 	;		If BL = 0FFh
  6231                              <1> 	;		   CX = VESA VBE Video Mode
  6232                              <1> 	;		   ; 11/12/2020
  6233                              <1> 	;		   If EDX > 0 -> LFB INFO (user) buffer addr
  6234                              <1> 	;		If BL < 0FFh, it is VGA/CGA video mode and
  6235                              <1> 	;			CX & EDX will not be used
  6236                              <1> 	;
  6237                              <1> 	;	    NOTE: The last VESA VBE video mode is 11Bh but
  6238                              <1> 	;	    TRDOS 386 will permit to set video mode upto 11Fh.
  6239                              <1> 	;	    Above 11Fh, from 140h to 1FEh, it will be accepted
  6240                              <1> 	;	    as Bochs/Plex86 emulator video mode and it will be
  6241                              <1> 	;	    used only if [vbe3] = 2 and detected
  6242                              <1> 	;	    video bios is BOCHS/PLEX86/QEMU/VIRTUALBOX vbios.
  6243                              <1> 	;	 	  	 		 	
  6244                              <1> 	; Outputs:
  6245                              <1> 	;	EAX = Requested (Proper) video mode number + 1
  6246                              <1> 	;	      ("dec eax" by user will give requested video mode),
  6247                              <1> 	;
  6248                              <1> 	;	If BL input is 0FFh
  6249                              <1> 	;	   EDX = LFBINFO table/structure (in user's buffer addr)
  6250                              <1> 	;	   EDX = 0 -> Invalid LFBINFO (do not use it)
  6251                              <1> 	;
  6252                              <1> 	;	EAX = 0 -> Error (but EDX will not be changed)
  6253                              <1> 	;
  6254                              <1> 	; 03/12/2020
  6255                              <1> 	; VESA VBE3 VIDEO BIOS (32 bit) PROTECTED MODE INTERFACE SETTINGS
  6256                              <1> 	;	
  6257                              <1> 	;	BH = 9 = set/get VBE3 Protected Mode Interface parameters
  6258                              <1> 	;		
  6259                              <1> 	;		BL = 0 - Disable protected mode interface
  6260                              <1> 	;			([pmi32] = 0)
  6261                              <1> 	;		 	Return: AL = 1	
  6262                              <1> 	;		BL = 1 - Enable protected mode Interface
  6263                              <1> 	;			([pmi32] = 1)
  6264                              <1> 	;			Return: AL = 2
  6265                              <1> 	;		BL = 2 - Get protected mode interface status
  6266                              <1> 	;			Return: AL = [pmi32] + 1 (AL = 1 or 2)
  6267                              <1> 	;
  6268                              <1> 	;		If [vbe3] <> 3 --> AL = 0
  6269                              <1> 	;
  6270                              <1> 	;		; 17/01/2021
  6271                              <1> 	;		BL = 3 - Disable/Cancel restore permission to user
  6272                              <1> 	;			Return: AL = 1 (if disabled) or 0
  6273                              <1> 	;		BL = 4 - Enable/Give restore permission to user
  6274                              <1> 	;			Return: AL = 2 (if enabled) or 0
  6275                              <1> 	;		BL = 5 - Get video state save/restore status
  6276                              <1> 	;			 (permission status)
  6277                              <1> 	;		        Return: AL = Status (enabled = 1)
  6278                              <1> 	;				; 22/01/2021
  6279                              <1> 	;				AH = state options ([srvso])
  6280                              <1> 	;		BL = 6 - Return VESA VBE number/status
  6281                              <1> 	;		        Return: AX = status
  6282                              <1> 	;			      if AH =  2, AL > 0 : Emulator
  6283                              <1> 	;				 AH =  3, VESA VBE3 video bios
  6284                              <1> 	;		; 28/02/2021 	 
  6285                              <1> 	;		BL = 7 - Set true color mode as 32bpp (default)
  6286                              <1> 	;			Return: AX = 32 (if VBE3) 
  6287                              <1> 	;		NOTE: Initial/default value is 32bpp for vbe3.
  6288                              <1> 	;			Return: AX = 0 -> error 	 
  6289                              <1> 	;		BL = 8 - Set true color mode as 24bpp (default)
  6290                              <1> 	;			Return: AX = 24
  6291                              <1> 	;			;Return: AX = 0 -> error 
  6292                              <1> 	;		BL = 9 - Return default/current true color mode
  6293                              <1> 	;			Return: AX = 32 (32 bpp)
  6294                              <1> 	;			Return: AX = 24 (24 bpp)
  6295                              <1> 	;			Return: AX = 0 -> error (not VESA bios)
  6296                              <1> 	;		 
  6297                              <1> 	;		BL > 9 : not implemented (28/02/2021)
  6298                              <1> 	;
  6299                              <1> 	;	; 19/01/2021 ([u.uid] check)	
  6300                              <1> 	;	Note: Enabling/Disabling are done by root ([u.uid] = 0)
  6301                              <1> 	;	      while [multi_tasking] = 0.
  6302                              <1> 	;
  6303                              <1>     	; 23/12/2020
  6304                              <1> 	; VIDEO MEMORY MAPPING:
  6305                              <1> 	;	BH = 10 = Map video memory to user's buffer
  6306                              <1> 	;
  6307                              <1> 	;	   BL = 0 : CGA memory (0B8000h) map (32K)
  6308                              <1> 	;	   BL = 1 : VGA memory (0A0000h) map (64K)
  6309                              <1> 	;	   BL = 2 : SVGA memory (LFB) map to user's buffer
  6310                              <1> 	;
  6311                              <1> 	;	ECX = User's buffer addr (low 12 bits will be cleared)
  6312                              <1> 	;	EDX = Buffer size in bytes (if BL = 2)
  6313                              <1> 	;		(will be trimmed if LFB size < EDX)
  6314                              <1> 	; Return:				
  6315                              <1>         ;	EAX = physical address of video memory (buffer)
  6316                              <1> 	;	EBX = mapped (actual) size of video memory (bytes)
  6317                              <1> 	;	ECX = virtual start address of user's video buffer 
  6318                              <1> 	;	EDX is same with EDX input
  6319                              <1> 	;
  6320                              <1> 	;	(Note: Memory page boundaries will be applied 
  6321                              <1> 	;	 to buffer size and buff start addr by rounding down.
  6322                              <1> 	;	 Rounded size & address values must not be zero.) 
  6323                              <1> 	;	-Normally, it is expected to request mapping by using
  6324                              <1> 	;	 correct buffer size of current or desired video mode-
  6325                              <1> 	;
  6326                              <1> 	;	EAX = 0 -> error ! memory can not mapped to user
  6327                              <1> 	;
  6328                              <1> 	; 04/01/2021
  6329                              <1> 	; SET/READ COLOR PALETTE (set/read DAC color registers)
  6330                              <1> 	;	((256 colors (8bpp) VGA/CGA video hardware feature))
  6331                              <1> 	;
  6332                              <1> 	;	BH = 11 = Set/Read DAC color registers
  6333                              <1> 	;
  6334                              <1> 	;	   (BL<4 Original method for std VGA video hardware)
  6335                              <1> 	;	   BL = 0 : Read all DAC color registers (256 colors)
  6336                              <1> 	;	       (6 bit colors, in RGB order)
  6337                              <1> 	;	   BL = 1 : Set all DAC color registers (256 colors)
  6338                              <1> 	;	       (6 bit colors, in RGB order)
  6339                              <1> 	;	   BL = 2 : Read single DAC color register
  6340                              <1> 	;	       (6 bit color, in RGB order)
  6341                              <1> 	;		((EAX will return with color value))
  6342                              <1> 	;		CL = DAC color register (index)
  6343                              <1> 	;	   BL = 3 : Set/Write single DAC color register
  6344                              <1> 	;	       (6 bit color, in RGB order, bit 6&7 are 0)
  6345                              <1> 	;		ECX byte 0 - DAC color register
  6346                              <1> 	;		ECX byte 1 - Red (6 bit)
  6347                              <1> 	;		ECX byte 2 - Green (6 bit)
  6348                              <1> 	;		ECX byte 3 - Blue (6 bit)
  6349                              <1> 	;	   (BL>3 Alternative method for BMP files etc.)	
  6350                              <1> 	;	   BL = 4 : Read all DAC color registers (256 colors)
  6351                              <1> 	;	       (8 bit colors, in BGR order, bit 0&1 is 0)
  6352                              <1> 	;	   BL = 5 : Set all DAC color registers (256 colors)
  6353                              <1> 	;	       (8 bit colors, in BGR order, bit 0&1 is 0)
  6354                              <1> 	;	   BL = 6 : Read single DAC color register
  6355                              <1> 	;	       (8 bit color, in BGR order, bit 0&1 is 0)
  6356                              <1> 	;		((EAX will return with color value))
  6357                              <1> 	;		CL = DAC color register (index)
  6358                              <1> 	;	   BL = 7 : Set/Write single DAC color register
  6359                              <1> 	;	       (8 bit color, bit 0&1 are 0)
  6360                              <1> 	;		ECX byte 0 - DAC color register
  6361                              <1> 	;		ECX byte 1 - Blue (8 bit)
  6362                              <1> 	;		ECX byte 2 - Green (8 bit)
  6363                              <1> 	;		ECX byte 3 - Red (8 bit)
  6364                              <1> 	;
  6365                              <1> 	;	  BL > 7 : invalid (not implemented)
  6366                              <1> 	;
  6367                              <1> 	;   if BL bit 2 is 1, 6 bit colors converted to 8 bit colors
  6368                              <1> 	;	(low two bits of color bytes will be 0)
  6369                              <1> 	;     ((color byte 00111111b will be converted to 11111100b))
  6370                              <1> 	;	and RGB byte order will be 
  6371                              <1> 	;		byte 0 - Blue (low 2 bits are 0)
  6372                              <1> 	;		byte 1 - Green (low 2 bits are 0)
  6373                              <1> 	;		byte 2 - Red (low 2 bits are 0)
  6374                              <1> 	;		byte 3 - pad (or zero byte)
  6375                              <1> 	;	and 256 colors buffer size must be 256*4 = 1024 bytes
  6376                              <1> 	;   if BL bit 2 is 0, 6 bit colors will be used directly
  6377                              <1> 	;	  (high two bits of 8 bit color bytes will be 0)
  6378                              <1> 	;     ((dac color 111111b will be converted to 00111111b))
  6379                              <1> 	;		byte 0 - Red (high 2 bits are 0)
  6380                              <1> 	;		byte 1 - Green (high 2 bits are 0)
  6381                              <1> 	;		byte 2 - Blue (high 2 bits are 0)
  6382                              <1> 	;	and 256 colors buffer size must be 256*3 = 768 bytes
  6383                              <1> 	;
  6384                              <1> 	;	ECX = User's buffer addr (256*3 = 768 bytes) or
  6385                              <1> 	;	      Color 
  6386                              <1> 	;
  6387                              <1> 	; Return:				
  6388                              <1>         ;	EAX = buffer size (for BL input = 0,1,4,5)
  6389                              <1> 	;	      or color value (for BL input = 2,3,6,7)
  6390                              <1> 	;
  6391                              <1> 	; 10/01/2021
  6392                              <1> 	; SET/READ FONT DATA
  6393                              <1> 	;
  6394                              <1> 	;	BH = 12 = Set/Read Character Font Data
  6395                              <1> 	;
  6396                              <1> 	;	   BL = 0 : Disable system font overwrite
  6397                              <1> 	;	   BL = 1 : Enable system font overwrite
  6398                              <1> 	;	   BL = 2 : Read system font 8x8
  6399                              <1> 	;	   BL = 3 : Read system font 8x14
  6400                              <1> 	;	   BL = 4 : Read system font 8x16
  6401                              <1> 	;	   BL = 5 : Read user defined font 8x8
  6402                              <1> 	;	   BL = 6 : Read user defined font 8x16
  6403                              <1> 	;	   BL = 7 : Write system font 8x8
  6404                              <1> 	;	   BL = 8 : Write system font 8x14
  6405                              <1> 	;	   BL = 9 : Write system font 8x16
  6406                              <1> 	;	   BL = 10 : Write user defined font 8x8
  6407                              <1> 	;	   BL = 11 : Write user defined font 8x16
  6408                              <1> 	;
  6409                              <1> 	;	  BL > 11 : invalid (not implemented)
  6410                              <1> 	;
  6411                              <1> 	;	For BL = 1 to 11
  6412                              <1> 	;	   ECX = number of characters (<= 256)
  6413                              <1> 	;	   EDX = first character (ascii code in DL)
  6414                              <1> 	;	   ESI = user's buffer address
  6415                              <1> 	;
  6416                              <1> 	; Return:				
  6417                              <1>         ;	EAX = number of characters (ecx input)
  6418                              <1> 	;	EAX = 0 -> error
  6419                              <1> 	;	(EAX = 256 for BL = 0 and 1 if successful)
  6420                              <1> 	;	
  6421                              <1> 	; Note: system font overwrite permission will be
  6422                              <1> 	;       given if [multi_tasking] = 0 
  6423                              <1> 	;	and [u.uid] = 0 (BL = 1) ; 19/01/2021
  6424                              <1> 	;       and if [ufont] bit 7 is 1 (BL = 7,8,9)
  6425                              <1> 	;
  6426                              <1> 	; 18/01/2021
  6427                              <1> 	; SAVE/RESTORE STANDARD VGA VIDEO STATE
  6428                              <1> 	;
  6429                              <1> 	;	BH = 13 = Save/Restore std VGA video state
  6430                              <1> 	;
  6431                              <1> 	;	   BL = 0 : Save VGA state (without DAC regs)
  6432                              <1> 	;		Return: EAX = VideoStateID (>0)
  6433                              <1> 	;			EAX = 0 (failed!)
  6434                              <1> 	;	       (size: 110 bytes for TRDOS 386 v2.0.3)
  6435                              <1> 	;	   BL = 1 : Restore VGA state (without DAC regs)
  6436                              <1> 	;		ECX = VideoStateID (to be verified)
  6437                              <1> 	;	        Return: EAX = Restore size (>0)
  6438                              <1> 	;	   BL = 2 : Save VGA state (complete)
  6439                              <1> 	;		Return: EAX = VideoStateID (>0)
  6440                              <1> 	;			EAX = 0 (failed!)
  6441                              <1> 	;	       (size: 882 bytes for TRDOS 386 v2.0.3) 
  6442                              <1> 	;	   BL = 3 : Restore VGA state (complete)
  6443                              <1> 	;		ECX = VideoStateID (to be verified)
  6444                              <1> 	;	        Return: EAX = Restore size (>0)
  6445                              <1> 	;
  6446                              <1> 	;	* Above options are for saving
  6447                              <1> 	;	*       video state to system memory
  6448                              <1> 	;	*	(location: VBE3VIDEOSTATE, 2048 bytes)
  6449                              <1> 	;	
  6450                              <1> 	;	   BL = 4 : Save VGA state (without DAC regs)
  6451                              <1> 	;		ECX = buffer address  
  6452                              <1> 	;		Return: EAX = transfer count
  6453                              <1> 	;	       (size: 110 bytes for TRDOS 386 v2.0.3)
  6454                              <1> 	;		ECX = buffer address  
  6455                              <1> 	;	   BL = 5 : Restore VGA state (without DAC regs)
  6456                              <1> 	;		ECX = buffer address  
  6457                              <1> 	;	        Return: EAX = transfer count
  6458                              <1> 	;	   BL = 6 : Save VGA state (complete)
  6459                              <1> 	;		ECX = buffer address  
  6460                              <1> 	;		Return: EAX = transfer count
  6461                              <1> 	;	       (size: 882 bytes for TRDOS 386 v2.0.3)
  6462                              <1> 	;	   BL = 7 : Restore VGA state (complete)
  6463                              <1> 	;		ECX = buffer address  
  6464                              <1> 	;	        Return: EAX = transfer count
  6465                              <1> 	;
  6466                              <1> 	;	* Above options are for saving
  6467                              <1> 	;	*       video state to user's buffer
  6468                              <1> 	;	*	(buffer size: 110 bytes or 882 bytes)
  6469                              <1> 	;
  6470                              <1> 	;	  BL > 7 : invalid (not implemented)
  6471                              <1> 	;
  6472                              <1> 	; 18/01/2021
  6473                              <1> 	; SAVE/RESTORE SUPER VGA (VESA VBE 2/3) VIDEO STATE
  6474                              <1> 	;
  6475                              <1> 	;	BH = 14 = Save/Restore SVGA video state
  6476                              <1> 	;
  6477                              <1> 	;	   BL = options
  6478                              <1> 	;		bit 0 - Save (0) or Restore (1)	
  6479                              <1> 	;		bit 1 - controller hardware state
  6480                              <1> 	;		bit 2 - BIOS data state
  6481                              <1> 	;		bit 3 - DAC state
  6482                              <1> 	;		bit 4 - (extended) Register state
  6483                              <1> 	;		bit 5 - system (0) or user (1) memory
  6484                              <1> 	;		bit 6 - verify without transfer
  6485                              <1> 	;		bit 7 - not used (must be 0)
  6486                              <1> 	;			
  6487                              <1> 	;	     if bit 0 = 0 and bit 5 = 0
  6488                              <1> 	;		Return:	EAX = VideoStateID (>0)	
  6489                              <1> 	;	     if bit 0 = 1
  6490                              <1> 	;		ECX = VideoStateID (bit 5 = 0)
  6491                              <1> 	;		Return: EAX = restore (transfer) size
  6492                              <1> 	;	     if bit 5 = 1
  6493                              <1> 	;		ECX = Buffer address
  6494                              <1> 	;		Return: EAX = transfer count (size)
  6495                              <1> 	;
  6496                              <1> 	;	     ECX = Buffer address or VideoStateID
  6497                              <1> 	;
  6498                              <1> 	;	  BL > 127 : invalid (not implemented)
  6499                              <1> 	;
  6500                              <1> 	;  Note: Required buffer size may be > 2048 bytes
  6501                              <1> 	;	 (function fails when buff size > 2048 bytes)
  6502                              <1> 	;	 proper option must be used
  6503                              <1> 	;
  6504                              <1> 	; 18/01/2021
  6505                              <1> 	; READ VESA EDID (EXTENDED DISPLAY IDENTIFICATION DATA)
  6506                              <1> 	;
  6507                              <1> 	;	BH = 15 = Read VESA EDID for connected monitor  
  6508                              <1> 	;		  (copy EDID to user)	
  6509                              <1> 	;
  6510                              <1> 	;	   BL = any
  6511                              <1> 	;
  6512                              <1> 	;	Input:
  6513                              <1> 	;	    ECX = user's (EDID) buffer address 
  6514                              <1> 	;		 (buffer size: 128 bytes)
  6515                              <1> 	;	Output:
  6516                              <1> 	;	    EAX = 128 (EDID size)
  6517                              <1> 	;	    or EAX = 0 -> Error!
  6518                              <1> 	;	       (EDID not ready or buffer addr error)	
  6519                              <1> 	;
  6520                              <1>  	
  6521                              <1> 	; 16/05/2016
  6522 0000E302 31C0                <1> 	xor	eax, eax
  6523 0000E304 A3[64030300]        <1> 	mov	[u.r0], eax
  6524 0000E309 20FF                <1> 	and	bh, bh
  6525 0000E30B 0F858B020000        <1> 	jnz	sysvideo_13 ; 11/07/2016
  6526                              <1> 
  6527                              <1> 	;; 21/11/2020 (TRDOS 386 v2.0.3)
  6528                              <1> 	;; tty/text mode transfers are only for video mode 3
  6529                              <1> 
  6530                              <1> 	; 22/11/2020
  6531                              <1> 	;cmp	byte [CRT_MODE], 3 ; 80x25 text, 16 colors
  6532                              <1> 	;jne	sysret ; invalid (nothing to do), [u.r0] = 0	
  6533                              <1> 	
  6534                              <1> 	; 23/11/2020
  6535                              <1> 	; bit 7,6,5,4 of BL are reserved and it must be 0
  6536                              <1> 	;	 	 for current 'sysvideo' version
  6537                              <1> 	;test	bl, 0F0h
  6538                              <1> 	;;jnz	sysret ; invalid (undefined) ! 
  6539                              <1> 	;; 28/01/2021
  6540                              <1> 	;jnz	short sysvideo_1_2 ; invalid (undefined) !
  6541                              <1> 	; 28/01/2021
  6542 0000E311 80FB07              <1> 	cmp	bl, 7
  6543 0000E314 776E                <1> 	ja	short sysvideo_1_2 ; invalid (undefined) !	
  6544                              <1> 
  6545                              <1> 	; Video mode 0, 80*25 text mode, CGA 16 colors  
  6546                              <1> 	; [CRT_MODE] = 3
  6547                              <1> 	;mov	bh, bl
  6548                              <1> 	;shr	bh, 2 ; 4..7 -> 1, 8..11 -> 2, 12..15 -> 3
  6549                              <1> 	;; 21/11/2020
  6550                              <1> 	;;and	bh, bh
  6551                              <1>         ;jnz	sysvideo_4  ; Display page window transfer etc.
  6552                              <1> 
  6553                              <1> 	; 28/01/2021
  6554 0000E316 F6C304              <1> 	test	bl, 4 ; bit 2
  6555 0000E319 0F85A2000000        <1> 	jnz	sysvideo_4 ; Display page window transfer
  6556                              <1> 
  6557                              <1> 	; Display page (complete) transfer
  6558 0000E31F 80FA07              <1> 	cmp	dl, 7
  6559                              <1> 	;jnz	sysret ; invalid (nothing to do), [u.r0] = 0
  6560 0000E322 760A                <1> 	jna	short sysvideo_0 ; 28/01/2021	
  6561 0000E324 FEC2                <1> 	inc	dl ; 0FFh -> 0 ("use current video page")
  6562 0000E326 755C                <1> 	jnz	short sysvideo_1_2  ; invalid
  6563                              <1> 	; dl = 0 -> use current current page
  6564 0000E328 8A15[5E8A0100]      <1> 	mov	dl, [ACTIVE_PAGE]
  6565                              <1> sysvideo_0:
  6566                              <1> 	; 28/01/2021 
  6567 0000E32E 80FB03              <1> 	cmp	bl, 3
  6568 0000E331 7206                <1> 	jb	short sysvideo_0_0
  6569 0000E333 09FF                <1> 	or	edi, edi
  6570 0000E335 744D                <1> 	jz	short sysvideo_1_2  ; invalid
  6571 0000E337 89FE                <1> 	mov	esi, edi ; save swap/exchange buffer addr
  6572                              <1> 	; ecx = user buffer for new video page content
  6573                              <1> 	; esi = user (swap) buffer for saving current video page  
  6574                              <1> sysvideo_0_0:
  6575 0000E339 BF00800B00          <1> 	mov	edi, 0B8000h
  6576                              <1> 	; dl = display page number, destination
  6577 0000E33E 66B80010            <1> 	mov	ax, 4096 ; 21/11/2020
  6578 0000E342 20D2                <1> 	and	dl, dl
  6579 0000E344 7408                <1> 	jz	short sysvideo_1
  6580                              <1> 	; 07/02/2021
  6581 0000E346 88D6                <1> 	mov	dh, dl
  6582                              <1> sysvideo_0_1:
  6583                              <1> 	; page length = 4096 bytes (but page content is 80*25*2 bytes)
  6584 0000E348 01C7                <1> 	add	edi, eax ; 21//11/2020 ([CRT_LEN] = 1000h for mode 3)
  6585 0000E34A FECE                <1> 	dec	dh
  6586 0000E34C 75FA                <1> 	jnz	short sysvideo_0_1
  6587                              <1> sysvideo_1:	
  6588 0000E34E 80E303              <1> 	and	bl, 3
  6589 0000E351 7536                <1> 	jnz	short sysvideo_2 ; user to system display page transfer
  6590                              <1> 	; system to system video page (content) transfer
  6591                              <1> 	; cl = display page number, source
  6592 0000E353 80F907              <1> 	cmp	cl, 7
  6593                              <1> 	;ja	sysret ; invalid (nothing to do), [u.r0] = 0
  6594 0000E356 760A                <1> 	jna	short sysvideo_1_0
  6595 0000E358 FEC1                <1> 	inc	cl ; 0FFh -> 0 ("use current video page")
  6596 0000E35A 7528                <1> 	jnz	short sysvideo_1_2  ; invalid
  6597 0000E35C 8A0D[5E8A0100]      <1> 	mov	cl, [ACTIVE_PAGE]
  6598                              <1> sysvideo_1_0:
  6599                              <1> 	; 28/01/2021
  6600 0000E362 38D1                <1> 	cmp	cl, dl
  6601 0000E364 741E                <1> 	je	short sysvideo_1_2  ; same video page !
  6602                              <1> 
  6603                              <1> 	; system to system video/display page transfer (mode 0)
  6604                              <1> 	; 21/11/2020
  6605                              <1> 	;mov	esi, 0B8000h
  6606                              <1> 	;movzx	eax, cl
  6607                              <1> 	;mov	edx, 4096 ; [CRT_LEN] = 1000h for video mode 3
  6608                              <1> 	;mov	ecx, edx
  6609                              <1> 	;mul	edx
  6610                              <1> 	;add	esi, eax
  6611                              <1> 	; 28/01/2021
  6612                              <1> 	;movzx	esi, cl
  6613                              <1> 	;shl	si, 12 ; * 4096
  6614                              <1> 	;add	esi, 0B8000h 
  6615                              <1> 	
  6616                              <1> 	; 28/01/2021
  6617 0000E366 A3[64030300]        <1> 	mov	[u.r0], eax ; 4096
  6618 0000E36B BE00800B00          <1> 	mov	esi, 0B8000h
  6619 0000E370 08C9                <1> 	or	cl, cl
  6620 0000E372 740A                <1> 	jz	short sysvideo_1_1
  6621                              <1> 	; 07/02/2021
  6622 0000E374 88C8                <1> 	mov	al, cl ; display/video page
  6623 0000E376 30E4                <1> 	xor	ah, ah
  6624 0000E378 66C1E00C            <1> 	shl	ax, 12 ; * 4096	
  6625 0000E37C 01C6                <1>  	add	esi, eax
  6626                              <1> sysvideo_1_1:
  6627                              <1> 	; 21/11/2020
  6628                              <1> 	;;mov	ecx, 4096
  6629                              <1> 	;mov	ecx, eax ; 4096
  6630                              <1> 	;;mov	[u.r0], ecx ; 4096 bytes
  6631                              <1> 	; 28/01/2021	
  6632                              <1> 	;mov	[u.r0], cx
  6633 0000E37E 31C9                <1> 	xor	ecx, ecx
  6634 0000E380 B504                <1> 	mov	ch, 4 ; mov ecx, 1024
  6635                              <1> 	;shr	cx, 2 ; / 4
  6636 0000E382 F3A5                <1> 	rep	movsd
  6637                              <1> sysvideo_1_2:
  6638 0000E384 E983F5FFFF          <1> 	jmp	sysret
  6639                              <1> sysvideo_2:  
  6640 0000E389 80FB02              <1> 	cmp	bl, 2
  6641                              <1>         ;ja	sysret; invalid (user to user), [u.r0] = 0
  6642                              <1> 	; 28/01/2021
  6643 0000E38C 7226                <1> 	jb	short sysvideo_3 ; user to system
  6644 0000E38E 7404                <1> 	je	short sysvideo_2_0 ; system to user
  6645                              <1> 	; bl = 3
  6646 0000E390 89CA                <1> 	mov	edx, ecx ; save user's buffer addr
  6647 0000E392 89F1                <1> 	mov	ecx, esi ; save swap address
  6648                              <1> sysvideo_2_0:
  6649                              <1> 	; bl = 2 (or bl = 3, stage 1)
  6650                              <1> 	; system to user video/display page transfer (mode 0)
  6651 0000E394 89FE                <1> 	mov	esi, edi
  6652 0000E396 89CF                <1> 	mov	edi, ecx ; user buffer ; 28/01/2021
  6653                              <1> 	; 21/11/2020
  6654 0000E398 89C1                <1> 	mov	ecx, eax ; 4096
  6655 0000E39A E8C5370000          <1> 	call	transfer_to_user_buffer ; fast transfer
  6656                              <1> 	;jc	sysret ; [u.r0] = 0
  6657 0000E39F 72E3                <1> 	jc	short sysvideo_1_2 ; 28/01/2021
  6658                              <1> 	; 28/01/2021
  6659 0000E3A1 80FB03              <1> 	cmp	bl, 3
  6660 0000E3A4 7408                <1> 	je	short sysvideo_2_2
  6661                              <1> sysvideo_2_1:
  6662                              <1> 	; 21/11/2020
  6663 0000E3A6 890D[64030300]      <1> 	mov	[u.r0], ecx
  6664                              <1> 	;;mov	[u.r0], cx
  6665                              <1> 	;jmp	sysret
  6666 0000E3AC EBD6                <1> 	jmp	short sysvideo_1_2
  6667                              <1> 
  6668                              <1> sysvideo_2_2:
  6669                              <1> 	; bl = 3 (exchange/swap) complete display page
  6670                              <1> 	; esi = video page start address
  6671                              <1> 	; edx = user's buffer address
  6672                              <1> 	
  6673                              <1> 	;mov	ecx, 4096
  6674 0000E3AE 89F7                <1> 	mov	edi, esi ; video page start address
  6675 0000E3B0 89D6                <1> 	mov	esi, edx ; user's (new page) buffer address
  6676 0000E3B2 EB04                <1> 	jmp	short sysvideo_2_3
  6677                              <1> sysvideo_3: 
  6678                              <1> 	; bl = 1 (or bl = 3, stage 2)
  6679                              <1> 	; user to system video/display page transfer (mode 0)	
  6680 0000E3B4 89CE                <1> 	mov	esi, ecx ; user buffer
  6681                              <1> 	; edi = video page address
  6682                              <1> 	; 21/11/2020
  6683 0000E3B6 89C1                <1> 	mov	ecx, eax ; 4096
  6684                              <1> sysvideo_2_3:
  6685 0000E3B8 E8F1370000          <1> 	call	transfer_from_user_buffer ; fast transfer
  6686                              <1> 	;jc	sysret ; [u.r0] = 0
  6687 0000E3BD 72C5                <1> 	jc	short sysvideo_1_2 ; 28/01/2021
  6688 0000E3BF EBE5                <1> 	jmp	short sysvideo_2_1
  6689                              <1> 
  6690                              <1> 	; 21/11/2020
  6691                              <1> 	;mov	[u.r0], ecx
  6692                              <1> 	;;mov	[u.r0], cx
  6693                              <1> 	;;jmp	sysret
  6694                              <1> 	;jmp	short sysvideo_1_2 ; 28/01/2021
  6695                              <1> 
  6696                              <1> sysvideo_4:
  6697                              <1> 	; 23/11/2020 (TRDOS 386 v2.0.3)
  6698                              <1> 
  6699                              <1> 	; Display page window transfer etc.
  6700 0000E3C1 80E303              <1> 	and	bl, 3
  6701 0000E3C4 0F85F7000000        <1>         jnz     sysvideo_9 ; user to system or system to user
  6702                              <1> 	; 21/11/2020
  6703                              <1> 	; system to system video/display page window transfer (mode 0)
  6704 0000E3CA 81FE00800B00        <1> 	cmp	esi, 0B8000h	; source buffer address (system)
  6705 0000E3D0 0F8236F5FFFF        <1> 	jb	sysret
  6706 0000E3D6 81FE00000C00        <1> 	cmp	esi, 0B8000h+(4096*8)
  6707 0000E3DC 0F832AF5FFFF        <1> 	jnb	sysret
  6708 0000E3E2 81FF00800B00        <1> 	cmp	edi, 0B8000h	; destination buffer address (system)	
  6709 0000E3E8 0F821EF5FFFF        <1> 	jb	sysret
  6710 0000E3EE 81FF00000C00        <1>         cmp     edi, 0B8000h+(4096*8)
  6711 0000E3F4 0F8312F5FFFF        <1> 	jnb	sysret
  6712                              <1> 	;
  6713 0000E3FA 51                  <1> 	push	ecx ; X1 and Y1 position - top left column, row
  6714 0000E3FB 0FB7C1              <1> 	movzx	eax, cx ; top left column
  6715                              <1> 	; 21/11/2020
  6716 0000E3FE C1E910              <1> 	shr	ecx, 16 ; top row
  6717 0000E401 740E                <1> 	jz	short sysvideo_4_0 ; bypass following code
  6718 0000E403 52                  <1> 	push	edx ; X2 and Y2 position - bottom right column, row
  6719 0000E404 50                  <1> 	push	eax
  6720 0000E405 66B8A000            <1> 	mov	ax, 80*2 ; 80 colums, 160 bytes per row
  6721 0000E409 F7E1                <1> 	mul	ecx
  6722                              <1> 		; eax = offset for start row number 
  6723 0000E40B 01C6                <1> 	add	esi, eax
  6724 0000E40D 01C7                <1> 	add	edi, eax
  6725 0000E40F 58                  <1> 	pop	eax
  6726 0000E410 5A                  <1> 	pop	edx
  6727                              <1> sysvideo_4_0:
  6728 0000E411 66D1E0              <1> 	shl	ax, 1 ; * 2 ; convert start column number to offset
  6729 0000E414 7404                <1> 	jz	short sysvideo_4_1	
  6730 0000E416 01C6                <1> 	add	esi, eax
  6731 0000E418 01C7                <1> 	add	edi, eax
  6732                              <1> 		; esi = source page window start offset
  6733                              <1> 		; edi = destination page window start offset
  6734                              <1> sysvideo_4_1:
  6735 0000E41A 59                  <1> 	pop	ecx
  6736                              <1> 	;mov	eax, 0B8000h+(80*25*2*8)
  6737                              <1> 	; 21/11/2020
  6738 0000E41B B800000C00          <1> 	mov	eax, 0B8000h+(4096*8)
  6739 0000E420 39C6                <1> 	cmp	esi, eax
  6740 0000E422 0F83E4F4FFFF        <1> 	jnb	sysret ; out of video page
  6741 0000E428 39C6                <1> 	cmp	esi, eax
  6742 0000E42A 0F83DCF4FFFF        <1> 	jnb	sysret  ;out of video page	
  6743                              <1> 
  6744 0000E430 56                  <1> 	push	esi ; ****
  6745 0000E431 57                  <1> 	push	edi ; ***
  6746 0000E432 52                  <1> 	push	edx ; **
  6747 0000E433 51                  <1> 	push	ecx ; *
  6748 0000E434 C1E910              <1> 	shr	ecx, 16 ; top row
  6749 0000E437 C1EA10              <1> 	shr	edx, 16 ; bottom row
  6750                              <1> 	; 21/11/2020
  6751                              <1> 	;cmp	ecx, 24 ; max. 25 rows
  6752 0000E43A 6683F918            <1> 	cmp	cx, 24
  6753 0000E43E 7778                <1> 	ja	short sysvideo_6 ; invalid, [u.r0] = 0
  6754                              <1> 	;cmp	edx, 24 ; max. 25 rows
  6755 0000E440 6683FA18            <1> 	cmp	dx, 24
  6756 0000E444 7772                <1> 	ja	short sysvideo_6 ; invalid, [u.r0] = 0		
  6757 0000E446 28CA                <1> 	sub	dl, cl ; end >= start
  6758 0000E448 726E                <1> 	jc	short sysvideo_6 ; invalid, [u.r0] = 0
  6759                              <1> 	; 21/11/2020
  6760 0000E44A 89D3                <1> 	mov	ebx, edx ; row count - 1
  6761 0000E44C 7415                <1> 	jz	short sysvideo_4_2
  6762 0000E44E 50                  <1> 	push	eax ; *****
  6763 0000E44F B8A0000000          <1> 	mov	eax, 80*2 ; bytes per row
  6764 0000E454 F7E3                <1> 	mul	ebx ; 21/11/2020
  6765                              <1> 		; eax = window end offset 
  6766                              <1> 		; (for the last row, before adding column bytes)
  6767 0000E456 01C6                <1> 	add	esi, eax
  6768 0000E458 01C7                <1> 	add	edi, eax
  6769 0000E45A 58                  <1> 	pop	eax ; ***** ; mode 3 video memory end (0C000h)
  6770 0000E45B 39C6                <1> 	cmp	esi, eax
  6771                              <1> 	;ja	short sysvideo_6 ; invalid, [u.r0] = 0
  6772 0000E45D 7359                <1> 	jnb	short sysvideo_6 ; 21/11/2020
  6773 0000E45F 39C7                <1> 	cmp	edi, eax
  6774                              <1> 	;ja	short sysvideo_6 ; invalid, [u.r0] = 0
  6775 0000E461 7355                <1> 	jnb	short sysvideo_6 ; 21/11/2020
  6776                              <1> sysvideo_4_2:
  6777 0000E463 59                  <1> 	pop	ecx ; *
  6778 0000E464 5A                  <1> 	pop	edx ; **
  6779 0000E465 81E1FFFF0000        <1> 	and	ecx, 0FFFFh
  6780 0000E46B 81E2FFFF0000        <1> 	and	edx, 0FFFFh
  6781                              <1> 	; 21/11/2020
  6782                              <1> 	;cmp	ecx, 79 ; max. 80 columns
  6783 0000E471 6683F94F            <1> 	cmp	cx, 79
  6784 0000E475 7743                <1> 	ja	short sysvideo_7 ; invalid, [u.r0] = 0
  6785                              <1> 	;cmp	edx, 79 ; max. 80 columns
  6786 0000E477 6683FA4F            <1> 	cmp	dx, 79 
  6787 0000E47B 773D                <1> 	ja	short sysvideo_7 ; invalid, [u.r0] = 0
  6788 0000E47D 28CA                <1> 	sub	dl, cl
  6789 0000E47F 7639                <1> 	jna	short sysvideo_7 ; invalid, [u.r0] = 0
  6790                              <1> 	; 21/11/2020
  6791 0000E481 740E                <1> 	jz	short sysvideo_4_3 
  6792                              <1> 	; edx = column count (width) - 1
  6793 0000E483 D0E2                <1> 	shl	dl, 1 ; * 2 ; byte offset (in end row)
  6794 0000E485 01D6                <1> 	add	esi, edx
  6795 0000E487 01D7                <1> 	add	edi, edx
  6796                              <1> 		; esi = source page window end offset
  6797                              <1> 		; edi = destination page window end offset
  6798 0000E489 39C6                <1> 	cmp	esi, eax ; video memory end
  6799                              <1> 	;ja	short sysvideo_7
  6800 0000E48B 732D                <1> 	jnb	short sysvideo_7 ; 21/11/2020
  6801 0000E48D 39C7                <1> 	cmp	edi, eax ; video memory end
  6802                              <1> 	;ja	short sysvideo_7
  6803 0000E48F 7329                <1> 	jnb	short sysvideo_7 ; 21/11/2020
  6804                              <1> sysvideo_4_3:
  6805 0000E491 5F                  <1> 	pop	edi ; ***
  6806 0000E492 5E                  <1> 	pop	esi ; ****
  6807 0000E493 FEC3                <1> 	inc	bl ; row count - 1 -> row count	
  6808 0000E495 FEC2                <1> 	inc	dl ; column count
  6809 0000E497 88D7                <1> 	mov	bh, dl
  6810 0000E499 D0E2                <1> 	shl	dl, 1 ; convert column count to byte offset
  6811                              <1> 	; 21/11/2020
  6812                              <1> 	; esi = source page window start offset
  6813                              <1> 	; edi = destination page window start offset
  6814 0000E49B B8A0000000          <1> 	mov	eax, 80*2 ; bytes per row
  6815                              <1> 	; Note: 160 bytes per row (even if move count < 160)
  6816                              <1> sysvideo_5:	
  6817 0000E4A0 88F9                <1> 	mov	cl, bh ; move/transfer -word- count per row
  6818 0000E4A2 0115[64030300]      <1> 	add	[u.r0], edx ; transfer count in bytes
  6819 0000E4A8 F366A5              <1> 	rep	movsw
  6820 0000E4AB 01C6                <1> 	add	esi, eax ; + 160 bytes to next row
  6821 0000E4AD 01C7                <1> 	add	edi, eax ; + 160 bytes to next row
  6822 0000E4AF FECB                <1> 	dec	bl ; remain count of rows
  6823 0000E4B1 75ED                <1> 	jnz	short sysvideo_5
  6824 0000E4B3 E954F4FFFF          <1> 	jmp	sysret
  6825                              <1> 
  6826                              <1> sysvideo_6:
  6827 0000E4B8 59                  <1> 	pop	ecx ; *
  6828 0000E4B9 5A                  <1> 	pop	edx ; **
  6829                              <1> sysvideo_7:	
  6830 0000E4BA 5F                  <1> 	pop	edi ; ***
  6831 0000E4BB 5E                  <1> 	pop	esi ; ****
  6832                              <1> sysvideo_8:
  6833 0000E4BC E94BF4FFFF          <1> 	jmp	sysret
  6834                              <1> 
  6835                              <1> sysvideo_9:
  6836                              <1> 	; user to system or system to user window transfer
  6837                              <1> 	; 28/01/2021 (bl = 3 -> swap/exchange)
  6838                              <1> 	;cmp	bl, 2
  6839                              <1> 	;;ja	sysret	; user to user transfer is invalid
  6840                              <1> 	;		; [u.r0] = 0
  6841                              <1> 	;ja	short sysvideo_8 ; 26/12/2020
  6842                              <1> 
  6843                              <1> 	; 28/01/2021
  6844 0000E4C1 80FB02              <1> 	cmp	bl, 2
  6845 0000E4C4 7604                <1> 	jna	short sysvideo_9_8 
  6846                              <1> 
  6847                              <1> 	; swap/ exchange video memory and user mem windows
  6848                              <1> 	; edi = swap address in user's memory space
  6849 0000E4C6 21FF                <1> 	and	edi, edi
  6850 0000E4C8 74F2                <1> 	jz	short sysvideo_8 ; invalid ; 28/01/2021
  6851                              <1>  
  6852                              <1> sysvideo_9_8:		
  6853 0000E4CA 56                  <1> 	push	esi ; ****
  6854 0000E4CB 57                  <1> 	push	edi ; ***
  6855 0000E4CC 52                  <1> 	push	edx ; **
  6856 0000E4CD 51                  <1> 	push	ecx ; *
  6857                              <1> 
  6858 0000E4CE C1E910              <1> 	shr	ecx, 16 ; top row
  6859 0000E4D1 C1EA10              <1> 	shr	edx, 16 ; bottom row
  6860                              <1> 	
  6861                              <1> 	; 21/11/2020
  6862                              <1> 	;cmp	ecx, 24 ; max. 25 rows
  6863 0000E4D4 6683F918            <1> 	cmp	cx, 24
  6864 0000E4D8 77DE                <1> 	ja	short sysvideo_6 ; invalid, [u.r0] = 0
  6865                              <1> 	;cmp	edx, 24 ; max. 25 rows
  6866 0000E4DA 6683FA18            <1> 	cmp	dx, 24
  6867 0000E4DE 77D8                <1> 	ja	short sysvideo_6 ; invalid, [u.r0] = 0	
  6868 0000E4E0 28CA                <1> 	sub	dl, cl
  6869 0000E4E2 72D4                <1> 	jc	short sysvideo_6 ; invalid, [u.r0] = 0
  6870                              <1> 
  6871                              <1> 	;mov	ch, cl ; top row
  6872                              <1> 	;mov	cl, [ACTIVE_PAGE]
  6873                              <1> 
  6874                              <1> 	;mov	edi, 80*25*2 ; 4000
  6875                              <1> 	; 21/11/2020
  6876                              <1> 	;mov	edi, 4096 ; [CRT_LEN = 4096 for video mode 3 
  6877                              <1> 	;shl	edi, cl  ; ! wrong for page 2 to page 7 !
  6878                              <1> 	;;add	edi, 0B8000h - 80*25*2
  6879                              <1> 	;add	edi, 0B8000h - 1000h ; - 4096
  6880                              <1> 	
  6881                              <1> 	; 21/11/2020
  6882                              <1> 	;xor	eax, eax
  6883                              <1> 	;mov	edi, 0B8000h
  6884                              <1> 	;and	cl, cl ; is video page = 0 ?
  6885                              <1> 	;jz	short sysvideo_9_1 ; yes
  6886                              <1> 	; eax = 0
  6887                              <1> 
  6888                              <1> ;sysvideo_9_0:
  6889                              <1> 	;add	ax, 4096
  6890                              <1> 	;dec	cl
  6891                              <1> 	;jnz	short sysvideo_9_0
  6892                              <1> 	;add	edi, eax
  6893                              <1> 	;	; edi = video page start address
  6894                              <1> 
  6895                              <1> 	; 21/11/2020
  6896 0000E4E4 BF00800B00          <1> 	mov	edi, 0B8000h
  6897 0000E4E9 803D[5E8A0100]00    <1> 	cmp	byte [ACTIVE_PAGE], 0
  6898 0000E4F0 760C                <1> 	jna	short sysvideo_9_1
  6899                              <1> stsvideo_9_0:
  6900 0000E4F2 B010                <1> 	mov	al, 16 ; 4096/256
  6901 0000E4F4 F625[5E8A0100]      <1> 	mul	byte [ACTIVE_PAGE] 
  6902 0000E4FA 86E0                <1> 	xchg	ah, al ; * 256
  6903 0000E4FC 01C7                <1> 	add	edi, eax
  6904                              <1> 		; edi = video page start address
  6905                              <1> sysvideo_9_1:
  6906                              <1> 	; bl = transfer direction 
  6907                              <1> 	;     (1 = from user, 2 = to user)
  6908                              <1> 	;     (3 = swap) ; 28/01/2021
  6909 0000E4FE 88D7                <1> 	mov	bh, dl ; row count - 1
  6910                              <1> 	;mov	dl, ch ; top row
  6911                              <1> 	; 21/11/2020
  6912 0000E500 08C9                <1> 	or	cl, cl ; top row number
  6913 0000E502 7408                <1> 	jz	short sysvideo_9_2
  6914                              <1> 
  6915                              <1> 	;mov	eax, 80*2
  6916 0000E504 66B8A000            <1> 	mov	ax, 80*2 ; 160, bytes per row
  6917 0000E508 F7E1                <1> 	mul	ecx ; 22/11/2020
  6918 0000E50A 01C7                <1> 	add	edi, eax
  6919                              <1> 		; edi = window start address for top row
  6920                              <1> sysvideo_9_2:
  6921 0000E50C 59                  <1> 	pop	ecx ; *
  6922 0000E50D 5A                  <1> 	pop	edx ; **
  6923 0000E50E 81E1FFFF0000        <1> 	and	ecx, 0FFFFh
  6924 0000E514 81E2FFFF0000        <1> 	and	edx, 0FFFFh
  6925                              <1> 	; 21/11/2020
  6926                              <1> 	;cmp	ecx, 79 ; max. 80 columns
  6927 0000E51A 6683F94F            <1> 	cmp	cx, 79
  6928 0000E51E 779A                <1> 	ja	short sysvideo_7 ; invalid, [u.r0] = 0
  6929                              <1> 	;cmp	edx, 79 ; max. 80 columns
  6930 0000E520 6683FA4F            <1> 	cmp	dx, 79
  6931 0000E524 7794                <1> 	ja	short sysvideo_7 ; invalid, [u.r0] = 0
  6932                              <1> 	
  6933 0000E526 28CA                <1> 	sub	dl, cl
  6934 0000E528 7290                <1> 	jc	short sysvideo_7 ; invalid, [u.r0] = 0
  6935                              <1> 	
  6936 0000E52A 08C9                <1> 	or	cl, cl ; left column 
  6937 0000E52C 7404                <1> 	jz	short sysvideo_9_3 ; 0
  6938                              <1> 
  6939                              <1> 	; 21/11/2020
  6940 0000E52E D0E1                <1> 	shl	cl, 1  ; column * 2
  6941 0000E530 01CF                <1> 	add	edi, ecx
  6942                              <1> 		; edi = window start addr for top left column
  6943                              <1> sysvideo_9_3:
  6944 0000E532 88D1                <1> 	mov	cl, dl
  6945 0000E534 FEC1                <1> 	inc	cl ; column count
  6946 0000E536 D0E1                <1> 	shl	cl, 1 ; column count * 2
  6947                              <1> 		; ecx = transfer count per row
  6948                              <1> 
  6949 0000E538 58                  <1> 	pop	eax ; *** (swap address)
  6950 0000E539 5E                  <1> 	pop	esi ; ****
  6951                              <1> 
  6952 0000E53A FEC7                <1> 	inc	bh  ; row count	
  6953                              <1> 	
  6954                              <1> 	;mov	edx, 80*2
  6955 0000E53C B2A0                <1> 	mov	dl, 80*2  ; bytes per row
  6956                              <1> 	;
  6957                              <1> 	;cmp	bl, 1 ; transfer direction
  6958                              <1> 	;ja	short sysvideo_11 ; system to user transfer
  6959                              <1> 	; 28/01/2021
  6960 0000E53E F6C301              <1> 	test	bl, 1
  6961 0000E541 7439                <1> 	jz	short sysvideo_11 ; system to user transfer
  6962                              <1> 
  6963                              <1> 	; user to system video/display page window transfer (mode 0)	
  6964 0000E543 21C0                <1> 	and	eax, eax ; swap address
  6965 0000E545 741B                <1> 	jz	short sysvideo_10 ; no window swap
  6966                              <1> sysvideo_9_7: ; 28/01/2021
  6967                              <1> 	; save previous window content in user's buffer (swap address)
  6968 0000E547 56                  <1> 	push	esi ; user buffer
  6969 0000E548 57                  <1> 	push	edi ; beginning address of the window
  6970                              <1> 	; 21/11/2020
  6971 0000E549 53                  <1> 	push	ebx ; save bh
  6972 0000E54A 89FE                <1> 	mov	esi, edi
  6973 0000E54C 89C7                <1> 	mov	edi, eax
  6974                              <1> sysvideo_9_4:
  6975 0000E54E E811360000          <1> 	call	transfer_to_user_buffer ; fast transfer
  6976 0000E553 7208                <1> 	jc	short sysvideo_9_5
  6977                              <1> 	; ecx = actual transfer count (must be same with input)
  6978 0000E555 01D6                <1> 	add	esi, edx ; next row address of (video page) window 
  6979 0000E557 01CF                <1> 	add	edi, ecx ; next row address of user's window
  6980                              <1> 		; Note: ecx may be less than row length of video page
  6981                              <1> 		; user's window uses offset according to window width
  6982 0000E559 FECF                <1> 	dec	bh
  6983 0000E55B 75F1                <1> 	jnz	short sysvideo_9_4 ; repeat for next row
  6984                              <1> sysvideo_9_5:
  6985 0000E55D 5B                  <1> 	pop	ebx ; restore bh
  6986 0000E55E 5F                  <1> 	pop	edi
  6987 0000E55F 5E                  <1> 	pop	esi
  6988                              <1> 	;jnc	short sysvideo_10
  6989 0000E560 7215                <1> 	jc	short sysvideo_9_6 ; 28/01/2021
  6990                              <1> ;sysvideo_9_6:
  6991                              <1> ;	jmp	sysret ; [u.r0] = 0
  6992                              <1> 
  6993                              <1> sysvideo_10:
  6994                              <1> 	; user to system video/display page window transfer (mode 0)	
  6995                              <1> 	; esi =	user buffer
  6996 0000E562 E847360000          <1> 	call	transfer_from_user_buffer ; fast transfer
  6997                              <1> 	;jc	sysret
  6998 0000E567 720E                <1> 	jc	short sysvideo_9_6 ; 28/01/2021
  6999                              <1> 	; ecx = actual transfer count (must be same with input)
  7000 0000E569 010D[64030300]      <1> 	add	[u.r0], ecx ; actual transfer count
  7001 0000E56F 01D7                <1> 	add	edi, edx ; next row address of (video page) window 
  7002 0000E571 01CE                <1> 	add	esi, ecx ; next row address of user's window
  7003                              <1> 		; Note: ecx may be less than row length of video page
  7004                              <1> 		; user's window uses offset according to window width
  7005 0000E573 FECF                <1> 	dec	bh
  7006 0000E575 75EB                <1> 	jnz	short sysvideo_10 ; repeat for next row
  7007                              <1> 	;jmp	sysret
  7008                              <1> sysvideo_9_6:
  7009 0000E577 E990F3FFFF          <1> 	jmp	sysret
  7010                              <1> 	
  7011                              <1> sysvideo_11:
  7012                              <1> 	; system to user video/display page window transfer (mode 0)
  7013 0000E57C 87FE                <1> 	xchg	edi, esi
  7014                              <1> sysvideo_12:
  7015                              <1> 	; esi = beginning addr of the (screen, video page) window
  7016                              <1> 	; edi =	user's buffer	
  7017 0000E57E E8E1350000          <1> 	call	transfer_to_user_buffer ; fast transfer
  7018 0000E583 0F8283F3FFFF        <1> 	jc	sysret
  7019                              <1> 	; ecx = actual transfer count (must be same with input)
  7020 0000E589 010D[64030300]      <1> 	add	[u.r0], ecx
  7021 0000E58F 01D6                <1> 	add	esi, edx ; next row (edx = 160)
  7022 0000E591 01CF                <1> 	add	edi, ecx ; next row of the user's window 
  7023                              <1> 			 ; (ecx <= 160)
  7024 0000E593 FECF                <1> 	dec	bh
  7025 0000E595 75E7                <1> 	jnz	short sysvideo_12
  7026                              <1> sysvideo_12_0:
  7027 0000E597 E970F3FFFF          <1> 	jmp	sysret
  7028                              <1> 
  7029                              <1> sysvideo_13:
  7030                              <1> 	; 28/12/2020
  7031 0000E59C 80FF01              <1> 	cmp	bh, 1
  7032 0000E59F 7753                <1>         ja      short sysvideo_15 ; 23/11/2020
  7033                              <1> 
  7034                              <1> 	; 25/02/2021
  7035                              <1> 	; 12/02/2021
  7036                              <1> 	; 29/01/2021, 31/01/2021
  7037                              <1> 	; 23/11/2020 (TRDOS 386 v2.0.3)
  7038                              <1> 	; (major modification, from mode 13h to all VGA modes,
  7039                              <1> 	;  except super VGA modes and liner frame buffer method)
  7040                              <1> 
  7041                              <1> 	; BH = 1 = VGA Graphics mode (0A0000h) data transfers
  7042                              <1> 
  7043                              <1> 	; 29/01/2021
  7044 0000E5A1 66B84001            <1> 	mov	ax, 320	; 320 pixels
  7045 0000E5A5 F6C380              <1> 	test	bl, 80h	; bit 7 (screen width, 640 pixels)		
  7046 0000E5A8 7408                <1> 	jz	short sysvideo_13_0
  7047 0000E5AA 66D1E0              <1> 	shl	ax, 1	; 640 pixels
  7048                              <1> 	;
  7049 0000E5AD 80E37F              <1> 	and	bl, 7Fh
  7050 0000E5B0 7405                <1> 	jz	short sysvideo_14
  7051                              <1> sysvideo_13_0:
  7052                              <1> 	; 29/01/2021
  7053 0000E5B2 80FB41              <1> 	cmp	bl, 41h
  7054 0000E5B5 77E0                <1> 	ja	short sysvideo_12_0 ; invalid (unknown) sub function
  7055                              <1> sysvideo_14:
  7056 0000E5B7 66A3[86120300]      <1> 	mov	[v_width], ax	; save screen width
  7057 0000E5BD C705[8A120300]0000- <1> 	mov	dword [v_mem], 0A0000h  ; save video memory address
  7057 0000E5C5 0A00                <1>
  7058 0000E5C7 C705[8E120300]0000- <1> 	mov	dword [v_siz], 65536	; save video memory size
  7058 0000E5CF 0100                <1>
  7059 0000E5D1 C705[96120300]0000- <1> 	mov	dword [v_end], 0B0000h	; save end of video page
  7059 0000E5D9 0B00                <1>
  7060 0000E5DB B708                <1> 	mov	bh, 8
  7061 0000E5DD 883D[89120300]      <1> 	mov	[v_bpp], bh ; 8	; bits per pixel (256 colors)
  7062 0000E5E3 881D[88120300]      <1> 	mov	[v_ops], bl	; VGA data transfer options
  7063                              <1> 	;mov	[maskbuff], edi ; 25/02/2021 
  7064 0000E5E9 893D[9A120300]      <1> 	mov	[maskcolor], edi ; 25/02/2021
  7065                              <1> 			; save mask color or bitmask buffer address
  7066 0000E5EF E9BD000000          <1> 	jmp	sysvideo_15_7
  7067                              <1> 
  7068                              <1> sysvideo_15:
  7069                              <1> 	; 28/12/2020
  7070 0000E5F4 80FF02              <1> 	cmp	bh, 2
  7071 0000E5F7 0F87F01E0000        <1>         ja      sysvideo_16
  7072                              <1> 
  7073                              <1> 	; 25/02/2021
  7074                              <1> 	; 12/02/2021
  7075                              <1> 	; 30/01/2021, 31/01/2021
  7076                              <1> 	; 01/01/2021, 29/01/2021
  7077                              <1> 	; 26/12/2020, 27/12/2020
  7078                              <1> 	; 25/12/2020 (TRDOS 386 v2.0.3)
  7079                              <1> 	;
  7080                              <1> 	; BH = 2 = SVGA (VESA VBE) Graphics mode (LFB) data transfers
  7081                              <1> 
  7082                              <1> 	; 25/12/2020
  7083                              <1> 	; resolution table entry will be saved into EBP register
  7084                              <1> 
  7085 0000E5FD 803D[5C090000]02    <1> 	cmp	byte [vbe3], 2 ; VESA VBE 3 video bios 
  7086                              <1> 			  ; or BOCHS/QEMU/VIRTUALBOX emu video bios
  7087 0000E604 724E                <1> 	jb	short sysvideo_15_4 ; no, nothing to do !
  7088 0000E606 770B                <1> 	ja	short sysvideo_15_0 ; yes
  7089                              <1> 
  7090                              <1> 	; Only Bochs/Plex86 (emu) vbe2 video bios is usable in pmid
  7091                              <1> 	; (if [vbe3] = 2) 
  7092 0000E608 A0[5D090000]        <1> 	mov	al, [vbe2bios] ; Bochs vbios sign is from C0h to C5h
  7093 0000E60D 24F0                <1> 	and	al, 0F0h
  7094 0000E60F 3CC0                <1> 	cmp	al, 0C0h
  7095 0000E611 7541                <1> 	jne	short sysvideo_15_4 ; unknown (vbe2) video bios
  7096                              <1> sysvideo_15_0:
  7097                              <1> 	; 29/01/2021
  7098 0000E613 80FB41              <1> 	cmp	bl, 41h
  7099 0000E616 773C                <1> 	ja	short sysvideo_15_4 ; invalid (unknown) sub function
  7100                              <1> 	; 29/01/2021
  7101 0000E618 881D[88120300]      <1> 	mov	[v_ops], bl	; SVGA data transfer options
  7102                              <1> 
  7103 0000E61E 89D8                <1> 	mov	eax, ebx ; hw of ebx is vesa vbe video mode
  7104 0000E620 C1E810              <1> 	shr	eax, 16 ; ax = vesa vbe video mode
  7105 0000E623 7513                <1> 	jnz	short sysvideo_15_2 
  7106                              <1> 	; ax = 0
  7107                              <1> 
  7108                              <1> 	; check & use current video mode
  7109 0000E625 803D[DA6F0000]FF    <1> 	cmp	byte [CRT_MODE], 0FFh ; extended (SVGA) mode ?
  7110 0000E62C 7526                <1> 	jne	short sysvideo_15_4 ; no
  7111                              <1> sysvideo_15_1:
  7112                              <1> 	; use current vbe (svga) video mode
  7113 0000E62E 66A1[1E120300]      <1> 	mov	ax, [video_mode] ; extended (SVGA, VESA VBE) mode
  7114 0000E634 6625FF01            <1> 	and	ax, 1FFh ; vesa vbe video mode: 1XXh
  7115                              <1> sysvideo_15_2:
  7116                              <1> 	; 29/01/2021
  7117                              <1> 	;mov	[maskbuff], edi ; 25/02/2021
  7118 0000E638 893D[9A120300]      <1> 	mov	[maskcolor], edi ; 25/02/2021
  7119                              <1> 			; save mask color or bitmask buffer address
  7120 0000E63E BD[66730000]        <1> 	mov	ebp, b_vbe_modes ; vbe mode table (in 'vidata.s')
  7121                              <1> sysvideo_15_3:
  7122 0000E643 663B4500            <1> 	cmp	ax, [ebp]
  7123 0000E647 7410                <1> 	je	short sysvideo_15_5
  7124 0000E649 83C508              <1> 	add	ebp, 8 ; vbe mode table entry size
  7125 0000E64C 81FD[26740000]      <1> 	cmp	ebp, end_of_b_vbe_modes
  7126 0000E652 72EF                <1>  	jb	short sysvideo_15_3	
  7127                              <1> sysvideo_15_4:
  7128                              <1> 	; desired video mode is not a valid (implemented)
  7129                              <1> 	;	  extended (VESA VBE, SVGA) video mode
  7130                              <1> 	;
  7131                              <1> 	; nothing to do !
  7132                              <1> 
  7133                              <1>  	; [u.r0] = 0  ; return value of EAX
  7134 0000E654 E9B3F2FFFF          <1>  	jmp	sysret
  7135                              <1> 
  7136                              <1> sysvideo_15_5:
  7137                              <1> 	; get LFB address
  7138 0000E659 A1[2C120300]        <1> 	mov	eax, [LFB_ADDR] ; [LFB_Info+LFBINFO.LFB_addr]
  7139 0000E65E 09C0                <1> 	or	eax, eax
  7140 0000E660 7509                <1> 	jnz	short sysvideo_15_6
  7141 0000E662 66A1[EB0E0000]      <1> 	mov	ax, [def_LFB_addr] ; default LFB addr 
  7142                              <1> 				   ; (for vbe mode 118h)
  7143 0000E668 C1E010              <1> 	shl	eax, 16
  7144                              <1> 	; 27/12/2020
  7145                              <1> 	;jz	short sysvideo_15_4
  7146                              <1> sysvideo_15_6:
  7147                              <1> 	; 29/01/2021
  7148 0000E66B A3[8A120300]        <1> 	mov	[v_mem], eax ; save video memory address
  7149                              <1> 	
  7150                              <1> 	; 27/12/2020
  7151                              <1> 	; 26/12/2020
  7152 0000E670 8B4502              <1> 	mov	eax, [ebp+2] ; width, height
  7153                              <1> 	; 29/01/2021
  7154 0000E673 66A3[86120300]      <1> 	mov	[v_width], ax ; save screen width
  7155                              <1> 	; 28/12/2020
  7156 0000E679 8A7D06              <1> 	mov	bh, [ebp+6] ; bpp
  7157                              <1> 	; 28/02/2021
  7158                              <1> 	; check default truecolor bpp value and use
  7159                              <1> 	; 32bpp instead of 24bpp if the default value
  7160                              <1> 	; has been set to 32bpp.
  7161 0000E67C 80FF18              <1> 	cmp	bh, 24
  7162 0000E67F 750B                <1> 	jne	short sysvideo_15_16
  7163 0000E681 803D[F7860100]20    <1> 	cmp	byte [truecolor], 32
  7164                              <1> 		; Default truecolor bpp value,
  7165                              <1> 		; it is 32 for VBE3 video bios
  7166                              <1> 		; (it can be set to 32 or 24)
  7167 0000E688 7502                <1> 	jne	short sysvideo_15_16 ; not VBE3 !
  7168                              <1> 				; or it is set to 24  	
  7169 0000E68A B720                <1> 	mov	bh, 32
  7170                              <1> 	; 28/02/2021
  7171                              <1> sysvideo_15_16:
  7172                              <1> 	; 29/01/2021
  7173 0000E68C 883D[89120300]      <1> 	mov	[v_bpp], bh ; bits per pixel
  7174                              <1> 
  7175 0000E692 52                  <1> 	push	edx ; *
  7176 0000E693 0FB7D0              <1> 	movzx	edx, ax  ; width
  7177 0000E696 C1E810              <1> 	shr	eax, 16  ; height
  7178 0000E699 F7E2                <1> 	mul	edx
  7179                              <1> 	; eax = linear frame buffer size (pixels)
  7180                              <1> 	; 29/01/2021
  7181 0000E69B A3[8E120300]        <1> 	mov	[v_siz], eax ; save video page size
  7182 0000E6A0 E8FD000000          <1> 	call	pixels_to_byte_count
  7183 0000E6A5 0305[8A120300]      <1> 	add	eax, [v_mem]
  7184 0000E6AB A3[96120300]        <1> 	mov	[v_end], eax ; save end of video page 
  7185 0000E6B0 5A                  <1> 	pop	edx ; *
  7186                              <1> 
  7187                              <1> 	; bh = bits per pixel
  7188                              <1> 	; (bh will not be used after here, 29/01/2021)
  7189                              <1> 
  7190                              <1> 	; bl = pixel operations & options
  7191                              <1> 	; ecx, edx, esi, edi input parameters
  7192                              <1> 	; [maskcolor] = edi input ; 25/02/2021
  7193                              <1> 
  7194                              <1> sysvideo_15_7:
  7195                              <1> 	; 29/01/2021
  7196                              <1> 	;test	byte [v_ops], 40h  ; system to user ?
  7197 0000E6B1 F6C340              <1> 	test	bl, 40h
  7198 0000E6B4 7517                <1> 	jnz	short sysvideo_15_9
  7199                              <1> 
  7200 0000E6B6 31C0                <1> 	xor	eax, eax
  7201 0000E6B8 88D8                <1> 	mov	al, bl
  7202 0000E6BA BB[E0E70000]        <1> 	mov	ebx, pixel_ops
  7203 0000E6BF 240F                <1> 	and	al, 0Fh ; isolate 16 pixel operations
  7204 0000E6C1 C0E002              <1> 	shl	al, 2 ; * 4 for dword table pointers 
  7205 0000E6C4 01C3                <1> 	add	ebx, eax
  7206                              <1> 
  7207                              <1> 	; ebx = subroutine address
  7208                              <1> 
  7209                              <1> 	; ecx, edx, esi, edi input parameters
  7210                              <1> 	; [maskbuff] = edi input
  7211                              <1> 	; [maskcolor] = edi input ; 25/02/2021
  7212                              <1> 
  7213 0000E6C6 FF13                <1> 	call	[ebx]		
  7214                              <1> sysvideo_15_8:
  7215 0000E6C8 E93FF2FFFF          <1> 	jmp	sysret
  7216                              <1> 
  7217                              <1> sysvideo_15_9:
  7218                              <1> 	; system to user display page or window copy
  7219                              <1> 	;test	byte [v_ops], 1 ; window copy ?
  7220 0000E6CD F6C301              <1> 	test	bl, 1	
  7221 0000E6D0 7521                <1> 	jnz	short sysvideo_15_10
  7222                              <1> 
  7223                              <1> 	; display page (full screen copy)
  7224 0000E6D2 8B35[8A120300]      <1> 	mov	esi, [v_mem] ; LFB start address
  7225 0000E6D8 A1[8E120300]        <1> 	mov	eax, [v_siz]
  7226 0000E6DD E8C0000000          <1> 	call	pixels_to_byte_count
  7227 0000E6E2 89C1                <1> 	mov	ecx, eax ; transfer count in bytes
  7228                              <1> 	;edi = user's buffer address
  7229 0000E6E4 E87B340000          <1> 	call	transfer_to_user_buffer
  7230 0000E6E9 72DD                <1> 	jc	short sysvideo_15_8	
  7231 0000E6EB 890D[64030300]      <1> 	mov	[u.r0], ecx
  7232 0000E6F1 EBD5                <1> 	jmp	short sysvideo_15_8
  7233                              <1> 
  7234                              <1> sysvideo_15_10:
  7235 0000E6F3 E820000000          <1> 	call	sysvideo_15_12 ; window preparations
  7236 0000E6F8 72CE                <1> 	jc	short sysvideo_15_8
  7237                              <1> 
  7238 0000E6FA 8B35[92120300]      <1> 	mov	esi, [v_str]
  7239                              <1> sysvideo_15_11:
  7240                              <1> 	; esi = window's current row address (video mem)
  7241                              <1> 	; edi = current row (virtual) addr in user's buff
  7242                              <1> 	; ecx = transfer count per row
  7243 0000E700 E85F340000          <1> 	call	transfer_to_user_buffer
  7244 0000E705 72C1                <1> 	jc	short sysvideo_15_8
  7245 0000E707 010D[64030300]      <1>  	add	[u.r0], ecx
  7246 0000E70D 4B                  <1> 	dec	ebx
  7247 0000E70E 74B8                <1> 	jz	short sysvideo_15_8 ; ok.
  7248                              <1> 	; next row
  7249 0000E710 01CF                <1> 	add	edi, ecx ; next row in user's buffer
  7250 0000E712 01D6                <1> 	add	esi, edx ; next row of window (system)
  7251 0000E714 EBEA                <1> 	jmp	short sysvideo_15_11
  7252                              <1> 
  7253                              <1> sysvideo_15_14:
  7254 0000E716 F9                  <1> 	stc	 ; error !
  7255                              <1> sysvideo_15_15:
  7256 0000E717 C3                  <1> 	retn
  7257                              <1> 
  7258                              <1> sysvideo_15_12:
  7259                              <1> 	; 30/01/2021
  7260                              <1> 	; 29/01/2021
  7261                              <1> 	; Window address preparations for window copy
  7262 0000E718 6621D2              <1> 	and	dx, dx
  7263 0000E71B 74F9                <1> 	jz	short sysvideo_15_14 ; invalid (zero columns)
  7264                              <1> 	;test	edx, 0FFFF0000h
  7265                              <1> 	;jz	short sysvideo_15_14 ; invalid (zero rows)
  7266 0000E71D 81FA00000100        <1> 	cmp	edx, 65536
  7267 0000E723 72F2                <1> 	jb	short sysvideo_15_15 ; invalid (zero rows)
  7268 0000E725 89C8                <1> 	mov	eax, ecx ; start position (row, column)
  7269 0000E727 E899000000          <1> 	call	calc_pixel_offset
  7270 0000E72C 3B05[8E120300]      <1> 	cmp	eax, [v_siz]
  7271 0000E732 73E2                <1> 	jnb	short sysvideo_15_14 ; out of display page
  7272                              <1> 				; nothing to do
  7273 0000E734 E869000000          <1> 	call	pixels_to_byte_count
  7274 0000E739 0305[8A120300]      <1> 	add	eax, [v_mem]
  7275 0000E73F A3[92120300]        <1> 	mov	[v_str], eax ; window start address
  7276                              <1> 			     ; (addr of top left corner)
  7277                              <1> 	; check column limit
  7278 0000E744 89C8                <1> 	mov	eax, ecx
  7279 0000E746 6601D0              <1> 	add	ax, dx  ; add columns to start column
  7280 0000E749 72CC                <1> 	jc	short sysvideo_15_15 ; cf = 1
  7281 0000E74B 663B05[86120300]    <1> 	cmp	ax, [v_width]
  7282 0000E752 77C2                <1> 	ja	short sysvideo_15_14
  7283                              <1> 
  7284 0000E754 89D0                <1> 	mov	eax, edx ; size
  7285 0000E756 2D00000100          <1> 	sub	eax, 65536 ; row count -> 0 based row #
  7286 0000E75B E865000000          <1> 	call	calc_pixel_offset
  7287 0000E760 3B05[8E120300]      <1> 	cmp	eax, [v_siz] ; video (display) page size
  7288 0000E766 77AE                <1> 	ja	short sysvideo_15_14 ; out of display page
  7289                              <1> 				; nothing to do
  7290 0000E768 E835000000          <1> 	call	pixels_to_byte_count
  7291 0000E76D 0305[92120300]      <1> 	add	eax, [v_str] ; window start address
  7292 0000E773 3B05[96120300]      <1> 	cmp	eax, [v_end] ; window end address (+1)
  7293                              <1> 			 ; (addr of bottom right corner +1)	
  7294 0000E779 779B                <1> 	ja	short sysvideo_15_14 ; out of display page
  7295                              <1> 				; nothing to do
  7296 0000E77B 89D3                <1> 	mov	ebx, edx
  7297 0000E77D C1EB10              <1> 	shr	ebx, 16 
  7298                              <1> 	; ebx = row count
  7299 0000E780 81E2FFFF0000        <1> 	and	edx, 0FFFFh
  7300                              <1> 	; edx = transfer count per row (from user's buffer)
  7301                              <1> 	;	(in pixels, window width)
  7302 0000E786 89D0                <1> 	mov	eax, edx
  7303 0000E788 A3[9E120300]        <1> 	mov	[pixcount], eax ; 27/02/2021
  7304 0000E78D E810000000          <1> 	call	pixels_to_byte_count
  7305 0000E792 89C1                <1> 	mov	ecx, eax
  7306                              <1> 	; ecx = transfer count per row (from user's buffer)
  7307                              <1> 	;	(in bytes, window width)
  7308 0000E794 66A1[86120300]      <1> 	mov	ax, [v_width]
  7309 0000E79A E803000000          <1> 	call	pixels_to_byte_count
  7310 0000E79F 89C2                <1> 	mov	edx, eax
  7311                              <1> 	; edx = byte count per row
  7312 0000E7A1 C3                  <1> 	retn ; cf = 0
  7313                              <1> 
  7314                              <1> pixels_to_byte_count:
  7315                              <1> 	; 29/01/2021
  7316                              <1> 	; INPUT:
  7317                              <1> 	;   eax = pixel count
  7318                              <1> 	; OUTPUT:
  7319                              <1> 	;   eax = byte count
  7320                              <1> 	;
  7321 0000E7A2 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8
  7322 0000E7A9 7619                <1> 	jna	short pixtobc_3 ; 8 bit colors
  7323 0000E7AB 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24
  7324 0000E7B2 720A                <1> 	jb	short pixtobc_1 ; 16 bit colors
  7325 0000E7B4 770B                <1> 	ja	short pixtobc_2 ; 32 bit colors
  7326                              <1> 	; 24 bit pixels
  7327                              <1> 	; eax = eax * 3
  7328                              <1> 	;push	edx
  7329                              <1> 	;mov	edx, eax
  7330                              <1> 	;shl	eax, 1
  7331                              <1> 	;add	eax, edx
  7332                              <1> 	;pop	edx
  7333 0000E7B6 50                  <1> 	push	eax
  7334 0000E7B7 D1E0                <1> 	shl	eax, 1
  7335 0000E7B9 010424              <1> 	add	[esp], eax
  7336 0000E7BC 58                  <1> 	pop	eax
  7337 0000E7BD C3                  <1> 	retn		
  7338                              <1> pixtobc_1:
  7339                              <1> 	; 32 bit pixels
  7340                              <1> 	; eax = eax * 2
  7341 0000E7BE D1E0                <1> 	shl	eax, 1
  7342 0000E7C0 C3                  <1> 	retn
  7343                              <1> pixtobc_2:
  7344                              <1> 	; 16 bit pixels
  7345                              <1> 	; eax = eax * 4
  7346 0000E7C1 C1E002              <1> 	shl	eax, 2
  7347                              <1> pixtobc_3:
  7348 0000E7C4 C3                  <1> 	retn
  7349                              <1> 
  7350                              <1> calc_pixel_offset:
  7351                              <1> 	; 29/01/2021
  7352                              <1> 	; INPUT:
  7353                              <1> 	;   eax = pixel position (row, column)
  7354                              <1> 	; OUTPUT:
  7355                              <1> 	;   eax = pixel offset (linear address)
  7356                              <1> 	;
  7357 0000E7C5 52                  <1> 	push	edx
  7358 0000E7C6 50                  <1> 	push	eax
  7359 0000E7C7 C1E810              <1> 	shr	eax, 16
  7360 0000E7CA 7409                <1> 	jz	short cpixo_0
  7361                              <1> 	; eax = row 
  7362 0000E7CC 0FB715[86120300]    <1> 	movzx	edx, word [v_width]
  7363 0000E7D3 F7E2                <1> 	mul	edx
  7364                              <1> cpixo_0:
  7365                              <1> 	; eax = row * screen width
  7366 0000E7D5 5A                  <1> 	pop	edx
  7367 0000E7D6 81E2FFFF0000        <1> 	and	edx, 0FFFFh
  7368                              <1> 	; edx = column
  7369 0000E7DC 01D0                <1> 	add	eax, edx
  7370                              <1> 	; eax = (row * screen width) + column		
  7371 0000E7DE 5A                  <1> 	pop	edx
  7372 0000E7DF C3                  <1> 	retn
  7373                              <1> 
  7374                              <1> 	; 02/02/2021
  7375                              <1> 	; 29/01/2021
  7376                              <1> pixel_ops:
  7377 0000E7E0 [20E80000]          <1> 	dd	pix_op_cpy ; copy pixels (user to system)
  7378 0000E7E4 [6BED0000]          <1> 	dd	pix_op_new ; change (new, fill) color
  7379 0000E7E8 [88E80000]          <1> 	dd	pix_op_add ; add color (up to 0FFh)
  7380 0000E7EC [3AE90000]          <1> 	dd	pix_op_sub ; sub color (down to 0)
  7381 0000E7F0 [55EB0000]          <1> 	dd	pix_op_orc ; or color
  7382 0000E7F4 [07EC0000]          <1> 	dd	pix_op_and ; and color
  7383 0000E7F8 [B9EC0000]          <1> 	dd	pix_op_xor ; xor color
  7384 0000E7FC [2FEE0000]          <1> 	dd	pix_op_not ; not color
  7385 0000E800 [D9EE0000]          <1> 	dd	pix_op_neg ; neg color
  7386 0000E804 [83EF0000]          <1> 	dd	pix_op_inc ; inc color
  7387 0000E808 [2DF00000]          <1> 	dd	pix_op_dec ; dec color
  7388 0000E80C [ECE90000]          <1> 	dd	pix_op_mix ; mix color
  7389 0000E810 [B3EA0000]          <1> 	dd	pix_op_rpl ; replace color
  7390 0000E814 [D7F00000]          <1> 	dd	pix_op_blk ; copy pixel block(s) (sys)
  7391 0000E818 [86F10000]          <1> 	dd	pix_op_lin ; write line(s)
  7392 0000E81C [69F50000]          <1> 	dd	pix_op_chr ; write character (font)
  7393                              <1> 
  7394                              <1> pix_op_cpy:
  7395                              <1> 	; 21/02/2021
  7396                              <1> 	; 06/02/2021
  7397                              <1> 	; 30/01/2021
  7398                              <1> 	; COPY PIXELS
  7399                              <1> 	;
  7400                              <1> 	; INPUT:
  7401                              <1> 	;  If bit 4 of BL or [v_ops] = 1 -window copy-
  7402                              <1> 	;  ECX = start position (row, column)
  7403                              <1> 	;        (HW = row, CX = column)
  7404                              <1> 	;  EDX = size (rows, colums)
  7405                              <1> 	;        (HW = rows, DX = columns)
  7406                              <1> 	;	 (0 -> invalid 	
  7407                              <1> 	;        (1 -> horizontal or vertical line)
  7408                              <1> 	;  If bit 4 of BL or [v_ops] = 0 -full screen-
  7409                              <1> 	;     ECX and EDX will not be used
  7410                              <1>   	;  ESI = user's buffer address
  7411                              <1> 	;  [maskcolor] = mask color (to be excluded)
  7412                              <1> 	;
  7413                              <1> 	; OUTPUT:
  7414                              <1> 	; 	[u.r0] will be > 0 if succesful
  7415                              <1> 
  7416 0000E820 F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  7417 0000E827 752E                <1> 	jnz	short pix_op_cpy_w ; window
  7418                              <1> 
  7419 0000E829 8B3D[8A120300]      <1> 	mov	edi, [v_mem] ; 21/02/2021
  7420                              <1> 	
  7421                              <1> 	; Copy user's buffer content do display page
  7422                              <1> 	; (full screen copy)
  7423 0000E82F A1[8E120300]        <1> 	mov	eax, [v_siz] ; video page size
  7424 0000E834 E869FFFFFF          <1> 	call	pixels_to_byte_count
  7425 0000E839 89C1                <1> 	mov	ecx, eax ; transfer count
  7426                              <1> 	; esi = user's buffer address (virtual)
  7427 0000E83B F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked copy ?
  7428 0000E842 7405                <1> 	jz	short pix_op_cpy_0 ; no	
  7429 0000E844 E9720F0000          <1> 	jmp	m_pix_op_cpy ; copy pixels except mask color
  7430                              <1> pix_op_cpy_0:
  7431                              <1> 	; esi = user buffer for full screen copy
  7432                              <1> 	; edi = start of video memory 
  7433                              <1> 	;	(start of display page)
  7434                              <1> 	; ecx = byte count (display page size in bytes)
  7435 0000E849 E860330000          <1> 	call	transfer_from_user_buffer
  7436 0000E84E 7206                <1> 	jc	short pix_op_cpy_1
  7437 0000E850 890D[64030300]      <1> 	mov	[u.r0], ecx
  7438                              <1> pix_op_cpy_1:
  7439 0000E856 C3                  <1> 	retn	; 06/02/2021
  7440                              <1> 
  7441                              <1> pix_op_cpy_w:
  7442 0000E857 E8BCFEFFFF          <1> 	call	sysvideo_15_12 ; window preparations
  7443 0000E85C 72F8                <1> 	jc	short pix_op_cpy_1
  7444                              <1> 	; ecx = bytes per row (to be applied)
  7445                              <1> 	; edx = screen width in bytes
  7446                              <1> 	; ebx = row count
  7447 0000E85E 8B3D[92120300]      <1> 	mov	edi, [v_str]
  7448 0000E864 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked copy ?
  7449 0000E86B 7405                <1> 	jz	short pix_op_cpy_w_0 ; no
  7450 0000E86D E90C100000          <1> 	jmp	m_pix_op_cpy_w ; window copy except mask color
  7451                              <1> pix_op_cpy_w_0:
  7452                              <1> 	; esi = current row (virtual) addr in user's buff
  7453                              <1> 	; edi = window's current row address (video mem)
  7454                              <1> 	; ecx = transfer count per row
  7455 0000E872 E837330000          <1> 	call	transfer_from_user_buffer
  7456 0000E877 72DD                <1> 	jc	short pix_op_cpy_1
  7457 0000E879 010D[64030300]      <1>  	add	[u.r0], ecx
  7458 0000E87F 4B                  <1> 	dec	ebx
  7459 0000E880 74D4                <1> 	jz	short pix_op_cpy_1 ; ok.
  7460                              <1> 	; next row
  7461 0000E882 01CE                <1> 	add	esi, ecx ; next row in user's buffer
  7462 0000E884 01D7                <1> 	add	edi, edx ; next row of window (system)
  7463 0000E886 EBEA                <1> 	jmp	short pix_op_cpy_w_0
  7464                              <1> 
  7465                              <1> pix_op_add:
  7466                              <1> 	; 31/01/2021
  7467                              <1> 	; 30/01/2021
  7468                              <1> 	; ADD COLOR
  7469                              <1> 	;
  7470                              <1> 	; INPUT:
  7471                              <1> 	;   CL = color (8 bit, 256 colors)
  7472                              <1> 	;  ECX = color (16 bit and true colors)
  7473                              <1> 	;  EDX = start position (row, column)
  7474                              <1> 	;        (HW = row, DX = column)
  7475                              <1> 	;  ESI = size (rows, colums)
  7476                              <1> 	;        (HW = rows, SI = columns)
  7477                              <1> 	;
  7478                              <1> 	;  [maskcolor] = mask color (to be excluded)
  7479                              <1> 	;
  7480                              <1> 	; OUTPUT:
  7481                              <1> 	; 	[u.r0] will be > 0 if succesful
  7482                              <1> 	
  7483 0000E888 F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  7484 0000E88F 7555                <1> 	jnz	short pix_op_add_w ; window
  7485                              <1> 	
  7486 0000E891 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  7487 0000E897 89FE                <1> 	mov	esi, edi
  7488                              <1> 	; ecx = color (CL, CX, ECX)
  7489 0000E899 89C8                <1> 	mov	eax, ecx
  7490 0000E89B 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  7491                              <1> 
  7492 0000E8A1 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color adding ?
  7493 0000E8A8 7405                <1> 	jz	short pix_op_add_0 ; no
  7494 0000E8AA E9CE100000          <1> 	jmp	m_pix_op_add ; add color except mask color
  7495                              <1> pix_op_add_0:
  7496 0000E8AF 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7497 0000E8B6 7707                <1> 	ja	short pix_op_add_1
  7498                              <1> 
  7499                              <1> 	; 256 colors (8bpp)
  7500 0000E8B8 E84D0A0000          <1> 	call	pix_op_add_8
  7501 0000E8BD EB1E                <1> 	jmp	short pix_op_add_4	
  7502                              <1> 			
  7503                              <1> pix_op_add_1:
  7504 0000E8BF 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7505 0000E8C6 7710                <1> 	ja	short pix_op_add_3 ; 32bpp	
  7506 0000E8C8 7207                <1> 	jb	short pix_op_add_2 ; 16bpp
  7507                              <1> 	
  7508                              <1> 	; 24 bit true colors
  7509 0000E8CA E85B0A0000          <1> 	call	pix_op_add_24
  7510 0000E8CF EB0C                <1> 	jmp	short pix_op_add_4
  7511                              <1> 
  7512                              <1> 	; 65536 colors (16bpp)
  7513                              <1> pix_op_add_2:
  7514 0000E8D1 E8420A0000          <1> 	call	pix_op_add_16
  7515 0000E8D6 EB05                <1> 	jmp	short pix_op_add_4
  7516                              <1> 
  7517                              <1> 	; 32 bit true colors
  7518                              <1> pix_op_add_3:
  7519 0000E8D8 E86D0A0000          <1> 	call	pix_op_add_32
  7520                              <1> pix_op_add_4:
  7521 0000E8DD 29F7                <1> 	sub	edi, esi
  7522 0000E8DF 893D[64030300]      <1> 	mov	[u.r0], edi	
  7523                              <1> pix_op_add_5:
  7524 0000E8E5 C3                  <1> 	retn		
  7525                              <1> 
  7526                              <1> pix_op_add_w:
  7527                              <1> 	; 31/01/2021
  7528 0000E8E6 51                  <1> 	push	ecx ; * ; color
  7529 0000E8E7 89D1                <1> 	mov	ecx, edx ; win start pos
  7530 0000E8E9 89F2                <1> 	mov	edx, esi ; size (rows, cols)
  7531 0000E8EB E828FEFFFF          <1> 	call	sysvideo_15_12 ; window preparations
  7532 0000E8F0 58                  <1> 	pop	eax ; * ; color
  7533 0000E8F1 72F2                <1> 	jc	short pix_op_add_5
  7534                              <1> 
  7535 0000E8F3 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color adding ?
  7536 0000E8FA 7405                <1> 	jz	short pix_op_add_w_0 ; no
  7537 0000E8FC E92A110000          <1> 	jmp	m_pix_op_add_w 
  7538                              <1> 			; window add color except mask color
  7539                              <1> pix_op_add_w_0:
  7540                              <1> 	; ecx = bytes per row (to be applied)
  7541                              <1> 	; edx = screen width in bytes
  7542                              <1> 	; ebx = row count
  7543                              <1> 	; eax = color
  7544                              <1> 
  7545 0000E901 8B3D[92120300]      <1> 	mov	edi, [v_str]
  7546 0000E907 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7547 0000E90E 7707                <1> 	ja	short pix_op_add_w_1
  7548                              <1> 
  7549                              <1> 	; 256 colors (8bpp)
  7550 0000E910 BD[0AF30000]        <1> 	mov	ebp, pix_op_add_8
  7551 0000E915 EB1E                <1> 	jmp	short pix_op_add_w_4
  7552                              <1> 			
  7553                              <1> pix_op_add_w_1:
  7554 0000E917 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7555 0000E91E 7710                <1> 	ja	short pix_op_add_w_3 ; 32bpp
  7556 0000E920 7207                <1> 	jb	short pix_op_add_w_2 ; 16bpp
  7557                              <1> 
  7558                              <1> 	; 24 bit true colors
  7559 0000E922 BD[2AF30000]        <1> 	mov	ebp, pix_op_add_24
  7560 0000E927 EB0C                <1> 	jmp	short pix_op_add_w_4
  7561                              <1> 
  7562                              <1> 	; 65536 colors (16bpp)
  7563                              <1> pix_op_add_w_2:
  7564 0000E929 BD[18F30000]        <1> 	mov	ebp, pix_op_add_16
  7565 0000E92E EB05                <1> 	jmp	short pix_op_add_w_4
  7566                              <1> 
  7567                              <1> 	; 32 bit true colors
  7568                              <1> pix_op_add_w_3:
  7569 0000E930 BD[4AF30000]        <1> 	mov	ebp, pix_op_add_32
  7570                              <1> pix_op_add_w_4:
  7571 0000E935 E95F010000          <1> 	jmp	pix_op_add_w_x
  7572                              <1> 
  7573                              <1> pix_op_sub:
  7574                              <1> 	; 31/01/2021
  7575                              <1> 	; SUB COLOR
  7576                              <1> 	;
  7577                              <1> 	; INPUT:
  7578                              <1> 	;   CL = color (8 bit, 256 colors)
  7579                              <1> 	;  ECX = color (16 bit and true colors)
  7580                              <1> 	;  EDX = start position (row, column)
  7581                              <1> 	;        (HW = row, DX = column)
  7582                              <1> 	;  ESI = size (rows, colums)
  7583                              <1> 	;        (HW = rows, SI = columns)
  7584                              <1> 	;
  7585                              <1> 	;  [maskcolor] = mask color (to be excluded)
  7586                              <1> 	;
  7587                              <1> 	; OUTPUT:
  7588                              <1> 	; 	[u.r0] will be > 0 if succesful
  7589                              <1> 	
  7590 0000E93A F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  7591 0000E941 7555                <1> 	jnz	short pix_op_sub_w ; window
  7592                              <1> 	
  7593 0000E943 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  7594 0000E949 89FE                <1> 	mov	esi, edi
  7595                              <1> 	; ecx = color (CL, CX, ECX)
  7596 0000E94B 89C8                <1> 	mov	eax, ecx
  7597 0000E94D 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  7598                              <1> 
  7599 0000E953 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color subtract ?
  7600 0000E95A 7405                <1> 	jz	short pix_op_sub_0 ; no
  7601 0000E95C E9FD100000          <1> 	jmp	m_pix_op_sub ; sub color except mask color
  7602                              <1> pix_op_sub_0:
  7603 0000E961 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7604 0000E968 7707                <1> 	ja	short pix_op_sub_1
  7605                              <1> 
  7606                              <1> 	; 256 colors (8bpp)
  7607 0000E96A E8EA090000          <1> 	call	pix_op_sub_8
  7608 0000E96F EB1E                <1> 	jmp	short pix_op_sub_4	
  7609                              <1> 			
  7610                              <1> pix_op_sub_1:
  7611 0000E971 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7612 0000E978 7710                <1> 	ja	short pix_op_sub_3 ; 32bpp	
  7613 0000E97A 7207                <1> 	jb	short pix_op_sub_2 ; 16bpp
  7614                              <1> 	
  7615                              <1> 	; 24 bit true colors
  7616 0000E97C E8FB090000          <1> 	call	pix_op_sub_24
  7617 0000E981 EB0C                <1> 	jmp	short pix_op_sub_4
  7618                              <1> 
  7619                              <1> 	; 65536 colors (16bpp)
  7620                              <1> pix_op_sub_2:
  7621 0000E983 E8E1090000          <1> 	call	pix_op_sub_16
  7622 0000E988 EB05                <1> 	jmp	short pix_op_sub_4
  7623                              <1> 
  7624                              <1> 	; 32 bit true colors
  7625                              <1> pix_op_sub_3:
  7626 0000E98A E8070A0000          <1> 	call	pix_op_sub_32
  7627                              <1> pix_op_sub_4:
  7628 0000E98F 29F7                <1> 	sub	edi, esi
  7629 0000E991 893D[64030300]      <1> 	mov	[u.r0], edi	
  7630                              <1> pix_op_sub_5:
  7631 0000E997 C3                  <1> 	retn		
  7632                              <1> 
  7633                              <1> pix_op_sub_w:
  7634                              <1> 	; 31/01/2021
  7635 0000E998 51                  <1> 	push	ecx ; * ; color
  7636 0000E999 89D1                <1> 	mov	ecx, edx ; win start pos
  7637 0000E99B 89F2                <1> 	mov	edx, esi ; size (rows, cols)
  7638 0000E99D E876FDFFFF          <1> 	call	sysvideo_15_12 ; window preparations
  7639 0000E9A2 58                  <1> 	pop	eax ; * ; color
  7640 0000E9A3 72F2                <1> 	jc	short pix_op_sub_5
  7641                              <1> 
  7642 0000E9A5 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color subtract ?
  7643 0000E9AC 7405                <1> 	jz	short pix_op_sub_w_0 ; no
  7644 0000E9AE E94E110000          <1> 	jmp	m_pix_op_sub_w 
  7645                              <1> 			; window sub color except mask color
  7646                              <1> pix_op_sub_w_0:
  7647                              <1> 	; ecx = bytes per row (to be applied)
  7648                              <1> 	; edx = screen width in bytes
  7649                              <1> 	; ebx = row count
  7650                              <1> 	; eax = color
  7651                              <1> 
  7652 0000E9B3 8B3D[92120300]      <1> 	mov	edi, [v_str]
  7653 0000E9B9 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7654 0000E9C0 7707                <1> 	ja	short pix_op_sub_w_1
  7655                              <1> 
  7656                              <1> 	; 256 colors (8bpp)
  7657 0000E9C2 BD[59F30000]        <1> 	mov	ebp, pix_op_sub_8
  7658 0000E9C7 EB1E                <1> 	jmp	short pix_op_sub_w_4
  7659                              <1> 			
  7660                              <1> pix_op_sub_w_1:
  7661 0000E9C9 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7662 0000E9D0 7710                <1> 	ja	short pix_op_sub_w_3 ; 32bpp
  7663 0000E9D2 7207                <1> 	jb	short pix_op_sub_w_2 ; 16bpp
  7664                              <1> 
  7665                              <1> 	; 24 bit true colors
  7666 0000E9D4 BD[7CF30000]        <1> 	mov	ebp, pix_op_sub_24
  7667 0000E9D9 EB0C                <1> 	jmp	short pix_op_sub_w_4
  7668                              <1> 
  7669                              <1> 	; 65536 colors (16bpp)
  7670                              <1> pix_op_sub_w_2:
  7671 0000E9DB BD[69F30000]        <1> 	mov	ebp, pix_op_sub_16
  7672 0000E9E0 EB05                <1> 	jmp	short pix_op_sub_w_4
  7673                              <1> 
  7674                              <1> 	; 32 bit true colors
  7675                              <1> pix_op_sub_w_3:
  7676 0000E9E2 BD[96F30000]        <1> 	mov	ebp, pix_op_sub_32
  7677                              <1> pix_op_sub_w_4:
  7678 0000E9E7 E9AD000000          <1> 	jmp	pix_op_sub_w_x
  7679                              <1> 
  7680                              <1> pix_op_mix:
  7681                              <1> 	; 31/01/2021
  7682                              <1> 	; MIX COLOR
  7683                              <1> 	;
  7684                              <1> 	; INPUT:
  7685                              <1> 	;   CL = color (8 bit, 256 colors)
  7686                              <1> 	;  ECX = color (16 bit and true colors)
  7687                              <1> 	;  EDX = start position (row, column)
  7688                              <1> 	;        (HW = row, DX = column)
  7689                              <1> 	;  ESI = size (rows, colums)
  7690                              <1> 	;        (HW = rows, SI = columns)
  7691                              <1> 	;
  7692                              <1> 	;  [maskcolor] = mask color (to be excluded)
  7693                              <1> 	;
  7694                              <1> 	; OUTPUT:
  7695                              <1> 	; 	[u.r0] will be > 0 if succesful
  7696                              <1> 	
  7697 0000E9EC F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  7698 0000E9F3 7555                <1> 	jnz	short pix_op_mix_w ; window
  7699                              <1> 	
  7700 0000E9F5 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  7701 0000E9FB 89FE                <1> 	mov	esi, edi
  7702                              <1> 	; ecx = color (CL, CX, ECX)
  7703 0000E9FD 89C8                <1> 	mov	eax, ecx
  7704 0000E9FF 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  7705                              <1> 
  7706 0000EA05 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color mix ?
  7707 0000EA0C 7405                <1> 	jz	short pix_op_mix_0 ; no
  7708 0000EA0E E921110000          <1> 	jmp	m_pix_op_mix ; mix colors except mask color
  7709                              <1> pix_op_mix_0:
  7710 0000EA13 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7711 0000EA1A 7707                <1> 	ja	short pix_op_mix_1
  7712                              <1> 
  7713                              <1> 	; 256 colors (8bpp)
  7714 0000EA1C E8F4090000          <1> 	call	pix_op_mix_8
  7715 0000EA21 EB1E                <1> 	jmp	short pix_op_mix_4	
  7716                              <1> 			
  7717                              <1> pix_op_mix_1:
  7718 0000EA23 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7719 0000EA2A 7710                <1> 	ja	short pix_op_mix_3 ; 32bpp	
  7720 0000EA2C 7207                <1> 	jb	short pix_op_mix_2 ; 16bpp
  7721                              <1> 	
  7722                              <1> 	; 24 bit true colors
  7723 0000EA2E E8FD090000          <1> 	call	pix_op_mix_24
  7724 0000EA33 EB0C                <1> 	jmp	short pix_op_mix_4
  7725                              <1> 
  7726                              <1> 	; 65536 colors (16bpp)
  7727                              <1> pix_op_mix_2:
  7728 0000EA35 E8E7090000          <1> 	call	pix_op_mix_16
  7729 0000EA3A EB05                <1> 	jmp	short pix_op_mix_4
  7730                              <1> 
  7731                              <1> 	; 32 bit true colors
  7732                              <1> pix_op_mix_3:
  7733 0000EA3C E80B0A0000          <1> 	call	pix_op_mix_32
  7734                              <1> pix_op_mix_4:
  7735 0000EA41 29F7                <1> 	sub	edi, esi
  7736 0000EA43 893D[64030300]      <1> 	mov	[u.r0], edi	
  7737                              <1> pix_op_mix_5:
  7738 0000EA49 C3                  <1> 	retn		
  7739                              <1> 
  7740                              <1> pix_op_mix_w:
  7741                              <1> 	; 31/01/2021
  7742 0000EA4A 51                  <1> 	push	ecx ; * ; color
  7743 0000EA4B 89D1                <1> 	mov	ecx, edx ; win start pos
  7744 0000EA4D 89F2                <1> 	mov	edx, esi ; size (rows, cols)
  7745 0000EA4F E8C4FCFFFF          <1> 	call	sysvideo_15_12 ; window preparations
  7746 0000EA54 58                  <1> 	pop	eax ; * ; color
  7747 0000EA55 72F2                <1> 	jc	short pix_op_mix_5
  7748                              <1> 
  7749 0000EA57 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color mix ?
  7750 0000EA5E 7405                <1> 	jz	short pix_op_mix_w_0 ; no
  7751 0000EA60 E96C110000          <1> 	jmp	m_pix_op_mix_w 
  7752                              <1> 			; window mix colors except mask color
  7753                              <1> pix_op_mix_w_0:
  7754                              <1> 	; ecx = bytes per row (to be applied)
  7755                              <1> 	; edx = screen width in bytes
  7756                              <1> 	; ebx = row count
  7757                              <1> 	; eax = color
  7758                              <1> 
  7759 0000EA65 8B3D[92120300]      <1> 	mov	edi, [v_str]
  7760 0000EA6B 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7761 0000EA72 7707                <1> 	ja	short pix_op_mix_w_1
  7762                              <1> 
  7763                              <1> 	; 256 colors (8bpp)
  7764 0000EA74 BD[15F40000]        <1> 	mov	ebp, pix_op_mix_8
  7765 0000EA79 EB1E                <1> 	jmp	short pix_op_mix_w_x
  7766                              <1> 			
  7767                              <1> pix_op_mix_w_1:
  7768 0000EA7B 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7769 0000EA82 7710                <1> 	ja	short pix_op_mix_w_3 ; 32bpp
  7770 0000EA84 7207                <1> 	jb	short pix_op_mix_w_2 ; 16bpp
  7771                              <1> 
  7772                              <1> 	; 24 bit true colors
  7773 0000EA86 BD[30F40000]        <1> 	mov	ebp, pix_op_mix_24
  7774 0000EA8B EB0C                <1> 	jmp	short pix_op_mix_w_x
  7775                              <1> 
  7776                              <1> 	; 65536 colors (16bpp)
  7777                              <1> pix_op_mix_w_2:
  7778 0000EA8D BD[21F40000]        <1> 	mov	ebp, pix_op_mix_16
  7779 0000EA92 EB05                <1> 	jmp	short pix_op_mix_w_x
  7780                              <1> 
  7781                              <1> 	; 32 bit true colors
  7782                              <1> pix_op_mix_w_3:
  7783 0000EA94 BD[4CF40000]        <1> 	mov	ebp, pix_op_mix_32
  7784                              <1> 	;jmp	short pix_op_mix_w_x
  7785                              <1> 
  7786                              <1> pix_op_mix_w_x:
  7787                              <1> pix_op_add_w_x:
  7788                              <1> pix_op_sub_w_x:
  7789                              <1> pix_op_rpl_w_x:
  7790                              <1> pix_op_orc_w_x:
  7791                              <1> pix_op_and_w_x:
  7792                              <1> pix_op_xor_w_x:
  7793                              <1> 	; 27/02/2021
  7794                              <1> 	; 31/01/2021
  7795                              <1> 	; ecx = bytes per row (to be applied)
  7796                              <1> 	; edx = windows (screen) width in bytes
  7797                              <1> 	; ebx = row count
  7798                              <1> 	; eax = color
  7799                              <1> 	; ebp = pixel operation subroutine address
  7800 0000EA99 52                  <1> 	push	edx
  7801 0000EA9A 51                  <1> 	push	ecx
  7802 0000EA9B 57                  <1> 	push	edi
  7803 0000EA9C 8B0D[9E120300]      <1> 	mov	ecx, [pixcount] ; 27/02/2021
  7804 0000EAA2 FFD5                <1> 	call	ebp ; call pixel-row operation
  7805 0000EAA4 5F                  <1> 	pop	edi
  7806 0000EAA5 59                  <1> 	pop	ecx ; bytes per row
  7807 0000EAA6 010D[64030300]      <1> 	add	[u.r0], ecx
  7808 0000EAAC 5A                  <1> 	pop	edx
  7809 0000EAAD 01D7                <1> 	add	edi, edx ; next row
  7810 0000EAAF 4B                  <1> 	dec	ebx
  7811 0000EAB0 75E7                <1> 	jnz	short pix_op_mix_w_x
  7812 0000EAB2 C3                  <1> 	retn
  7813                              <1> 
  7814                              <1> pix_op_rpl:
  7815                              <1> 	; 01/02/2021
  7816                              <1> 	; REPLACE COLOR
  7817                              <1> 	;
  7818                              <1> 	; INPUT:
  7819                              <1> 	;   CL = old/current color (8 bit, 256 colors)
  7820                              <1> 	;  ECX = old/current color (16 bit and true colors)
  7821                              <1> 	;   DL = new color (8 bit, 256 colors)
  7822                              <1> 	;  EDX = new color (16 bit and true colors)
  7823                              <1> 	;  ESI = start position (row, column)
  7824                              <1> 	;        (HW = row, DX = column)
  7825                              <1> 	;  EDI = size (rows, colums)
  7826                              <1> 	;        (HW = rows, SI = columns)
  7827                              <1> 	; OUTPUT:
  7828                              <1> 	; 	[u.r0] will be > 0 if succesful
  7829                              <1> 	
  7830 0000EAB3 F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  7831 0000EABA 754D                <1> 	jnz	short pix_op_rpl_w ; window
  7832                              <1> 	
  7833 0000EABC 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  7834 0000EAC2 89FE                <1> 	mov	esi, edi
  7835                              <1> 	; ecx = old color (CL, CX, ECX) -to be replaced with-
  7836                              <1> 	; edx = new color (CL, CX, ECX) -new one-
  7837 0000EAC4 89D0                <1> 	mov	eax, edx ; new color
  7838 0000EAC6 890D[9A120300]      <1> 	mov	[maskcolor], ecx ; old color
  7839 0000EACC 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  7840                              <1> pix_op_rpl_0:
  7841 0000EAD2 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7842 0000EAD9 7707                <1> 	ja	short pix_op_rpl_1
  7843                              <1> 
  7844                              <1> 	; 256 colors (8bpp)
  7845 0000EADB E8300A0000          <1> 	call	pix_op_rpl_8
  7846 0000EAE0 EB1E                <1> 	jmp	short pix_op_rpl_4
  7847                              <1> 			
  7848                              <1> pix_op_rpl_1:
  7849 0000EAE2 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7850 0000EAE9 7710                <1> 	ja	short pix_op_rpl_3 ; 32bpp	
  7851 0000EAEB 7207                <1> 	jb	short pix_op_rpl_2 ; 16bpp
  7852                              <1> 
  7853                              <1> 	; 24 bit true colors
  7854 0000EAED E8410A0000          <1> 	call	pix_op_rpl_24
  7855 0000EAF2 EB0C                <1> 	jmp	short pix_op_rpl_4
  7856                              <1> 
  7857                              <1> 	; 65536 colors (16bpp)
  7858                              <1> pix_op_rpl_2:
  7859 0000EAF4 E8270A0000          <1> 	call	pix_op_rpl_16
  7860 0000EAF9 EB05                <1> 	jmp	short pix_op_rpl_4
  7861                              <1> 
  7862                              <1> 	; 32 bit true colors	
  7863                              <1> pix_op_rpl_3:
  7864 0000EAFB E8550A0000          <1> 	call	pix_op_rpl_32
  7865                              <1> pix_op_rpl_4:
  7866 0000EB00 29F7                <1> 	sub	edi, esi
  7867 0000EB02 893D[64030300]      <1> 	mov	[u.r0], edi	
  7868                              <1> pix_op_rpl_5:
  7869 0000EB08 C3                  <1> 	retn
  7870                              <1> 
  7871                              <1> pix_op_rpl_w:
  7872                              <1> 	; 01/02/2021
  7873 0000EB09 890D[9A120300]      <1> 	mov	[maskcolor], ecx ; old color
  7874 0000EB0F 52                  <1> 	push	edx ; * ; new color
  7875 0000EB10 89F1                <1> 	mov	ecx, esi ; win start pos
  7876 0000EB12 89FA                <1> 	mov	edx, edi ; size (rows, cols)
  7877 0000EB14 E8FFFBFFFF          <1> 	call	sysvideo_15_12 ; window preparations
  7878 0000EB19 58                  <1> 	pop	eax ; * ; new color
  7879 0000EB1A 72EC                <1> 	jc	short pix_op_rpl_5
  7880                              <1> 
  7881                              <1> 	; replace window color
  7882                              <1> pix_op_rpl_w_0:
  7883                              <1> 	; ecx = bytes per row (to be applied)
  7884                              <1> 	; edx = screen width in bytes
  7885                              <1> 	; ebx = row count
  7886                              <1> 	; eax = new color
  7887                              <1> 	; [maskcolor] = old color
  7888                              <1>  
  7889 0000EB1C 8B3D[92120300]      <1> 	mov	edi, [v_str]
  7890                              <1> 
  7891 0000EB22 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7892 0000EB29 7707                <1> 	ja	short pix_op_rpl_w_1
  7893                              <1> 
  7894                              <1> 	; 256 colors (8bpp)
  7895 0000EB2B BD[10F50000]        <1> 	mov	ebp, pix_op_rpl_8
  7896 0000EB30 EB1E                <1> 	jmp	short pix_op_rpl_w_4
  7897                              <1> 			
  7898                              <1> pix_op_rpl_w_1:
  7899 0000EB32 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7900 0000EB39 7710                <1> 	ja	short pix_op_rpl_w_3 ; 32bpp
  7901 0000EB3B 7207                <1> 	jb	short pix_op_rpl_w_2 ; 16bpp
  7902                              <1> 
  7903                              <1> 	; 24 bit true colors
  7904 0000EB3D BD[33F50000]        <1> 	mov	ebp, pix_op_rpl_24
  7905 0000EB42 EB0C                <1> 	jmp	short pix_op_rpl_w_4
  7906                              <1> 
  7907                              <1> 	; 65536 colors (16bpp)
  7908                              <1> pix_op_rpl_w_2:
  7909 0000EB44 BD[20F50000]        <1> 	mov	ebp, pix_op_rpl_16
  7910 0000EB49 EB05                <1> 	jmp	short pix_op_rpl_w_4
  7911                              <1> 
  7912                              <1> 	; 32 bit true colors
  7913                              <1> pix_op_rpl_w_3:
  7914 0000EB4B BD[55F50000]        <1> 	mov	ebp, pix_op_rpl_32
  7915                              <1> pix_op_rpl_w_4:
  7916 0000EB50 E944FFFFFF          <1> 	jmp	pix_op_rpl_w_x
  7917                              <1> 
  7918                              <1> pix_op_orc:
  7919                              <1> 	; 31/01/2021
  7920                              <1> 	; OR COLOR
  7921                              <1> 	;
  7922                              <1> 	; INPUT:
  7923                              <1> 	;   CL = color (8 bit, 256 colors)
  7924                              <1> 	;  ECX = color (16 bit and true colors)
  7925                              <1> 	;  EDX = start position (row, column)
  7926                              <1> 	;        (HW = row, DX = column)
  7927                              <1> 	;  ESI = size (rows, colums)
  7928                              <1> 	;        (HW = rows, SI = columns)
  7929                              <1> 	;
  7930                              <1> 	;  [maskcolor] = mask color (to be excluded)
  7931                              <1> 	;
  7932                              <1> 	; OUTPUT:
  7933                              <1> 	; 	[u.r0] will be > 0 if succesful
  7934                              <1> 	
  7935 0000EB55 F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  7936 0000EB5C 7555                <1> 	jnz	short pix_op_or_w ; window
  7937                              <1> 	
  7938 0000EB5E 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  7939 0000EB64 89FE                <1> 	mov	esi, edi
  7940                              <1> 	; ecx = color (CL, CX, ECX)
  7941 0000EB66 89C8                <1> 	mov	eax, ecx
  7942 0000EB68 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  7943                              <1> 
  7944 0000EB6E F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color 'or' ?
  7945 0000EB75 7405                <1> 	jz	short pix_op_or_0 ; no
  7946 0000EB77 E948110000          <1> 	jmp	m_pix_op_or ; 'or' color except mask color
  7947                              <1> pix_op_or_0:
  7948 0000EB7C 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7949 0000EB83 7707                <1> 	ja	short pix_op_or_1
  7950                              <1> 
  7951                              <1> 	; 256 colors (8bpp)
  7952 0000EB85 E81C080000          <1> 	call	pix_op_or_8
  7953 0000EB8A EB1E                <1> 	jmp	short pix_op_or_4	
  7954                              <1> 			
  7955                              <1> pix_op_or_1:
  7956 0000EB8C 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7957 0000EB93 7710                <1> 	ja	short pix_op_or_3 ; 32bpp	
  7958 0000EB95 7207                <1> 	jb	short pix_op_or_2 ; 16bpp
  7959                              <1> 	
  7960                              <1> 	; 24 bit true colors
  7961 0000EB97 E818080000          <1> 	call	pix_op_or_24
  7962 0000EB9C EB0C                <1> 	jmp	short pix_op_or_4
  7963                              <1> 
  7964                              <1> 	; 65536 colors (16bpp)
  7965                              <1> pix_op_or_2:
  7966 0000EB9E E809080000          <1> 	call	pix_op_or_16
  7967 0000EBA3 EB05                <1> 	jmp	short pix_op_or_4
  7968                              <1> 
  7969                              <1> 	; 32 bit true colors
  7970                              <1> pix_op_or_3:
  7971 0000EBA5 E819080000          <1> 	call	pix_op_or_32
  7972                              <1> pix_op_or_4:
  7973 0000EBAA 29F7                <1> 	sub	edi, esi
  7974 0000EBAC 893D[64030300]      <1> 	mov	[u.r0], edi	
  7975                              <1> pix_op_or_5:
  7976 0000EBB2 C3                  <1> 	retn		
  7977                              <1> 
  7978                              <1> pix_op_or_w:
  7979                              <1> 	; 31/01/2021
  7980 0000EBB3 51                  <1> 	push	ecx ; * ; color
  7981 0000EBB4 89D1                <1> 	mov	ecx, edx ; win start pos
  7982 0000EBB6 89F2                <1> 	mov	edx, esi ; size (rows, cols)
  7983 0000EBB8 E85BFBFFFF          <1> 	call	sysvideo_15_12 ; window preparations
  7984 0000EBBD 58                  <1> 	pop	eax ; * ; color
  7985 0000EBBE 72F2                <1> 	jc	short pix_op_or_5
  7986                              <1> 
  7987 0000EBC0 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color 'or' ?
  7988 0000EBC7 7405                <1> 	jz	short pix_op_or_w_0 ; no
  7989 0000EBC9 E983110000          <1> 	jmp	m_pix_op_or_w 
  7990                              <1> 			; window 'or' color except mask color
  7991                              <1> pix_op_or_w_0:
  7992                              <1> 	; ecx = bytes per row (to be applied)
  7993                              <1> 	; edx = screen width in bytes
  7994                              <1> 	; ebx = row count
  7995                              <1> 	; eax = color
  7996                              <1> 
  7997 0000EBCE 8B3D[92120300]      <1> 	mov	edi, [v_str]
  7998 0000EBD4 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7999 0000EBDB 7707                <1> 	ja	short pix_op_or_w_1
  8000                              <1> 
  8001                              <1> 	; 256 colors (8bpp)
  8002 0000EBDD BD[A6F30000]        <1> 	mov	ebp, pix_op_or_8
  8003 0000EBE2 EB1E                <1> 	jmp	short pix_op_or_w_4
  8004                              <1> 			
  8005                              <1> pix_op_or_w_1:
  8006 0000EBE4 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8007 0000EBEB 7710                <1> 	ja	short pix_op_or_w_3 ; 32bpp
  8008 0000EBED 7207                <1> 	jb	short pix_op_or_w_2 ; 16bpp
  8009                              <1> 
  8010                              <1> 	; 24 bit true colors
  8011 0000EBEF BD[B4F30000]        <1> 	mov	ebp, pix_op_or_24
  8012 0000EBF4 EB0C                <1> 	jmp	short pix_op_or_w_4
  8013                              <1> 
  8014                              <1> 	; 65536 colors (16bpp)
  8015                              <1> pix_op_or_w_2:
  8016 0000EBF6 BD[ACF30000]        <1> 	mov	ebp, pix_op_or_16
  8017 0000EBFB EB05                <1> 	jmp	short pix_op_or_w_4
  8018                              <1> 
  8019                              <1> 	; 32 bit true colors
  8020                              <1> pix_op_or_w_3:
  8021 0000EBFD BD[C3F30000]        <1> 	mov	ebp, pix_op_or_32
  8022                              <1> pix_op_or_w_4:
  8023 0000EC02 E992FEFFFF          <1> 	jmp	pix_op_orc_w_x
  8024                              <1> 
  8025                              <1> pix_op_and:
  8026                              <1> 	; 31/01/2021
  8027                              <1> 	; AND COLOR
  8028                              <1> 	;
  8029                              <1> 	; INPUT:
  8030                              <1> 	;   CL = color (8 bit, 256 colors)
  8031                              <1> 	;  ECX = color (16 bit and true colors)
  8032                              <1> 	;  EDX = start position (row, column)
  8033                              <1> 	;        (HW = row, DX = column)
  8034                              <1> 	;  ESI = size (rows, colums)
  8035                              <1> 	;        (HW = rows, SI = columns)
  8036                              <1> 	;
  8037                              <1> 	;  [maskcolor] = mask color (to be excluded)
  8038                              <1> 	;
  8039                              <1> 	; OUTPUT:
  8040                              <1> 	; 	[u.r0] will be > 0 if succesful
  8041                              <1> 	
  8042 0000EC07 F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  8043 0000EC0E 7555                <1> 	jnz	short pix_op_and_w ; window
  8044                              <1> 	
  8045 0000EC10 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  8046 0000EC16 89FE                <1> 	mov	esi, edi
  8047                              <1> 	; ecx = color (CL, CX, ECX)
  8048 0000EC18 89C8                <1> 	mov	eax, ecx
  8049 0000EC1A 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  8050                              <1> 
  8051 0000EC20 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color 'and' ?
  8052 0000EC27 7405                <1> 	jz	short pix_op_and_0 ; no
  8053 0000EC29 E9D60F0000          <1> 	jmp	m_pix_op_and ; 'and' color except mask color
  8054                              <1> pix_op_and_0:
  8055 0000EC2E 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8056 0000EC35 7707                <1> 	ja	short pix_op_and_1
  8057                              <1> 
  8058                              <1> 	; 256 colors (8bpp)
  8059 0000EC37 E88F070000          <1> 	call	pix_op_and_8
  8060 0000EC3C EB1E                <1> 	jmp	short pix_op_and_4	
  8061                              <1> 			
  8062                              <1> pix_op_and_1:
  8063 0000EC3E 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8064 0000EC45 7710                <1> 	ja	short pix_op_and_3 ; 32bpp	
  8065 0000EC47 7207                <1> 	jb	short pix_op_and_2 ; 16bpp
  8066                              <1> 	
  8067                              <1> 	; 24 bit true colors
  8068 0000EC49 E88B070000          <1> 	call	pix_op_and_24
  8069 0000EC4E EB0C                <1> 	jmp	short pix_op_and_4
  8070                              <1> 
  8071                              <1> 	; 65536 colors (16bpp)
  8072                              <1> pix_op_and_2:
  8073 0000EC50 E87C070000          <1> 	call	pix_op_and_16
  8074 0000EC55 EB05                <1> 	jmp	short pix_op_and_4
  8075                              <1> 
  8076                              <1> 	; 32 bit true colors
  8077                              <1> pix_op_and_3:
  8078 0000EC57 E88C070000          <1> 	call	pix_op_and_32
  8079                              <1> pix_op_and_4:
  8080 0000EC5C 29F7                <1> 	sub	edi, esi
  8081 0000EC5E 893D[64030300]      <1> 	mov	[u.r0], edi	
  8082                              <1> pix_op_and_5:
  8083 0000EC64 C3                  <1> 	retn		
  8084                              <1> 
  8085                              <1> pix_op_and_w:
  8086                              <1> 	; 31/01/2021
  8087 0000EC65 51                  <1> 	push	ecx ; * ; color
  8088 0000EC66 89D1                <1> 	mov	ecx, edx ; win start pos
  8089 0000EC68 89F2                <1> 	mov	edx, esi ; size (rows, cols)
  8090 0000EC6A E8A9FAFFFF          <1> 	call	sysvideo_15_12 ; window preparations
  8091 0000EC6F 58                  <1> 	pop	eax ; * ; color
  8092 0000EC70 72F2                <1> 	jc	short pix_op_and_5
  8093                              <1> 
  8094 0000EC72 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color 'and' ?
  8095 0000EC79 7405                <1> 	jz	short pix_op_and_w_0 ; no
  8096 0000EC7B E911100000          <1> 	jmp	m_pix_op_and_w 
  8097                              <1> 			; window 'and' color except mask color
  8098                              <1> pix_op_and_w_0:
  8099                              <1> 	; ecx = bytes per row (to be applied)
  8100                              <1> 	; edx = screen width in bytes
  8101                              <1> 	; ebx = row count
  8102                              <1> 	; eax = color
  8103                              <1> 
  8104 0000EC80 8B3D[92120300]      <1> 	mov	edi, [v_str]
  8105 0000EC86 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8106 0000EC8D 7707                <1> 	ja	short pix_op_and_w_1
  8107                              <1> 
  8108                              <1> 	; 256 colors (8bpp)
  8109 0000EC8F BD[CBF30000]        <1> 	mov	ebp, pix_op_and_8
  8110 0000EC94 EB1E                <1> 	jmp	short pix_op_and_w_4
  8111                              <1> 			
  8112                              <1> pix_op_and_w_1:
  8113 0000EC96 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8114 0000EC9D 7710                <1> 	ja	short pix_op_and_w_3 ; 32bpp
  8115 0000EC9F 7207                <1> 	jb	short pix_op_and_w_2 ; 16bpp
  8116                              <1> 
  8117                              <1> 	; 24 bit true colors
  8118 0000ECA1 BD[D9F30000]        <1> 	mov	ebp, pix_op_and_24
  8119 0000ECA6 EB0C                <1> 	jmp	short pix_op_and_w_4
  8120                              <1> 
  8121                              <1> 	; 65536 colors (16bpp)
  8122                              <1> pix_op_and_w_2:
  8123 0000ECA8 BD[D1F30000]        <1> 	mov	ebp, pix_op_and_16
  8124 0000ECAD EB05                <1> 	jmp	short pix_op_and_w_4
  8125                              <1> 
  8126                              <1> 	; 32 bit true colors
  8127                              <1> pix_op_and_w_3:
  8128 0000ECAF BD[E8F30000]        <1> 	mov	ebp, pix_op_and_32
  8129                              <1> pix_op_and_w_4:
  8130 0000ECB4 E9E0FDFFFF          <1> 	jmp	pix_op_and_w_x
  8131                              <1> 
  8132                              <1> pix_op_xor:
  8133                              <1> 	; 31/01/2021
  8134                              <1> 	; XOR COLOR
  8135                              <1> 	;
  8136                              <1> 	; INPUT:
  8137                              <1> 	;   CL = color (8 bit, 256 colors)
  8138                              <1> 	;  ECX = color (16 bit and true colors)
  8139                              <1> 	;  EDX = start position (row, column)
  8140                              <1> 	;        (HW = row, DX = column)
  8141                              <1> 	;  ESI = size (rows, colums)
  8142                              <1> 	;        (HW = rows, SI = columns)
  8143                              <1> 	;
  8144                              <1> 	;  [maskcolor] = mask color (to be excluded)
  8145                              <1> 	;
  8146                              <1> 	; OUTPUT:
  8147                              <1> 	; 	[u.r0] will be > 0 if succesful
  8148                              <1> 	
  8149 0000ECB9 F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  8150 0000ECC0 7555                <1> 	jnz	short pix_op_xor_w ; window
  8151                              <1> 	
  8152 0000ECC2 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  8153 0000ECC8 89FE                <1> 	mov	esi, edi
  8154                              <1> 	; ecx = color (CL, CX, ECX)
  8155 0000ECCA 89C8                <1> 	mov	eax, ecx
  8156 0000ECCC 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  8157                              <1> 
  8158 0000ECD2 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color 'xor' ?
  8159 0000ECD9 7405                <1> 	jz	short pix_op_xor_0 ; no
  8160 0000ECDB E9A4100000          <1> 	jmp	m_pix_op_xor ; 'xor' color except mask color
  8161                              <1> pix_op_xor_0:
  8162 0000ECE0 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8163 0000ECE7 7707                <1> 	ja	short pix_op_xor_1
  8164                              <1> 
  8165                              <1> 	; 256 colors (8bpp)
  8166 0000ECE9 E802070000          <1> 	call	pix_op_xor_8
  8167 0000ECEE EB1E                <1> 	jmp	short pix_op_xor_4	
  8168                              <1> 			
  8169                              <1> pix_op_xor_1:
  8170 0000ECF0 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8171 0000ECF7 7710                <1> 	ja	short pix_op_xor_3 ; 32bpp	
  8172 0000ECF9 7207                <1> 	jb	short pix_op_xor_2 ; 16bpp
  8173                              <1> 	
  8174                              <1> 	; 24 bit true colors
  8175 0000ECFB E8FE060000          <1> 	call	pix_op_xor_24
  8176 0000ED00 EB0C                <1> 	jmp	short pix_op_xor_4
  8177                              <1> 
  8178                              <1> 	; 65536 colors (16bpp)
  8179                              <1> pix_op_xor_2:
  8180 0000ED02 E8EF060000          <1> 	call	pix_op_xor_16
  8181 0000ED07 EB05                <1> 	jmp	short pix_op_xor_4
  8182                              <1> 
  8183                              <1> 	; 32 bit true colors
  8184                              <1> pix_op_xor_3:
  8185 0000ED09 E8FF060000          <1> 	call	pix_op_xor_32
  8186                              <1> pix_op_xor_4:
  8187 0000ED0E 29F7                <1> 	sub	edi, esi
  8188 0000ED10 893D[64030300]      <1> 	mov	[u.r0], edi	
  8189                              <1> pix_op_xor_5:
  8190 0000ED16 C3                  <1> 	retn		
  8191                              <1> 
  8192                              <1> pix_op_xor_w:
  8193                              <1> 	; 31/01/2021
  8194 0000ED17 51                  <1> 	push	ecx ; * ; color
  8195 0000ED18 89D1                <1> 	mov	ecx, edx ; win start pos
  8196 0000ED1A 89F2                <1> 	mov	edx, esi ; size (rows, cols)
  8197 0000ED1C E8F7F9FFFF          <1> 	call	sysvideo_15_12 ; window preparations
  8198 0000ED21 58                  <1> 	pop	eax ; * ; color
  8199 0000ED22 72F2                <1> 	jc	short pix_op_xor_5
  8200                              <1> 
  8201 0000ED24 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color 'xor' ?
  8202 0000ED2B 7405                <1> 	jz	short pix_op_xor_w_0 ; no
  8203 0000ED2D E9DF100000          <1> 	jmp	m_pix_op_xor_w 
  8204                              <1> 			; window 'xor' color except mask color
  8205                              <1> pix_op_xor_w_0:
  8206                              <1> 	; ecx = bytes per row (to be applied)
  8207                              <1> 	; edx = screen width in bytes
  8208                              <1> 	; ebx = row count
  8209                              <1> 	; eax = color
  8210                              <1> 
  8211 0000ED32 8B3D[92120300]      <1> 	mov	edi, [v_str]
  8212 0000ED38 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8213 0000ED3F 7707                <1> 	ja	short pix_op_xor_w_1
  8214                              <1> 
  8215                              <1> 	; 256 colors (8bpp)
  8216 0000ED41 BD[F0F30000]        <1> 	mov	ebp, pix_op_xor_8
  8217 0000ED46 EB1E                <1> 	jmp	short pix_op_xor_w_4
  8218                              <1> 			
  8219                              <1> pix_op_xor_w_1:
  8220 0000ED48 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8221 0000ED4F 7710                <1> 	ja	short pix_op_xor_w_3 ; 32bpp
  8222 0000ED51 7207                <1> 	jb	short pix_op_xor_w_2 ; 16bpp
  8223                              <1> 
  8224                              <1> 	; 24 bit true colors
  8225 0000ED53 BD[FEF30000]        <1> 	mov	ebp, pix_op_xor_24
  8226 0000ED58 EB0C                <1> 	jmp	short pix_op_xor_w_4
  8227                              <1> 
  8228                              <1> 	; 65536 colors (16bpp)
  8229                              <1> pix_op_xor_w_2:
  8230 0000ED5A BD[F6F30000]        <1> 	mov	ebp, pix_op_xor_16
  8231 0000ED5F EB05                <1> 	jmp	short pix_op_xor_w_4
  8232                              <1> 
  8233                              <1> 	; 32 bit true colors
  8234                              <1> pix_op_xor_w_3:
  8235 0000ED61 BD[0DF40000]        <1> 	mov	ebp, pix_op_xor_32
  8236                              <1> pix_op_xor_w_4:
  8237 0000ED66 E92EFDFFFF          <1> 	jmp	pix_op_xor_w_x
  8238                              <1> 
  8239                              <1> pix_op_new:
  8240                              <1> 	; 31/01/2021
  8241                              <1> 	; 30/01/2021
  8242                              <1> 	; CHANGE COLOR
  8243                              <1> 	;
  8244                              <1> 	; INPUT:
  8245                              <1> 	;   CL = color (8 bit, 256 colors)
  8246                              <1> 	;  ECX = color (16 bit and true colors)
  8247                              <1> 	;  EDX = start position (row, column)
  8248                              <1> 	;        (HW = row, DX = column)
  8249                              <1> 	;  ESI = size (rows, colums)
  8250                              <1> 	;        (HW = rows, SI = columns)
  8251                              <1> 	;
  8252                              <1> 	;  [maskcolor] = mask color (to be excluded)
  8253                              <1> 	;
  8254                              <1> 	; OUTPUT:
  8255                              <1> 	; 	[u.r0] will be > 0 if succesful
  8256                              <1> 	
  8257 0000ED6B F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  8258 0000ED72 7554                <1> 	jnz	short pix_op_new_w ; window
  8259                              <1> 	
  8260 0000ED74 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  8261 0000ED7A 89FE                <1> 	mov	esi, edi
  8262                              <1> 	; ecx = color (CL, CX, ECX)
  8263 0000ED7C 89C8                <1> 	mov	eax, ecx
  8264 0000ED7E 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  8265                              <1> 
  8266 0000ED84 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color change ?
  8267 0000ED8B 7405                <1> 	jz	short pix_op_new_0 ; no
  8268 0000ED8D E90D0B0000          <1> 	jmp	m_pix_op_new ; change color except mask color
  8269                              <1> pix_op_new_0:
  8270 0000ED92 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8271 0000ED99 7706                <1> 	ja	short pix_op_new_2
  8272                              <1> 
  8273                              <1> 	; 256 colors (8bpp)
  8274                              <1> pix_op_new_1:
  8275 0000ED9B 88C4                <1> 	mov	ah, al
  8276 0000ED9D D1E9                <1> 	shr	ecx, 1	
  8277 0000ED9F EB12                <1> 	jmp	short pix_op_new_3
  8278                              <1> 			
  8279                              <1> pix_op_new_2:
  8280 0000EDA1 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8281 0000EDA8 7713                <1> 	ja	short pix_op_new_4 ; 32bpp	
  8282 0000EDAA 7207                <1> 	jb	short pix_op_new_3 ; 16bpp
  8283                              <1> 
  8284                              <1> 	; 31/01/2021
  8285                              <1> 	
  8286                              <1> 	; 24 bit true colors
  8287 0000EDAC E84A050000          <1> 	call	pix_op_new_24
  8288                              <1> 
  8289 0000EDB1 EB0C                <1> 	jmp	short pix_op_new_5
  8290                              <1> 
  8291                              <1> 	; 65536 colors (16bpp)
  8292                              <1> pix_op_new_3:
  8293 0000EDB3 89C2                <1> 	mov	edx, eax
  8294 0000EDB5 C1E010              <1> 	shl	eax, 16
  8295 0000EDB8 6689D0              <1> 	mov	ax, dx
  8296 0000EDBB D1E9                <1> 	shr	ecx, 1 ; dword counts
  8297                              <1> 	; 32 bit true colors	
  8298                              <1> pix_op_new_4:
  8299 0000EDBD F3AB                <1> 	rep	stosd
  8300                              <1> pix_op_new_5:
  8301 0000EDBF 29F7                <1> 	sub	edi, esi
  8302 0000EDC1 893D[64030300]      <1> 	mov	[u.r0], edi	
  8303                              <1> pix_op_new_6:
  8304 0000EDC7 C3                  <1> 	retn		
  8305                              <1> 
  8306                              <1> pix_op_new_w:
  8307                              <1> 	; 31/01/2021
  8308                              <1> 	; 30/01/2021
  8309 0000EDC8 51                  <1> 	push	ecx ; * ; color
  8310 0000EDC9 89D1                <1> 	mov	ecx, edx ; win start pos
  8311 0000EDCB 89F2                <1> 	mov	edx, esi ; size (rows, cols)
  8312 0000EDCD E846F9FFFF          <1> 	call	sysvideo_15_12 ; window preparations
  8313 0000EDD2 58                  <1> 	pop	eax ; * ; color
  8314 0000EDD3 72F2                <1> 	jc	short pix_op_new_6
  8315                              <1> 
  8316 0000EDD5 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color change ?
  8317 0000EDDC 7405                <1> 	jz	short pix_op_new_w_0 ; no
  8318 0000EDDE E94A0B0000          <1> 	jmp	m_pix_op_new_w 
  8319                              <1> 			; window chg color except mask color
  8320                              <1> pix_op_new_w_0:
  8321                              <1> 	; ecx = bytes per row (to be applied)
  8322                              <1> 	; edx = screen width in bytes
  8323                              <1> 	; ebx = row count
  8324                              <1> 	; eax = color
  8325                              <1> 
  8326 0000EDE3 8B3D[92120300]      <1> 	mov	edi, [v_str]
  8327                              <1> 
  8328 0000EDE9 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8329 0000EDF0 7707                <1> 	ja	short pix_op_new_w_1
  8330                              <1> 
  8331                              <1> 	; 256 colors (8bpp)
  8332 0000EDF2 BD[F4F20000]        <1> 	mov	ebp, pix_op_new_8
  8333 0000EDF7 EB1E                <1> 	jmp	short pix_op_new_w_x
  8334                              <1> 			
  8335                              <1> pix_op_new_w_1:
  8336 0000EDF9 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8337 0000EE00 7710                <1> 	ja	short pix_op_new_w_3 ; 32bpp
  8338 0000EE02 7207                <1> 	jb	short pix_op_new_w_2 ; 16bpp
  8339                              <1> 
  8340                              <1> 	; 24 bit true colors
  8341 0000EE04 BD[FBF20000]        <1> 	mov	ebp, pix_op_new_24
  8342 0000EE09 EB0C                <1> 	jmp	short pix_op_new_w_x
  8343                              <1> 
  8344                              <1> 	; 65536 colors (16bpp)
  8345                              <1> pix_op_new_w_2:
  8346 0000EE0B BD[F7F20000]        <1> 	mov	ebp, pix_op_new_16
  8347 0000EE10 EB05                <1> 	jmp	short pix_op_new_w_x
  8348                              <1> 
  8349                              <1> 	; 32 bit true colors
  8350                              <1> pix_op_new_w_3:
  8351 0000EE12 BD[07F30000]        <1> 	mov	ebp, pix_op_new_32
  8352                              <1> 	;jmp	short pix_op_new_w_x
  8353                              <1> 
  8354                              <1> pix_op_new_w_x:
  8355                              <1> pix_op_not_w_x:
  8356                              <1> pix_op_neg_w_x:
  8357                              <1> pix_op_inc_w_x:
  8358                              <1> pix_op_dec_w_x:
  8359                              <1> 	; 27/02/2021
  8360                              <1> 	; 01/02/2021
  8361                              <1> 	; 31/01/2021
  8362                              <1> 	; ecx = bytes per row (to be applied)
  8363                              <1> 	; edx = windows (screen) width in bytes
  8364                              <1> 	; ebx = row count
  8365                              <1> 	; eax = color
  8366                              <1> 	; ebp = pixel operation subroutine address
  8367                              <1> 	;push	edx ; 01/02/2021
  8368 0000EE17 51                  <1> 	push	ecx
  8369 0000EE18 57                  <1> 	push	edi
  8370 0000EE19 8B0D[9E120300]      <1> 	mov	ecx, [pixcount] ; 27/02/2021
  8371 0000EE1F FFD5                <1> 	call	ebp ; call pixel-row operation
  8372 0000EE21 5F                  <1> 	pop	edi
  8373 0000EE22 59                  <1> 	pop	ecx ; bytes per row
  8374 0000EE23 010D[64030300]      <1> 	add	[u.r0], ecx
  8375                              <1> 	;pop	edx ; 01/02/2021
  8376 0000EE29 01D7                <1> 	add	edi, edx ; next row
  8377 0000EE2B 4B                  <1> 	dec	ebx
  8378 0000EE2C 75E9                <1> 	jnz	short pix_op_new_w_x
  8379 0000EE2E C3                  <1> 	retn
  8380                              <1> 
  8381                              <1> pix_op_not:
  8382                              <1> 	; 31/01/2021
  8383                              <1> 	; NOT COLOR
  8384                              <1> 	;
  8385                              <1> 	; INPUT:
  8386                              <1> 	;  ECX = start position (row, column)
  8387                              <1> 	;        (HW = row, CX = column)
  8388                              <1> 	;  EDX = size (rows, colums)
  8389                              <1> 	;        (HW = rows, DX = columns)
  8390                              <1> 	;	 (0 -> invalid 	
  8391                              <1> 	;        (1 -> horizontal or vertical line)
  8392                              <1> 	;  [maskcolor] = mask color (to be excluded)
  8393                              <1> 	;
  8394                              <1> 	; OUTPUT:
  8395                              <1> 	; 	[u.r0] will be > 0 if succesful
  8396                              <1> 	
  8397 0000EE2F F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  8398 0000EE36 7553                <1> 	jnz	short pix_op_not_w ; window
  8399                              <1> 	
  8400 0000EE38 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  8401 0000EE3E 89FE                <1> 	mov	esi, edi
  8402 0000EE40 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  8403                              <1> 
  8404 0000EE46 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color 'not' ?
  8405 0000EE4D 7405                <1> 	jz	short pix_op_not_0 ; no
  8406 0000EE4F E9F00F0000          <1> 	jmp	m_pix_op_not ; 'not' color except mask color
  8407                              <1> pix_op_not_0:
  8408 0000EE54 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8409 0000EE5B 7707                <1> 	ja	short pix_op_not_1
  8410                              <1> 
  8411                              <1> 	; 256 colors (8bpp)
  8412 0000EE5D E8F6050000          <1> 	call	pix_op_not_8
  8413 0000EE62 EB1E                <1> 	jmp	short pix_op_not_4
  8414                              <1> 			
  8415                              <1> pix_op_not_1:
  8416 0000EE64 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8417 0000EE6B 7710                <1> 	ja	short pix_op_not_3 ; 32bpp	
  8418 0000EE6D 7207                <1> 	jb	short pix_op_not_2 ; 16bpp
  8419                              <1> 
  8420                              <1> 	; 24 bit true colors
  8421 0000EE6F E8F2050000          <1> 	call	pix_op_not_24
  8422 0000EE74 EB0C                <1> 	jmp	short pix_op_not_4
  8423                              <1> 
  8424                              <1> 	; 65536 colors (16bpp)
  8425                              <1> pix_op_not_2:
  8426 0000EE76 E8E3050000          <1> 	call	pix_op_not_16
  8427 0000EE7B EB05                <1> 	jmp	short pix_op_not_4
  8428                              <1> 
  8429                              <1> 	; 32 bit true colors	
  8430                              <1> pix_op_not_3:
  8431 0000EE7D E8EF050000          <1> 	call	pix_op_not_32
  8432                              <1> pix_op_not_4:
  8433 0000EE82 29F7                <1> 	sub	edi, esi
  8434 0000EE84 893D[64030300]      <1> 	mov	[u.r0], edi	
  8435                              <1> pix_op_not_5:
  8436 0000EE8A C3                  <1> 	retn
  8437                              <1> 
  8438                              <1> pix_op_not_w:
  8439                              <1> 	; 31/01/2021
  8440                              <1> 	; ecx = win start pos (row, column)
  8441                              <1> 	; edx = size (rows, columns)
  8442 0000EE8B E888F8FFFF          <1> 	call	sysvideo_15_12 ; window preparations
  8443 0000EE90 72F8                <1> 	jc	short pix_op_not_5
  8444                              <1> 
  8445 0000EE92 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color 'not' ?
  8446 0000EE99 7405                <1> 	jz	short pix_op_not_w_0 ; no
  8447 0000EE9B E929100000          <1> 	jmp	m_pix_op_not_w 
  8448                              <1> 			; window 'not' color except mask color
  8449                              <1> pix_op_not_w_0:
  8450                              <1> 	; ecx = bytes per row (to be applied)
  8451                              <1> 	; edx = screen width in bytes
  8452                              <1> 	; ebx = row count
  8453                              <1> 
  8454 0000EEA0 8B3D[92120300]      <1> 	mov	edi, [v_str]
  8455                              <1> 
  8456 0000EEA6 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8457 0000EEAD 7707                <1> 	ja	short pix_op_not_w_1
  8458                              <1> 
  8459                              <1> 	; 256 colors (8bpp)
  8460 0000EEAF BD[58F40000]        <1> 	mov	ebp, pix_op_not_8
  8461 0000EEB4 EB1E                <1> 	jmp	short pix_op_not_w_4
  8462                              <1> 			
  8463                              <1> pix_op_not_w_1:
  8464 0000EEB6 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8465 0000EEBD 7710                <1> 	ja	short pix_op_not_w_3 ; 32bpp
  8466 0000EEBF 7207                <1> 	jb	short pix_op_not_w_2 ; 16bpp
  8467                              <1> 
  8468                              <1> 	; 24 bit true colors
  8469 0000EEC1 BD[66F40000]        <1> 	mov	ebp, pix_op_not_24
  8470 0000EEC6 EB0C                <1> 	jmp	short pix_op_not_w_4
  8471                              <1> 
  8472                              <1> 	; 65536 colors (16bpp)
  8473                              <1> pix_op_not_w_2:
  8474 0000EEC8 BD[5EF40000]        <1> 	mov	ebp, pix_op_not_16
  8475 0000EECD EB05                <1> 	jmp	short pix_op_not_w_4
  8476                              <1> 
  8477                              <1> 	; 32 bit true colors
  8478                              <1> pix_op_not_w_3:
  8479 0000EECF BD[71F40000]        <1> 	mov	ebp, pix_op_not_32
  8480                              <1> pix_op_not_w_4:
  8481 0000EED4 E93EFFFFFF          <1> 	jmp	pix_op_not_w_x
  8482                              <1> 
  8483                              <1> pix_op_neg:
  8484                              <1> 	; 31/01/2021
  8485                              <1> 	; NEGATE COLOR
  8486                              <1> 	;
  8487                              <1> 	; INPUT:
  8488                              <1> 	;  ECX = start position (row, column)
  8489                              <1> 	;        (HW = row, CX = column)
  8490                              <1> 	;  EDX = size (rows, colums)
  8491                              <1> 	;        (HW = rows, DX = columns)
  8492                              <1> 	;	 (0 -> invalid 	
  8493                              <1> 	;        (1 -> horizontal or vertical line)
  8494                              <1> 	;  [maskcolor] = mask color (to be excluded)
  8495                              <1> 	;
  8496                              <1> 	; OUTPUT:
  8497                              <1> 	; 	[u.r0] will be > 0 if succesful
  8498                              <1> 	
  8499 0000EED9 F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  8500 0000EEE0 7553                <1> 	jnz	short pix_op_neg_w ; window
  8501                              <1> 	
  8502 0000EEE2 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  8503 0000EEE8 89FE                <1> 	mov	esi, edi
  8504 0000EEEA 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  8505                              <1> 
  8506 0000EEF0 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked negate color ?
  8507 0000EEF7 7405                <1> 	jz	short pix_op_neg_0 ; no
  8508 0000EEF9 E9FE0F0000          <1> 	jmp	m_pix_op_neg ; 'neg' color except mask color
  8509                              <1> pix_op_neg_0:
  8510 0000EEFE 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8511 0000EF05 7707                <1> 	ja	short pix_op_neg_1
  8512                              <1> 
  8513                              <1> 	; 256 colors (8bpp)
  8514 0000EF07 E86D050000          <1> 	call	pix_op_neg_8
  8515 0000EF0C EB1E                <1> 	jmp	short pix_op_neg_4
  8516                              <1> 			
  8517                              <1> pix_op_neg_1:
  8518 0000EF0E 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8519 0000EF15 7710                <1> 	ja	short pix_op_neg_3 ; 32bpp	
  8520 0000EF17 7207                <1> 	jb	short pix_op_neg_2 ; 16bpp
  8521                              <1> 
  8522                              <1> 	; 24 bit true colors
  8523 0000EF19 E869050000          <1> 	call	pix_op_neg_24
  8524 0000EF1E EB0C                <1> 	jmp	short pix_op_neg_4
  8525                              <1> 
  8526                              <1> 	; 65536 colors (16bpp)
  8527                              <1> pix_op_neg_2:
  8528 0000EF20 E85A050000          <1> 	call	pix_op_neg_16
  8529 0000EF25 EB05                <1> 	jmp	short pix_op_neg_4
  8530                              <1> 
  8531                              <1> 	; 32 bit true colors	
  8532                              <1> pix_op_neg_3:
  8533 0000EF27 E86D050000          <1> 	call	pix_op_neg_32
  8534                              <1> pix_op_neg_4:
  8535 0000EF2C 29F7                <1> 	sub	edi, esi
  8536 0000EF2E 893D[64030300]      <1> 	mov	[u.r0], edi	
  8537                              <1> pix_op_neg_5:
  8538 0000EF34 C3                  <1> 	retn
  8539                              <1> 
  8540                              <1> pix_op_neg_w:
  8541                              <1> 	; 31/01/2021
  8542                              <1> 	; ecx = win start pos (row, column)
  8543                              <1> 	; edx = size (rows, columns)
  8544 0000EF35 E8DEF7FFFF          <1> 	call	sysvideo_15_12 ; window preparations
  8545 0000EF3A 72F8                <1> 	jc	short pix_op_neg_5
  8546                              <1> 
  8547 0000EF3C F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked negate color ?
  8548 0000EF43 7405                <1> 	jz	short pix_op_neg_w_0 ; no
  8549 0000EF45 E937100000          <1> 	jmp	m_pix_op_neg_w 
  8550                              <1> 			; window 'neg' color except mask color
  8551                              <1> pix_op_neg_w_0:
  8552                              <1> 	; ecx = bytes per row (to be applied)
  8553                              <1> 	; edx = screen width in bytes
  8554                              <1> 	; ebx = row count
  8555                              <1> 
  8556 0000EF4A 8B3D[92120300]      <1> 	mov	edi, [v_str]
  8557                              <1> 
  8558 0000EF50 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8559 0000EF57 7707                <1> 	ja	short pix_op_neg_w_1
  8560                              <1> 
  8561                              <1> 	; 256 colors (8bpp)
  8562 0000EF59 BD[79F40000]        <1> 	mov	ebp, pix_op_neg_8
  8563 0000EF5E EB1E                <1> 	jmp	short pix_op_neg_w_4
  8564                              <1> 			
  8565                              <1> pix_op_neg_w_1:
  8566 0000EF60 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8567 0000EF67 7710                <1> 	ja	short pix_op_neg_w_3 ; 32bpp
  8568 0000EF69 7207                <1> 	jb	short pix_op_neg_w_2 ; 16bpp
  8569                              <1> 
  8570                              <1> 	; 24 bit true colors
  8571 0000EF6B BD[87F40000]        <1> 	mov	ebp, pix_op_neg_24
  8572 0000EF70 EB0C                <1> 	jmp	short pix_op_neg_w_4
  8573                              <1> 
  8574                              <1> 	; 65536 colors (16bpp)
  8575                              <1> pix_op_neg_w_2:
  8576 0000EF72 BD[7FF40000]        <1> 	mov	ebp, pix_op_neg_16
  8577 0000EF77 EB05                <1> 	jmp	short pix_op_neg_w_4
  8578                              <1> 
  8579                              <1> 	; 32 bit true colors
  8580                              <1> pix_op_neg_w_3:
  8581 0000EF79 BD[99F40000]        <1> 	mov	ebp, pix_op_neg_32
  8582                              <1> pix_op_neg_w_4:
  8583 0000EF7E E994FEFFFF          <1> 	jmp	pix_op_neg_w_x
  8584                              <1> 
  8585                              <1> pix_op_inc:
  8586                              <1> 	; 31/01/2021
  8587                              <1> 	; INCREASE COLOR
  8588                              <1> 	;
  8589                              <1> 	; INPUT:
  8590                              <1> 	;  ECX = start position (row, column)
  8591                              <1> 	;        (HW = row, CX = column)
  8592                              <1> 	;  EDX = size (rows, colums)
  8593                              <1> 	;        (HW = rows, DX = columns)
  8594                              <1> 	;	 (0 -> invalid 	
  8595                              <1> 	;        (1 -> horizontal or vertical line)
  8596                              <1> 	;  [maskcolor] = mask color (to be excluded)
  8597                              <1> 	;
  8598                              <1> 	; OUTPUT:
  8599                              <1> 	; 	[u.r0] will be > 0 if succesful
  8600                              <1> 	
  8601 0000EF83 F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  8602 0000EF8A 7553                <1> 	jnz	short pix_op_inc_w ; window
  8603                              <1> 	
  8604 0000EF8C 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  8605 0000EF92 89FE                <1> 	mov	esi, edi
  8606 0000EF94 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  8607                              <1> 
  8608 0000EF9A F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked increase color ?
  8609 0000EFA1 7405                <1> 	jz	short pix_op_inc_0 ; no
  8610 0000EFA3 E90C100000          <1> 	jmp	m_pix_op_inc ; 'inc' color except mask color
  8611                              <1> pix_op_inc_0:
  8612 0000EFA8 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8613 0000EFAF 7707                <1> 	ja	short pix_op_inc_1
  8614                              <1> 
  8615                              <1> 	; 256 colors (8bpp)
  8616 0000EFB1 E8EB040000          <1> 	call	pix_op_inc_8
  8617 0000EFB6 EB1E                <1> 	jmp	short pix_op_inc_4
  8618                              <1> 			
  8619                              <1> pix_op_inc_1:
  8620 0000EFB8 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8621 0000EFBF 7710                <1> 	ja	short pix_op_inc_3 ; 32bpp	
  8622 0000EFC1 7207                <1> 	jb	short pix_op_inc_2 ; 16bpp
  8623                              <1> 
  8624                              <1> 	; 24 bit true colors
  8625 0000EFC3 E8F0040000          <1> 	call	pix_op_inc_24
  8626 0000EFC8 EB0C                <1> 	jmp	short pix_op_inc_4
  8627                              <1> 
  8628                              <1> 	; 65536 colors (16bpp)
  8629                              <1> pix_op_inc_2:
  8630 0000EFCA E8DC040000          <1> 	call	pix_op_inc_16
  8631 0000EFCF EB05                <1> 	jmp	short pix_op_inc_4
  8632                              <1> 
  8633                              <1> 	; 32 bit true colors	
  8634                              <1> pix_op_inc_3:
  8635 0000EFD1 E8F6040000          <1> 	call	pix_op_inc_32
  8636                              <1> pix_op_inc_4:
  8637 0000EFD6 29F7                <1> 	sub	edi, esi
  8638 0000EFD8 893D[64030300]      <1> 	mov	[u.r0], edi	
  8639                              <1> pix_op_inc_5:
  8640 0000EFDE C3                  <1> 	retn			
  8641                              <1> 
  8642                              <1> pix_op_inc_w:
  8643                              <1> 	; 31/01/2021
  8644                              <1> 	; ecx = win start pos (row, column)
  8645                              <1> 	; edx = size (rows, columns)
  8646 0000EFDF E834F7FFFF          <1> 	call	sysvideo_15_12 ; window preparations
  8647 0000EFE4 72F8                <1> 	jc	short pix_op_inc_5
  8648                              <1> 
  8649 0000EFE6 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked increase color ?
  8650 0000EFED 7405                <1> 	jz	short pix_op_inc_w_0 ; no
  8651 0000EFEF E959100000          <1> 	jmp	m_pix_op_inc_w 
  8652                              <1> 			; window 'inc' color except mask color
  8653                              <1> pix_op_inc_w_0:
  8654                              <1> 	; ecx = bytes per row (to be applied)
  8655                              <1> 	; edx = screen width in bytes
  8656                              <1> 	; ebx = row count
  8657                              <1> 
  8658 0000EFF4 8B3D[92120300]      <1> 	mov	edi, [v_str]
  8659                              <1> 
  8660 0000EFFA 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8661 0000F001 7707                <1> 	ja	short pix_op_inc_w_1
  8662                              <1> 
  8663                              <1> 	; 256 colors (8bpp)
  8664 0000F003 BD[A1F40000]        <1> 	mov	ebp, pix_op_inc_8
  8665 0000F008 EB1E                <1> 	jmp	short pix_op_inc_w_4
  8666                              <1> 			
  8667                              <1> pix_op_inc_w_1:
  8668 0000F00A 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8669 0000F011 7710                <1> 	ja	short pix_op_inc_w_3 ; 32bpp
  8670 0000F013 7207                <1> 	jb	short pix_op_inc_w_2 ; 16bpp
  8671                              <1> 
  8672                              <1> 	; 24 bit true colors
  8673 0000F015 BD[B8F40000]        <1> 	mov	ebp, pix_op_inc_24
  8674 0000F01A EB0C                <1> 	jmp	short pix_op_inc_w_4
  8675                              <1> 
  8676                              <1> 	; 65536 colors (16bpp)
  8677                              <1> pix_op_inc_w_2:
  8678 0000F01C BD[ABF40000]        <1> 	mov	ebp, pix_op_inc_16
  8679 0000F021 EB05                <1> 	jmp	short pix_op_inc_w_4
  8680                              <1> 
  8681                              <1> 	; 32 bit true colors
  8682                              <1> pix_op_inc_w_3:
  8683 0000F023 BD[CCF40000]        <1> 	mov	ebp, pix_op_inc_32
  8684                              <1> pix_op_inc_w_4:
  8685 0000F028 E9EAFDFFFF          <1> 	jmp	pix_op_inc_w_x
  8686                              <1> 
  8687                              <1> pix_op_dec:
  8688                              <1> 	; 31/01/2021
  8689                              <1> 	; DECREASE COLOR
  8690                              <1> 	;
  8691                              <1> 	; INPUT:
  8692                              <1> 	;  ECX = start position (row, column)
  8693                              <1> 	;        (HW = row, CX = column)
  8694                              <1> 	;  EDX = size (rows, colums)
  8695                              <1> 	;        (HW = rows, DX = columns)
  8696                              <1> 	;	 (0 -> invalid 	
  8697                              <1> 	;        (1 -> horizontal or vertical line)
  8698                              <1> 	;  [maskcolor] = mask color (to be excluded)
  8699                              <1> 	;
  8700                              <1> 	; OUTPUT:
  8701                              <1> 	; 	[u.r0] will be > 0 if succesful
  8702                              <1> 	
  8703 0000F02D F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  8704 0000F034 7553                <1> 	jnz	short pix_op_dec_w ; window
  8705                              <1> 	
  8706 0000F036 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  8707 0000F03C 89FE                <1> 	mov	esi, edi
  8708 0000F03E 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  8709                              <1> 
  8710 0000F044 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked decrease color ?
  8711 0000F04B 7405                <1> 	jz	short pix_op_dec_0 ; no
  8712 0000F04D E92E100000          <1> 	jmp	m_pix_op_dec ; 'dec' color except mask color
  8713                              <1> pix_op_dec_0:
  8714 0000F052 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8715 0000F059 7707                <1> 	ja	short pix_op_dec_1
  8716                              <1> 
  8717                              <1> 	; 256 colors (8bpp)
  8718 0000F05B E878040000          <1> 	call	pix_op_dec_8
  8719 0000F060 EB1E                <1> 	jmp	short pix_op_dec_4
  8720                              <1> 			
  8721                              <1> pix_op_dec_1:
  8722 0000F062 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8723 0000F069 7710                <1> 	ja	short pix_op_dec_3 ; 32bpp	
  8724 0000F06B 7207                <1> 	jb	short pix_op_dec_2 ; 16bpp
  8725                              <1> 
  8726                              <1> 	; 24 bit true colors
  8727 0000F06D E87D040000          <1> 	call	pix_op_dec_24
  8728 0000F072 EB0C                <1> 	jmp	short pix_op_dec_4
  8729                              <1> 
  8730                              <1> 	; 65536 colors (16bpp)
  8731                              <1> pix_op_dec_2:
  8732 0000F074 E869040000          <1> 	call	pix_op_dec_16
  8733 0000F079 EB05                <1> 	jmp	short pix_op_dec_4
  8734                              <1> 
  8735                              <1> 	; 32 bit true colors	
  8736                              <1> pix_op_dec_3:
  8737 0000F07B E882040000          <1> 	call	pix_op_dec_32
  8738                              <1> pix_op_dec_4:
  8739 0000F080 29F7                <1> 	sub	edi, esi
  8740 0000F082 893D[64030300]      <1> 	mov	[u.r0], edi	
  8741                              <1> pix_op_dec_5:
  8742 0000F088 C3                  <1> 	retn			
  8743                              <1> 
  8744                              <1> pix_op_dec_w:
  8745                              <1> 	; 31/01/2021
  8746                              <1> 	; ecx = win start pos (row, column)
  8747                              <1> 	; edx = size (rows, columns)
  8748 0000F089 E88AF6FFFF          <1> 	call	sysvideo_15_12 ; window preparations
  8749 0000F08E 72F8                <1> 	jc	short pix_op_dec_5
  8750                              <1> 
  8751 0000F090 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked decrease color ?
  8752 0000F097 7405                <1> 	jz	short pix_op_dec_w_0 ; no
  8753 0000F099 E976100000          <1> 	jmp	m_pix_op_dec_w 
  8754                              <1> 			; window 'dec' color except mask color
  8755                              <1> pix_op_dec_w_0:
  8756                              <1> 	; ecx = bytes per row (to be applied)
  8757                              <1> 	; edx = screen width in bytes
  8758                              <1> 	; ebx = row count
  8759                              <1> 
  8760 0000F09E 8B3D[92120300]      <1> 	mov	edi, [v_str]
  8761                              <1> 
  8762 0000F0A4 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8763 0000F0AB 7707                <1> 	ja	short pix_op_dec_w_1
  8764                              <1> 
  8765                              <1> 	; 256 colors (8bpp)
  8766 0000F0AD BD[D8F40000]        <1> 	mov	ebp, pix_op_dec_8
  8767 0000F0B2 EB1E                <1> 	jmp	short pix_op_dec_w_4
  8768                              <1> 			
  8769                              <1> pix_op_dec_w_1:
  8770 0000F0B4 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8771 0000F0BB 7710                <1> 	ja	short pix_op_dec_w_3 ; 32bpp
  8772 0000F0BD 7207                <1> 	jb	short pix_op_dec_w_2 ; 16bpp
  8773                              <1> 
  8774                              <1> 	; 24 bit true colors
  8775 0000F0BF BD[EFF40000]        <1> 	mov	ebp, pix_op_dec_24
  8776 0000F0C4 EB0C                <1> 	jmp	short pix_op_dec_w_4
  8777                              <1> 
  8778                              <1> 	; 65536 colors (16bpp)
  8779                              <1> pix_op_dec_w_2:
  8780 0000F0C6 BD[E2F40000]        <1> 	mov	ebp, pix_op_dec_16
  8781 0000F0CB EB05                <1> 	jmp	short pix_op_dec_w_4
  8782                              <1> 
  8783                              <1> 	; 32 bit true colors
  8784                              <1> pix_op_dec_w_3:
  8785 0000F0CD BD[02F50000]        <1> 	mov	ebp, pix_op_dec_32
  8786                              <1> pix_op_dec_w_4:
  8787 0000F0D2 E940FDFFFF          <1> 	jmp	pix_op_dec_w_x
  8788                              <1> 
  8789                              <1> pix_op_blk:
  8790                              <1> 	; 23/01/2021
  8791                              <1> 	; 22/02/2021
  8792                              <1> 	; 02/02/2021
  8793                              <1> 	; COPY PIXEL BLOCK -system to system-
  8794                              <1> 	; WRITE PIXEL BLOCKS -user to system-
  8795                              <1> 	;
  8796                              <1> 	; INPUT:
  8797                              <1> 	;   -If BL bit 5 is 0-	
  8798                              <1> 	;    ECX = start position (row, column) (*)
  8799                              <1> 	;    (HW = row, CX = column)
  8800                              <1> 	;    EDX = size (rows, colums) (*)
  8801                              <1> 	;    (HW = rows, DX = columns)
  8802                              <1> 	;         (0 -> invalid)
  8803                              <1> 	;         (1 -> horizontal or vertical line)
  8804                              <1> 	;    ESI = destination (row, column) (***)
  8805                              <1> 	;   -If BL bit 5 is 1-	
  8806                              <1> 	;     CL = color (8 bit, 256 colors)
  8807                              <1> 	;    ECX = color (16 bit and true colors)
  8808                              <1> 	;    EDX = count of blocks (not bytes)
  8809                              <1> 	;	 (limit: 2048 blocks/windows)	  	
  8810                              <1> 	;    ESI = user's buffer address 
  8811                              <1> 	;	  contains 64 bit block data
  8812                              <1> 	;	  BLOCK ADDRESS - (row, col), dword
  8813                              <1> 	;	  (first 32 bits)
  8814                              <1> 	;	  BLOCK SIZE - (rows, cols), dword
  8815                              <1> 	;	  (second 32 bits)
  8816                              <1> 	; OUTPUT:
  8817                              <1> 	; 	[u.r0] will be > 0 if succesful
  8818                              <1> 
  8819                              <1> 	; Window option ([v_ops] bit 4) will be ignored  	
  8820                              <1> 	; (Function is used for display page coordinates)
  8821                              <1> 
  8822 0000F0D7 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked or direct ?
  8823 0000F0DE 755A                <1> 	jnz	short pix_op_blk_u ; blocks from user's buffer
  8824                              <1> 
  8825 0000F0E0 89F0                <1> 	mov	eax, esi ; destination position (row, col)
  8826 0000F0E2 E8DEF6FFFF          <1> 	call	calc_pixel_offset
  8827 0000F0E7 3B05[8E120300]      <1> 	cmp	eax, [v_siz]
  8828 0000F0ED 734A                <1> 	jnb	short pix_op_blk_retn ; out of display page
  8829 0000F0EF 89C6                <1> 	mov	esi, eax
  8830 0000F0F1 E8ACF6FFFF          <1> 	call	pixels_to_byte_count
  8831 0000F0F6 89C7                <1> 	mov	edi, eax
  8832 0000F0F8 89D0                <1> 	mov	eax, edx  ; size
  8833 0000F0FA E8C6F6FFFF          <1> 	call	calc_pixel_offset
  8834                              <1> 	; 22/02/2021
  8835 0000F0FF 3B05[8E120300]      <1> 	cmp	eax, [v_siz]
  8836 0000F105 7732                <1> 	ja	short pix_op_blk_retn ; out of display page
  8837 0000F107 01C6                <1> 	add	esi, eax
  8838 0000F109 3B35[8E120300]      <1> 	cmp	esi, [v_siz]
  8839 0000F10F 7728                <1> 	ja	short pix_op_blk_retn ; out of display page
  8840                              <1> 
  8841 0000F111 033D[8A120300]      <1> 	add	edi, [v_mem] ; destination address
  8842                              <1> 	
  8843                              <1> 	; 23/01/2021
  8844                              <1> 	;call	pixels_to_byte_count
  8845                              <1> 	;add	edi, eax
  8846                              <1> 	;jc	short pix_op_blk_retn ; out of display page
  8847                              <1> 	;cmp	edi, [v_end]
  8848                              <1> 	;ja	short pix_op_blk_retn ; out of display page
  8849                              <1> 	;sub	edi, eax
  8850                              <1> 
  8851 0000F117 E8FCF5FFFF          <1> 	call	sysvideo_15_12 ; window preparations
  8852 0000F11C 721B                <1> 	jc	short pix_op_blk_retn ; something wrong !?
  8853                              <1> 	; ecx = bytes per row (to be applied)
  8854                              <1> 	; edx = screen width in bytes
  8855                              <1> 	; ebx = row count
  8856                              <1> 
  8857 0000F11E 8B35[92120300]      <1> 	mov	esi, [v_str] ; source address
  8858                              <1> 
  8859                              <1> 	; Note:
  8860                              <1> 	; ecx & edx are already adjusted for pixel sizes
  8861                              <1> 	; so, following code is proper all pixel sizes
  8862                              <1> 
  8863 0000F124 29CA                <1> 	sub	edx, ecx ; screen width - window width
  8864                              <1> pix_op_blk_0:
  8865 0000F126 89C8                <1> 	mov	eax, ecx
  8866 0000F128 0105[64030300]      <1> 	add	[u.r0], eax
  8867 0000F12E F3A4                <1> 	rep	movsb
  8868 0000F130 89C1                <1> 	mov	ecx, eax	
  8869 0000F132 01D6                <1> 	add	esi, edx ; next row
  8870 0000F134 01D7                <1> 	add	edi, edx ; next row
  8871 0000F136 4B                  <1> 	dec	ebx
  8872 0000F137 75ED                <1> 	jnz	short pix_op_blk_0
  8873                              <1> pix_op_blk_retn:
  8874 0000F139 C3                  <1> 	retn
  8875                              <1> 
  8876                              <1> pix_op_blk_u:
  8877                              <1> 	; fill blocks (windows) with desired color
  8878                              <1> 	; according to block definitions in user's buffer
  8879 0000F13A 81FA00080000        <1> 	cmp	edx, 2048
  8880 0000F140 7605                <1> 	jna	short pix_op_blk_u_0
  8881                              <1> 	; Maximum 2048 blocks
  8882 0000F142 BA00080000          <1> 	mov	edx, 2048
  8883                              <1> pix_op_blk_u_0:
  8884 0000F147 8025[88120300]DF    <1> 	and	byte [v_ops], ~20h ; clear masked bit
  8885 0000F14E 890D[9A120300]      <1> 	mov	[maskcolor], ecx ; save pixel color
  8886                              <1> 	; 22/02/2021
  8887                              <1> 	;mov	ebp, edx ; save blocks count
  8888                              <1> 	;push	ebp
  8889                              <1> pix_op_blk_u_next:
  8890 0000F154 52                  <1> 	push	edx
  8891 0000F155 B908000000          <1> 	mov	ecx, 8
  8892 0000F15A BF[A2120300]        <1> 	mov	edi, buffer8 ; 8 bytes small buffer
  8893                              <1> 	; esi = user's buffer address
  8894 0000F15F E84A2A0000          <1> 	call	transfer_from_user_buffer
  8895 0000F164 72D3                <1> 	jc	short pix_op_blk_retn
  8896 0000F166 01CE                <1> 	add	esi, ecx ; 22/02/2021
  8897 0000F168 56                  <1> 	push	esi
  8898 0000F169 8B15[A2120300]      <1> 	mov	edx, [buffer8] ; block start pos (row,col)
  8899 0000F16F 8B35[A6120300]      <1> 	mov	esi, [buffer8+4] ; block size (rows,cols)
  8900 0000F175 8B0D[9A120300]      <1> 	mov	ecx, [maskcolor]
  8901 0000F17B E848FCFFFF          <1> 	call	pix_op_new_w ; new (change) color (window)
  8902 0000F180 5E                  <1> 	pop	esi
  8903                              <1> 	;pop	ebp
  8904                              <1> 	;dec	ebp
  8905 0000F181 5A                  <1> 	pop	edx
  8906 0000F182 4A                  <1> 	dec	edx
  8907 0000F183 75CF                <1> 	jnz	short pix_op_blk_u_next
  8908 0000F185 C3                  <1> 	retn
  8909                              <1> 
  8910                              <1> pix_op_lin:
  8911                              <1> 	; 12/02/2021
  8912                              <1> 	; 11/02/2021
  8913                              <1> 	; 10/02/2021
  8914                              <1> 	; 05/02/2021
  8915                              <1> 	; 02/02/2021
  8916                              <1> 	; WRITE LINE -direct-
  8917                              <1> 	; WRITE LINE(S) -via user's buffer-
  8918                              <1> 	;
  8919                              <1> 	; INPUT:
  8920                              <1> 	;   -If BL bit 5 is 0-	
  8921                              <1> 	;     CL = color (8 bit, 256 colors)
  8922                              <1> 	;    ECX = color (16 bit and true colors)
  8923                              <1> 	;     DX = low 12 bits - size (length)
  8924                              <1> 	;	   high 4 bits - direction or type
  8925                              <1> 	;	     0 - Horizontal line
  8926                              <1> 	;	     1 - Vertical line
  8927                              <1> 	;	   > 1 - undefined, invalid
  8928                              <1> 	;    ESI = start position (row, column)
  8929                              <1> 	;	  (HW = row, SI = column)
  8930                              <1> 	;   -If BL bit 5 is 1-
  8931                              <1> 	;     CL = color (8 bit, 256 colors)
  8932                              <1> 	;    ECX = color (16 bit and true colors)
  8933                              <1> 	;     DX = number of lines (in user buffer)
  8934                              <1> 	;	   (limit: 2048 lines)	
  8935                              <1> 	;    ESI = user's buffer
  8936                              <1> 	;          contains 64 bit data for lines
  8937                              <1> 	;	   START POINT: 32 bit (row, col)
  8938                              <1> 	;	   LENGTH: 32 bit
  8939                              <1> 	;		   high 16 bits - 0
  8940                              <1> 	;		   bit 0-11 - length
  8941                              <1> 	;	   	   bit 12-15 - type (length)
  8942                              <1> 	; OUTPUT:
  8943                              <1> 	; 	[u.r0] will be > 0 if succesful
  8944                              <1> 
  8945                              <1> 	; Window option ([v_ops] bit 4) will be ignored
  8946                              <1> 	; (Function is used for display page coordinates)
  8947                              <1> 
  8948                              <1> 	; 10/02/2021
  8949 0000F186 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked or direct ?
  8950 0000F18D 7445                <1> 	jz	short pix_op_lin_vh ; direct (v/h lines) 
  8951                              <1> 
  8952                              <1> 	; lines from user's buffer
  8953                              <1> pix_op_lin_u:
  8954                              <1> 	; draw lines with desired color
  8955                              <1> 	; according to line definitions in user's buffer
  8956 0000F18F 81FA00080000        <1> 	cmp	edx, 2048
  8957 0000F195 7605                <1> 	jna	short pix_op_lin_u_0
  8958                              <1> 	; Maximum 2048 lines
  8959 0000F197 BA00080000          <1> 	mov	edx, 2048
  8960                              <1> pix_op_lin_u_0:
  8961 0000F19C 890D[9A120300]      <1> 	mov	[maskcolor], ecx ; save pixel color
  8962 0000F1A2 89D5                <1> 	mov	ebp, edx ; save line count
  8963                              <1> pix_op_lin_u_next:
  8964 0000F1A4 B908000000          <1> 	mov	ecx, 8
  8965 0000F1A9 BF[A2120300]        <1> 	mov	edi, buffer8 ; 8 bytes small buffer
  8966                              <1> 	; esi = user's buffer address
  8967 0000F1AE E8FB290000          <1> 	call	transfer_from_user_buffer
  8968 0000F1B3 721E                <1> 	jc	short pix_op_lin_retn
  8969 0000F1B5 01CE                <1> 	add	esi, ecx ; 11/02/2021
  8970 0000F1B7 56                  <1> 	push	esi
  8971 0000F1B8 8B35[A2120300]      <1> 	mov	esi, [buffer8] ; line start pos (row,col)
  8972 0000F1BE 8B15[A6120300]      <1> 	mov	edx, [buffer8+4] ; line length
  8973 0000F1C4 8B0D[9A120300]      <1> 	mov	ecx, [maskcolor]
  8974 0000F1CA E805000000          <1> 	call	pix_op_lin_vh ; new (change) color (window)
  8975 0000F1CF 5E                  <1> 	pop	esi
  8976 0000F1D0 4D                  <1> 	dec	ebp
  8977 0000F1D1 75D1                <1> 	jnz	short pix_op_lin_u_next
  8978                              <1> pix_op_lin_retn:
  8979 0000F1D3 C3                  <1> 	retn
  8980                              <1> 
  8981                              <1> pix_op_lin_vh:
  8982 0000F1D4 81FA38140000        <1> 	cmp	edx, 1438h ; 1920*1080 (780hx438h) limit
  8983 0000F1DA 7761                <1> 	ja	short pix_op_lin_err1 ; invalid type 
  8984                              <1> 			    	; (for current version)
  8985 0000F1DC 66F7C2FF0F          <1> 	test	dx, 0FFFh
  8986 0000F1E1 745A                <1> 	jz	short pix_op_lin_err1 ; zero length!
  8987                              <1> 
  8988 0000F1E3 89F0                <1> 	mov	eax, esi ; start point (row, col)
  8989 0000F1E5 E8DBF5FFFF          <1> 	call	calc_pixel_offset
  8990 0000F1EA 3B05[8E120300]      <1> 	cmp	eax, [v_siz]
  8991 0000F1F0 734B                <1> 	jnb	short pix_op_lin_err1 ; out of display page!
  8992 0000F1F2 E8ABF5FFFF          <1> 	call	pixels_to_byte_count
  8993 0000F1F7 89C7                <1> 	mov	edi, eax ; start point offset
  8994 0000F1F9 033D[8A120300]      <1> 	add	edi, [v_mem] ; LFB start address
  8995 0000F1FF 89C8                <1> 	mov	eax, ecx ; color
  8996                              <1> 
  8997 0000F201 F6C610              <1> 	test	dh, 10h
  8998 0000F204 0F848A000000        <1> 	jz	pix_op_lin_h ; Horizontal line
  8999                              <1> 
  9000                              <1> pix_op_lin_v:
  9001                              <1> 	; Vertical line
  9002 0000F20A 80E60F              <1> 	and 	dh, 0Fh ; low 12 bits
  9003 0000F20D 51                  <1> 	push	ecx ; color
  9004 0000F20E 89D1                <1> 	mov	ecx, edx
  9005 0000F210 0FB705[86120300]    <1> 	movzx	eax, word [v_width]
  9006 0000F217 89C3                <1> 	mov	ebx, eax
  9007                              <1> 	; 12/02/2021
  9008 0000F219 F7E2                <1> 	mul	edx ; rows * [v_width]
  9009 0000F21B 01F8                <1> 	add	eax, edi
  9010 0000F21D 3B05[96120300]      <1> 	cmp	eax, [v_end]
  9011 0000F223 58                  <1> 	pop	eax ; color
  9012 0000F224 7717                <1> 	ja	short pix_op_lin_err1 ; out of display page
  9013                              <1> 	; ecx = rows	
  9014 0000F226 89CA                <1> 	mov	edx, ecx
  9015                              <1> 
  9016 0000F228 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  9017 0000F22F 770D                <1> 	ja	short pix_op_lin_v_2
  9018                              <1> 	; 256 colors (1 byte per pixel)
  9019 0000F231 010D[64030300]      <1> 	add	[u.r0], ecx ; byte count
  9020                              <1> pix_op_lin_v_1:
  9021 0000F237 8807                <1> 	mov	[edi], al
  9022 0000F239 01DF                <1> 	add	edi, ebx  ; next row	
  9023 0000F23B E2FA                <1> 	loop	pix_op_lin_v_1
  9024                              <1> pix_op_lin_err1:
  9025 0000F23D C3                  <1> 	retn
  9026                              <1> 
  9027                              <1> pix_op_lin_v_2:
  9028 0000F23E 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  9029 0000F245 773A                <1> 	ja	short pix_op_lin_v_6 ; 32bpp
  9030 0000F247 7226                <1> 	jb	short pix_op_lin_v_4 ; 16bpp
  9031                              <1> 	
  9032                              <1> 	; 24 bit true colors
  9033                              <1> 	; * 3
  9034 0000F249 53                  <1> 	push	ebx ; screen width in pixels
  9035 0000F24A D1E3                <1> 	shl	ebx, 1
  9036 0000F24C 011C24              <1> 	add	[esp], ebx
  9037 0000F24F 5B                  <1> 	pop	ebx ; screen width in bytes
  9038 0000F250 010D[64030300]      <1> 	add	[u.r0], ecx
  9039 0000F256 D1E2                <1> 	shl	edx, 1
  9040 0000F258 0115[64030300]      <1> 	add	[u.r0], edx ; byte count
  9041                              <1> pix_op_lin_v_3:
  9042 0000F25E 668907              <1> 	mov	[edi], ax
  9043 0000F261 C1C810              <1> 	ror	eax, 16
  9044 0000F264 884702              <1> 	mov	[edi+2], al	
  9045 0000F267 C1C010              <1> 	rol	eax, 16
  9046 0000F26A 01DF                <1> 	add	edi, ebx  ; next row	
  9047 0000F26C E2F0                <1> 	loop	pix_op_lin_v_3
  9048 0000F26E C3                  <1> 	retn
  9049                              <1> 
  9050                              <1> pix_op_lin_v_4:
  9051                              <1> 	; 16 bit (65536) colors
  9052 0000F26F D1E3                <1> 	shl	ebx, 1
  9053 0000F271 D1E2                <1> 	shl	edx, 1
  9054 0000F273 0115[64030300]      <1> 	add	[u.r0], edx
  9055                              <1> pix_op_lin_v_5:
  9056 0000F279 668907              <1> 	mov	[edi], ax
  9057 0000F27C 01DF                <1> 	add	edi, ebx  ; next row	
  9058 0000F27E E2F9                <1> 	loop	pix_op_lin_v_5
  9059 0000F280 C3                  <1> 	retn
  9060                              <1> 
  9061                              <1> pix_op_lin_v_6:
  9062                              <1> 	; 32 bit true colors
  9063 0000F281 C1E302              <1> 	shl	ebx, 2
  9064 0000F284 C1E202              <1> 	shl	edx, 2
  9065 0000F287 0115[64030300]      <1> 	add	[u.r0], edx ; byte count
  9066                              <1> pix_op_lin_v_7:
  9067 0000F28D 8907                <1> 	mov	[edi], eax
  9068 0000F28F 01DF                <1> 	add	edi, ebx  ; next row	
  9069 0000F291 E2FA                <1> 	loop	pix_op_lin_v_7
  9070 0000F293 C3                  <1> 	retn		
  9071                              <1> 
  9072                              <1> pix_op_lin_h:
  9073                              <1> 	; Horizontal line
  9074 0000F294 80E60F              <1> 	and 	dh, 0Fh ; low 12 bits
  9075 0000F297 89D1                <1>   	mov	ecx, edx
  9076 0000F299 6601D6              <1> 	add	si, dx ; start column + columns
  9077 0000F29C 663B35[86120300]    <1> 	cmp	si, [v_width] ; screen width
  9078 0000F2A3 7711                <1> 	ja	short pix_op_lin_err2 ; out of columns limit
  9079                              <1> 
  9080 0000F2A5 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  9081 0000F2AC 7709                <1> 	ja	short pix_op_lin_h_1
  9082                              <1> 	; 256 colors (1 byte per pixel)
  9083 0000F2AE 010D[64030300]      <1> 	add	[u.r0], ecx
  9084 0000F2B4 F3AA                <1> 	rep	stosb
  9085                              <1> pix_op_lin_err2:
  9086 0000F2B6 C3                  <1> 	retn
  9087                              <1> 
  9088                              <1> pix_op_lin_h_1:
  9089 0000F2B7 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  9090 0000F2BE 7728                <1> 	ja	short pix_op_lin_h_4 ; 32bpp
  9091 0000F2C0 721A                <1> 	jb	short pix_op_lin_h_3 ; 16bpp
  9092                              <1> 	
  9093                              <1> 	; 24 bit true colors
  9094                              <1> 	; * 3
  9095 0000F2C2 0115[64030300]      <1> 	add	[u.r0], edx
  9096 0000F2C8 D1E2                <1> 	shl	edx, 1
  9097 0000F2CA 0115[64030300]      <1> 	add	[u.r0], edx
  9098                              <1> pix_op_lin_h_2:
  9099 0000F2D0 66AB                <1> 	stosw
  9100 0000F2D2 C1C810              <1> 	ror	eax, 16
  9101 0000F2D5 AA                  <1> 	stosb	
  9102 0000F2D6 C1C010              <1> 	rol	eax, 16
  9103 0000F2D9 E2F5                <1> 	loop	pix_op_lin_h_2
  9104 0000F2DB C3                  <1> 	retn
  9105                              <1> 
  9106                              <1> pix_op_lin_h_3:
  9107                              <1> 	; 16 bit (65536) colors
  9108 0000F2DC D1E2                <1> 	shl	edx, 1
  9109 0000F2DE 0115[64030300]      <1> 	add	[u.r0], edx
  9110 0000F2E4 F366AB              <1> 	rep	stosw
  9111 0000F2E7 C3                  <1> 	retn
  9112                              <1> 
  9113                              <1> pix_op_lin_h_4:
  9114                              <1> 	; 32 bit true colors
  9115 0000F2E8 C1E202              <1> 	shl	edx, 2
  9116 0000F2EB 0115[64030300]      <1> 	add	[u.r0], edx
  9117 0000F2F1 F3AB                <1> 	rep	stosd
  9118 0000F2F3 C3                  <1> 	retn
  9119                              <1> 
  9120                              <1> pix_op_new_8:
  9121                              <1> 	; 8 bit colors (256 colors)
  9122                              <1> 	; CHANGE PIXEL COLOR
  9123                              <1> 	; ecx = pixel count per row
  9124                              <1> 	;  al = color
  9125                              <1> 	; edi = start pixel address 
  9126                              <1> 
  9127 0000F2F4 F3AA                <1> 	rep	stosb
  9128 0000F2F6 C3                  <1> 	retn
  9129                              <1> 
  9130                              <1> pix_op_new_16:
  9131                              <1> 	; 16 bit colors (65536 colors)
  9132                              <1> 	; CHANGE PIXEL COLOR
  9133                              <1> 	; ecx = pixel count per row
  9134                              <1> 	;  ax = color
  9135                              <1> 	; edi = start pixel address 
  9136                              <1> 
  9137 0000F2F7 F366AB              <1> 	rep	stosw
  9138 0000F2FA C3                  <1> 	retn
  9139                              <1> 
  9140                              <1> pix_op_new_24:
  9141                              <1> 	; 24 bit true colors
  9142                              <1> 	; CHANGE PIXEL COLOR
  9143                              <1> 	; ecx = pixel count per row
  9144                              <1> 	; eax = color
  9145                              <1> 	; edi = start pixel address 
  9146                              <1> 
  9147 0000F2FB 66AB                <1> 	stosw
  9148 0000F2FD C1C810              <1> 	ror	eax, 16	
  9149 0000F300 AA                  <1> 	stosb
  9150 0000F301 C1C010              <1> 	rol	eax, 16
  9151 0000F304 E2F5                <1> 	loop	pix_op_new_24
  9152 0000F306 C3                  <1> 	retn
  9153                              <1> 
  9154                              <1> pix_op_new_32:
  9155                              <1> 	; 32 bit true colors
  9156                              <1> 	; CHANGE PIXEL COLOR
  9157                              <1> 	; ecx = pixel count per row
  9158                              <1> 	; eax = color
  9159                              <1> 	; edi = start pixel address 
  9160                              <1> 
  9161 0000F307 F3AB                <1> 	rep	stosd
  9162 0000F309 C3                  <1> 	retn
  9163                              <1> 
  9164                              <1> pix_op_add_8:
  9165                              <1> 	; 8 bit colors (256 colors)
  9166                              <1> 	; ADD PIXEL COLOR
  9167                              <1> 	; ecx = pixel count per row
  9168                              <1> 	;  al = color
  9169                              <1> 	; edi = start pixel address 
  9170                              <1> 
  9171 0000F30A 88C4                <1> 	mov	ah, al
  9172                              <1> pix_op_add_8_0:
  9173 0000F30C 0207                <1> 	add	al, [edi]
  9174 0000F30E 7302                <1> 	jnc	short pix_op_add_8_1
  9175 0000F310 B0FF                <1> 	mov	al, 0FFh ; Max. value	
  9176                              <1> pix_op_add_8_1:
  9177 0000F312 AA                  <1> 	stosb
  9178 0000F313 88E0                <1> 	mov	al, ah
  9179 0000F315 E2F5                <1> 	loop	pix_op_add_8_0
  9180 0000F317 C3                  <1> 	retn
  9181                              <1> 
  9182                              <1> pix_op_add_16:
  9183                              <1> 	; 16 bit colors (65536 colors)
  9184                              <1> 	; ADD PIXEL COLOR
  9185                              <1> 	; ecx = pixel count per row
  9186                              <1> 	;  ax = color
  9187                              <1> 	; edi = start pixel address 
  9188                              <1> 
  9189 0000F318 89C2                <1> 	mov	edx, eax
  9190                              <1> pix_op_add_16_0:
  9191 0000F31A 660307              <1> 	add	ax, [edi]
  9192 0000F31D 7304                <1> 	jnc	short pix_op_add_16_1
  9193 0000F31F 66B8FFFF            <1> 	mov	ax, 0FFFFh ; Max. value	
  9194                              <1> pix_op_add_16_1:
  9195 0000F323 66AB                <1> 	stosw
  9196 0000F325 89D0                <1> 	mov	eax, edx
  9197 0000F327 E2F1                <1> 	loop	pix_op_add_16_0
  9198 0000F329 C3                  <1> 	retn
  9199                              <1> 
  9200                              <1> pix_op_add_24:
  9201                              <1> 	; 24 bit true colors
  9202                              <1> 	; ADD PIXEL COLOR
  9203                              <1> 	; ecx = pixel count per row
  9204                              <1> 	; eax = color
  9205                              <1> 	; edi = start pixel address 
  9206                              <1> 
  9207 0000F32A 53                  <1> 	push	ebx
  9208 0000F32B BBFFFFFF00          <1> 	mov	ebx, 0FFFFFFh
  9209                              <1> 	;and	eax, ebx ; 0FFFFFFh
  9210 0000F330 89C2                <1> 	mov	edx, eax
  9211                              <1> pix_op_add_24_0:
  9212 0000F332 8B07                <1> 	mov	eax, [edi]
  9213 0000F334 21D8                <1> 	and	eax, ebx ; 0FFFFFFh
  9214 0000F336 01D0                <1> 	add	eax, edx
  9215 0000F338 39D8                <1> 	cmp	eax, ebx
  9216 0000F33A 7602                <1> 	jna	short pix_op_add_24_1
  9217 0000F33C 89D8                <1> 	mov	eax, ebx ; 0FFFFFFh  ; Max. value
  9218                              <1> pix_op_add_24_1: 
  9219 0000F33E 66AB                <1> 	stosw
  9220 0000F340 C1E810              <1> 	shr	eax, 16
  9221 0000F343 AA                  <1> 	stosb
  9222 0000F344 E2EC                <1> 	loop	pix_op_add_24_0
  9223 0000F346 89D0                <1> 	mov	eax, edx
  9224 0000F348 5B                  <1> 	pop	ebx
  9225 0000F349 C3                  <1> 	retn
  9226                              <1> 
  9227                              <1> pix_op_add_32:
  9228                              <1> 	; 32 bit true colors
  9229                              <1> 	; ADD PIXEL COLOR
  9230                              <1> 	; ecx = pixel count per row
  9231                              <1> 	; eax = color
  9232                              <1> 	; edi = start pixel address 
  9233                              <1> 
  9234 0000F34A 89C2                <1> 	mov	edx, eax
  9235                              <1> pix_op_add_32_0:
  9236 0000F34C 0307                <1> 	add	eax, [edi]
  9237 0000F34E 7303                <1> 	jnc	short pix_op_add_32_1
  9238                              <1> 	;mov	eax, 0FFFFFFFFh ; Max. value
  9239 0000F350 29C0                <1> 	sub	eax, eax
  9240 0000F352 48                  <1> 	dec	eax	
  9241                              <1> pix_op_add_32_1:
  9242 0000F353 AB                  <1> 	stosd
  9243 0000F354 89D0                <1> 	mov	eax, edx
  9244 0000F356 E2F4                <1> 	loop	pix_op_add_32_0
  9245 0000F358 C3                  <1> 	retn
  9246                              <1> 
  9247                              <1> pix_op_sub_8:
  9248                              <1> 	; 8 bit colors (256 colors)
  9249                              <1> 	; SUBTRACT PIXEL COLOR
  9250                              <1> 	; ecx = pixel count per row
  9251                              <1> 	;  al = color
  9252                              <1> 	; edi = start pixel address 
  9253                              <1> 
  9254 0000F359 88C4                <1> 	mov	ah, al
  9255                              <1> pix_op_sub_8_0:
  9256 0000F35B 8A07                <1> 	mov	al, [edi]
  9257 0000F35D 28E0                <1> 	sub	al, ah
  9258 0000F35F 7302                <1> 	jnb	short pix_op_sub_8_1
  9259 0000F361 30C0                <1> 	xor	al, al ; 0 ; Min. value	
  9260                              <1> pix_op_sub_8_1:
  9261 0000F363 AA                  <1> 	stosb
  9262 0000F364 E2F5                <1> 	loop	pix_op_sub_8_0
  9263 0000F366 88E0                <1> 	mov	al, ah
  9264 0000F368 C3                  <1> 	retn
  9265                              <1> 
  9266                              <1> pix_op_sub_16:
  9267                              <1> 	; 16 bit colors (65536 colors)
  9268                              <1> 	; SUBTRACT PIXEL COLOR
  9269                              <1> 	; ecx = pixel count per row
  9270                              <1> 	;  ax = color
  9271                              <1> 	; edi = start pixel address 
  9272                              <1> 
  9273 0000F369 89C2                <1> 	mov	edx, eax
  9274                              <1> pix_op_sub_16_0:
  9275 0000F36B 668B07              <1> 	mov	ax, [edi]
  9276 0000F36E 6629D0              <1> 	sub	ax, dx
  9277 0000F371 7302                <1> 	jnb	short pix_op_sub_16_1
  9278 0000F373 31C0                <1> 	xor	eax, eax ; 0 ; Min. value	
  9279                              <1> pix_op_sub_16_1:
  9280 0000F375 66AB                <1> 	stosw
  9281 0000F377 E2F2                <1> 	loop	pix_op_sub_16_0
  9282 0000F379 89D0                <1> 	mov	eax, edx
  9283 0000F37B C3                  <1> 	retn
  9284                              <1> 
  9285                              <1> pix_op_sub_24:
  9286                              <1> 	; 24 bit true colors
  9287                              <1> 	; SUBTRACT PIXEL COLOR
  9288                              <1> 	; ecx = pixel count per row
  9289                              <1> 	; eax = color
  9290                              <1> 	; edi = start pixel address 
  9291                              <1> 
  9292                              <1> 	;and	eax, 0FFFFFFh
  9293 0000F37C 89C2                <1> 	mov	edx, eax
  9294                              <1> pix_op_sub_24_0:
  9295 0000F37E 8B07                <1> 	mov	eax, [edi]
  9296                              <1> 	; 27/02/2021
  9297 0000F380 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
  9298 0000F385 29D0                <1> 	sub	eax, edx
  9299 0000F387 7302                <1> 	jnb	short pix_op_sub_24_1
  9300 0000F389 31C0                <1> 	xor	eax, eax ; 0 ; Min. value
  9301                              <1> pix_op_sub_24_1: 
  9302 0000F38B 66AB                <1> 	stosw
  9303 0000F38D C1E810              <1> 	shr	eax, 16
  9304 0000F390 AA                  <1> 	stosb
  9305 0000F391 E2EB                <1> 	loop	pix_op_sub_24_0
  9306 0000F393 89D0                <1> 	mov	eax, edx
  9307 0000F395 C3                  <1> 	retn
  9308                              <1> 
  9309                              <1> pix_op_sub_32:
  9310                              <1> 	; 32 bit true colors
  9311                              <1> 	; SUBTRACT PIXEL COLOR
  9312                              <1> 	; ecx = pixel count per row
  9313                              <1> 	; eax = color
  9314                              <1> 	; edi = start pixel address 
  9315                              <1> 
  9316 0000F396 89C2                <1> 	mov	edx, eax
  9317                              <1> pix_op_sub_32_0:
  9318 0000F398 8B07                <1> 	mov	eax, [edi]
  9319 0000F39A 29D0                <1> 	sub	eax, edx
  9320 0000F39C 7302                <1> 	jnb	short pix_op_sub_32_1
  9321 0000F39E 31C0                <1> 	xor	eax, eax ; 0 ; Min. value
  9322                              <1> pix_op_sub_32_1:
  9323 0000F3A0 AB                  <1> 	stosd
  9324 0000F3A1 E2F5                <1> 	loop	pix_op_sub_32_0
  9325 0000F3A3 89D0                <1> 	mov	eax, edx
  9326 0000F3A5 C3                  <1> 	retn
  9327                              <1> 
  9328                              <1> pix_op_or_8:
  9329                              <1> 	; 8 bit colors (256 colors)
  9330                              <1> 	; OR PIXEL COLOR
  9331                              <1> 	; ecx = pixel count per row
  9332                              <1> 	;  al = color
  9333                              <1> 	; edi = start pixel address 
  9334                              <1> 
  9335                              <1> pix_op_or_8_0:
  9336 0000F3A6 0807                <1> 	or	[edi], al
  9337 0000F3A8 47                  <1> 	inc	edi
  9338 0000F3A9 E2FB                <1> 	loop	pix_op_or_8_0
  9339 0000F3AB C3                  <1> 	retn
  9340                              <1> 
  9341                              <1> pix_op_or_16:
  9342                              <1> 	; 16 bit colors (65536 colors)
  9343                              <1> 	; OR PIXEL COLOR
  9344                              <1> 	; ecx = pixel count per row
  9345                              <1> 	;  ax = color
  9346                              <1> 	; edi = start pixel address 
  9347                              <1> 
  9348                              <1> pix_op_or_16_0:
  9349 0000F3AC 660907              <1> 	or	[edi], ax
  9350 0000F3AF 47                  <1> 	inc	edi
  9351 0000F3B0 47                  <1> 	inc	edi
  9352 0000F3B1 E2F9                <1> 	loop	pix_op_or_16_0
  9353 0000F3B3 C3                  <1> 	retn
  9354                              <1> 
  9355                              <1> pix_op_or_24:
  9356                              <1> 	; 24 bit true colors
  9357                              <1> 	; OR PIXEL COLOR
  9358                              <1> 	; ecx = pixel count per row
  9359                              <1> 	; eax = color
  9360                              <1> 	; edi = start pixel address 
  9361                              <1> 
  9362 0000F3B4 89C2                <1> 	mov	edx, eax
  9363                              <1> pix_op_or_24_0:
  9364 0000F3B6 0B07                <1> 	or	eax, [edi]
  9365 0000F3B8 66AB                <1> 	stosw
  9366 0000F3BA C1E810              <1> 	shr	eax, 16
  9367 0000F3BD AA                  <1> 	stosb	
  9368 0000F3BE 89D0                <1> 	mov	eax, edx
  9369 0000F3C0 E2F4                <1> 	loop	pix_op_or_24_0
  9370 0000F3C2 C3                  <1> 	retn
  9371                              <1> 
  9372                              <1> pix_op_or_32:
  9373                              <1> 	; 32 bit true colors
  9374                              <1> 	; OR PIXEL COLOR
  9375                              <1> 	; ecx = pixel count per row
  9376                              <1> 	; eax = color
  9377                              <1> 	; edi = start pixel address 
  9378                              <1> 
  9379                              <1> 	;mov	edx, eax
  9380                              <1> pix_op_or_32_0:
  9381                              <1> 	;or	eax, [edi]
  9382                              <1> 	;stosd
  9383                              <1> 	;mov	eax, edx
  9384 0000F3C3 0907                <1> 	or	[edi], eax
  9385 0000F3C5 83C704              <1> 	add	edi, 4
  9386 0000F3C8 E2F9                <1> 	loop	pix_op_or_32_0
  9387 0000F3CA C3                  <1> 	retn
  9388                              <1> 
  9389                              <1> pix_op_and_8:
  9390                              <1> 	; 8 bit colors (256 colors)
  9391                              <1> 	; AND PIXEL COLOR
  9392                              <1> 	; ecx = pixel count per row
  9393                              <1> 	;  al = color
  9394                              <1> 	; edi = start pixel address 
  9395                              <1> 
  9396                              <1> pix_op_and_8_0:
  9397 0000F3CB 2007                <1> 	and	[edi], al
  9398 0000F3CD 47                  <1> 	inc	edi
  9399 0000F3CE E2FB                <1> 	loop	pix_op_and_8_0
  9400 0000F3D0 C3                  <1> 	retn
  9401                              <1> 
  9402                              <1> pix_op_and_16:
  9403                              <1> 	; 16 bit colors (65536 colors)
  9404                              <1> 	; AND PIXEL COLOR
  9405                              <1> 	; ecx = pixel count per row
  9406                              <1> 	;  ax = color
  9407                              <1> 	; edi = start pixel address 
  9408                              <1> 
  9409                              <1> pix_op_and_16_0:
  9410 0000F3D1 662107              <1> 	and	[edi], ax
  9411 0000F3D4 47                  <1> 	inc	edi
  9412 0000F3D5 47                  <1> 	inc	edi
  9413 0000F3D6 E2F9                <1> 	loop	pix_op_and_16_0
  9414 0000F3D8 C3                  <1> 	retn
  9415                              <1> 
  9416                              <1> pix_op_and_24:
  9417                              <1> 	; 24 bit true colors
  9418                              <1> 	; AND PIXEL COLOR
  9419                              <1> 	; ecx = pixel count per row
  9420                              <1> 	; eax = color
  9421                              <1> 	; edi = start pixel address 
  9422                              <1> 
  9423 0000F3D9 89C2                <1> 	mov	edx, eax
  9424                              <1> pix_op_and_24_0:
  9425 0000F3DB 2307                <1> 	and	eax, [edi]
  9426 0000F3DD 66AB                <1> 	stosw
  9427 0000F3DF C1E810              <1> 	shr	eax, 16
  9428 0000F3E2 AA                  <1> 	stosb	
  9429 0000F3E3 89D0                <1> 	mov	eax, edx
  9430 0000F3E5 E2F4                <1> 	loop	pix_op_and_24_0
  9431 0000F3E7 C3                  <1> 	retn
  9432                              <1> 
  9433                              <1> pix_op_and_32:
  9434                              <1> 	; 32 bit true colors
  9435                              <1> 	; AND PIXEL COLOR
  9436                              <1> 	; ecx = pixel count per row
  9437                              <1> 	; eax = color
  9438                              <1> 	; edi = start pixel address 
  9439                              <1> 
  9440                              <1> 	;mov	edx, eax
  9441                              <1> pix_op_and_32_0:
  9442                              <1> 	;and	eax, [edi]
  9443                              <1> 	;stosd
  9444                              <1> 	;mov	eax, edx
  9445 0000F3E8 2107                <1> 	and	[edi], eax
  9446 0000F3EA 83C704              <1> 	add	edi, 4
  9447 0000F3ED E2F9                <1> 	loop	pix_op_and_32_0
  9448 0000F3EF C3                  <1> 	retn
  9449                              <1> 
  9450                              <1> pix_op_xor_8:
  9451                              <1> 	; 8 bit colors (256 colors)
  9452                              <1> 	; XOR PIXEL COLOR
  9453                              <1> 	; ecx = pixel count per row
  9454                              <1> 	;  al = color
  9455                              <1> 	; edi = start pixel address 
  9456                              <1> 
  9457                              <1> pix_op_xor_8_0:
  9458 0000F3F0 3007                <1> 	xor	[edi], al
  9459 0000F3F2 47                  <1> 	inc	edi
  9460 0000F3F3 E2FB                <1> 	loop	pix_op_xor_8_0
  9461 0000F3F5 C3                  <1> 	retn
  9462                              <1> 
  9463                              <1> pix_op_xor_16:
  9464                              <1> 	; 16 bit colors (65536 colors)
  9465                              <1> 	; XOR PIXEL COLOR
  9466                              <1> 	; ecx = pixel count per row
  9467                              <1> 	;  ax = color
  9468                              <1> 	; edi = start pixel address 
  9469                              <1> 
  9470                              <1> pix_op_xor_16_0:
  9471 0000F3F6 663107              <1> 	xor	[edi], ax
  9472 0000F3F9 47                  <1> 	inc	edi
  9473 0000F3FA 47                  <1> 	inc	edi
  9474 0000F3FB E2F9                <1> 	loop	pix_op_xor_16_0
  9475 0000F3FD C3                  <1> 	retn
  9476                              <1> 
  9477                              <1> pix_op_xor_24:
  9478                              <1> 	; 24 bit true colors
  9479                              <1> 	; XOR PIXEL COLOR
  9480                              <1> 	; ecx = pixel count per row
  9481                              <1> 	; eax = color
  9482                              <1> 	; edi = start pixel address 
  9483                              <1> 
  9484 0000F3FE 89C2                <1> 	mov	edx, eax
  9485                              <1> pix_op_xor_24_0:
  9486 0000F400 3307                <1> 	xor	eax, [edi]
  9487 0000F402 66AB                <1> 	stosw
  9488 0000F404 C1E810              <1> 	shr	eax, 16
  9489 0000F407 AA                  <1> 	stosb	
  9490 0000F408 89D0                <1> 	mov	eax, edx
  9491 0000F40A E2F4                <1> 	loop	pix_op_xor_24_0
  9492 0000F40C C3                  <1> 	retn
  9493                              <1> 
  9494                              <1> pix_op_xor_32:
  9495                              <1> 	; 32 bit true colors
  9496                              <1> 	; XOR PIXEL COLOR
  9497                              <1> 	; ecx = pixel count per row
  9498                              <1> 	; eax = color
  9499                              <1> 	; edi = start pixel address 
  9500                              <1> 
  9501                              <1> 	;mov	edx, eax
  9502                              <1> pix_op_xor_32_0:
  9503                              <1> 	;xor	eax, [edi]
  9504                              <1> 	;stosd
  9505                              <1> 	;mov	eax, edx
  9506 0000F40D 3107                <1> 	xor	[edi], eax
  9507 0000F40F 83C704              <1> 	add	edi, 4
  9508 0000F412 E2F9                <1> 	loop	pix_op_xor_32_0
  9509 0000F414 C3                  <1> 	retn
  9510                              <1> 
  9511                              <1> pix_op_mix_8:
  9512                              <1> 	; 8 bit colors (256 colors)
  9513                              <1> 	; MIX (AVERAGE) PIXEL COLORS
  9514                              <1> 	; ecx = pixel count per row
  9515                              <1> 	;  al = color
  9516                              <1> 	; edi = start pixel address 
  9517                              <1> 
  9518 0000F415 88C4                <1> 	mov	ah, al
  9519                              <1> pix_op_mix_8_0:
  9520 0000F417 0207                <1> 	add	al, [edi]
  9521 0000F419 D0D8                <1> 	rcr	al, 1
  9522 0000F41B AA                  <1> 	stosb
  9523 0000F41C 88E0                <1> 	mov	al, ah
  9524 0000F41E E2F7                <1> 	loop	pix_op_mix_8_0
  9525 0000F420 C3                  <1> 	retn
  9526                              <1> 
  9527                              <1> pix_op_mix_16:
  9528                              <1> 	; 16 bit colors (65536 colors)
  9529                              <1> 	; MIX (AVERAGE) PIXEL COLORS
  9530                              <1> 	; ecx = pixel count per row
  9531                              <1> 	;  ax = color
  9532                              <1> 	; edi = start pixel address 
  9533                              <1> 
  9534 0000F421 89C2                <1> 	mov	edx, eax
  9535                              <1> pix_op_mix_16_0:
  9536 0000F423 660307              <1> 	add	ax, [edi]
  9537 0000F426 66D1D8              <1> 	rcr	ax, 1
  9538 0000F429 66AB                <1> 	stosw
  9539 0000F42B 89D0                <1> 	mov	eax, edx
  9540 0000F42D E2F4                <1> 	loop	pix_op_mix_16_0
  9541 0000F42F C3                  <1> 	retn
  9542                              <1> 
  9543                              <1> pix_op_mix_24:
  9544                              <1> 	; 24 bit true colors
  9545                              <1> 	; MIX (AVERAGE) PIXEL COLORS
  9546                              <1> 	; ecx = pixel count per row
  9547                              <1> 	; eax = color
  9548                              <1> 	; edi = start pixel address 
  9549                              <1> 
  9550 0000F430 53                  <1> 	push	ebx
  9551 0000F431 BBFFFFFF00          <1> 	mov	ebx, 0FFFFFFh
  9552                              <1> 	;and	eax, ebx ; 0FFFFFFh
  9553 0000F436 89C2                <1> 	mov	edx, eax
  9554                              <1> pix_op_mix_24_0:
  9555 0000F438 8B07                <1> 	mov	eax, [edi]
  9556 0000F43A 21D8                <1> 	and	eax, ebx ; 0FFFFFFh
  9557 0000F43C 01D0                <1> 	add	eax, edx
  9558 0000F43E D1E8                <1> 	shr	eax, 1
  9559                              <1> 	;rcr	eax, 1
  9560 0000F440 66AB                <1> 	stosw
  9561 0000F442 C1E810              <1> 	shr	eax, 16
  9562 0000F445 AA                  <1> 	stosb
  9563 0000F446 E2F0                <1> 	loop	pix_op_mix_24_0
  9564 0000F448 89D0                <1> 	mov	eax, edx
  9565 0000F44A 5B                  <1> 	pop	ebx
  9566 0000F44B C3                  <1> 	retn
  9567                              <1> 
  9568                              <1> pix_op_mix_32:
  9569                              <1> 	; 32 bit true colors
  9570                              <1> 	; MIX (AVERAGE) PIXEL COLORS
  9571                              <1> 	; ecx = pixel count per row
  9572                              <1> 	; eax = color
  9573                              <1> 	; edi = start pixel address 
  9574                              <1> 
  9575 0000F44C 89C2                <1> 	mov	edx, eax
  9576                              <1> pix_op_mix_32_0:
  9577 0000F44E 0307                <1> 	add	eax, [edi]
  9578 0000F450 D1D8                <1> 	rcr	eax, 1	
  9579 0000F452 AB                  <1> 	stosd
  9580 0000F453 89D0                <1> 	mov	eax, edx
  9581 0000F455 E2F7                <1> 	loop	pix_op_mix_32_0
  9582 0000F457 C3                  <1> 	retn
  9583                              <1> 
  9584                              <1> pix_op_not_8:
  9585                              <1> 	; 8 bit colors (256 colors)
  9586                              <1> 	; NOT PIXEL COLOR
  9587                              <1> 	; ecx = pixel count per row
  9588                              <1> 	; edi = start pixel address 
  9589                              <1> 
  9590                              <1> pix_op_not_8_0:
  9591 0000F458 F617                <1> 	not	byte [edi]
  9592 0000F45A 47                  <1> 	inc	edi
  9593 0000F45B E2FB                <1> 	loop	pix_op_not_8_0
  9594 0000F45D C3                  <1> 	retn
  9595                              <1> 
  9596                              <1> pix_op_not_16:
  9597                              <1> 	; 16 bit colors (65536 colors)
  9598                              <1> 	; NOT PIXEL COLOR
  9599                              <1> 	; ecx = pixel count per row
  9600                              <1> 	; edi = start pixel address 
  9601                              <1> 
  9602                              <1> pix_op_not_16_0:
  9603 0000F45E 66F717              <1> 	not	word [edi]
  9604 0000F461 47                  <1> 	inc	edi
  9605 0000F462 47                  <1> 	inc	edi
  9606 0000F463 E2F9                <1> 	loop	pix_op_not_16_0
  9607 0000F465 C3                  <1> 	retn
  9608                              <1> 
  9609                              <1> pix_op_not_24:
  9610                              <1> 	; 24 bit true colors
  9611                              <1> 	; NOT PIXEL COLOR
  9612                              <1> 	; ecx = pixel count per row
  9613                              <1> 	; edi = start pixel address 
  9614                              <1> 
  9615                              <1> pix_op_not_24_0:
  9616 0000F466 66F717              <1> 	not	word [edi]
  9617 0000F469 47                  <1> 	inc	edi
  9618 0000F46A 47                  <1> 	inc	edi
  9619 0000F46B F617                <1> 	not	byte [edi]
  9620 0000F46D 47                  <1> 	inc	edi
  9621 0000F46E E2F6                <1> 	loop	pix_op_not_24_0
  9622 0000F470 C3                  <1> 	retn
  9623                              <1> 
  9624                              <1> pix_op_not_32:
  9625                              <1> 	; 32 bit true colors
  9626                              <1> 	; NOT PIXEL COLOR
  9627                              <1> 	; ecx = pixel count per row
  9628                              <1> 	; eax = color
  9629                              <1> 	; edi = start pixel address 
  9630                              <1> pix_op_not_32_0:
  9631 0000F471 F717                <1> 	not	dword [edi]
  9632 0000F473 83C704              <1> 	add	edi, 4
  9633 0000F476 E2F9                <1> 	loop	pix_op_not_32_0
  9634 0000F478 C3                  <1> 	retn
  9635                              <1> 
  9636                              <1> pix_op_neg_8:
  9637                              <1> 	; 8 bit colors (256 colors)
  9638                              <1> 	; NEG PIXEL COLOR
  9639                              <1> 	; ecx = pixel count per row
  9640                              <1> 	; edi = start pixel address 
  9641                              <1> 
  9642                              <1> pix_op_neg_8_0:
  9643 0000F479 F61F                <1> 	neg	byte [edi]
  9644 0000F47B 47                  <1> 	inc	edi
  9645 0000F47C E2FB                <1> 	loop	pix_op_neg_8_0
  9646 0000F47E C3                  <1> 	retn
  9647                              <1> 
  9648                              <1> pix_op_neg_16:
  9649                              <1> 	; 16 bit colors (65536 colors)
  9650                              <1> 	; NEG PIXEL COLOR
  9651                              <1> 	; ecx = pixel count per row
  9652                              <1> 	; edi = start pixel address 
  9653                              <1> 
  9654                              <1> pix_op_neg_16_0:
  9655 0000F47F 66F71F              <1> 	neg	word [edi]
  9656 0000F482 47                  <1> 	inc	edi
  9657 0000F483 47                  <1> 	inc	edi
  9658 0000F484 E2F9                <1> 	loop	pix_op_neg_16_0
  9659 0000F486 C3                  <1> 	retn
  9660                              <1> 
  9661                              <1> pix_op_neg_24:
  9662                              <1> 	; 24 bit true colors
  9663                              <1> 	; NEG PIXEL COLOR
  9664                              <1> 	; ecx = pixel count per row
  9665                              <1> 	; edi = start pixel address 
  9666                              <1> 
  9667                              <1> pix_op_neg_24_0:
  9668 0000F487 8B07                <1> 	mov	eax, [edi]
  9669 0000F489 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
  9670 0000F48E F7D8                <1> 	neg	eax
  9671 0000F490 66AB                <1> 	stosw
  9672 0000F492 C1E810              <1> 	shr	eax, 16
  9673 0000F495 AA                  <1> 	stosb
  9674 0000F496 E2EF                <1> 	loop	pix_op_neg_24_0
  9675 0000F498 C3                  <1> 	retn
  9676                              <1> 
  9677                              <1> pix_op_neg_32:
  9678                              <1> 	; 32 bit true colors
  9679                              <1> 	; NEG PIXEL COLOR
  9680                              <1> 	; ecx = pixel count per row
  9681                              <1> 	; eax = color
  9682                              <1> 	; edi = start pixel address 
  9683                              <1> pix_op_neg_32_0:
  9684 0000F499 F71F                <1> 	neg	dword [edi]
  9685 0000F49B 83C704              <1> 	add	edi, 4
  9686 0000F49E E2F9                <1> 	loop	pix_op_neg_32_0
  9687 0000F4A0 C3                  <1> 	retn
  9688                              <1> 
  9689                              <1> pix_op_inc_8:
  9690                              <1> 	; 8 bit colors (256 colors)
  9691                              <1> 	; INCREASE PIXEL COLOR
  9692                              <1> 	; ecx = pixel count per row
  9693                              <1> 	; edi = start pixel address 
  9694                              <1> 
  9695                              <1> pix_op_inc_8_0:
  9696 0000F4A1 FE07                <1> 	inc	byte [edi]
  9697 0000F4A3 7502                <1> 	jnz	short pix_op_inc_8_1
  9698                              <1> 	;mov	[edi], 0FFh ; Max. value	
  9699 0000F4A5 FE0F                <1> 	dec	byte [edi]
  9700                              <1> pix_op_inc_8_1:
  9701 0000F4A7 47                  <1> 	inc	edi
  9702 0000F4A8 E2F7                <1> 	loop	pix_op_inc_8_0
  9703 0000F4AA C3                  <1> 	retn
  9704                              <1> 
  9705                              <1> pix_op_inc_16:
  9706                              <1> 	; 16 bit colors (65536 colors)
  9707                              <1> 	; INCREASE PIXEL COLOR
  9708                              <1> 	; ecx = pixel count per row
  9709                              <1> 	; edi = start pixel address 
  9710                              <1> 
  9711                              <1> pix_op_inc_16_0:
  9712 0000F4AB 66FF07              <1> 	inc	word [edi]
  9713 0000F4AE 7503                <1> 	jnz	short pix_op_inc_16_1
  9714                              <1> 	;mov	word [edi], 0FFFFh ; Max. value
  9715 0000F4B0 66FF0F              <1> 	dec	word [edi]
  9716                              <1> pix_op_inc_16_1:
  9717 0000F4B3 47                  <1> 	inc	edi
  9718 0000F4B4 47                  <1> 	inc	edi
  9719 0000F4B5 E2F4                <1> 	loop	pix_op_inc_16_0
  9720 0000F4B7 C3                  <1> 	retn
  9721                              <1> 
  9722                              <1> pix_op_inc_24:
  9723                              <1> 	; 24 bit true colors
  9724                              <1> 	; INCREASE PIXEL COLOR
  9725                              <1> 	; ecx = pixel count per row
  9726                              <1> 	; edi = start pixel address 
  9727                              <1> 
  9728                              <1> pix_op_inc_24_0:
  9729 0000F4B8 8B07                <1> 	mov	eax, [edi]
  9730 0000F4BA 40                  <1> 	inc	eax
  9731 0000F4BB 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
  9732 0000F4C0 7501                <1> 	jnz	short pix_op_inc_24_1
  9733                              <1> 	;mov	eax, 0FFFFFFh  ; Max. value
  9734 0000F4C2 48                  <1> 	dec	eax ; 0FFFFFFFFh
  9735                              <1> pix_op_inc_24_1: 
  9736 0000F4C3 66AB                <1> 	stosw
  9737 0000F4C5 C1E810              <1> 	shr	eax, 16
  9738 0000F4C8 AA                  <1> 	stosb
  9739 0000F4C9 E2ED                <1> 	loop	pix_op_inc_24_0
  9740 0000F4CB C3                  <1> 	retn
  9741                              <1> 
  9742                              <1> pix_op_inc_32:
  9743                              <1> 	; 32 bit true colors
  9744                              <1> 	; INCREASE PIXEL COLOR
  9745                              <1> 	; ecx = pixel count per row
  9746                              <1> 	; edi = start pixel address 
  9747                              <1> 
  9748                              <1> pix_op_inc_32_0:
  9749 0000F4CC FF07                <1> 	inc	dword [edi]
  9750 0000F4CE 7502                <1> 	jnz	short pix_op_inc_32_1
  9751                              <1> 	;mov	dword [edi], 0FFFFFFFFh ; Max. value
  9752 0000F4D0 FF0F                <1> 	dec	dword [edi]
  9753                              <1> pix_op_inc_32_1:
  9754 0000F4D2 83C704              <1> 	add	edi, 4
  9755 0000F4D5 E2F5                <1> 	loop	pix_op_inc_32_0
  9756 0000F4D7 C3                  <1> 	retn
  9757                              <1> 
  9758                              <1> pix_op_dec_8:
  9759                              <1> 	; 8 bit colors (256 colors)
  9760                              <1> 	; DECREASE PIXEL COLOR
  9761                              <1> 	; ecx = pixel count per row
  9762                              <1> 	; edi = start pixel address 
  9763                              <1> 
  9764                              <1> pix_op_dec_8_0:
  9765 0000F4D8 FE0F                <1> 	dec	byte [edi]
  9766 0000F4DA 7902                <1> 	jns	short pix_op_dec_8_1
  9767 0000F4DC FE07                <1> 	inc	byte [edi] ; 0 ; Min. value	
  9768                              <1> pix_op_dec_8_1:
  9769 0000F4DE 47                  <1> 	inc	edi
  9770 0000F4DF E2F7                <1> 	loop	pix_op_dec_8_0
  9771 0000F4E1 C3                  <1> 	retn
  9772                              <1> 
  9773                              <1> pix_op_dec_16:
  9774                              <1> 	; 16 bit colors (65536 colors)
  9775                              <1> 	; DECREASE PIXEL COLOR
  9776                              <1> 	; ecx = pixel count per row
  9777                              <1> 	; edi = start pixel address 
  9778                              <1> 
  9779                              <1> pix_op_dec_16_0:
  9780 0000F4E2 66FF0F              <1> 	dec	word [edi]
  9781 0000F4E5 7903                <1> 	jns	short pix_op_dec_16_1
  9782 0000F4E7 66FF07              <1> 	inc	word [edi] ; 0 ; Min. value	
  9783                              <1> pix_op_dec_16_1:
  9784 0000F4EA 47                  <1> 	inc edi
  9785 0000F4EB 47                  <1> 	inc edi
  9786 0000F4EC E2F4                <1> 	loop	pix_op_dec_16_0
  9787 0000F4EE C3                  <1> 	retn
  9788                              <1> 
  9789                              <1> pix_op_dec_24:
  9790                              <1> 	; 24 bit true colors
  9791                              <1> 	; DECREASE PIXEL COLOR
  9792                              <1> 	; ecx = pixel count per row
  9793                              <1> 	; edi = start pixel address 
  9794                              <1> 
  9795                              <1> pix_op_dec_24_0:
  9796 0000F4EF 8B07                <1> 	mov	eax, [edi]
  9797 0000F4F1 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
  9798 0000F4F6 7401                <1> 	jz	short pix_op_dec_24_1
  9799                              <1> 			; 0 ; Min. value
  9800 0000F4F8 48                  <1> 	dec	eax
  9801                              <1> pix_op_dec_24_1:
  9802 0000F4F9 66AB                <1> 	stosw
  9803 0000F4FB C1E810              <1> 	shr	eax, 16
  9804 0000F4FE AA                  <1> 	stosb
  9805 0000F4FF E2B7                <1> 	loop	pix_op_inc_24_0
  9806 0000F501 C3                  <1> 	retn
  9807                              <1> 
  9808                              <1> pix_op_dec_32:
  9809                              <1> 	; 32 bit true colors
  9810                              <1> 	; DECREASE PIXEL COLOR
  9811                              <1> 	; ecx = pixel count per row
  9812                              <1> 	; edi = start pixel address 
  9813                              <1> 
  9814                              <1> pix_op_dec_32_0:
  9815 0000F502 FF0F                <1> 	dec	dword [edi]
  9816 0000F504 7902                <1> 	jns	short pix_op_dec_32_1
  9817 0000F506 FF07                <1> 	inc	dword [edi] ; 0 ; Min. value
  9818                              <1> pix_op_dec_32_1:
  9819 0000F508 83C704              <1> 	add	edi, 4
  9820 0000F50B E2F5                <1> 	loop	pix_op_dec_32_0
  9821 0000F50D 89D0                <1> 	mov	eax, edx
  9822 0000F50F C3                  <1> 	retn
  9823                              <1> 
  9824                              <1> pix_op_rpl_8:
  9825                              <1> 	; 8 bit colors (256 colors)
  9826                              <1> 	; REPLACE PIXEL COLORS
  9827                              <1> 	; ecx = pixel count per row
  9828                              <1> 	;  al = new color
  9829                              <1> 	; byte [maskcolor] = old color
  9830                              <1> 	; edi = start pixel address
  9831                              <1> 
  9832 0000F510 8A25[9A120300]      <1> 	mov	ah, [maskcolor]
  9833                              <1> pix_op_rpl_8_0:
  9834 0000F516 3A27                <1> 	cmp	ah, [edi]
  9835 0000F518 7502                <1> 	jne	short pix_op_rpl_8_1
  9836 0000F51A 8807                <1> 	mov	[edi], al
  9837                              <1> pix_op_rpl_8_1:
  9838 0000F51C 47                  <1> 	inc	edi
  9839 0000F51D E2F7                <1> 	loop	pix_op_rpl_8_0
  9840 0000F51F C3                  <1> 	retn
  9841                              <1> 
  9842                              <1> pix_op_rpl_16:
  9843                              <1> 	; 16 bit colors (65536 colors)
  9844                              <1> 	; REPLACE PIXEL COLORS
  9845                              <1> 	; ecx = pixel count per row
  9846                              <1> 	;  ax = new color
  9847                              <1> 	; word [maskcolor] = old color
  9848                              <1> 	; edi = start pixel address
  9849                              <1> 
  9850 0000F520 8B15[9A120300]      <1> 	mov	edx, [maskcolor]
  9851                              <1> pix_op_rpl_16_0:
  9852 0000F526 663B17              <1> 	cmp	dx, [edi]
  9853 0000F529 7503                <1> 	jne	short pix_op_rpl_16_1
  9854 0000F52B 668907              <1> 	mov	[edi], ax
  9855                              <1> pix_op_rpl_16_1:
  9856 0000F52E 47                  <1> 	inc	edi
  9857 0000F52F 47                  <1> 	inc	edi
  9858 0000F530 E2F4                <1> 	loop	pix_op_rpl_16_0
  9859 0000F532 C3                  <1> 	retn
  9860                              <1> 
  9861                              <1> pix_op_rpl_24:
  9862                              <1> 	; 24 bit true colors
  9863                              <1> 	; REPLACE PIXEL COLORS
  9864                              <1> 	; ecx = pixel count per row
  9865                              <1> 	; eax = new color
  9866                              <1> 	; [maskcolor] = old color
  9867                              <1> 	; edi = start pixel address
  9868                              <1> 
  9869                              <1> pix_op_rpl_24_0:
  9870 0000F533 8B17                <1> 	mov	edx, [edi]
  9871 0000F535 81E2FFFFFF00        <1> 	and	edx, 0FFFFFFh
  9872 0000F53B 3B15[9A120300]      <1> 	cmp	edx, [maskcolor]
  9873 0000F541 7406                <1> 	je	short pix_op_rpl_24_1
  9874 0000F543 83C703              <1> 	add	edi, 3
  9875 0000F546 E2EB                <1> 	loop	pix_op_rpl_24_0
  9876 0000F548 C3                  <1> 	retn
  9877                              <1> pix_op_rpl_24_1: 
  9878 0000F549 AA                  <1> 	stosb
  9879 0000F54A C1C808              <1> 	ror	eax, 8
  9880 0000F54D 66AB                <1> 	stosw
  9881 0000F54F C1C008              <1> 	rol	eax, 8
  9882 0000F552 E2DF                <1> 	loop	pix_op_rpl_24_0
  9883 0000F554 C3                  <1> 	retn
  9884                              <1> 
  9885                              <1> pix_op_rpl_32:
  9886                              <1> 	; 32 bit true colors
  9887                              <1> 	; REPLACE PIXEL COLORS
  9888                              <1> 	; ecx = pixel count per row
  9889                              <1> 	; eax = new color
  9890                              <1> 	; [maskcolor] = old color
  9891                              <1> 	; edi = start pixel address
  9892                              <1> 
  9893 0000F555 8B15[9A120300]      <1> 	mov	edx, [maskcolor]
  9894                              <1> pix_op_rpl_32_0:
  9895 0000F55B 3B17                <1> 	cmp	edx, [edi]
  9896 0000F55D 7504                <1> 	jne	short pix_op_rpl_32_2
  9897 0000F55F AB                  <1> 	stosd
  9898 0000F560 E2F9                <1> 	loop	pix_op_rpl_32_0
  9899 0000F562 C3                  <1> 	retn	
  9900                              <1> pix_op_rpl_32_2:
  9901 0000F563 83C704              <1> 	add	edi, 4
  9902 0000F566 E2F3                <1> 	loop	pix_op_rpl_32_0
  9903 0000F568 C3                  <1> 	retn
  9904                              <1> 
  9905                              <1> pix_op_chr:
  9906                              <1> 	; 15/02/2021
  9907                              <1> 	; 05/02/2021
  9908                              <1> 	; WRITE CHARACTER (FONT)
  9909                              <1> 	; 05/01/2021 ([ufont])
  9910                              <1> 	; 01/01/2021
  9911                              <1> 	;     CL = char's color (8 bit, 256 colors)
  9912                              <1> 	;    ECX = char's color (16 bit and true colors)
  9913                              <1> 	;     DL = Character's ASCII code
  9914                              <1> 	;     DH bit 0 -> font height
  9915                              <1> 	;	  0 -> 8x16 character font
  9916                              <1> 	;	  1 -> 8x8 character font
  9917                              <1> 	;     DH bit 1 & 2 -> scale	
  9918                              <1> 	;	  0 = 1/1 (8 pixels per char row)
  9919                              <1> 	;	  1 = 2/1 (16 pixels per char row)
  9920                              <1> 	;	  2 = 3/1 (24 pixels per char row)
  9921                              <1> 	;	  3 = 4/1 (32 pixels per char row) 
  9922                              <1> 	;     DH bit 6 -> [ufont] option (1 = use [ufont])
  9923                              <1> 	;     If DH bit 7 = 1
  9924                              <1> 	;	 USER FONT (from user buffer)
  9925                              <1> 	;	    DL = 0 -> 8x8 (width: 1 byte per row)
  9926                              <1> 	;	    DL = 1 -> 8x16
  9927                              <1> 	;	    DL = 2 -> 16x16 (width: 2 bytes)
  9928                              <1> 	;	    DL = 3 -> 16x32
  9929                              <1> 	;	    DL = 4 -> 24x24 (width: 3 bytes)
  9930                              <1> 	;	    DL = 5 -> 24x48
  9931                              <1> 	;	    DL = 6 -> 32x32 (width: 4 bytes)
  9932                              <1> 	;	    DL = 7 -> 32x64
  9933                              <1> 	;	    DL > 7 -> invalid (unused)
  9934                              <1> 	;	 EDI = user's font buffer address
  9935                              <1> 	;	    (NOTE: byte order is as row0,row1,row2..)
  9936                              <1> 	;     ESI = start position (row, column) (*)
  9937                              <1> 	;	     (HW = row, SI = column)
  9938                              <1> 
  9939 0000F569 89F0                <1> 	mov	eax, esi ; start position
  9940 0000F56B E855F2FFFF          <1> 	call	calc_pixel_offset
  9941 0000F570 3B05[8E120300]      <1> 	cmp	eax, [v_siz]
  9942 0000F576 736D                <1> 	jnb	short pix_op_chr_err ; out of display page!
  9943 0000F578 E825F2FFFF          <1> 	call	pixels_to_byte_count
  9944                              <1> 	; eax = font start offset
  9945 0000F57D 0305[8A120300]      <1> 	add	eax, [v_mem] ; LFB start address
  9946 0000F583 A3[92120300]        <1> 	mov	[v_str], eax ; font start address 
  9947                              <1> 
  9948 0000F588 890D[9A120300]      <1> 	mov	[maskcolor], ecx ; save char's color
  9949                              <1> 
  9950 0000F58E 8835[88120300]      <1> 	mov	[v_ops], dh
  9951                              <1> 
  9952 0000F594 81E6FFFF0000        <1> 	and	esi, 0FFFFh
  9953 0000F59A 8935[A2120300]      <1> 	mov	[buffer8], esi ; start column
  9954                              <1> 
  9955 0000F5A0 31DB                <1> 	xor	ebx, ebx ; 0
  9956 0000F5A2 31C0                <1> 	xor	eax, eax ; 15/02/2021
  9957                              <1> 
  9958 0000F5A4 F6C680              <1> 	test	dh, 80h
  9959 0000F5A7 7577                <1> 	jnz	short pix_op_chr_u ; user font
  9960                              <1> 
  9961 0000F5A9 80E63F              <1> 	and	dh, 3Fh ; clear bit 6, [UFONT] option bit
  9962 0000F5AC 7409                <1> 	jz	short pix_op_chr_0
  9963                              <1> 
  9964 0000F5AE 80FE07              <1> 	cmp	dh, 7
  9965 0000F5B1 7732                <1> 	ja	short pix_op_chr_err
  9966                              <1> 			 ; invalid (undefined) option 
  9967 0000F5B3 88F4                <1> 	mov	ah, dh
  9968 0000F5B5 D0EC                <1> 	shr	ah, 1
  9969                              <1> 	; ah = 0 to 3, scale
  9970                              <1> 	;jmp	short pix_op_chr_font_pixels
  9971                              <1> 
  9972                              <1> pix_op_chr_font_pixels:
  9973                              <1> 	; 05/02/2021
  9974                              <1> 	; write scaled font to buffer
  9975                              <1> 
  9976                              <1> 	; DL = ASCII code of character
  9977                              <1> 	; AH = scale
  9978                              <1> 	; EDI = buffer address (kernel)
  9979                              <1> 
  9980                              <1> pix_op_chr_0:
  9981 0000F5B7 88D3                <1> 	mov	bl, dl ; 15/02/2021
  9982 0000F5B9 31C9                <1> 	xor	ecx, ecx
  9983 0000F5BB B610                <1> 	mov	dh, 16
  9984 0000F5BD F605[88120300]01    <1> 	test	byte [v_ops], 1 ; 8x8 font ?
  9985 0000F5C4 7428                <1> 	jz	short pix_op_chr_2 ; 8x16 font 
  9986 0000F5C6 B608                <1> 	mov	dh, 8
  9987 0000F5C8 C1E303              <1> 	shl	ebx, 3 ; * 8
  9988 0000F5CB F605[88120300]40    <1> 	test	byte [v_ops], 40h ; [ufont] option
  9989 0000F5D2 7412                <1> 	jz	short pix_op_chr_1  ; no
  9990                              <1> 	; test 8x8 user font is ready flag
  9991 0000F5D4 F605[7E120300]01    <1> 	test	byte [ufont], 1
  9992 0000F5DB 7409                <1> 	jz	short pix_op_chr_1 ; no
  9993 0000F5DD 81C300500900        <1> 	add	ebx, VGAFONT8USER
  9994 0000F5E3 EB2C                <1> 	jmp	short pix_op_chr_fpos_0
  9995                              <1> pix_op_chr_err:
  9996 0000F5E5 C3                  <1> 	retn
  9997                              <1> pix_op_chr_1:
  9998 0000F5E6 81C3[C4600100]      <1> 	add	ebx, vgafont8 ; system font (8x8)
  9999 0000F5EC EB23                <1> 	jmp	short pix_op_chr_fpos_0
 10000                              <1> pix_op_chr_2:
 10001 0000F5EE C1E304              <1> 	shl	ebx, 4 ; * 16
 10002 0000F5F1 F605[88120300]40    <1> 	test	byte [v_ops], 40h ; [ufont] option
 10003 0000F5F8 7411                <1> 	jz	short pix_op_chr_3  ; no
 10004                              <1> 	; test 8x16 user font is ready flag
 10005 0000F5FA F605[7E120300]02    <1> 	test	byte [ufont], 2
 10006 0000F601 7408                <1> 	jz	short pix_op_chr_3 ; no
 10007 0000F603 81C300400900        <1> 	add	ebx, VGAFONT16USER
 10008 0000F609 EB06                <1> 	jmp	short pix_op_chr_fpos_0
 10009                              <1> pix_op_chr_3:
 10010 0000F60B 81C3[C4760100]      <1> 	add	ebx, vgafont16 ; system font (8x16)
 10011                              <1> pix_op_chr_fpos_0:
 10012 0000F611 20E4                <1> 	and	ah, ah
 10013 0000F613 754B                <1> 	jnz	short pix_op_chr_fpos_1 ; scale > 1 
 10014                              <1> 	; no scale (scale = 1)
 10015 0000F615 89DE                <1> 	mov	esi, ebx ; 15/02/2021
 10016 0000F617 88F1                <1> 	mov	cl, dh ; rows/height (16 or 8)	
 10017 0000F619 B608                <1> 	mov	dh, 8  ; columns/width
 10018 0000F61B E9CD000000          <1> 	jmp	pix_op_chr_f2p
 10019                              <1> pix_op_chr_u:
 10020                              <1> 	; write user defined font 
 10021 0000F620 80FE80              <1> 	cmp	dh, 80h
 10022 0000F623 75C0                <1> 	jne	short pix_op_chr_err
 10023 0000F625 80FA07              <1> 	cmp	dl, 7
 10024 0000F628 77BB                <1> 	ja	short pix_op_chr_err
 10025                              <1> 
 10026                              <1> 	; 16/02/2021
 10027 0000F62A 89FE                <1> 	mov	esi, edi ; user's font buffer
 10028                              <1> 	
 10029                              <1> 	;xor	eax, eax
 10030                              <1> 	; eax = 0 ; 15/02/2021	
 10031 0000F62C 88D4                <1> 	mov	ah, dl
 10032 0000F62E D0EC                <1> 	shr	ah, 1
 10033 0000F630 FEC4                <1> 	inc	ah	
 10034                              <1> 	; ah =  1 to 4
 10035 0000F632 88E0                <1> 	mov	al, ah
 10036 0000F634 C0E003              <1> 	shl	al, 3 ; * 8
 10037                              <1> 	; al = 8,16,24,32
 10038 0000F637 88C3                <1> 	mov	bl, al
 10039 0000F639 88C7                <1> 	mov	bh, al
 10040 0000F63B F6E4                <1> 	mul	ah
 10041                              <1> 	; ax = 8,32,72,128 bytes 
 10042 0000F63D F6C201              <1> 	test	dl, 1
 10043 0000F640 7405                <1> 	jz	short pix_op_chr_u_0
 10044 0000F642 66D1E0              <1> 	shl	ax, 1 ; *2
 10045                              <1> 	; ax = 16,32,144,256 bytes
 10046 0000F645 D0E7                <1> 	shl	bh, 1
 10047                              <1> pix_op_chr_u_0:
 10048                              <1> 	; eax = byte count
 10049 0000F647 89C1                <1> 	mov	ecx, eax
 10050 0000F649 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
 10051                              <1> 	; esi = user buffer
 10052 0000F64E E85B250000          <1> 	call	transfer_from_user_buffer
 10053 0000F653 7290                <1> 	jc	short pix_op_chr_err
 10054                              <1> 
 10055 0000F655 88F9                <1> 	mov	cl, bh ; rows/height
 10056 0000F657 88DE                <1> 	mov	dh, bl ; columns (width)
 10057 0000F659 89FE                <1> 	mov	esi, edi ; VBE3SAVERESTOREBLOCK
 10058 0000F65B E98D000000          <1> 	jmp	pix_op_chr_f2p
 10059                              <1> 
 10060                              <1> pix_op_chr_fpos_1:
 10061                              <1> 	; 18/02/2021
 10062                              <1> 	; scale > 1
 10063 0000F660 88F5                <1> 	mov	ch, dh ; 16 or 8
 10064 0000F662 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
 10065 0000F667 89FE                <1> 	mov	esi, edi
 10066 0000F669 FECC                <1> 	dec	ah
 10067 0000F66B 7523                <1> 	jnz	short pix_op_chr_fpos_5 ; scale > 2
 10068                              <1> 	; scale = 2
 10069                              <1> pix_op_chr_fpos_2:	
 10070 0000F66D B108                <1> 	mov	cl, 8
 10071 0000F66F 8A13                <1> 	mov	dl, [ebx]
 10072                              <1> pix_op_chr_fpos_3:
 10073 0000F671 66C1E002            <1> 	shl 	ax, 2
 10074 0000F675 D0E2                <1> 	shl	dl, 1
 10075 0000F677 7302                <1> 	jnc	short pix_op_chr_fpos_4
 10076 0000F679 0C03                <1> 	or	al, 3
 10077                              <1> pix_op_chr_fpos_4:
 10078 0000F67B FEC9                <1> 	dec	cl
 10079 0000F67D 75F2                <1> 	jnz	short pix_op_chr_fpos_3
 10080 0000F67F 66AB                <1> 	stosw
 10081                              <1> 	; 18/02/2021
 10082 0000F681 66AB                <1> 	stosw
 10083 0000F683 43                  <1> 	inc	ebx
 10084 0000F684 FECD                <1> 	dec	ch
 10085 0000F686 75E5                <1> 	jnz	short pix_op_chr_fpos_2
 10086                              <1> 	; scale = 2
 10087 0000F688 88F1                <1> 	mov	cl, dh ; 16 or 8 (height/rows)
 10088 0000F68A D0E1                <1> 	shl	cl, 1  ; 32 or 16 rows
 10089 0000F68C B610                <1> 	mov	dh, 16 ; columns (width)
 10090 0000F68E EB5D                <1> 	jmp	short pix_op_chr_f2p
 10091                              <1> pix_op_chr_fpos_5:
 10092 0000F690 FECC                <1> 	dec	ah
 10093 0000F692 7538                <1> 	jnz	short pix_op_chr_fpos_9 ; scale = 4
 10094                              <1> 	; scale = 3
 10095                              <1> pix_op_chr_fpos_6:	
 10096 0000F694 B108                <1> 	mov	cl, 8
 10097 0000F696 8A13                <1> 	mov	dl, [ebx]
 10098                              <1> pix_op_chr_fpos_7:
 10099 0000F698 C1E003              <1> 	shl 	eax, 3
 10100 0000F69B D0E2                <1> 	shl	dl, 1 ; 18/02/2021
 10101 0000F69D 7302                <1> 	jnc	short pix_op_chr_fpos_8
 10102 0000F69F 0C07                <1> 	or	al, 7
 10103                              <1> pix_op_chr_fpos_8:
 10104 0000F6A1 FEC9                <1> 	dec	cl
 10105 0000F6A3 75F3                <1> 	jnz	short pix_op_chr_fpos_7
 10106 0000F6A5 66AB                <1> 	stosw
 10107                              <1> 	; 18/02/2021
 10108 0000F6A7 C1C810              <1> 	ror	eax, 16
 10109 0000F6AA AA                  <1> 	stosb
 10110 0000F6AB C1C010              <1> 	rol	eax, 16
 10111 0000F6AE 66AB                <1> 	stosw
 10112 0000F6B0 C1C810              <1> 	ror	eax, 16
 10113 0000F6B3 AA                  <1> 	stosb	
 10114 0000F6B4 C1C010              <1> 	rol	eax, 16
 10115 0000F6B7 66AB                <1> 	stosw
 10116 0000F6B9 C1E810              <1> 	shr	eax, 16 ; 27/02/2021
 10117 0000F6BC AA                  <1> 	stosb
 10118 0000F6BD 43                  <1> 	inc	ebx
 10119                              <1> 	; 18/02/2021
 10120 0000F6BE FECD                <1> 	dec	ch
 10121 0000F6C0 75D2                <1> 	jnz	short pix_op_chr_fpos_6
 10122                              <1> 	; scale = 3
 10123 0000F6C2 88F1                <1> 	mov	cl, dh ; 16 or 8 (height/rows)
 10124 0000F6C4 D0E1                <1> 	shl	cl, 1 
 10125 0000F6C6 00F1                <1> 	add	cl, dh ; 48 or 24 rows
 10126 0000F6C8 B618                <1> 	mov	dh, 24 ; columns (width)
 10127 0000F6CA EB21                <1> 	jmp	short pix_op_chr_f2p
 10128                              <1> 
 10129                              <1> pix_op_chr_fpos_9:
 10130                              <1> 	; scale = 4
 10131 0000F6CC B108                <1> 	mov	cl, 8
 10132 0000F6CE 8A13                <1> 	mov	dl, [ebx]
 10133                              <1> pix_op_chr_fpos_10:
 10134                              <1> 	; 18/02/2021
 10135 0000F6D0 C1E004              <1> 	shl 	eax, 4
 10136 0000F6D3 D0E2                <1> 	shl	dl, 1 ; 18/02/2021
 10137 0000F6D5 7302                <1> 	jnc	short pix_op_chr_fpos_11
 10138 0000F6D7 0C0F                <1> 	or	al, 0Fh ; or al, 15
 10139                              <1> pix_op_chr_fpos_11:
 10140 0000F6D9 FEC9                <1> 	dec	cl
 10141 0000F6DB 75F3                <1> 	jnz	short pix_op_chr_fpos_10
 10142 0000F6DD AB                  <1> 	stosd
 10143                              <1> 	; 18/02/2021
 10144 0000F6DE AB                  <1> 	stosd
 10145 0000F6DF AB                  <1> 	stosd
 10146 0000F6E0 AB                  <1> 	stosd
 10147 0000F6E1 43                  <1> 	inc	ebx
 10148 0000F6E2 FECD                <1> 	dec	ch
 10149 0000F6E4 75E6                <1> 	jnz	short pix_op_chr_fpos_9
 10150                              <1> 	; scale = 4
 10151 0000F6E6 88F1                <1> 	mov	cl, dh ; 16 or 8 (height/rows)
 10152 0000F6E8 C0E102              <1> 	shl	cl, 2 ; 64 or 32 rows
 10153 0000F6EB B620                <1> 	mov	dh, 32 ; columns (width)
 10154                              <1> 	;jmp	short pix_op_chr_f2p
 10155                              <1>  	
 10156                              <1> pix_op_chr_f2p:
 10157                              <1> 	; write font pixels
 10158 0000F6ED 8B3D[92120300]      <1> 	mov	edi, [v_str]
 10159                              <1> 	; 15/02/2021
 10160                              <1> pix_op_chr_f2p_next:
 10161 0000F6F3 80FE08              <1> 	cmp	dh, 8
 10162 0000F6F6 7706                <1> 	ja	short pix_op_chr_f2p_24
 10163                              <1> pix_op_chr_f2p_8:
 10164 0000F6F8 AC                  <1> 	lodsb
 10165 0000F6F9 C1E018              <1> 	shl	eax, 24 ; 15/02/2021
 10166 0000F6FC EB16                <1> 	jmp	short pix_op_chr_f2p_0
 10167                              <1> pix_op_chr_f2p_24:
 10168 0000F6FE 80FE18              <1> 	cmp	dh, 24
 10169 0000F701 7710                <1> 	ja	short pix_op_chr_f2p_32
 10170 0000F703 7207                <1> 	jb	short pix_op_chr_f2p_16	
 10171                              <1> 	; 27/02/2021
 10172                              <1> 	;mov	eax, [esi]
 10173 0000F705 AD                  <1> 	lodsd
 10174 0000F706 C1E008              <1> 	shl	eax, 8
 10175                              <1> 	;add	esi, 3
 10176 0000F709 4E                  <1> 	dec	esi
 10177 0000F70A EB08                <1> 	jmp	short pix_op_chr_f2p_0
 10178                              <1> pix_op_chr_f2p_16:
 10179 0000F70C 66AD                <1> 	lodsw
 10180 0000F70E C1E010              <1> 	shl	eax, 16 ; 15/02/2021
 10181 0000F711 EB01                <1> 	jmp	short pix_op_chr_f2p_0
 10182                              <1> pix_op_chr_f2p_32:
 10183 0000F713 AD                  <1> 	lodsd
 10184                              <1> pix_op_chr_f2p_0:
 10185                              <1> 	; EAX = font row (8,16,24,32 pixels)
 10186                              <1> 	;	(bits are shifted to left)
 10187                              <1> 	; CL = rows
 10188                              <1> 	; DH = bits per row (8,16,24,32)
 10189 0000F714 8B1D[A2120300]      <1> 	mov	ebx, [buffer8] ; start column
 10190 0000F71A 57                  <1> 	push	edi ; *
 10191 0000F71B 52                  <1> 	push	edx ; **
 10192                              <1> pix_op_chr_f2p_1:
 10193 0000F71C E82E000000          <1> 	call	pix_op_chr_w_pixel
 10194                              <1> pix_op_chr_f2p_2:
 10195 0000F721 663B1D[86120300]    <1> 	cmp	bx, [v_width] ; current column
 10196 0000F728 7304                <1> 	jnb	short pix_op_chr_f2p_3
 10197 0000F72A FECE                <1> 	dec	dh
 10198 0000F72C 75EE                <1> 	jnz	short pix_op_chr_f2p_1 ; next bit
 10199                              <1> pix_op_chr_f2p_3:
 10200                              <1> 	;mov	ebx, [buffer8]
 10201 0000F72E 5A                  <1> 	pop	edx ; **
 10202 0000F72F 58                  <1> 	pop	eax ; *
 10203 0000F730 3B3D[96120300]      <1> 	cmp	edi, [v_end]
 10204 0000F736 7316                <1> 	jnb	short pix_op_chr_f2p_4
 10205 0000F738 FEC9                <1> 	dec	cl
 10206 0000F73A 7412                <1> 	jz	short pix_op_chr_f2p_4
 10207                              <1> 	; 27/02/2021
 10208 0000F73C 89C7                <1> 	mov	edi, eax
 10209 0000F73E 0FB705[86120300]    <1> 	movzx	eax, word [v_width]
 10210 0000F745 E858F0FFFF          <1> 	call	pixels_to_byte_count
 10211 0000F74A 01C7                <1> 	add	edi, eax ; next position
 10212 0000F74C EBA5                <1> 	jmp	short pix_op_chr_f2p_next
 10213                              <1> pix_op_chr_f2p_4:
 10214 0000F74E C3                  <1> 	retn
 10215                              <1> 
 10216                              <1> pix_op_chr_w_pixel:
 10217                              <1> 	; 15/02/2021
 10218 0000F74F 89C5                <1> 	mov	ebp, eax
 10219 0000F751 A1[9A120300]        <1> 	mov	eax, [maskcolor]
 10220 0000F756 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 10221 0000F75D 7711                <1> 	ja	short pix_op_chr_wp_2
 10222                              <1> 	; 256 colors (1 byte per pixel)
 10223 0000F75F D1E5                <1> 	shl	ebp, 1
 10224 0000F761 7302                <1> 	jnc	short pix_op_chr_wp_0
 10225 0000F763 8807                <1> 	mov	[edi], al
 10226                              <1> pix_op_chr_wp_0:
 10227 0000F765 47                  <1> 	inc	edi
 10228 0000F766 FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
 10229                              <1> pix_op_chr_wp_1:
 10230 0000F76C 43                  <1> 	inc	ebx
 10231 0000F76D 89E8                <1> 	mov	eax, ebp
 10232 0000F76F C3                  <1> 	retn
 10233                              <1> pix_op_chr_wp_2:
 10234 0000F770 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 10235 0000F777 772E                <1> 	ja	short pix_op_chr_wp_6 ; 32bpp
 10236 0000F779 721C                <1> 	jb	short pix_op_chr_wp_4 ; 16bpp
 10237                              <1> 	; 24 bit true colors
 10238                              <1> 	; * 3
 10239 0000F77B D1E5                <1> 	shl	ebp, 1
 10240 0000F77D 7309                <1> 	jnc	short pix_op_chr_wp_3
 10241 0000F77F 668907              <1> 	mov	[edi], ax
 10242 0000F782 C1E810              <1> 	shr	eax, 16
 10243 0000F785 884702              <1> 	mov	[edi+2], al
 10244                              <1> pix_op_chr_wp_3:
 10245 0000F788 B803000000          <1> 	mov	eax, 3 ; 27/02/2021 
 10246 0000F78D 01C7                <1> 	add	edi, eax  ; add edi, 3
 10247 0000F78F 0105[64030300]      <1> 	add	[u.r0], eax ; +3
 10248                              <1> 	
 10249 0000F795 EBD5                <1> 	jmp	short pix_op_chr_wp_1
 10250                              <1> 
 10251                              <1> pix_op_chr_wp_4:
 10252                              <1> 	; 16 bit (65536) colors
 10253 0000F797 D1E5                <1> 	shl	ebp, 1
 10254 0000F799 7303                <1> 	jnc	short pix_op_chr_wp_5
 10255 0000F79B 668907              <1> 	mov	[edi], ax
 10256                              <1> pix_op_chr_wp_5:
 10257 0000F79E 47                  <1> 	inc	edi
 10258 0000F79F FF05[64030300]      <1> 	inc	dword [u.r0] ; +1 
 10259 0000F7A5 EBBE                <1> 	jmp	short pix_op_chr_wp_0
 10260                              <1> 
 10261                              <1> pix_op_chr_wp_6:
 10262                              <1> 	; 32 bit true colors
 10263 0000F7A7 D1E5                <1> 	shl	ebp, 1
 10264 0000F7A9 7302                <1> 	jnc	short pix_op_chr_wp_7
 10265 0000F7AB 8907                <1> 	mov	[edi], eax
 10266                              <1> pix_op_chr_wp_7:
 10267 0000F7AD 31C0                <1> 	xor	eax, eax
 10268 0000F7AF B004                <1> 	mov	al, 4
 10269 0000F7B1 01C7                <1> 	add	edi, eax ; add edi, 4
 10270 0000F7B3 0105[64030300]      <1> 	add	[u.r0], eax ; +4
 10271 0000F7B9 EBB1                <1> 	jmp	short pix_op_chr_wp_1
 10272                              <1> 
 10273                              <1> m_pix_op_cpy:
 10274                              <1> 	; 26/02/2021
 10275                              <1> 	; 06/02/2021
 10276                              <1> 	; MASKED COPY PIXELS (full screen)
 10277                              <1> 	;
 10278                              <1> 	; jump from pix_op_cpy
 10279                              <1> 	;
 10280                              <1> 	; INPUT:
 10281                              <1> 	;   ecx = transfer count (bytes)
 10282                              <1> 	;   edi = [v_mem] = start address of LFB 
 10283                              <1> 	;   esi = user's buffer address (virtual)
 10284                              <1> 	;
 10285                              <1> 	; OUTPUT:
 10286                              <1> 	;   [u.r0] will be > 0 if succesful
 10287                              <1> 
 10288                              <1> 	; Full screen masked copy
 10289                              <1> 
 10290                              <1> 	; Modified regs: eax, ebx, edx, esi, edi, ecx
 10291                              <1> 
 10292                              <1> m_pix_op_cpy_0:
 10293                              <1> 	;push	ebx ; *** ; 26/02/2021
 10294 0000F7BB 57                  <1> 	push	edi ; **
 10295 0000F7BC 51                  <1> 	push	ecx ; *
 10296 0000F7BD 81F9F8070000        <1> 	cmp	ecx, 2040 ; (3*680) ; 26/02/2021
 10297 0000F7C3 7605                <1> 	jna	short m_pix_op_cpy_1
 10298 0000F7C5 B9F8070000          <1> 	mov	ecx, 2040
 10299                              <1> m_pix_op_cpy_1:
 10300 0000F7CA BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; temporary buff
 10301 0000F7CF E8DA230000          <1> 	call	transfer_from_user_buffer
 10302 0000F7D4 726C                <1> 	jc	short m_pix_op_cpy_3
 10303 0000F7D6 01CE                <1> 	add	esi, ecx
 10304 0000F7D8 89F5                <1> 	mov	ebp, esi  ; save user's buffer address
 10305 0000F7DA 89FE                <1> 	mov	esi, edi
 10306 0000F7DC 89CB                <1> 	mov	ebx, ecx
 10307 0000F7DE 59                  <1> 	pop	ecx ; *
 10308 0000F7DF 29D9                <1> 	sub	ecx, ebx
 10309 0000F7E1 5F                  <1> 	pop	edi ; **
 10310 0000F7E2 31D2                <1> 	xor	edx, edx ; 26/02/2021
 10311 0000F7E4 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8
 10312 0000F7EB 7435                <1> 	je	short m_pix_op_cpy_1_8
 10313 0000F7ED 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24
 10314 0000F7F4 776D                <1> 	ja	short m_pix_op_cpy_1_32
 10315 0000F7F6 724D                <1> 	jb	short m_pix_op_cpy_1_16
 10316                              <1> m_pix_op_cpy_1_24:
 10317                              <1> 	; 24 bit masked copy
 10318                              <1> 	;mov	edx, 3
 10319 0000F7F8 B203                <1> 	mov	dl, 3 ; 26/02/2021
 10320                              <1> m_pix_op_cpy_1_24_0:
 10321 0000F7FA 66AD                <1> 	lodsw
 10322 0000F7FC C1E010              <1> 	shl	eax, 16
 10323 0000F7FF AC                  <1> 	lodsb
 10324 0000F800 C1C010              <1> 	rol	eax, 16
 10325 0000F803 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 10326 0000F809 740F                <1> 	je	short m_pix_op_cpy_1_24_1 ; exclude
 10327 0000F80B 668907              <1> 	mov	[edi], ax
 10328 0000F80E C1E810              <1> 	shr	eax, 16
 10329 0000F811 884702              <1> 	mov	[edi+2], al
 10330 0000F814 0115[64030300]      <1> 	add	[u.r0], edx ; +3
 10331                              <1> m_pix_op_cpy_1_24_1:
 10332 0000F81A 01D7                <1> 	add	edi, edx ; +3
 10333 0000F81C 29D3                <1> 	sub	ebx, edx ; sub ebx, 3
 10334 0000F81E 77DA                <1> 	ja	short m_pix_op_cpy_1_24_0
 10335 0000F820 EB15                <1>  	jmp	short m_pix_op_cpy_2
 10336                              <1> 
 10337                              <1> m_pix_op_cpy_1_8:
 10338                              <1> 	; 8 bit masked copy
 10339 0000F822 AC                  <1> 	lodsb
 10340 0000F823 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
 10341 0000F829 7408                <1> 	je	short m_pix_op_cpy_1_8_1 ; exclude
 10342 0000F82B 8807                <1> 	mov	[edi], al
 10343 0000F82D FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
 10344                              <1> m_pix_op_cpy_1_8_1:
 10345 0000F833 47                  <1> 	inc	edi ; +1
 10346 0000F834 4B                  <1> 	dec	ebx 	
 10347 0000F835 75EB                <1> 	jnz	short m_pix_op_cpy_1_8
 10348                              <1> m_pix_op_cpy_2:
 10349 0000F837 89EE                <1> 	mov	esi, ebp ; restore user's buffer addr
 10350 0000F839 09C9                <1> 	or	ecx, ecx
 10351                              <1> 	; 26/02/2021
 10352 0000F83B 7407                <1> 	jz	short m_pix_of_cpy_4
 10353 0000F83D E979FFFFFF          <1> 	jmp	m_pix_op_cpy_0
 10354                              <1> m_pix_op_cpy_3:
 10355 0000F842 59                  <1> 	pop	ecx ; *
 10356 0000F843 5F                  <1> 	pop	edi ; **
 10357                              <1> m_pix_of_cpy_4:
 10358                              <1> 	;pop	ebx ; *** ; 26/02/2021 
 10359 0000F844 C3                  <1> 	retn
 10360                              <1> 
 10361                              <1> m_pix_op_cpy_1_16:
 10362                              <1> 	; 16 bit masked copy
 10363                              <1> 	;mov	edx, 2
 10364 0000F845 B202                <1> 	mov	dl, 2 ; 26/02/2021
 10365                              <1> m_pix_op_cpy_1_16_0:
 10366 0000F847 66AD                <1> 	lodsw
 10367 0000F849 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
 10368 0000F850 7409                <1> 	je	short m_pix_op_cpy_1_16_1 ; exclude
 10369 0000F852 668907              <1> 	mov	[edi], ax
 10370 0000F855 0115[64030300]      <1> 	add	[u.r0], edx ; +2
 10371                              <1> m_pix_op_cpy_1_16_1:
 10372 0000F85B 01D7                <1> 	add	edi, edx ; +2
 10373 0000F85D 29D3                <1> 	sub	ebx, edx ; sub ebx, 2
 10374 0000F85F 77E6                <1> 	ja	short m_pix_op_cpy_1_16_0
 10375 0000F861 EBD4                <1>  	jmp	short m_pix_op_cpy_2
 10376                              <1> 
 10377                              <1> m_pix_op_cpy_1_32:
 10378                              <1> 	; 32 bit masked copy
 10379                              <1> 	;mov	edx, 4
 10380 0000F863 B204                <1> 	mov	dl, 4 ; 26/02/2021
 10381                              <1> m_pix_op_cpy_1_32_0:
 10382 0000F865 AD                  <1> 	lodsd
 10383 0000F866 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 10384 0000F86C 7408                <1> 	je	short m_pix_op_cpy_1_32_1 ; exclude
 10385 0000F86E 8907                <1> 	mov	[edi], eax
 10386 0000F870 0115[64030300]      <1> 	add	[u.r0], edx ; +4
 10387                              <1> m_pix_op_cpy_1_32_1:
 10388 0000F876 01D7                <1> 	add	edi, edx ; +4
 10389 0000F878 29D3                <1> 	sub	ebx, edx ; sub ebx, 4
 10390 0000F87A 77E9                <1> 	ja	short m_pix_op_cpy_1_32_0
 10391 0000F87C EBB9                <1>  	jmp	short m_pix_op_cpy_2
 10392                              <1> 	
 10393                              <1> m_pix_op_cpy_w:
 10394                              <1> 	; 26/02/2021
 10395                              <1> 	; 06/02/2021
 10396                              <1> 	; MASKED COPY PIXELS (window)
 10397                              <1> 	;
 10398                              <1> 	; jump from pix_op_cpy_w
 10399                              <1> 	;
 10400                              <1> 	; INPUT:
 10401                              <1> 	;   ecx = bytes per row (to be applied)
 10402                              <1> 	;   edx = screen width in bytes
 10403                              <1> 	;   ebx = row count
 10404                              <1> 	;   esi = user's buffer address
 10405                              <1> 	;   [v_str] = window start address
 10406                              <1> 	;
 10407                              <1> 	; OUTPUT:
 10408                              <1> 	;   [u.r0] will be > 0 if succesful
 10409                              <1> 
 10410                              <1> 	; Window masked copy
 10411                              <1> 
 10412                              <1> m_pix_op_cpy_w_0:
 10413 0000F87E 8B3D[92120300]      <1> 	mov	edi, [v_str]
 10414                              <1> m_pix_op_cpy_w_1:
 10415 0000F884 57                  <1> 	push	edi
 10416 0000F885 56                  <1> 	push	esi
 10417 0000F886 53                  <1> 	push	ebx
 10418 0000F887 52                  <1> 	push	edx
 10419 0000F888 51                  <1> 	push	ecx
 10420 0000F889 E82DFFFFFF          <1> 	call	m_pix_op_cpy ; 26/02/2021
 10421 0000F88E 59                  <1> 	pop	ecx
 10422 0000F88F 5A                  <1> 	pop	edx
 10423 0000F890 5B                  <1> 	pop	ebx
 10424 0000F891 5E                  <1> 	pop	esi
 10425 0000F892 5F                  <1> 	pop	edi
 10426 0000F893 7209                <1> 	jc	short m_pix_op_cpy_w_2
 10427 0000F895 4B                  <1> 	dec	ebx
 10428 0000F896 7406                <1> 	jz	short m_pix_op_cpy_w_2 ; ok.
 10429                              <1> 	; next row
 10430 0000F898 01CE                <1> 	add	esi, ecx ; next row in user's buffer
 10431 0000F89A 01D7                <1> 	add	edi, edx ; next row of window (system)
 10432 0000F89C EBE6                <1> 	jmp	short m_pix_op_cpy_w_1
 10433                              <1> m_pix_op_cpy_w_2:
 10434 0000F89E C3                  <1> 	retn
 10435                              <1> 
 10436                              <1> m_pix_op_new:
 10437                              <1> 	; 06/02/2021
 10438                              <1> 	; CHANGE COLOR (MASKED, full screen)
 10439                              <1> 	;
 10440                              <1> 	; jump from pix_op_new
 10441                              <1> 	;
 10442                              <1> 	; INPUT:
 10443                              <1> 	;   eax = color (AL, AX, EAX)
 10444                              <1> 	;   ecx = [v_siz] ; display page pixel count
 10445                              <1> 	;   esi = edi = [v_mem] ; LFB start address
 10446                              <1> 	;
 10447                              <1> 	;   [maskcolor] = mask color (to be excluded)
 10448                              <1> 	;
 10449                              <1> 	; OUTPUT:
 10450                              <1> 	; 	[u.r0] will be > 0 if succesful
 10451                              <1> 	
 10452                              <1> 	; Full screen
 10453                              <1> m_pix_op_new_0:
 10454 0000F89F 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 10455 0000F8A6 7717                <1> 	ja	short m_pix_op_new_1
 10456                              <1> 	; 256 colors (8bpp)
 10457                              <1> 	;jmp	short m_pix_op_new_8
 10458                              <1> m_pix_op_new_8:
 10459                              <1> 	; 8 bit colors (256 colors)
 10460 0000F8A8 88C2                <1> 	mov	dl, al ; new color
 10461                              <1> m_pix_op_new_8_0:
 10462 0000F8AA AC                  <1> 	lodsb 
 10463 0000F8AB 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
 10464 0000F8B1 7408                <1> 	je	short m_pix_op_new_8_1 ; exclude
 10465 0000F8B3 8817                <1> 	mov	[edi], dl
 10466 0000F8B5 FF05[64030300]      <1> 	inc	dword [u.r0]
 10467                              <1> m_pix_op_new_8_1:
 10468 0000F8BB 47                  <1> 	inc	edi
 10469 0000F8BC E2EC                <1> 	loop	m_pix_op_new_8_0
 10470 0000F8BE C3                  <1> 	retn
 10471                              <1> m_pix_op_new_1:
 10472 0000F8BF 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 10473 0000F8C6 774B                <1> 	ja	short m_pix_op_new_3 ; 32bpp	
 10474 0000F8C8 722C                <1> 	jb	short m_pix_op_new_2 ; 16bpp
 10475                              <1> 	; 24 bit true colors
 10476                              <1> 	;jmp	short m_pix_op_new_24
 10477                              <1> m_pix_op_new_24:
 10478                              <1> 	; 24 bit true colors
 10479 0000F8CA 89C2                <1> 	mov	edx, eax ; new color
 10480                              <1> m_pix_op_new_24_0:
 10481 0000F8CC 66AD                <1> 	lodsw
 10482 0000F8CE C1E010              <1> 	shl	eax, 16
 10483 0000F8D1 AC                  <1> 	lodsb
 10484 0000F8D2 C1C010              <1> 	rol	eax, 16	
 10485 0000F8D5 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 10486 0000F8DB 7413                <1> 	je	short m_pix_op_new_24_1 ; exclude
 10487 0000F8DD 668917              <1> 	mov	[edi], dx
 10488 0000F8E0 C1CA10              <1> 	ror	edx, 16
 10489 0000F8E3 885702              <1> 	mov	[edi+2], dl
 10490 0000F8E6 C1C210              <1> 	rol	edx, 16
 10491 0000F8E9 8305[64030300]03    <1> 	add	dword [u.r0], 3
 10492                              <1> m_pix_op_new_24_1:
 10493 0000F8F0 83C703              <1> 	add	edi, 3
 10494 0000F8F3 E2D7                <1> 	loop	m_pix_op_new_24_0
 10495 0000F8F5 C3                  <1> 	retn
 10496                              <1> 	; 65536 colors (16bpp)
 10497                              <1> m_pix_op_new_2:
 10498                              <1> 	;jmp	short m_pix_op_new_16
 10499                              <1> m_pix_op_new_16:
 10500                              <1> 	; 16 bit colors (65536 colors)
 10501 0000F8F6 89C2                <1> 	mov	edx, eax ; new color
 10502                              <1> m_pix_op_new_16_0:
 10503 0000F8F8 66AD                <1> 	lodsw
 10504 0000F8FA 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
 10505 0000F901 740A                <1> 	je	short m_pix_op_new_16_1 ; exclude
 10506 0000F903 668917              <1> 	mov	[edi], dx
 10507 0000F906 8305[64030300]02    <1> 	add	dword [u.r0], 2
 10508                              <1> m_pix_op_new_16_1:
 10509 0000F90D 83C702              <1> 	add	edi, 2
 10510 0000F910 E2E6                <1> 	loop	m_pix_op_new_16_0
 10511 0000F912 C3                  <1> 	retn
 10512                              <1> m_pix_op_new_3:
 10513                              <1> 	; 32 bit true colors
 10514                              <1> 	;jmp	short m_pix_op_new_32
 10515                              <1> m_pix_op_new_32:
 10516                              <1> 	; 32 bit true colors
 10517 0000F913 89C2                <1> 	mov	edx, eax ; new color
 10518                              <1> m_pix_op_new_32_0:
 10519 0000F915 AD                  <1> 	lodsd 
 10520 0000F916 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 10521 0000F91C 7409                <1> 	je	short m_pix_op_new_32_1 ; exclude
 10522 0000F91E 8917                <1> 	mov	[edi], edx
 10523 0000F920 8305[64030300]04    <1> 	add	dword [u.r0], 4
 10524                              <1> m_pix_op_new_32_1:
 10525 0000F927 83C704              <1> 	add	edi, 4
 10526 0000F92A E2E9                <1> 	loop	m_pix_op_new_32_0
 10527 0000F92C C3                  <1> 	retn
 10528                              <1> 
 10529                              <1> m_pix_op_new_w:
 10530                              <1> 	; 06/02/2021
 10531                              <1> 	; CHANGE COLOR (MASKED, window)
 10532                              <1> 	;
 10533                              <1> 	; jump from pix_op_new_w
 10534                              <1> 	;
 10535                              <1> 	; INPUT:
 10536                              <1> 	;   ecx = bytes per row (to be applied)
 10537                              <1> 	;   edx = screen width in bytes
 10538                              <1> 	;   ebx = row count
 10539                              <1> 	;   eax = color
 10540                              <1> 	;
 10541                              <1> 	;   [maskcolor] = mask color (to be excluded)
 10542                              <1> 	;
 10543                              <1> 	; OUTPUT:
 10544                              <1> 	; 	[u.r0] will be > 0 if succesful
 10545                              <1> 
 10546                              <1> 	; Window
 10547                              <1> 	;mov	edi, [v_str] ; LFB start address
 10548                              <1> 	;mov	esi, edi 
 10549                              <1> 
 10550 0000F92D 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 10551 0000F934 7707                <1> 	ja	short m_pix_op_new_w_1
 10552                              <1> 
 10553                              <1> 	; 256 colors (8bpp)
 10554 0000F936 BD[A8F80000]        <1> 	mov	ebp, m_pix_op_new_8
 10555 0000F93B EB1E                <1> 	jmp	short m_pix_op_new_w_x
 10556                              <1> 			
 10557                              <1> m_pix_op_new_w_1:
 10558 0000F93D 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 10559 0000F944 7710                <1> 	ja	short m_pix_op_new_w_3 ; 32bpp
 10560 0000F946 7207                <1> 	jb	short m_pix_op_new_w_2 ; 16bpp
 10561                              <1> 
 10562                              <1> 	; 24 bit true colors
 10563 0000F948 BD[CAF80000]        <1> 	mov	ebp, m_pix_op_new_24
 10564 0000F94D EB0C                <1> 	jmp	short m_pix_op_new_w_x
 10565                              <1> 
 10566                              <1> 	; 65536 colors (16bpp)
 10567                              <1> m_pix_op_new_w_2:
 10568 0000F94F BD[F6F80000]        <1> 	mov	ebp, m_pix_op_new_16
 10569 0000F954 EB05                <1> 	jmp	short m_pix_op_new_w_x
 10570                              <1> 
 10571                              <1> 	; 32 bit true colors
 10572                              <1> m_pix_op_new_w_3:
 10573 0000F956 BD[13F90000]        <1> 	mov	ebp, m_pix_op_new_32
 10574                              <1> 	;jmp	short m_pix_op_new_w_x
 10575                              <1> 
 10576                              <1> m_pix_op_new_w_x:
 10577                              <1> m_pix_op_add_w_x:
 10578                              <1> m_pix_op_sub_w_x:
 10579                              <1> m_pix_op_mix_w_x:
 10580                              <1> m_pix_op_and_w_x:
 10581                              <1> m_pix_op_orc_w_x:
 10582                              <1> m_pix_op_xor_w_x:
 10583                              <1> m_pix_op_not_w_x:
 10584                              <1> m_pix_op_neg_w_x:
 10585                              <1> m_pix_op_inc_w_x:
 10586                              <1> m_pix_op_dec_w_x:
 10587                              <1> 	; 27/02/2021
 10588                              <1> 	; 26/02/2021
 10589                              <1> 	; 06/02/2021
 10590                              <1> 	; ecx = bytes per row (to be applied)
 10591                              <1> 	; edx = windows (screen) width in bytes
 10592                              <1> 	; ebx = row count
 10593                              <1> 	; eax = color
 10594                              <1> 	; ebp = pixel operation subroutine address
 10595                              <1> 	; edi = esi = window start address
 10596                              <1> 
 10597 0000F95B 8B3D[92120300]      <1> 	mov	edi, [v_str] ; LFB start address
 10598 0000F961 89FE                <1> 	mov	esi, edi
 10599                              <1> m_pix_op_w_x_next:
 10600 0000F963 52                  <1> 	push	edx
 10601 0000F964 51                  <1> 	push	ecx
 10602 0000F965 56                  <1> 	push	esi
 10603 0000F966 57                  <1> 	push	edi
 10604 0000F967 50                  <1> 	push	eax ; 26/02/2021
 10605 0000F968 8B0D[9E120300]      <1> 	mov	ecx, [pixcount] ; 27/02/2021  
 10606 0000F96E FFD5                <1> 	call	ebp ; call masked pixel-row operation
 10607 0000F970 58                  <1> 	pop	eax ; 26/02/2021
 10608 0000F971 5F                  <1> 	pop	edi
 10609 0000F972 5E                  <1> 	pop	esi
 10610 0000F973 59                  <1> 	pop	ecx
 10611 0000F974 5A                  <1> 	pop	edx
 10612 0000F975 01D6                <1> 	add	esi, edx ; next row
 10613 0000F977 01D7                <1> 	add	edi, edx ; next row
 10614 0000F979 4B                  <1> 	dec	ebx
 10615 0000F97A 75E7                <1> 	jnz	short m_pix_op_w_x_next
 10616 0000F97C C3                  <1> 	retn
 10617                              <1> 
 10618                              <1> m_pix_op_add:
 10619                              <1> 	; 06/02/2021
 10620                              <1> 	; ADD COLOR (MASKED, full screen)
 10621                              <1> 	;
 10622                              <1> 	; jump from pix_op_add
 10623                              <1> 	;
 10624                              <1> 	; INPUT:
 10625                              <1> 	;   eax = color (AL, AX, EAX)
 10626                              <1> 	;   ecx = [v_siz] ; display page pixel count
 10627                              <1> 	;   esi = edi = [v_mem] ; LFB start address
 10628                              <1> 	;
 10629                              <1> 	;   [maskcolor] = mask color (to be excluded)
 10630                              <1> 	;
 10631                              <1> 	; OUTPUT:
 10632                              <1> 	; 	[u.r0] will be > 0 if succesful
 10633                              <1> 	
 10634                              <1> 	; Full screen
 10635                              <1> m_pix_op_add_0:
 10636 0000F97D 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 10637 0000F984 771C                <1> 	ja	short m_pix_op_add_1
 10638                              <1> 	; 256 colors (8bpp)
 10639                              <1> 	;jmp	short m_pix_op_add_8
 10640                              <1> m_pix_op_add_8:
 10641                              <1> 	; 8 bit colors (256 colors)
 10642 0000F986 88C2                <1> 	mov	dl, al ; new color
 10643                              <1> m_pix_op_add_8_0:
 10644 0000F988 AC                  <1> 	lodsb 
 10645 0000F989 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
 10646 0000F98F 740D                <1> 	je	short m_pix_op_add_8_1 ; exclude
 10647 0000F991 FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
 10648 0000F997 0017                <1> 	add	[edi], dl
 10649 0000F999 7303                <1> 	jnc	short m_pix_op_add_8_1
 10650 0000F99B C607FF              <1> 	mov	byte [edi], 0FFh 
 10651                              <1> m_pix_op_add_8_1:
 10652 0000F99E 47                  <1> 	inc	edi
 10653 0000F99F E2E7                <1> 	loop	m_pix_op_add_8_0
 10654 0000F9A1 C3                  <1> 	retn
 10655                              <1> m_pix_op_add_1:
 10656 0000F9A2 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 10657 0000F9A9 775E                <1> 	ja	short m_pix_op_add_3 ; 32bpp	
 10658 0000F9AB 7238                <1> 	jb	short m_pix_op_add_2 ; 16bpp
 10659                              <1> 	; 24 bit true colors
 10660                              <1> 	;jmp	short m_pix_op_add_24
 10661                              <1> m_pix_op_add_24:
 10662                              <1> 	; 24 bit true colors
 10663 0000F9AD 89C2                <1> 	mov	edx, eax ; new color
 10664 0000F9AF 81CA000000FF        <1> 	or	edx, 0FF000000h
 10665                              <1> m_pix_op_add_24_0:
 10666 0000F9B5 66AD                <1> 	lodsw
 10667 0000F9B7 C1E010              <1> 	shl	eax, 16
 10668 0000F9BA AC                  <1> 	lodsb
 10669 0000F9BB C1C010              <1> 	rol	eax, 16	
 10670 0000F9BE 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 10671 0000F9C4 7419                <1> 	je	short m_pix_op_add_24_2 ; exclude
 10672 0000F9C6 8305[64030300]03    <1> 	add	dword [u.r0], 3 ; +3
 10673 0000F9CD 01D0                <1> 	add	eax, edx
 10674 0000F9CF 7305                <1> 	jnc	short m_pix_op_add_24_1
 10675 0000F9D1 B8FFFFFF00          <1> 	mov	eax, 0FFFFFFh
 10676                              <1> m_pix_op_add_24_1:	
 10677 0000F9D6 668907              <1> 	mov	[edi], ax
 10678 0000F9D9 C1E810              <1> 	shr	eax, 16
 10679 0000F9DC 884702              <1> 	mov	[edi+2], al
 10680                              <1> m_pix_op_add_24_2:
 10681 0000F9DF 83C703              <1> 	add	edi, 3 ; +3
 10682 0000F9E2 E2D1                <1> 	loop	m_pix_op_add_24_0
 10683 0000F9E4 C3                  <1> 	retn
 10684                              <1> 	; 65536 colors (16bpp)
 10685                              <1> m_pix_op_add_2:
 10686                              <1> 	;jmp	short m_pix_op_add_16
 10687                              <1> m_pix_op_add_16:
 10688                              <1> 	; 16 bit colors (65536 colors)
 10689 0000F9E5 89C2                <1> 	mov	edx, eax ; new color
 10690                              <1> m_pix_op_add_16_0:
 10691 0000F9E7 66AD                <1> 	lodsw
 10692 0000F9E9 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
 10693 0000F9F0 7411                <1> 	je	short m_pix_op_add_16_1 ; exclude
 10694 0000F9F2 8305[64030300]02    <1> 	add	dword [u.r0], 2 ; +2
 10695 0000F9F9 660117              <1> 	add	[edi], dx
 10696 0000F9FC 7305                <1> 	jnc	short m_pix_op_add_16_1
 10697 0000F9FE 66C707FFFF          <1> 	mov	word [edi], 0FFFFh
 10698                              <1> m_pix_op_add_16_1:
 10699 0000FA03 83C702              <1> 	add	edi, 2 ; +2
 10700 0000FA06 E2DF                <1> 	loop	m_pix_op_add_16_0
 10701 0000FA08 C3                  <1> 	retn
 10702                              <1> m_pix_op_add_3:
 10703                              <1> 	; 32 bit true colors
 10704                              <1> 	;jmp	short m_pix_op_add_32
 10705                              <1> m_pix_op_add_32:
 10706                              <1> 	; 32 bit true colors
 10707 0000FA09 89C2                <1> 	mov	edx, eax ; new color
 10708                              <1> m_pix_op_add_32_0:
 10709 0000FA0B AD                  <1> 	lodsd 
 10710 0000FA0C 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 10711 0000FA12 7411                <1> 	je	short m_pix_op_add_32_1 ; exclude
 10712 0000FA14 8305[64030300]04    <1> 	add	dword [u.r0], 4 ; +4
 10713 0000FA1B 0117                <1> 	add	[edi], edx
 10714 0000FA1D 7306                <1> 	jnc	short m_pix_op_add_32_1
 10715 0000FA1F C707FFFFFFFF        <1> 	mov	dword [edi], 0FFFFFFFFh
 10716                              <1> m_pix_op_add_32_1:
 10717 0000FA25 83C704              <1> 	add	edi, 4 ; +4
 10718 0000FA28 E2E1                <1> 	loop	m_pix_op_add_32_0
 10719 0000FA2A C3                  <1> 	retn
 10720                              <1> 
 10721                              <1> m_pix_op_add_w:
 10722                              <1> 	; 06/02/2021
 10723                              <1> 	; ADD COLOR (MASKED, window)
 10724                              <1> 	;
 10725                              <1> 	; jump from pix_op_add_w
 10726                              <1> 	;
 10727                              <1> 	; INPUT:
 10728                              <1> 	;   ecx = bytes per row (to be applied)
 10729                              <1> 	;   edx = screen width in bytes
 10730                              <1> 	;   ebx = row count
 10731                              <1> 	;   eax = color
 10732                              <1> 	;
 10733                              <1> 	;   [maskcolor] = mask color (to be excluded)
 10734                              <1> 	;
 10735                              <1> 	; OUTPUT:
 10736                              <1> 	; 	[u.r0] will be > 0 if succesful
 10737                              <1> 
 10738                              <1> 	; window
 10739                              <1> 	;mov	edi, [v_str] ; LFB start address
 10740                              <1> 	;mov	esi, edi 
 10741                              <1> 
 10742 0000FA2B 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 10743 0000FA32 7707                <1> 	ja	short m_pix_op_add_w_1
 10744                              <1> 
 10745                              <1> 	; 256 colors (8bpp)
 10746 0000FA34 BD[86F90000]        <1> 	mov	ebp, m_pix_op_add_8
 10747 0000FA39 EB1E                <1> 	jmp	short m_pix_op_add_w_4
 10748                              <1> 			
 10749                              <1> m_pix_op_add_w_1:
 10750 0000FA3B 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 10751 0000FA42 7710                <1> 	ja	short m_pix_op_add_w_3 ; 32bpp
 10752 0000FA44 7207                <1> 	jb	short m_pix_op_add_w_2 ; 16bpp
 10753                              <1> 
 10754                              <1> 	; 24 bit true colors
 10755 0000FA46 BD[ADF90000]        <1> 	mov	ebp, m_pix_op_add_24
 10756 0000FA4B EB0C                <1> 	jmp	short m_pix_op_add_w_4
 10757                              <1> 
 10758                              <1> 	; 65536 colors (16bpp)
 10759                              <1> m_pix_op_add_w_2:
 10760 0000FA4D BD[E5F90000]        <1> 	mov	ebp, m_pix_op_add_16
 10761 0000FA52 EB05                <1> 	jmp	short m_pix_op_add_w_4
 10762                              <1> 
 10763                              <1> 	; 32 bit true colors
 10764                              <1> m_pix_op_add_w_3:
 10765 0000FA54 BD[09FA0000]        <1> 	mov	ebp, m_pix_op_add_32
 10766                              <1> m_pix_op_add_w_4:
 10767 0000FA59 E9FDFEFFFF          <1> 	jmp	m_pix_op_add_w_x
 10768                              <1> 
 10769                              <1> m_pix_op_sub:
 10770                              <1> 	; 02/03/2021
 10771                              <1> 	; 06/02/2021
 10772                              <1> 	; SUBTRACT COLOR (MASKED, full screen)
 10773                              <1> 	;
 10774                              <1> 	; jump from pix_op_sub
 10775                              <1> 	;
 10776                              <1> 	; INPUT:
 10777                              <1> 	;   eax = color (AL, AX, EAX)
 10778                              <1> 	;   ecx = [v_siz] ; display page pixel count
 10779                              <1> 	;   esi = edi = [v_mem] ; LFB start address
 10780                              <1> 	;
 10781                              <1> 	;   [maskcolor] = mask color (to be excluded)
 10782                              <1> 	;
 10783                              <1> 	; OUTPUT:
 10784                              <1> 	; 	[u.r0] will be > 0 if succesful
 10785                              <1> 	
 10786                              <1> 	; Full screen
 10787                              <1> m_pix_op_sub_0:
 10788 0000FA5E 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 10789 0000FA65 771C                <1> 	ja	short m_pix_op_sub_1
 10790                              <1> 	; 256 colors (8bpp)
 10791                              <1> 	;jmp	short m_pix_op_sub_8
 10792                              <1> m_pix_op_sub_8:
 10793                              <1> 	; 8 bit colors (256 colors)
 10794 0000FA67 88C2                <1> 	mov	dl, al ; new color
 10795                              <1> m_pix_op_sub_8_0:
 10796 0000FA69 AC                  <1> 	lodsb 
 10797 0000FA6A 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
 10798 0000FA70 740D                <1> 	je	short m_pix_op_sub_8_1 ; exclude
 10799 0000FA72 FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
 10800 0000FA78 2817                <1> 	sub	[edi], dl
 10801 0000FA7A 7303                <1> 	jnb	short m_pix_op_sub_8_1
 10802 0000FA7C C60700              <1> 	mov	byte [edi], 0 
 10803                              <1> m_pix_op_sub_8_1:
 10804 0000FA7F 47                  <1> 	inc	edi
 10805 0000FA80 E2E7                <1> 	loop	m_pix_op_sub_8_0
 10806 0000FA82 C3                  <1> 	retn
 10807                              <1> m_pix_op_sub_1:
 10808 0000FA83 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 10809 0000FA8A 7755                <1> 	ja	short m_pix_op_sub_3 ; 32bpp	
 10810 0000FA8C 722F                <1> 	jb	short m_pix_op_sub_2 ; 16bpp
 10811                              <1> 	; 24 bit true colors
 10812                              <1> 	;jmp	short m_pix_op_sub_24
 10813                              <1> m_pix_op_sub_24:
 10814                              <1> 	; 24 bit true colors
 10815 0000FA8E 89C2                <1> 	mov	edx, eax ; new color
 10816                              <1> 	; 02/03/2021
 10817                              <1> m_pix_op_sub_24_0:
 10818 0000FA90 66AD                <1> 	lodsw
 10819 0000FA92 C1E010              <1> 	shl	eax, 16
 10820 0000FA95 AC                  <1> 	lodsb
 10821 0000FA96 C1C010              <1> 	rol	eax, 16	
 10822 0000FA99 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 10823 0000FA9F 7416                <1> 	je	short m_pix_op_sub_24_2 ; exclude
 10824 0000FAA1 8305[64030300]03    <1> 	add	dword [u.r0], 3 ; +3
 10825 0000FAA8 29D0                <1> 	sub	eax, edx
 10826 0000FAAA 7302                <1> 	jnb	short m_pix_op_sub_24_1
 10827 0000FAAC 31C0                <1> 	xor	eax, eax ; 0
 10828                              <1> m_pix_op_sub_24_1:	
 10829 0000FAAE 668907              <1> 	mov	[edi], ax
 10830 0000FAB1 C1E810              <1> 	shr	eax, 16
 10831 0000FAB4 884702              <1> 	mov	[edi+2], al
 10832                              <1> m_pix_op_sub_24_2:
 10833 0000FAB7 83C703              <1> 	add	edi, 3 ; +3
 10834 0000FABA E2D4                <1> 	loop	m_pix_op_sub_24_0
 10835 0000FABC C3                  <1> 	retn
 10836                              <1> 	; 65536 colors (16bpp)
 10837                              <1> m_pix_op_sub_2:
 10838                              <1> 	;jmp	short m_pix_op_sub_16
 10839                              <1> m_pix_op_sub_16:
 10840                              <1> 	; 16 bit colors (65536 colors)
 10841 0000FABD 89C2                <1> 	mov	edx, eax ; new color
 10842                              <1> m_pix_op_sub_16_0:
 10843 0000FABF 66AD                <1> 	lodsw
 10844 0000FAC1 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
 10845 0000FAC8 7411                <1> 	je	short m_pix_op_sub_16_1 ; exclude
 10846 0000FACA 8305[64030300]02    <1> 	add	dword [u.r0], 2 ; +2
 10847 0000FAD1 662917              <1> 	sub	[edi], dx
 10848 0000FAD4 7305                <1> 	jnb	short m_pix_op_sub_16_1
 10849 0000FAD6 31C0                <1> 	xor	eax, eax
 10850 0000FAD8 668907              <1> 	mov	[edi], ax ; 0
 10851                              <1> m_pix_op_sub_16_1:
 10852 0000FADB 83C702              <1> 	add	edi, 2 ; +2
 10853 0000FADE E2DF                <1> 	loop	m_pix_op_sub_16_0
 10854 0000FAE0 C3                  <1> 	retn
 10855                              <1> m_pix_op_sub_3:
 10856                              <1> 	; 32 bit true colors
 10857                              <1> 	;jmp	short m_pix_op_sub_32
 10858                              <1> m_pix_op_sub_32:
 10859                              <1> 	; 32 bit true colors
 10860 0000FAE1 89C2                <1> 	mov	edx, eax ; new color
 10861                              <1> m_pix_op_sub_32_0:
 10862 0000FAE3 AD                  <1> 	lodsd 
 10863 0000FAE4 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 10864 0000FAEA 740F                <1> 	je	short m_pix_op_sub_32_1 ; exclude
 10865 0000FAEC 8305[64030300]04    <1> 	add	dword [u.r0], 4 ; +4
 10866 0000FAF3 2917                <1> 	sub	[edi], edx
 10867 0000FAF5 7304                <1> 	jnb	short m_pix_op_sub_32_1
 10868 0000FAF7 31C0                <1> 	xor	eax, eax
 10869 0000FAF9 8907                <1> 	mov	[edi], eax ; 0
 10870                              <1> m_pix_op_sub_32_1:
 10871 0000FAFB 83C704              <1> 	add	edi, 4 ; +4
 10872 0000FAFE E2E3                <1> 	loop	m_pix_op_sub_32_0
 10873 0000FB00 C3                  <1> 	retn
 10874                              <1> 
 10875                              <1> m_pix_op_sub_w:
 10876                              <1> 	; 06/02/2021
 10877                              <1> 	; SUBTRACT COLOR (MASKED, window)
 10878                              <1> 	;
 10879                              <1> 	; jump from pix_op_sub_w
 10880                              <1> 	;
 10881                              <1> 	; INPUT:
 10882                              <1> 	;   ecx = bytes per row (to be applied)
 10883                              <1> 	;   edx = screen width in bytes
 10884                              <1> 	;   ebx = row count
 10885                              <1> 	;   eax = color
 10886                              <1> 	;
 10887                              <1> 	;   [maskcolor] = mask color (to be excluded)
 10888                              <1> 	;
 10889                              <1> 	; OUTPUT:
 10890                              <1> 	; 	[u.r0] will be > 0 if succesful
 10891                              <1> 
 10892                              <1> 	; window
 10893                              <1> 	;mov	edi, [v_str] ; LFB start address
 10894                              <1> 	;mov	esi, edi 
 10895                              <1> 
 10896 0000FB01 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 10897 0000FB08 7707                <1> 	ja	short m_pix_op_sub_w_1
 10898                              <1> 
 10899                              <1> 	; 256 colors (8bpp)
 10900 0000FB0A BD[67FA0000]        <1> 	mov	ebp, m_pix_op_sub_8
 10901 0000FB0F EB1E                <1> 	jmp	short m_pix_op_sub_w_4
 10902                              <1> 			
 10903                              <1> m_pix_op_sub_w_1:
 10904 0000FB11 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 10905 0000FB18 7710                <1> 	ja	short m_pix_op_sub_w_3 ; 32bpp
 10906 0000FB1A 7207                <1> 	jb	short m_pix_op_sub_w_2 ; 16bpp
 10907                              <1> 
 10908                              <1> 	; 24 bit true colors
 10909 0000FB1C BD[8EFA0000]        <1> 	mov	ebp, m_pix_op_sub_24
 10910 0000FB21 EB0C                <1> 	jmp	short m_pix_op_sub_w_4
 10911                              <1> 
 10912                              <1> 	; 65536 colors (16bpp)
 10913                              <1> m_pix_op_sub_w_2:
 10914 0000FB23 BD[BDFA0000]        <1> 	mov	ebp, m_pix_op_sub_16
 10915 0000FB28 EB05                <1> 	jmp	short m_pix_op_sub_w_4
 10916                              <1> 
 10917                              <1> 	; 32 bit true colors
 10918                              <1> m_pix_op_sub_w_3:
 10919 0000FB2A BD[E1FA0000]        <1> 	mov	ebp, m_pix_op_sub_32
 10920                              <1> m_pix_op_sub_w_4:
 10921 0000FB2F E927FEFFFF          <1> 	jmp	m_pix_op_sub_w_x
 10922                              <1> 
 10923                              <1> m_pix_op_mix:
 10924                              <1> 	; 25/02/2021
 10925                              <1> 	; 06/02/2021
 10926                              <1> 	; MIX COLOR (MASKED, full screen)
 10927                              <1> 	;
 10928                              <1> 	; jump from pix_op_mix
 10929                              <1> 	;
 10930                              <1> 	; INPUT:
 10931                              <1> 	;   eax = color (AL, AX, EAX)
 10932                              <1> 	;   ecx = [v_siz] ; display page pixel count
 10933                              <1> 	;   esi = edi = [v_mem] ; LFB start address
 10934                              <1> 	;
 10935                              <1> 	;   [maskcolor] = mask color (to be excluded)
 10936                              <1> 	;
 10937                              <1> 	; OUTPUT:
 10938                              <1> 	; 	[u.r0] will be > 0 if succesful
 10939                              <1> 	
 10940                              <1> 	; Full screen
 10941                              <1> m_pix_op_mix_0:
 10942 0000FB34 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 10943 0000FB3B 771B                <1> 	ja	short m_pix_op_mix_1
 10944                              <1> 	; 256 colors (8bpp)
 10945                              <1> 	;jmp	short m_pix_op_mix_8
 10946                              <1> m_pix_op_mix_8:
 10947                              <1> 	; 8 bit colors (256 colors)
 10948 0000FB3D 88C2                <1> 	mov	dl, al ; new (mixing) color
 10949                              <1> m_pix_op_mix_8_0:
 10950 0000FB3F AC                  <1> 	lodsb 
 10951 0000FB40 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
 10952 0000FB46 740C                <1> 	je	short m_pix_op_mix_8_1 ; exclude
 10953 0000FB48 00D0                <1> 	add	al, dl ; 25/02/2021
 10954 0000FB4A D0D8                <1> 	rcr	al, 1	
 10955 0000FB4C 8807                <1> 	mov	[edi], al
 10956 0000FB4E FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
 10957                              <1> m_pix_op_mix_8_1:
 10958 0000FB54 47                  <1> 	inc	edi
 10959 0000FB55 E2E8                <1> 	loop	m_pix_op_mix_8_0
 10960 0000FB57 C3                  <1> 	retn
 10961                              <1> m_pix_op_mix_1:
 10962 0000FB58 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 10963 0000FB5F 7752                <1> 	ja	short m_pix_op_mix_3 ; 32bpp	
 10964 0000FB61 722D                <1> 	jb	short m_pix_op_mix_2 ; 16bpp
 10965                              <1> 	; 24 bit true colors
 10966                              <1> 	;jmp	short m_pix_op_mix_24
 10967                              <1> m_pix_op_mix_24:
 10968                              <1> 	; 24 bit true colors
 10969 0000FB63 89C2                <1> 	mov	edx, eax ; new color
 10970                              <1> 	;and	edx, 0FFFFFFh
 10971                              <1> m_pix_op_mix_24_0:
 10972 0000FB65 66AD                <1> 	lodsw
 10973 0000FB67 C1E010              <1> 	shl	eax, 16
 10974 0000FB6A AC                  <1> 	lodsb
 10975 0000FB6B C1C010              <1> 	rol	eax, 16	
 10976 0000FB6E 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 10977 0000FB74 7414                <1> 	je	short m_pix_op_mix_24_1 ; exclude
 10978 0000FB76 01D0                <1> 	add	eax, edx
 10979 0000FB78 D1E8                <1> 	shr	eax, 1
 10980 0000FB7A 668907              <1> 	mov	[edi], ax
 10981 0000FB7D C1E810              <1> 	shr	eax, 16
 10982 0000FB80 884702              <1> 	mov	[edi+2], al
 10983 0000FB83 8305[64030300]03    <1> 	add	dword [u.r0], 3 ; +3
 10984                              <1> m_pix_op_mix_24_1:
 10985 0000FB8A 83C703              <1> 	add	edi, 3 ; +3
 10986 0000FB8D E2D6                <1> 	loop	m_pix_op_mix_24_0
 10987 0000FB8F C3                  <1> 	retn
 10988                              <1> 	; 65536 colors (16bpp)
 10989                              <1> m_pix_op_mix_2:
 10990                              <1> 	;jmp	short m_pix_op_mix_16
 10991                              <1> m_pix_op_mix_16:
 10992                              <1> 	; 16 bit colors (65536 colors)
 10993 0000FB90 89C2                <1> 	mov	edx, eax ; new color
 10994                              <1> 	;and	edx, 0FFFFh
 10995                              <1> m_pix_op_mix_16_0:
 10996 0000FB92 66AD                <1> 	lodsw
 10997 0000FB94 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
 10998 0000FB9B 7410                <1> 	je	short m_pix_op_mix_16_1 ; exclude
 10999 0000FB9D 6601D0              <1> 	add	ax, dx
 11000 0000FBA0 66D1D8              <1> 	rcr	ax, 1
 11001 0000FBA3 668907              <1> 	mov	[edi], ax
 11002 0000FBA6 8305[64030300]02    <1> 	add	dword [u.r0], 2 ; +2
 11003                              <1> m_pix_op_mix_16_1:
 11004 0000FBAD 83C702              <1> 	add	edi, 2 ; +2
 11005 0000FBB0 E2E0                <1> 	loop	m_pix_op_mix_16_0
 11006 0000FBB2 C3                  <1> 	retn
 11007                              <1> m_pix_op_mix_3:
 11008                              <1> 	; 32 bit true colors
 11009                              <1> 	;jmp	short m_pix_op_mix_32
 11010                              <1> m_pix_op_mix_32:
 11011                              <1> 	; 32 bit true colors
 11012 0000FBB3 89C2                <1> 	mov	edx, eax ; new color
 11013                              <1> m_pix_op_mix_32_0:
 11014 0000FBB5 AD                  <1> 	lodsd 
 11015 0000FBB6 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 11016 0000FBBC 740D                <1> 	je	short m_pix_op_mix_32_1 ; exclude
 11017 0000FBBE 01D0                <1> 	add	eax, edx
 11018                              <1> 	; 02/03/2021
 11019 0000FBC0 D1D8                <1> 	rcr	eax, 1
 11020 0000FBC2 8907                <1> 	mov	[edi], eax	
 11021 0000FBC4 8305[64030300]04    <1> 	add	dword [u.r0], 4 ; +4
 11022                              <1> m_pix_op_mix_32_1:
 11023 0000FBCB 83C704              <1> 	add	edi, 4 ; +4
 11024 0000FBCE E2E5                <1> 	loop	m_pix_op_mix_32_0
 11025 0000FBD0 C3                  <1> 	retn
 11026                              <1> 
 11027                              <1> m_pix_op_mix_w:
 11028                              <1> 	; 06/02/2021
 11029                              <1> 	; MIX COLOR (MASKED, window)
 11030                              <1> 	;
 11031                              <1> 	; jump from pix_op_mix_w
 11032                              <1> 	;
 11033                              <1> 	; INPUT:
 11034                              <1> 	;   ecx = bytes per row (to be applied)
 11035                              <1> 	;   edx = screen width in bytes
 11036                              <1> 	;   ebx = row count
 11037                              <1> 	;   eax = color
 11038                              <1> 	;
 11039                              <1> 	;   [maskcolor] = mask color (to be excluded)
 11040                              <1> 	;
 11041                              <1> 	; OUTPUT:
 11042                              <1> 	; 	[u.r0] will be > 0 if succesful
 11043                              <1> 
 11044                              <1> 	; window
 11045                              <1> 	;mov	edi, [v_str] ; LFB start address
 11046                              <1> 	;mov	esi, edi 
 11047                              <1> 
 11048 0000FBD1 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 11049 0000FBD8 7707                <1> 	ja	short m_pix_op_mix_w_1
 11050                              <1> 
 11051                              <1> 	; 256 colors (8bpp)
 11052 0000FBDA BD[3DFB0000]        <1> 	mov	ebp, m_pix_op_mix_8
 11053 0000FBDF EB1E                <1> 	jmp	short m_pix_op_mix_w_4
 11054                              <1> 			
 11055                              <1> m_pix_op_mix_w_1:
 11056 0000FBE1 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 11057 0000FBE8 7710                <1> 	ja	short m_pix_op_mix_w_3 ; 32bpp
 11058 0000FBEA 7207                <1> 	jb	short m_pix_op_mix_w_2 ; 16bpp
 11059                              <1> 
 11060                              <1> 	; 24 bit true colors
 11061 0000FBEC BD[63FB0000]        <1> 	mov	ebp, m_pix_op_mix_24
 11062 0000FBF1 EB0C                <1> 	jmp	short m_pix_op_mix_w_4
 11063                              <1> 
 11064                              <1> 	; 65536 colors (16bpp)
 11065                              <1> m_pix_op_mix_w_2:
 11066 0000FBF3 BD[90FB0000]        <1> 	mov	ebp, m_pix_op_mix_16
 11067 0000FBF8 EB05                <1> 	jmp	short m_pix_op_mix_w_4
 11068                              <1> 
 11069                              <1> 	; 32 bit true colors
 11070                              <1> m_pix_op_mix_w_3:
 11071 0000FBFA BD[B3FB0000]        <1> 	mov	ebp, m_pix_op_mix_32
 11072                              <1> m_pix_op_mix_w_4:
 11073 0000FBFF E957FDFFFF          <1> 	jmp	m_pix_op_mix_w_x
 11074                              <1> 
 11075                              <1> m_pix_op_and:
 11076                              <1> 	; 06/02/2021
 11077                              <1> 	; AND COLOR (MASKED, full screen)
 11078                              <1> 	;
 11079                              <1> 	; jump from pix_op_and
 11080                              <1> 	;
 11081                              <1> 	; INPUT:
 11082                              <1> 	;   eax = color (AL, AX, EAX)
 11083                              <1> 	;   ecx = [v_siz] ; display page pixel count
 11084                              <1> 	;   esi = edi = [v_mem] ; LFB start address
 11085                              <1> 	;
 11086                              <1> 	;   [maskcolor] = mask color (to be excluded)
 11087                              <1> 	;
 11088                              <1> 	; OUTPUT:
 11089                              <1> 	; 	[u.r0] will be > 0 if succesful
 11090                              <1> 	
 11091                              <1> 	; Full screen
 11092                              <1> m_pix_op_and_0:
 11093 0000FC04 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 11094 0000FC0B 7717                <1> 	ja	short m_pix_op_and_1
 11095                              <1> 	; 256 colors (8bpp)
 11096                              <1> 	;jmp	short m_pix_op_and_8
 11097                              <1> m_pix_op_and_8:
 11098                              <1> 	; 8 bit colors (256 colors)
 11099 0000FC0D 88C2                <1> 	mov	dl, al ; new color
 11100                              <1> m_pix_op_and_8_0:
 11101 0000FC0F AC                  <1> 	lodsb 
 11102 0000FC10 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
 11103 0000FC16 7408                <1> 	je	short m_pix_op_and_8_1 ; exclude
 11104 0000FC18 2017                <1> 	and	[edi], dl
 11105 0000FC1A FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
 11106                              <1> m_pix_op_and_8_1:
 11107 0000FC20 47                  <1> 	inc	edi
 11108 0000FC21 E2EC                <1> 	loop	m_pix_op_and_8_0
 11109 0000FC23 C3                  <1> 	retn
 11110                              <1> m_pix_op_and_1:
 11111 0000FC24 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 11112 0000FC2B 774A                <1> 	ja	short m_pix_op_and_3 ; 32bpp	
 11113 0000FC2D 722B                <1> 	jb	short m_pix_op_and_2 ; 16bpp
 11114                              <1> 	; 24 bit true colors
 11115                              <1> 	;jmp	short m_pix_op_and_24
 11116                              <1> m_pix_op_and_24:
 11117                              <1> 	; 24 bit true colors
 11118 0000FC2F 89C2                <1> 	mov	edx, eax ; new color
 11119                              <1> 	;and	edx, 0FFFFFFh
 11120                              <1> m_pix_op_and_24_0:
 11121 0000FC31 66AD                <1> 	lodsw
 11122 0000FC33 C1E010              <1> 	shl	eax, 16
 11123 0000FC36 AC                  <1> 	lodsb
 11124 0000FC37 C1C010              <1> 	rol	eax, 16	
 11125 0000FC3A 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 11126 0000FC40 7412                <1> 	je	short m_pix_op_and_24_1 ; exclude
 11127 0000FC42 21D0                <1> 	and	eax, edx
 11128 0000FC44 668907              <1> 	mov	[edi], ax
 11129 0000FC47 C1E810              <1> 	shr	eax, 16
 11130 0000FC4A 884702              <1> 	mov	[edi+2], al
 11131 0000FC4D 8305[64030300]03    <1> 	add	dword [u.r0], 3 ; +3
 11132                              <1> m_pix_op_and_24_1:
 11133 0000FC54 83C703              <1> 	add	edi, 3 ; +3
 11134 0000FC57 E2D8                <1> 	loop	m_pix_op_and_24_0
 11135 0000FC59 C3                  <1> 	retn
 11136                              <1> 	; 65536 colors (16bpp)
 11137                              <1> m_pix_op_and_2:
 11138                              <1> 	;jmp	short m_pix_op_and_16
 11139                              <1> m_pix_op_and_16:
 11140                              <1> 	; 16 bit colors (65536 colors)
 11141 0000FC5A 89C2                <1> 	mov	edx, eax ; new color
 11142                              <1> 	;and	edx, 0FFFFh
 11143                              <1> m_pix_op_and_16_0:
 11144 0000FC5C 66AD                <1> 	lodsw
 11145 0000FC5E 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
 11146 0000FC65 740A                <1> 	je	short m_pix_op_and_16_1 ; exclude
 11147 0000FC67 662117              <1> 	and	[edi], dx
 11148 0000FC6A 8305[64030300]02    <1> 	add	dword [u.r0], 2 ; +2
 11149                              <1> m_pix_op_and_16_1:
 11150 0000FC71 83C702              <1> 	add	edi, 2 ; +2
 11151 0000FC74 E2E6                <1> 	loop	m_pix_op_and_16_0
 11152 0000FC76 C3                  <1> 	retn
 11153                              <1> m_pix_op_and_3:
 11154                              <1> 	; 32 bit true colors
 11155                              <1> 	;jmp	short m_pix_op_and_32
 11156                              <1> m_pix_op_and_32:
 11157                              <1> 	; 32 bit true colors
 11158 0000FC77 89C2                <1> 	mov	edx, eax ; new color
 11159                              <1> m_pix_op_and_32_0:
 11160 0000FC79 AD                  <1> 	lodsd 
 11161 0000FC7A 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 11162 0000FC80 7409                <1> 	je	short m_pix_op_and_32_1 ; exclude
 11163 0000FC82 2117                <1> 	and	[edi], edx ; 25/02/2021	
 11164 0000FC84 8305[64030300]04    <1> 	add	dword [u.r0], 4 ; +4
 11165                              <1> m_pix_op_and_32_1:
 11166 0000FC8B 83C704              <1> 	add	edi, 4 ; +4
 11167 0000FC8E E2E9                <1> 	loop	m_pix_op_and_32_0
 11168 0000FC90 C3                  <1> 	retn
 11169                              <1> 
 11170                              <1> m_pix_op_and_w:
 11171                              <1> 	; 06/02/2021
 11172                              <1> 	; AND COLOR (MASKED, window)
 11173                              <1> 	;
 11174                              <1> 	; jump from pix_op_and_w
 11175                              <1> 	;
 11176                              <1> 	; INPUT:
 11177                              <1> 	;   ecx = bytes per row (to be applied)
 11178                              <1> 	;   edx = screen width in bytes
 11179                              <1> 	;   ebx = row count
 11180                              <1> 	;   eax = color
 11181                              <1> 	;
 11182                              <1> 	;   [maskcolor] = mask color (to be excluded)
 11183                              <1> 	;
 11184                              <1> 	; OUTPUT:
 11185                              <1> 	; 	[u.r0] will be > 0 if succesful
 11186                              <1> 
 11187                              <1> 	; window
 11188                              <1> 	;mov	edi, [v_str] ; LFB start address
 11189                              <1> 	;mov	esi, edi 
 11190                              <1> 
 11191 0000FC91 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 11192 0000FC98 7707                <1> 	ja	short m_pix_op_and_w_1
 11193                              <1> 
 11194                              <1> 	; 256 colors (8bpp)
 11195 0000FC9A BD[0DFC0000]        <1> 	mov	ebp, m_pix_op_and_8
 11196 0000FC9F EB1E                <1> 	jmp	short m_pix_op_and_w_4
 11197                              <1> 			
 11198                              <1> m_pix_op_and_w_1:
 11199 0000FCA1 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 11200 0000FCA8 7710                <1> 	ja	short m_pix_op_and_w_3 ; 32bpp
 11201 0000FCAA 7207                <1> 	jb	short m_pix_op_and_w_2 ; 16bpp
 11202                              <1> 
 11203                              <1> 	; 24 bit true colors
 11204 0000FCAC BD[2FFC0000]        <1> 	mov	ebp, m_pix_op_and_24
 11205 0000FCB1 EB0C                <1> 	jmp	short m_pix_op_and_w_4
 11206                              <1> 
 11207                              <1> 	; 65536 colors (16bpp)
 11208                              <1> m_pix_op_and_w_2:
 11209 0000FCB3 BD[5AFC0000]        <1> 	mov	ebp, m_pix_op_and_16
 11210 0000FCB8 EB05                <1> 	jmp	short m_pix_op_and_w_4
 11211                              <1> 
 11212                              <1> 	; 32 bit true colors
 11213                              <1> m_pix_op_and_w_3:
 11214 0000FCBA BD[77FC0000]        <1> 	mov	ebp, m_pix_op_and_32
 11215                              <1> m_pix_op_and_w_4:
 11216 0000FCBF E997FCFFFF          <1> 	jmp	m_pix_op_and_w_x
 11217                              <1> 
 11218                              <1> m_pix_op_or:
 11219                              <1> 	; 06/02/2021
 11220                              <1> 	; OR COLOR (MASKED, full screen)
 11221                              <1> 	;
 11222                              <1> 	; jump from pix_op_orc
 11223                              <1> 	;
 11224                              <1> 	; INPUT:
 11225                              <1> 	;   eax = color (AL, AX, EAX)
 11226                              <1> 	;   ecx = [v_siz] ; display page pixel count
 11227                              <1> 	;   esi = edi = [v_mem] ; LFB start address
 11228                              <1> 	;
 11229                              <1> 	;   [maskcolor] = mask color (to be excluded)
 11230                              <1> 	;
 11231                              <1> 	; OUTPUT:
 11232                              <1> 	; 	[u.r0] will be > 0 if succesful
 11233                              <1> 	
 11234                              <1> 	; Full screen
 11235                              <1> m_pix_op_or_0:
 11236 0000FCC4 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 11237 0000FCCB 7717                <1> 	ja	short m_pix_op_or_1
 11238                              <1> 	; 256 colors (8bpp)
 11239                              <1> 	;jmp	short m_pix_op_or_8
 11240                              <1> m_pix_op_or_8:
 11241                              <1> 	; 8 bit colors (256 colors)
 11242 0000FCCD 88C2                <1> 	mov	dl, al ; new color
 11243                              <1> m_pix_op_or_8_0:
 11244 0000FCCF AC                  <1> 	lodsb 
 11245 0000FCD0 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
 11246 0000FCD6 7408                <1> 	je	short m_pix_op_or_8_1 ; exclude
 11247 0000FCD8 0817                <1> 	or	[edi], dl
 11248 0000FCDA FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
 11249                              <1> m_pix_op_or_8_1:
 11250 0000FCE0 47                  <1> 	inc	edi
 11251 0000FCE1 E2EC                <1> 	loop	m_pix_op_or_8_0
 11252 0000FCE3 C3                  <1> 	retn
 11253                              <1> m_pix_op_or_1:
 11254 0000FCE4 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 11255 0000FCEB 774A                <1> 	ja	short m_pix_op_or_3 ; 32bpp	
 11256 0000FCED 722B                <1> 	jb	short m_pix_op_or_2 ; 16bpp
 11257                              <1> 	; 24 bit true colors
 11258                              <1> 	;jmp	short m_pix_op_or_24
 11259                              <1> m_pix_op_or_24:
 11260                              <1> 	; 24 bit true colors
 11261 0000FCEF 89C2                <1> 	mov	edx, eax ; new color
 11262                              <1> 	;and	edx, 0FFFFFFh
 11263                              <1> m_pix_op_or_24_0:
 11264 0000FCF1 66AD                <1> 	lodsw
 11265 0000FCF3 C1E010              <1> 	shl	eax, 16
 11266 0000FCF6 AC                  <1> 	lodsb
 11267 0000FCF7 C1C010              <1> 	rol	eax, 16	
 11268 0000FCFA 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 11269 0000FD00 7412                <1> 	je	short m_pix_op_or_24_1 ; exclude
 11270 0000FD02 09D0                <1> 	or	eax, edx
 11271 0000FD04 668907              <1> 	mov	[edi], ax
 11272 0000FD07 C1E810              <1> 	shr	eax, 16
 11273 0000FD0A 884702              <1> 	mov	[edi+2], al
 11274 0000FD0D 8305[64030300]03    <1> 	add	dword [u.r0], 3 ; +3
 11275                              <1> m_pix_op_or_24_1:
 11276 0000FD14 83C703              <1> 	add	edi, 3 ; +3
 11277 0000FD17 E2D8                <1> 	loop	m_pix_op_or_24_0
 11278 0000FD19 C3                  <1> 	retn
 11279                              <1> 	; 65536 colors (16bpp)
 11280                              <1> m_pix_op_or_2:
 11281                              <1> 	;jmp	short m_pix_op_or_16
 11282                              <1> m_pix_op_or_16:
 11283                              <1> 	; 16 bit colors (65536 colors)
 11284 0000FD1A 89C2                <1> 	mov	edx, eax ; new color
 11285                              <1> 	;and	edx, 0FFFFh
 11286                              <1> m_pix_op_or_16_0:
 11287 0000FD1C 66AD                <1> 	lodsw
 11288 0000FD1E 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
 11289 0000FD25 740A                <1> 	je	short m_pix_op_or_16_1 ; exclude
 11290 0000FD27 660917              <1> 	or	[edi], dx
 11291 0000FD2A 8305[64030300]02    <1> 	add	dword [u.r0], 2 ; +2
 11292                              <1> m_pix_op_or_16_1:
 11293 0000FD31 83C702              <1> 	add	edi, 2 ; +2
 11294 0000FD34 E2E6                <1> 	loop	m_pix_op_or_16_0
 11295 0000FD36 C3                  <1> 	retn
 11296                              <1> m_pix_op_or_3:
 11297                              <1> 	; 32 bit true colors
 11298                              <1> 	;jmp	short m_pix_op_or_32
 11299                              <1> m_pix_op_or_32:
 11300                              <1> 	; 32 bit true colors
 11301 0000FD37 89C2                <1> 	mov	edx, eax ; new color
 11302                              <1> m_pix_op_or_32_0:
 11303 0000FD39 AD                  <1> 	lodsd 
 11304 0000FD3A 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 11305 0000FD40 7409                <1> 	je	short m_pix_op_or_32_1 ; exclude
 11306 0000FD42 0917                <1> 	or	[edi], edx ; 25/02/2021	
 11307 0000FD44 8305[64030300]04    <1> 	add	dword [u.r0], 4 ; +4
 11308                              <1> m_pix_op_or_32_1:
 11309 0000FD4B 83C704              <1> 	add	edi, 4 ; +4
 11310 0000FD4E E2E9                <1> 	loop	m_pix_op_or_32_0
 11311 0000FD50 C3                  <1> 	retn
 11312                              <1> 
 11313                              <1> m_pix_op_or_w:
 11314                              <1> 	; 06/02/2021
 11315                              <1> 	; MIX COLOR (MASKED, window)
 11316                              <1> 	;
 11317                              <1> 	; jump from pix_op_or_w
 11318                              <1> 	;
 11319                              <1> 	; INPUT:
 11320                              <1> 	;   ecx = bytes per row (to be applied)
 11321                              <1> 	;   edx = screen width in bytes
 11322                              <1> 	;   ebx = row count
 11323                              <1> 	;   eax = color
 11324                              <1> 	;
 11325                              <1> 	;   [maskcolor] = mask color (to be excluded)
 11326                              <1> 	;
 11327                              <1> 	; OUTPUT:
 11328                              <1> 	; 	[u.r0] will be > 0 if succesful
 11329                              <1> 
 11330                              <1> 	; window
 11331                              <1> 	;mov	edi, [v_str] ; LFB start address
 11332                              <1> 	;mov	esi, edi 
 11333                              <1> 
 11334 0000FD51 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 11335 0000FD58 7707                <1> 	ja	short m_pix_op_or_w_1
 11336                              <1> 
 11337                              <1> 	; 256 colors (8bpp)
 11338 0000FD5A BD[CDFC0000]        <1> 	mov	ebp, m_pix_op_or_8
 11339 0000FD5F EB1E                <1> 	jmp	short m_pix_op_or_w_4
 11340                              <1> 			
 11341                              <1> m_pix_op_or_w_1:
 11342 0000FD61 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 11343 0000FD68 7710                <1> 	ja	short m_pix_op_or_w_3 ; 32bpp
 11344 0000FD6A 7207                <1> 	jb	short m_pix_op_or_w_2 ; 16bpp
 11345                              <1> 
 11346                              <1> 	; 24 bit true colors
 11347 0000FD6C BD[EFFC0000]        <1> 	mov	ebp, m_pix_op_or_24
 11348 0000FD71 EB0C                <1> 	jmp	short m_pix_op_or_w_4
 11349                              <1> 
 11350                              <1> 	; 65536 colors (16bpp)
 11351                              <1> m_pix_op_or_w_2:
 11352 0000FD73 BD[1AFD0000]        <1> 	mov	ebp, m_pix_op_or_16
 11353 0000FD78 EB05                <1> 	jmp	short m_pix_op_or_w_4
 11354                              <1> 
 11355                              <1> 	; 32 bit true colors
 11356                              <1> m_pix_op_or_w_3:
 11357 0000FD7A BD[37FD0000]        <1> 	mov	ebp, m_pix_op_or_32
 11358                              <1> m_pix_op_or_w_4:
 11359 0000FD7F E9D7FBFFFF          <1> 	jmp	m_pix_op_orc_w_x
 11360                              <1> 
 11361                              <1> m_pix_op_xor:
 11362                              <1> 	; 06/02/2021
 11363                              <1> 	; XOR COLOR (MASKED, full screen)
 11364                              <1> 	;
 11365                              <1> 	; jump from pix_op_xor
 11366                              <1> 	;
 11367                              <1> 	; INPUT:
 11368                              <1> 	;   eax = color (AL, AX, EAX)
 11369                              <1> 	;   ecx = [v_siz] ; display page pixel count
 11370                              <1> 	;   esi = edi = [v_mem] ; LFB start address
 11371                              <1> 	;
 11372                              <1> 	;   [maskcolor] = mask color (to be excluded)
 11373                              <1> 	;
 11374                              <1> 	; OUTPUT:
 11375                              <1> 	; 	[u.r0] will be > 0 if succesful
 11376                              <1> 	
 11377                              <1> 	; Full screen
 11378                              <1> m_pix_op_xor_0:
 11379 0000FD84 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 11380 0000FD8B 7717                <1> 	ja	short m_pix_op_xor_1
 11381                              <1> 	; 256 colors (8bpp)
 11382                              <1> 	;jmp	short m_pix_op_xor_8
 11383                              <1> m_pix_op_xor_8:
 11384                              <1> 	; 8 bit colors (256 colors)
 11385 0000FD8D 88C2                <1> 	mov	dl, al ; new color
 11386                              <1> m_pix_op_xor_8_0:
 11387 0000FD8F AC                  <1> 	lodsb 
 11388 0000FD90 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
 11389 0000FD96 7408                <1> 	je	short m_pix_op_xor_8_1 ; exclude
 11390 0000FD98 3017                <1> 	xor	[edi], dl
 11391 0000FD9A FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
 11392                              <1> m_pix_op_xor_8_1:
 11393 0000FDA0 47                  <1> 	inc	edi
 11394 0000FDA1 E2EC                <1> 	loop	m_pix_op_xor_8_0
 11395 0000FDA3 C3                  <1> 	retn
 11396                              <1> m_pix_op_xor_1:
 11397 0000FDA4 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 11398 0000FDAB 774A                <1> 	ja	short m_pix_op_xor_3 ; 32bpp	
 11399 0000FDAD 722B                <1> 	jb	short m_pix_op_xor_2 ; 16bpp
 11400                              <1> 	; 24 bit true colors
 11401                              <1> 	;jmp	short m_pix_op_xor_24
 11402                              <1> m_pix_op_xor_24:
 11403                              <1> 	; 24 bit true colors
 11404 0000FDAF 89C2                <1> 	mov	edx, eax ; new color
 11405                              <1> 	;and	edx, 0FFFFFFh
 11406                              <1> m_pix_op_xor_24_0:
 11407 0000FDB1 66AD                <1> 	lodsw
 11408 0000FDB3 C1E010              <1> 	shl	eax, 16
 11409 0000FDB6 AC                  <1> 	lodsb
 11410 0000FDB7 C1C010              <1> 	rol	eax, 16	
 11411 0000FDBA 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 11412 0000FDC0 7412                <1> 	je	short m_pix_op_xor_24_1 ; exclude
 11413 0000FDC2 31D0                <1> 	xor	eax, edx
 11414 0000FDC4 668907              <1> 	mov	[edi], ax
 11415 0000FDC7 C1E810              <1> 	shr	eax, 16
 11416 0000FDCA 884702              <1> 	mov	[edi+2], al
 11417 0000FDCD 8305[64030300]03    <1> 	add	dword [u.r0], 3 ; +3
 11418                              <1> m_pix_op_xor_24_1:
 11419 0000FDD4 83C703              <1> 	add	edi, 3 ; +3
 11420 0000FDD7 E2D8                <1> 	loop	m_pix_op_xor_24_0
 11421 0000FDD9 C3                  <1> 	retn
 11422                              <1> 	; 65536 colors (16bpp)
 11423                              <1> m_pix_op_xor_2:
 11424                              <1> 	;jmp	short m_pix_op_xor_16
 11425                              <1> m_pix_op_xor_16:
 11426                              <1> 	; 16 bit colors (65536 colors)
 11427 0000FDDA 89C2                <1> 	mov	edx, eax ; new color
 11428                              <1> 	;and	edx, 0FFFFh
 11429                              <1> m_pix_op_xor_16_0:
 11430 0000FDDC 66AD                <1> 	lodsw
 11431 0000FDDE 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
 11432 0000FDE5 740A                <1> 	je	short m_pix_op_xor_16_1 ; exclude
 11433 0000FDE7 663117              <1> 	xor	[edi], dx
 11434 0000FDEA 8305[64030300]02    <1> 	add	dword [u.r0], 2 ; +2
 11435                              <1> m_pix_op_xor_16_1:
 11436 0000FDF1 83C702              <1> 	add	edi, 2 ; +2
 11437 0000FDF4 E2E6                <1> 	loop	m_pix_op_xor_16_0
 11438 0000FDF6 C3                  <1> 	retn
 11439                              <1> m_pix_op_xor_3:
 11440                              <1> 	; 32 bit true colors
 11441                              <1> 	;jmp	short m_pix_op_xor_32
 11442                              <1> m_pix_op_xor_32:
 11443                              <1> 	; 32 bit true colors
 11444 0000FDF7 89C2                <1> 	mov	edx, eax ; new color
 11445                              <1> m_pix_op_xor_32_0:
 11446 0000FDF9 AD                  <1> 	lodsd 
 11447 0000FDFA 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 11448 0000FE00 7409                <1> 	je	short m_pix_op_xor_32_1 ; exclude
 11449 0000FE02 3117                <1> 	xor	[edi], edx ; 25/02/2021	
 11450 0000FE04 8305[64030300]04    <1> 	add	dword [u.r0], 4 ; +4
 11451                              <1> m_pix_op_xor_32_1:
 11452 0000FE0B 83C704              <1> 	add	edi, 4 ; +4
 11453 0000FE0E E2E9                <1> 	loop	m_pix_op_xor_32_0
 11454 0000FE10 C3                  <1> 	retn
 11455                              <1> 
 11456                              <1> m_pix_op_xor_w:
 11457                              <1> 	; 06/02/2021
 11458                              <1> 	; XOR COLOR (MASKED, window)
 11459                              <1> 	;
 11460                              <1> 	; jump from pix_op_xor_w
 11461                              <1> 	;
 11462                              <1> 	; INPUT:
 11463                              <1> 	;   ecx = bytes per row (to be applied)
 11464                              <1> 	;   edx = screen width in bytes
 11465                              <1> 	;   ebx = row count
 11466                              <1> 	;   eax = color
 11467                              <1> 	;
 11468                              <1> 	;   [maskcolor] = mask color (to be excluded)
 11469                              <1> 	;
 11470                              <1> 	; OUTPUT:
 11471                              <1> 	; 	[u.r0] will be > 0 if succesful
 11472                              <1> 
 11473                              <1> 	; window
 11474                              <1> 	;mov	edi, [v_str] ; LFB start address
 11475                              <1> 	;mov	esi, edi 
 11476                              <1> 
 11477 0000FE11 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 11478 0000FE18 7707                <1> 	ja	short m_pix_op_xor_w_1
 11479                              <1> 
 11480                              <1> 	; 256 colors (8bpp)
 11481 0000FE1A BD[8DFD0000]        <1> 	mov	ebp, m_pix_op_xor_8
 11482 0000FE1F EB1E                <1> 	jmp	short m_pix_op_xor_w_4
 11483                              <1> 			
 11484                              <1> m_pix_op_xor_w_1:
 11485 0000FE21 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 11486 0000FE28 7710                <1> 	ja	short m_pix_op_xor_w_3 ; 32bpp
 11487 0000FE2A 7207                <1> 	jb	short m_pix_op_xor_w_2 ; 16bpp
 11488                              <1> 
 11489                              <1> 	; 24 bit true colors
 11490 0000FE2C BD[AFFD0000]        <1> 	mov	ebp, m_pix_op_xor_24
 11491 0000FE31 EB0C                <1> 	jmp	short m_pix_op_xor_w_4
 11492                              <1> 
 11493                              <1> 	; 65536 colors (16bpp)
 11494                              <1> m_pix_op_xor_w_2:
 11495 0000FE33 BD[DAFD0000]        <1> 	mov	ebp, m_pix_op_xor_16
 11496 0000FE38 EB05                <1> 	jmp	short m_pix_op_xor_w_4
 11497                              <1> 
 11498                              <1> 	; 32 bit true colors
 11499                              <1> m_pix_op_xor_w_3:
 11500 0000FE3A BD[F7FD0000]        <1> 	mov	ebp, m_pix_op_xor_32
 11501                              <1> m_pix_op_xor_w_4:
 11502 0000FE3F E917FBFFFF          <1> 	jmp	m_pix_op_xor_w_x
 11503                              <1> 
 11504                              <1> m_pix_op_not:
 11505                              <1> 	; 06/02/2021
 11506                              <1> 	; NOT COLOR (MASKED, full screen)
 11507                              <1> 	;
 11508                              <1> 	; jump from pix_op_not
 11509                              <1> 	;
 11510                              <1> 	; INPUT:
 11511                              <1> 	;   ecx = [v_siz] ; display page pixel count
 11512                              <1> 	;   esi = edi = [v_mem] ; LFB start address
 11513                              <1> 	;
 11514                              <1> 	;   [maskcolor] = mask color (to be excluded)
 11515                              <1> 	;
 11516                              <1> 	; OUTPUT:
 11517                              <1> 	; 	[u.r0] will be > 0 if succesful
 11518                              <1> 	
 11519                              <1> 	; Full screen
 11520                              <1> m_pix_op_not_0:
 11521 0000FE44 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 11522 0000FE4B 7715                <1> 	ja	short m_pix_op_not_1
 11523                              <1> 	; 256 colors (8bpp)
 11524                              <1> 	;jmp	short m_pix_op_not_8
 11525                              <1> m_pix_op_not_8:
 11526                              <1> 	; 8 bit colors (256 colors)
 11527 0000FE4D AC                  <1> 	lodsb 
 11528 0000FE4E 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
 11529 0000FE54 7408                <1> 	je	short m_pix_op_not_8_1 ; exclude
 11530 0000FE56 F617                <1> 	not	byte [edi]
 11531 0000FE58 FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
 11532                              <1> m_pix_op_not_8_1:
 11533 0000FE5E 47                  <1> 	inc	edi
 11534 0000FE5F E2EC                <1> 	loop	m_pix_op_not_8
 11535 0000FE61 C3                  <1> 	retn
 11536                              <1> m_pix_op_not_1:
 11537 0000FE62 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 11538 0000FE69 7746                <1> 	ja	short m_pix_op_not_3 ; 32bpp	
 11539 0000FE6B 7229                <1> 	jb	short m_pix_op_not_2 ; 16bpp
 11540                              <1> 	; 24 bit true colors
 11541                              <1> 	;jmp	short m_pix_op_not_24
 11542                              <1> m_pix_op_not_24:
 11543                              <1> 	; 24 bit true colors
 11544 0000FE6D 66AD                <1> 	lodsw
 11545 0000FE6F C1E010              <1> 	shl	eax, 16
 11546 0000FE72 AC                  <1> 	lodsb
 11547 0000FE73 C1C010              <1> 	rol	eax, 16	
 11548 0000FE76 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 11549 0000FE7C 7412                <1> 	je	short m_pix_op_not_24_1 ; exclude
 11550 0000FE7E F7D0                <1> 	not	eax
 11551 0000FE80 668907              <1> 	mov	[edi], ax
 11552 0000FE83 C1E810              <1> 	shr	eax, 16
 11553 0000FE86 884702              <1> 	mov	[edi+2], al
 11554 0000FE89 8305[64030300]03    <1> 	add	dword [u.r0], 3 ; +3
 11555                              <1> m_pix_op_not_24_1:
 11556 0000FE90 83C703              <1> 	add	edi, 3 ; +3
 11557 0000FE93 E2D8                <1> 	loop	m_pix_op_not_24
 11558 0000FE95 C3                  <1> 	retn
 11559                              <1> 	; 65536 colors (16bpp)
 11560                              <1> m_pix_op_not_2:
 11561                              <1> 	;jmp	short m_pix_op_not_16
 11562                              <1> m_pix_op_not_16:
 11563                              <1> 	; 16 bit colors (65536 colors)
 11564 0000FE96 66AD                <1> 	lodsw
 11565 0000FE98 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
 11566 0000FE9F 740A                <1> 	je	short m_pix_op_not_16_1 ; exclude
 11567 0000FEA1 66F717              <1> 	not	word [edi]
 11568 0000FEA4 8305[64030300]02    <1> 	add	dword [u.r0], 2 ; +2
 11569                              <1> m_pix_op_not_16_1:
 11570 0000FEAB 83C702              <1> 	add	edi, 2 ; +2
 11571 0000FEAE E2E6                <1> 	loop	m_pix_op_not_16
 11572 0000FEB0 C3                  <1> 	retn
 11573                              <1> m_pix_op_not_3:
 11574                              <1> 	; 32 bit true colors
 11575                              <1> 	;jmp	short m_pix_op_not_32
 11576                              <1> m_pix_op_not_32:
 11577                              <1> 	; 32 bit true colors
 11578 0000FEB1 AD                  <1> 	lodsd 
 11579 0000FEB2 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 11580 0000FEB8 7409                <1> 	je	short m_pix_op_not_32_1 ; exclude
 11581 0000FEBA F717                <1> 	not	dword [edi]	
 11582 0000FEBC 8305[64030300]04    <1> 	add	dword [u.r0], 4 ; +4
 11583                              <1> m_pix_op_not_32_1:
 11584 0000FEC3 83C704              <1> 	add	edi, 4 ; +4
 11585 0000FEC6 E2E9                <1> 	loop	m_pix_op_not_32
 11586 0000FEC8 C3                  <1> 	retn
 11587                              <1> 
 11588                              <1> m_pix_op_not_w:
 11589                              <1> 	; 06/02/2021
 11590                              <1> 	; NOT COLOR (MASKED, window)
 11591                              <1> 	;
 11592                              <1> 	; jump from pix_op_not_w
 11593                              <1> 	;
 11594                              <1> 	; INPUT:
 11595                              <1> 	;   ecx = bytes per row (to be applied)
 11596                              <1> 	;   edx = screen width in bytes
 11597                              <1> 	;   ebx = row count
 11598                              <1> 	;
 11599                              <1> 	;   [maskcolor] = mask color (to be excluded)
 11600                              <1> 	;
 11601                              <1> 	; OUTPUT:
 11602                              <1> 	; 	[u.r0] will be > 0 if succesful
 11603                              <1> 
 11604                              <1> 	; window
 11605                              <1> 	;mov	edi, [v_str] ; LFB start address
 11606                              <1> 	;mov	esi, edi 
 11607                              <1> 
 11608 0000FEC9 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 11609 0000FED0 7707                <1> 	ja	short m_pix_op_not_w_1
 11610                              <1> 
 11611                              <1> 	; 256 colors (8bpp)
 11612 0000FED2 BD[4DFE0000]        <1> 	mov	ebp, m_pix_op_not_8
 11613 0000FED7 EB1E                <1> 	jmp	short m_pix_op_not_w_4
 11614                              <1> 			
 11615                              <1> m_pix_op_not_w_1:
 11616 0000FED9 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 11617 0000FEE0 7710                <1> 	ja	short m_pix_op_not_w_3 ; 32bpp
 11618 0000FEE2 7207                <1> 	jb	short m_pix_op_not_w_2 ; 16bpp
 11619                              <1> 
 11620                              <1> 	; 24 bit true colors
 11621 0000FEE4 BD[6DFE0000]        <1> 	mov	ebp, m_pix_op_not_24
 11622 0000FEE9 EB0C                <1> 	jmp	short m_pix_op_not_w_4
 11623                              <1> 
 11624                              <1> 	; 65536 colors (16bpp)
 11625                              <1> m_pix_op_not_w_2:
 11626 0000FEEB BD[96FE0000]        <1> 	mov	ebp, m_pix_op_not_16
 11627 0000FEF0 EB05                <1> 	jmp	short m_pix_op_not_w_4
 11628                              <1> 
 11629                              <1> 	; 32 bit true colors
 11630                              <1> m_pix_op_not_w_3:
 11631 0000FEF2 BD[B1FE0000]        <1> 	mov	ebp, m_pix_op_not_32
 11632                              <1> m_pix_op_not_w_4:
 11633 0000FEF7 E95FFAFFFF          <1> 	jmp	m_pix_op_not_w_x
 11634                              <1> 
 11635                              <1> m_pix_op_neg:
 11636                              <1> 	; 06/02/2021
 11637                              <1> 	; NEGATIVE COLOR (MASKED, full screen)
 11638                              <1> 	;
 11639                              <1> 	; jump from pix_op_neg
 11640                              <1> 	;
 11641                              <1> 	; INPUT:
 11642                              <1> 	;   ecx = [v_siz] ; display page pixel count
 11643                              <1> 	;   esi = edi = [v_mem] ; LFB start address
 11644                              <1> 	;
 11645                              <1> 	;   [maskcolor] = mask color (to be excluded)
 11646                              <1> 	;
 11647                              <1> 	; OUTPUT:
 11648                              <1> 	; 	[u.r0] will be > 0 if succesful
 11649                              <1> 	
 11650                              <1> 	; Full screen
 11651                              <1> m_pix_op_neg_0:
 11652 0000FEFC 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 11653 0000FF03 7715                <1> 	ja	short m_pix_op_neg_1
 11654                              <1> 	; 256 colors (8bpp)
 11655                              <1> 	;jmp	short m_pix_op_neg_8
 11656                              <1> m_pix_op_neg_8:
 11657                              <1> 	; 8 bit colors (256 colors)
 11658 0000FF05 AC                  <1> 	lodsb 
 11659 0000FF06 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
 11660 0000FF0C 7408                <1> 	je	short m_pix_op_neg_8_1 ; exclude
 11661 0000FF0E F61F                <1> 	neg	byte [edi]
 11662 0000FF10 FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
 11663                              <1> m_pix_op_neg_8_1:
 11664 0000FF16 47                  <1> 	inc	edi
 11665 0000FF17 E2EC                <1> 	loop	m_pix_op_neg_8
 11666 0000FF19 C3                  <1> 	retn
 11667                              <1> m_pix_op_neg_1:
 11668 0000FF1A 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 11669 0000FF21 7746                <1> 	ja	short m_pix_op_neg_3 ; 32bpp	
 11670 0000FF23 7229                <1> 	jb	short m_pix_op_neg_2 ; 16bpp
 11671                              <1> 	; 24 bit true colors
 11672                              <1> 	;jmp	short m_pix_op_neg_24
 11673                              <1> m_pix_op_neg_24:
 11674                              <1> 	; 24 bit true colors
 11675 0000FF25 66AD                <1> 	lodsw
 11676 0000FF27 C1E010              <1> 	shl	eax, 16
 11677 0000FF2A AC                  <1> 	lodsb
 11678 0000FF2B C1C010              <1> 	rol	eax, 16	
 11679 0000FF2E 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 11680 0000FF34 7412                <1> 	je	short m_pix_op_neg_24_1 ; exclude
 11681 0000FF36 F7D8                <1> 	neg	eax
 11682 0000FF38 668907              <1> 	mov	[edi], ax
 11683 0000FF3B C1E810              <1> 	shr	eax, 16
 11684 0000FF3E 884702              <1> 	mov	[edi+2], al
 11685 0000FF41 8305[64030300]03    <1> 	add	dword [u.r0], 3 ; +3
 11686                              <1> m_pix_op_neg_24_1:
 11687 0000FF48 83C703              <1> 	add	edi, 3 ; +3
 11688 0000FF4B E2D8                <1> 	loop	m_pix_op_neg_24
 11689 0000FF4D C3                  <1> 	retn
 11690                              <1> 	; 65536 colors (16bpp)
 11691                              <1> m_pix_op_neg_2:
 11692                              <1> 	;jmp	short m_pix_op_neg_16
 11693                              <1> m_pix_op_neg_16:
 11694                              <1> 	; 16 bit colors (65536 colors)
 11695 0000FF4E 66AD                <1> 	lodsw
 11696 0000FF50 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
 11697 0000FF57 740A                <1> 	je	short m_pix_op_neg_16_1 ; exclude
 11698 0000FF59 66F71F              <1> 	neg	word [edi]
 11699 0000FF5C 8305[64030300]02    <1> 	add	dword [u.r0], 2 ; +2
 11700                              <1> m_pix_op_neg_16_1:
 11701 0000FF63 83C702              <1> 	add	edi, 2 ; +2
 11702 0000FF66 E2E6                <1> 	loop	m_pix_op_neg_16
 11703 0000FF68 C3                  <1> 	retn
 11704                              <1> m_pix_op_neg_3:
 11705                              <1> 	; 32 bit true colors
 11706                              <1> 	;jmp	short m_pix_op_neg_32
 11707                              <1> m_pix_op_neg_32:
 11708                              <1> 	; 32 bit true colors
 11709 0000FF69 AD                  <1> 	lodsd 
 11710 0000FF6A 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 11711 0000FF70 7409                <1> 	je	short m_pix_op_neg_32_1 ; exclude
 11712 0000FF72 F71F                <1> 	neg	dword [edi]	
 11713 0000FF74 8305[64030300]04    <1> 	add	dword [u.r0], 4 ; +4
 11714                              <1> m_pix_op_neg_32_1:
 11715 0000FF7B 83C704              <1> 	add	edi, 4 ; +4
 11716 0000FF7E E2E9                <1> 	loop	m_pix_op_neg_32
 11717 0000FF80 C3                  <1> 	retn
 11718                              <1> 
 11719                              <1> m_pix_op_neg_w:
 11720                              <1> 	; 06/02/2021
 11721                              <1> 	; NEGATIVE COLOR (MASKED, window)
 11722                              <1> 	;
 11723                              <1> 	; jump from pix_op_neg_w
 11724                              <1> 	;
 11725                              <1> 	; INPUT:
 11726                              <1> 	;   ecx = bytes per row (to be applied)
 11727                              <1> 	;   edx = screen width in bytes
 11728                              <1> 	;   ebx = row count
 11729                              <1> 	;
 11730                              <1> 	;   [maskcolor] = mask color (to be excluded)
 11731                              <1> 	;
 11732                              <1> 	; OUTPUT:
 11733                              <1> 	; 	[u.r0] will be > 0 if succesful
 11734                              <1> 
 11735                              <1> 	; window
 11736                              <1> 	;mov	edi, [v_str] ; LFB start address
 11737                              <1> 	;mov	esi, edi 
 11738                              <1> 
 11739 0000FF81 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 11740 0000FF88 7707                <1> 	ja	short m_pix_op_neg_w_1
 11741                              <1> 
 11742                              <1> 	; 256 colors (8bpp)
 11743 0000FF8A BD[05FF0000]        <1> 	mov	ebp, m_pix_op_neg_8
 11744 0000FF8F EB1E                <1> 	jmp	short m_pix_op_neg_w_4
 11745                              <1> 			
 11746                              <1> m_pix_op_neg_w_1:
 11747 0000FF91 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 11748 0000FF98 7710                <1> 	ja	short m_pix_op_neg_w_3 ; 32bpp
 11749 0000FF9A 7207                <1> 	jb	short m_pix_op_neg_w_2 ; 16bpp
 11750                              <1> 
 11751                              <1> 	; 24 bit true colors
 11752 0000FF9C BD[25FF0000]        <1> 	mov	ebp, m_pix_op_neg_24
 11753 0000FFA1 EB0C                <1> 	jmp	short m_pix_op_neg_w_4
 11754                              <1> 
 11755                              <1> 	; 65536 colors (16bpp)
 11756                              <1> m_pix_op_neg_w_2:
 11757 0000FFA3 BD[4EFF0000]        <1> 	mov	ebp, m_pix_op_neg_16
 11758 0000FFA8 EB05                <1> 	jmp	short m_pix_op_neg_w_4
 11759                              <1> 
 11760                              <1> 	; 32 bit true colors
 11761                              <1> m_pix_op_neg_w_3:
 11762 0000FFAA BD[69FF0000]        <1> 	mov	ebp, m_pix_op_neg_32
 11763                              <1> m_pix_op_neg_w_4:
 11764 0000FFAF E9A7F9FFFF          <1> 	jmp	m_pix_op_neg_w_x
 11765                              <1> 
 11766                              <1> m_pix_op_inc:
 11767                              <1> 	; 06/02/2021
 11768                              <1> 	; INCREASE COLOR (MASKED, full screen)
 11769                              <1> 	;
 11770                              <1> 	; jump from pix_op_inc
 11771                              <1> 	;
 11772                              <1> 	; INPUT:
 11773                              <1> 	;   ecx = [v_siz] ; display page pixel count
 11774                              <1> 	;   esi = edi = [v_mem] ; LFB start address
 11775                              <1> 	;
 11776                              <1> 	;   [maskcolor] = mask color (to be excluded)
 11777                              <1> 	;
 11778                              <1> 	; OUTPUT:
 11779                              <1> 	; 	[u.r0] will be > 0 if succesful
 11780                              <1> 	
 11781                              <1> 	; Full screen
 11782                              <1> m_pix_op_inc_0:
 11783 0000FFB4 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 11784 0000FFBB 7719                <1> 	ja	short m_pix_op_inc_1
 11785                              <1> 	; 256 colors (8bpp)
 11786                              <1> 	;jmp	short m_pix_op_inc_8
 11787                              <1> m_pix_op_inc_8:
 11788                              <1> 	; 8 bit colors (256 colors)
 11789 0000FFBD AC                  <1> 	lodsb 
 11790 0000FFBE 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
 11791 0000FFC4 740C                <1> 	je	short m_pix_op_inc_8_1 ; exclude
 11792 0000FFC6 FE07                <1> 	inc	byte [edi]
 11793 0000FFC8 7502                <1> 	jnz	short m_pix_op_inc_8_0
 11794 0000FFCA FE0F                <1> 	dec	byte [edi]
 11795                              <1> m_pix_op_inc_8_0:
 11796 0000FFCC FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
 11797                              <1> m_pix_op_inc_8_1:
 11798 0000FFD2 47                  <1> 	inc	edi
 11799 0000FFD3 E2E8                <1> 	loop	m_pix_op_inc_8
 11800 0000FFD5 C3                  <1> 	retn
 11801                              <1> m_pix_op_inc_1:
 11802 0000FFD6 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 11803 0000FFDD 7752                <1> 	ja	short m_pix_op_inc_3 ; 32bpp	
 11804 0000FFDF 7230                <1> 	jb	short m_pix_op_inc_2 ; 16bpp
 11805                              <1> 	; 24 bit true colors
 11806                              <1> 	;jmp	short m_pix_op_inc_24
 11807                              <1> m_pix_op_inc_24:
 11808                              <1> 	; 24 bit true colors
 11809 0000FFE1 66AD                <1> 	lodsw
 11810 0000FFE3 C1E010              <1> 	shl	eax, 16
 11811 0000FFE6 AC                  <1> 	lodsb
 11812 0000FFE7 C1C010              <1> 	rol	eax, 16	
 11813 0000FFEA 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 11814 0000FFF0 7419                <1> 	je	short m_pix_op_inc_24_1 ; exclude
 11815 0000FFF2 40                  <1> 	inc	eax
 11816 0000FFF3 3DFFFFFF00          <1> 	cmp	eax, 0FFFFFFh
 11817 0000FFF8 7601                <1> 	jna	short m_pix_op_inc_24_0
 11818 0000FFFA 48                  <1> 	dec	eax 
 11819                              <1> m_pix_op_inc_24_0:
 11820 0000FFFB 668907              <1> 	mov	[edi], ax
 11821 0000FFFE C1E810              <1> 	shr	eax, 16
 11822 00010001 884702              <1> 	mov	[edi+2], al
 11823 00010004 8305[64030300]03    <1> 	add	dword [u.r0], 3 ; +3
 11824                              <1> m_pix_op_inc_24_1:
 11825 0001000B 83C703              <1> 	add	edi, 3 ; +3
 11826 0001000E E2D1                <1> 	loop	m_pix_op_inc_24
 11827 00010010 C3                  <1> 	retn
 11828                              <1> 	; 65536 colors (16bpp)
 11829                              <1> m_pix_op_inc_2:
 11830                              <1> 	;jmp	short m_pix_op_inc_16
 11831                              <1> m_pix_op_inc_16:
 11832                              <1> 	; 16 bit colors (65536 colors)
 11833 00010011 66AD                <1> 	lodsw
 11834 00010013 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
 11835 0001001A 740F                <1> 	je	short m_pix_op_inc_16_1 ; exclude
 11836 0001001C 66FF07              <1> 	inc	word [edi]
 11837 0001001F 7503                <1> 	jnz	short m_pix_op_inc_16_0
 11838 00010021 66FF0F              <1> 	dec	word [edi]
 11839                              <1> m_pix_op_inc_16_0:
 11840 00010024 8305[64030300]02    <1> 	add	dword [u.r0], 2 ; +2
 11841                              <1> m_pix_op_inc_16_1:
 11842 0001002B 83C702              <1> 	add	edi, 2 ; +2
 11843 0001002E E2E1                <1> 	loop	m_pix_op_inc_16
 11844 00010030 C3                  <1> 	retn
 11845                              <1> m_pix_op_inc_3:
 11846                              <1> 	; 32 bit true colors
 11847                              <1> 	;jmp	short m_pix_op_inc_32
 11848                              <1> m_pix_op_inc_32:
 11849                              <1> 	; 32 bit true colors
 11850 00010031 AD                  <1> 	lodsd 
 11851 00010032 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 11852 00010038 740D                <1> 	je	short m_pix_op_inc_32_1 ; exclude
 11853 0001003A FF07                <1> 	inc	dword [edi]
 11854 0001003C 7502                <1> 	jnz	short m_pix_op_inc_32_0
 11855 0001003E FF0F                <1> 	dec	dword [edi]
 11856                              <1> m_pix_op_inc_32_0:	
 11857 00010040 8305[64030300]04    <1> 	add	dword [u.r0], 4 ; +4
 11858                              <1> m_pix_op_inc_32_1:
 11859 00010047 83C704              <1> 	add	edi, 4 ; +4
 11860 0001004A E2E5                <1> 	loop	m_pix_op_inc_32
 11861 0001004C C3                  <1> 	retn
 11862                              <1> 
 11863                              <1> m_pix_op_inc_w:
 11864                              <1> 	; 06/02/2021
 11865                              <1> 	; INCREASE COLOR (MASKED, window)
 11866                              <1> 	;
 11867                              <1> 	; jump from pix_op_inc_w
 11868                              <1> 	;
 11869                              <1> 	; INPUT:
 11870                              <1> 	;   ecx = bytes per row (to be applied)
 11871                              <1> 	;   edx = screen width in bytes
 11872                              <1> 	;   ebx = row count
 11873                              <1> 	;
 11874                              <1> 	;   [maskcolor] = mask color (to be excluded)
 11875                              <1> 	;
 11876                              <1> 	; OUTPUT:
 11877                              <1> 	; 	[u.r0] will be > 0 if succesful
 11878                              <1> 
 11879                              <1> 	; window
 11880                              <1> 	;mov	edi, [v_str] ; LFB start address
 11881                              <1> 	;mov	esi, edi 
 11882                              <1> 
 11883 0001004D 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 11884 00010054 7707                <1> 	ja	short m_pix_op_inc_w_1
 11885                              <1> 
 11886                              <1> 	; 256 colors (8bpp)
 11887 00010056 BD[BDFF0000]        <1> 	mov	ebp, m_pix_op_inc_8
 11888 0001005B EB1E                <1> 	jmp	short m_pix_op_inc_w_4
 11889                              <1> 			
 11890                              <1> m_pix_op_inc_w_1:
 11891 0001005D 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 11892 00010064 7710                <1> 	ja	short m_pix_op_inc_w_3 ; 32bpp
 11893 00010066 7207                <1> 	jb	short m_pix_op_inc_w_2 ; 16bpp
 11894                              <1> 
 11895                              <1> 	; 24 bit true colors
 11896 00010068 BD[E1FF0000]        <1> 	mov	ebp, m_pix_op_inc_24
 11897 0001006D EB0C                <1> 	jmp	short m_pix_op_inc_w_4
 11898                              <1> 
 11899                              <1> 	; 65536 colors (16bpp)
 11900                              <1> m_pix_op_inc_w_2:
 11901 0001006F BD[11000100]        <1> 	mov	ebp, m_pix_op_inc_16
 11902 00010074 EB05                <1> 	jmp	short m_pix_op_inc_w_4
 11903                              <1> 
 11904                              <1> 	; 32 bit true colors
 11905                              <1> m_pix_op_inc_w_3:
 11906 00010076 BD[31000100]        <1> 	mov	ebp, m_pix_op_inc_32
 11907                              <1> m_pix_op_inc_w_4:
 11908 0001007B E9DBF8FFFF          <1> 	jmp	m_pix_op_inc_w_x
 11909                              <1> 
 11910                              <1> m_pix_op_dec:
 11911                              <1> 	; 06/02/2021
 11912                              <1> 	; DECREASE COLOR (MASKED, full screen)
 11913                              <1> 	;
 11914                              <1> 	; jump from pix_op_dec
 11915                              <1> 	;
 11916                              <1> 	; INPUT:
 11917                              <1> 	;   ecx = [v_siz] ; display page pixel count
 11918                              <1> 	;   esi = edi = [v_mem] ; LFB start address
 11919                              <1> 	;
 11920                              <1> 	;   [maskcolor] = mask color (to be excluded)
 11921                              <1> 	;
 11922                              <1> 	; OUTPUT:
 11923                              <1> 	; 	[u.r0] will be > 0 if succesful
 11924                              <1> 	
 11925                              <1> 	; Full screen
 11926                              <1> m_pix_op_dec_0:
 11927 00010080 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 11928 00010087 7719                <1> 	ja	short m_pix_op_dec_1
 11929                              <1> 	; 256 colors (8bpp)
 11930                              <1> 	;jmp	short m_pix_op_dec_8
 11931                              <1> m_pix_op_dec_8:
 11932                              <1> 	; 8 bit colors (256 colors)
 11933 00010089 AC                  <1> 	lodsb 
 11934 0001008A 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
 11935 00010090 740C                <1> 	je	short m_pix_op_dec_8_1 ; exclude
 11936 00010092 FE0F                <1> 	dec	byte [edi]
 11937 00010094 7902                <1> 	jns	short m_pix_op_dec_8_0
 11938 00010096 FE07                <1> 	inc	byte [edi]
 11939                              <1> m_pix_op_dec_8_0:
 11940 00010098 FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
 11941                              <1> m_pix_op_dec_8_1:
 11942 0001009E 47                  <1> 	inc	edi
 11943 0001009F E2E8                <1> 	loop	m_pix_op_dec_8
 11944 000100A1 C3                  <1> 	retn
 11945                              <1> m_pix_op_dec_1:
 11946 000100A2 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 11947 000100A9 774D                <1> 	ja	short m_pix_op_dec_3 ; 32bpp	
 11948 000100AB 722B                <1> 	jb	short m_pix_op_dec_2 ; 16bpp
 11949                              <1> 	; 24 bit true colors
 11950                              <1> 	;jmp	short m_pix_op_dec_24
 11951                              <1> m_pix_op_dec_24:
 11952                              <1> 	; 24 bit true colors
 11953 000100AD 66AD                <1> 	lodsw
 11954 000100AF C1E010              <1> 	shl	eax, 16
 11955 000100B2 AC                  <1> 	lodsb
 11956 000100B3 C1C010              <1> 	rol	eax, 16	
 11957 000100B6 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 11958 000100BC 7414                <1> 	je	short m_pix_op_dec_24_1 ; exclude
 11959 000100BE 48                  <1> 	dec	eax
 11960 000100BF 7901                <1> 	jns	short m_pix_op_dec_24_0
 11961 000100C1 40                  <1> 	inc	eax 
 11962                              <1> m_pix_op_dec_24_0:
 11963 000100C2 668907              <1> 	mov	[edi], ax
 11964 000100C5 C1E810              <1> 	shr	eax, 16
 11965 000100C8 884702              <1> 	mov	[edi+2], al
 11966 000100CB 8305[64030300]03    <1> 	add	dword [u.r0], 3 ; +3
 11967                              <1> m_pix_op_dec_24_1:
 11968 000100D2 83C703              <1> 	add	edi, 3 ; +3
 11969 000100D5 E2D6                <1> 	loop	m_pix_op_dec_24
 11970 000100D7 C3                  <1> 	retn
 11971                              <1> 	; 65536 colors (16bpp)
 11972                              <1> m_pix_op_dec_2:
 11973                              <1> 	;jmp	short m_pix_op_dec_16
 11974                              <1> m_pix_op_dec_16:
 11975                              <1> 	; 16 bit colors (65536 colors)
 11976 000100D8 66AD                <1> 	lodsw
 11977 000100DA 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
 11978 000100E1 740F                <1> 	je	short m_pix_op_dec_16_1 ; exclude
 11979 000100E3 66FF0F              <1> 	dec	word [edi]
 11980 000100E6 7903                <1> 	jns	short m_pix_op_dec_16_0
 11981 000100E8 66FF07              <1> 	inc	word [edi]
 11982                              <1> m_pix_op_dec_16_0:
 11983 000100EB 8305[64030300]02    <1> 	add	dword [u.r0], 2 ; +2
 11984                              <1> m_pix_op_dec_16_1:
 11985 000100F2 83C702              <1> 	add	edi, 2 ; +2
 11986 000100F5 E2E1                <1> 	loop	m_pix_op_dec_16
 11987 000100F7 C3                  <1> 	retn
 11988                              <1> m_pix_op_dec_3:
 11989                              <1> 	; 32 bit true colors
 11990                              <1> 	;jmp	short m_pix_op_dec_32
 11991                              <1> m_pix_op_dec_32:
 11992                              <1> 	; 32 bit true colors
 11993 000100F8 AD                  <1> 	lodsd 
 11994 000100F9 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
 11995 000100FF 740D                <1> 	je	short m_pix_op_dec_32_1 ; exclude
 11996 00010101 FF0F                <1> 	dec	dword [edi]
 11997 00010103 7902                <1> 	jns	short m_pix_op_dec_32_0
 11998 00010105 FF07                <1> 	inc	dword [edi]
 11999                              <1> m_pix_op_dec_32_0:	
 12000 00010107 8305[64030300]04    <1> 	add	dword [u.r0], 4 ; +4
 12001                              <1> m_pix_op_dec_32_1:
 12002 0001010E 83C704              <1> 	add	edi, 4 ; +4
 12003 00010111 E2E5                <1> 	loop	m_pix_op_dec_32
 12004 00010113 C3                  <1> 	retn
 12005                              <1> 
 12006                              <1> m_pix_op_dec_w:
 12007                              <1> 	; 06/02/2021
 12008                              <1> 	; DECREASE COLOR (MASKED, window)
 12009                              <1> 	;
 12010                              <1> 	; jump from pix_op_dec_w
 12011                              <1> 	;
 12012                              <1> 	; INPUT:
 12013                              <1> 	;   ecx = bytes per row (to be applied)
 12014                              <1> 	;   edx = screen width in bytes
 12015                              <1> 	;   ebx = row count
 12016                              <1> 	;
 12017                              <1> 	;   [maskcolor] = mask color (to be excluded)
 12018                              <1> 	;
 12019                              <1> 	; OUTPUT:
 12020                              <1> 	; 	[u.r0] will be > 0 if succesful
 12021                              <1> 
 12022                              <1> 	; window
 12023                              <1> 	;mov	edi, [v_str] ; LFB start address
 12024                              <1> 	;mov	esi, edi 
 12025                              <1> 
 12026 00010114 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 12027 0001011B 7707                <1> 	ja	short m_pix_op_dec_w_1
 12028                              <1> 
 12029                              <1> 	; 256 colors (8bpp)
 12030 0001011D BD[89000100]        <1> 	mov	ebp, m_pix_op_dec_8
 12031 00010122 EB1E                <1> 	jmp	short m_pix_op_dec_w_4
 12032                              <1> 			
 12033                              <1> m_pix_op_dec_w_1:
 12034 00010124 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 12035 0001012B 7710                <1> 	ja	short m_pix_op_dec_w_3 ; 32bpp
 12036 0001012D 7207                <1> 	jb	short m_pix_op_dec_w_2 ; 16bpp
 12037                              <1> 
 12038                              <1> 	; 24 bit true colors
 12039 0001012F BD[AD000100]        <1> 	mov	ebp, m_pix_op_dec_24
 12040 00010134 EB0C                <1> 	jmp	short m_pix_op_dec_w_4
 12041                              <1> 
 12042                              <1> 	; 65536 colors (16bpp)
 12043                              <1> m_pix_op_dec_w_2:
 12044 00010136 BD[D8000100]        <1> 	mov	ebp, m_pix_op_dec_16
 12045 0001013B EB05                <1> 	jmp	short m_pix_op_dec_w_4
 12046                              <1> 
 12047                              <1> 	; 32 bit true colors
 12048                              <1> m_pix_op_dec_w_3:
 12049 0001013D BD[F8000100]        <1> 	mov	ebp, m_pix_op_dec_32
 12050                              <1> m_pix_op_dec_w_4:
 12051 00010142 E914F8FFFF          <1> 	jmp	m_pix_op_dec_w_x
 12052                              <1> 
 12053                              <1> sysvideo_39:
 12054                              <1> 	; 15/02/2021
 12055                              <1> 	; 07/02/2021, 08/02/2021
 12056                              <1> 	; 03/01/2021, 04/01/2021
 12057                              <1> 	; 23/11/2020
 12058                              <1> 	; BH = 3
 12059                              <1> 	; PIXEL READ/WRITE
 12060                              <1> 	
 12061                              <1> 	; 07/02/2021
 12062                              <1> 	; 04/01/2021 (TRDOS 386 v2.0.3)
 12063 00010147 80FB03              <1> 	cmp	bl, 3
 12064 0001014A 761A                <1> 	jna	short sysvideo_39_1
 12065                              <1> 	; 07/02/2021
 12066 0001014C 80FB06              <1> 	cmp	bl, 6
 12067 0001014F 7705                <1> 	ja	short sysvideo_39_0
 12068 00010151 E91A010000          <1> 	jmp	sysvideo_39_31
 12069                              <1> sysvideo_39_0:
 12070                              <1> 	; error
 12071 00010156 B3FF                <1> 	mov	bl, 0FFh
 12072 00010158 8B2D[60030300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
 12073 0001015E 895D10              <1> 	mov	[ebp+16], ebx ; EBX
 12074 00010161 E9A6D7FFFF          <1> 	jmp	sysret
 12075                              <1> sysvideo_39_1:
 12076 00010166 803D[DA6F0000]FF    <1> 	cmp	byte [CRT_MODE], 0FFh
 12077 0001016D 7312                <1> 	jnb	short sysvideo_39_2 ; SVGA (VESA VBE) video mode
 12078                              <1> 
 12079                              <1> 	; Std VGA or CGA mode
 12080 0001016F 81C200000A00        <1> 	add	edx, 0A0000h
 12081 00010175 72DF                <1> 	jc	short sysvideo_39_0
 12082 00010177 81FAFFFF0A00        <1> 	cmp	edx, 0AFFFFh
 12083 0001017D 77D7                <1> 	ja	short sysvideo_39_0
 12084 0001017F EB1E                <1> 	jmp	short sysvideo_39_3 ; 8bpp
 12085                              <1> 
 12086                              <1> sysvideo_39_2:
 12087                              <1> 	; use current vbe (svga) video mode
 12088                              <1> 
 12089                              <1> 	; get LFB address
 12090 00010181 A1[2C120300]        <1> 	mov	eax, [LFB_ADDR] ; [LFB_Info+LFBINFO.LFB_addr]
 12091 00010186 09C0                <1> 	or	eax, eax
 12092 00010188 74CC                <1> 	jz	short sysvideo_39_0
 12093 0001018A 3B15[30120300]      <1> 	cmp	edx, [LFB_SIZE] 
 12094 00010190 73C4                <1> 	jnb	short sysvideo_39_0
 12095                              <1> 
 12096 00010192 01C2                <1> 	add	edx, eax
 12097                              <1> 	;jc	short sysvideo_39_0
 12098                              <1> 
 12099                              <1> 	; Pixel read/write in VESA VBE (2/3) video mode
 12100                              <1> 	; Video memory at Linear Frame Buffer base address
 12101                              <1> 
 12102 00010194 8A3D[38120300]      <1> 	mov	bh, [LFB_Info+LFBINFO.bpp]
 12103                              <1> 
 12104 0001019A 80FF08              <1> 	cmp	bh, 8 ; 8bpp
 12105 0001019D 775D                <1> 	ja	short sysvideo_39_17
 12106                              <1> 
 12107                              <1> 	; 8 bits per pixel
 12108                              <1> sysvideo_39_3:
 12109 0001019F 80FB01              <1> 	cmp	bl, 1 ; 1 = write pixel
 12110 000101A2 7406                <1> 	je	short sysvideo_39_5
 12111 000101A4 7712                <1> 	ja	short sysvideo_39_8
 12112                              <1> sysvideo_39_4:
 12113                              <1> 	; read pixel (8bpp)
 12114 000101A6 8A02                <1> 	mov	al, [edx]
 12115                              <1> 	;mov	[u.r0], al
 12116                              <1> 	;jmp	sysret
 12117 000101A8 EB04                <1> 	jmp	short sysvideo_39_7
 12118                              <1> sysvideo_39_5:
 12119                              <1> 	; write pixel (8bpp)
 12120 000101AA 88C8                <1> 	mov	al, cl
 12121                              <1> sysvideo_39_6:
 12122 000101AC 8802                <1> 	mov	[edx], al
 12123                              <1> sysvideo_39_7:
 12124 000101AE A2[64030300]        <1> 	mov	[u.r0], al
 12125 000101B3 E954D7FFFF          <1> 	jmp	sysret
 12126                              <1> sysvideo_39_8:
 12127 000101B8 80FB03              <1> 	cmp	bl, 3 ; mix
 12128 000101BB 7208                <1> 	jb	short sysvideo_39_9
 12129                              <1> 	; mix  pixel colors (8bpp)
 12130 000101BD 8A02                <1> 	mov	al, [edx]
 12131 000101BF 00C8                <1> 	add	al, cl
 12132 000101C1 D0D8                <1> 	rcr	al, 1
 12133 000101C3 EBE7                <1> 	jmp	short sysvideo_39_6
 12134                              <1> sysvideo_39_9:
 12135                              <1> 	 ; swap pixel colors (8bpp)
 12136 000101C5 88C8                <1> 	mov	al, cl
 12137 000101C7 8602                <1> 	xchg	[edx], al
 12138 000101C9 EBE3                <1> 	jmp	short sysvideo_39_7
 12139                              <1> 
 12140                              <1> 	; 16 bits per pixel
 12141                              <1> sysvideo_39_10:
 12142 000101CB 80FB01              <1> 	cmp	bl, 1 ; 1 = write pixel
 12143 000101CE 7406                <1> 	je	short sysvideo_39_12
 12144 000101D0 7714                <1> 	ja	short sysvideo_39_15
 12145                              <1> sysvideo_39_11:
 12146                              <1> 	; read pixel (16bpp)
 12147 000101D2 8B02                <1> 	mov	eax, [edx]
 12148                              <1> 	;mov	[u.r0], ax
 12149                              <1> 	;jmp	sysret
 12150 000101D4 EB05                <1> 	jmp	short sysvideo_39_14
 12151                              <1> sysvideo_39_12:
 12152                              <1> 	; write pixel (16bpp)
 12153 000101D6 89C8                <1> 	mov	eax, ecx
 12154                              <1> sysvideo_39_13:
 12155 000101D8 668902              <1> 	mov	[edx], ax
 12156                              <1> sysvideo_39_14:
 12157 000101DB 66A3[64030300]      <1> 	mov	[u.r0], ax
 12158 000101E1 E926D7FFFF          <1> 	jmp	sysret
 12159                              <1> sysvideo_39_15:
 12160 000101E6 80FB03              <1> 	cmp	bl, 3 ; mix
 12161 000101E9 720A                <1> 	jb	short sysvideo_39_16
 12162                              <1> 	; mix  pixel colors (16bpp)
 12163 000101EB 8B02                <1> 	mov	eax, [edx]
 12164 000101ED 6601C8              <1> 	add	ax, cx
 12165 000101F0 66D1D8              <1> 	rcr	ax, 1
 12166 000101F3 EBE3                <1> 	jmp	short sysvideo_39_13
 12167                              <1> sysvideo_39_16:
 12168                              <1> 	 ; swap pixel colors (16bpp)
 12169 000101F5 89C8                <1> 	mov	eax, ecx
 12170 000101F7 668702              <1> 	xchg	[edx], ax
 12171 000101FA EBDF                <1> 	jmp	short sysvideo_39_14
 12172                              <1> sysvideo_39_17:
 12173 000101FC 80FF18              <1> 	cmp	bh, 24
 12174 000101FF 7743                <1> 	ja	short sysvideo_39_24
 12175 00010201 72C8                <1> 	jb	short sysvideo_39_10  
 12176                              <1> 	
 12177                              <1> 	; 24 bits per pixel
 12178 00010203 81E1FFFFFF00        <1> 	and	ecx, 0FFFFFFh
 12179 00010209 80FB01              <1> 	cmp	bl, 1 ; 1 = write pixel
 12180 0001020C 7406                <1> 	je	short sysvideo_39_19
 12181 0001020E 7712                <1> 	ja	short sysvideo_39_22
 12182                              <1> sysvideo_39_18:
 12183                              <1> 	; read pixel (24bpp)
 12184 00010210 8B02                <1> 	mov	eax, [edx]
 12185                              <1> 	;and	eax, 0FFFFFFh
 12186                              <1> 	;mov	[u.r0], eax
 12187                              <1> 	;jmp	sysret
 12188 00010212 EB04                <1> 	jmp	short sysvideo_39_21
 12189                              <1> sysvideo_39_19:
 12190                              <1> 	; write pixel (24bpp)
 12191 00010214 89C8                <1> 	mov	eax, ecx
 12192                              <1> sysvideo_39_20:
 12193                              <1> 	;and	eax, 0FFFFFFh
 12194 00010216 8902                <1> 	mov	[edx], eax
 12195                              <1> sysvideo_39_21:
 12196 00010218 A3[64030300]        <1> 	mov	[u.r0], eax
 12197 0001021D E9EAD6FFFF          <1> 	jmp	sysret
 12198                              <1> sysvideo_39_22:
 12199 00010222 80FB03              <1> 	cmp	bl, 3 ; mix
 12200 00010225 720D                <1> 	jb	short sysvideo_39_23
 12201                              <1> 	; mix  pixel colors (24bpp)
 12202 00010227 8B02                <1> 	mov	eax, [edx]
 12203 00010229 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
 12204                              <1> 	;and	ecx, 0FFFFFFh
 12205 0001022E 01C8                <1> 	add	eax, ecx
 12206 00010230 D1D8                <1> 	rcr	eax, 1
 12207 00010232 EBE2                <1> 	jmp	short sysvideo_39_20
 12208                              <1> sysvideo_39_23:
 12209                              <1> 	 ; swap pixel colors (24bpp)
 12210 00010234 89C8                <1> 	mov	eax, ecx
 12211                              <1> 	;and	eax, 0FFFFFFh
 12212 00010236 668702              <1> 	xchg	[edx], ax
 12213 00010239 C1C810              <1> 	ror	eax, 16
 12214 0001023C 884202              <1> 	mov	[edx+2], al	
 12215 0001023F C1C010              <1> 	rol	eax, 16
 12216 00010242 EBD4                <1> 	jmp	short sysvideo_39_21
 12217                              <1> 
 12218                              <1> 	; 32 bits per pixel
 12219                              <1> sysvideo_39_24:
 12220 00010244 80FB01              <1> 	cmp	bl, 1 ; 1 = write pixel
 12221 00010247 7406                <1> 	je	short sysvideo_39_26
 12222 00010249 7712                <1> 	ja	short sysvideo_39_29
 12223                              <1> sysvideo_39_25:
 12224                              <1> 	; read pixel (32bpp)
 12225 0001024B 8B02                <1> 	mov	eax, [edx]
 12226                              <1> 	;mov	[u.r0], eax
 12227                              <1> 	;jmp	sysret
 12228 0001024D EB04                <1> 	jmp	short sysvideo_39_28
 12229                              <1> sysvideo_39_26:
 12230                              <1> 	; write pixel (32bpp)
 12231 0001024F 89C8                <1> 	mov	eax, ecx
 12232                              <1> sysvideo_39_27:
 12233 00010251 8902                <1> 	mov	[edx], eax
 12234                              <1> sysvideo_39_28:
 12235 00010253 A3[64030300]        <1> 	mov	[u.r0], eax
 12236 00010258 E9AFD6FFFF          <1> 	jmp	sysret
 12237                              <1> sysvideo_39_29:
 12238 0001025D 80FB03              <1> 	cmp	bl, 3 ; mix
 12239 00010260 7208                <1> 	jb	short sysvideo_39_30
 12240                              <1> 	; mix  pixel colors (32bpp)
 12241 00010262 8B02                <1> 	mov	eax, [edx]
 12242 00010264 01C8                <1> 	add	eax, ecx
 12243 00010266 D1D8                <1> 	rcr	eax, 1
 12244 00010268 EBE7                <1> 	jmp	short sysvideo_39_27
 12245                              <1> sysvideo_39_30:
 12246                              <1> 	 ; swap pixel colors (32bpp)
 12247 0001026A 89C8                <1> 	mov	eax, ecx
 12248 0001026C 8702                <1> 	xchg	[edx], eax
 12249 0001026E EBE3                <1> 	jmp	short sysvideo_39_28
 12250                              <1> 
 12251                              <1> sysvideo_39_31:
 12252                              <1> 	; 06/03/2021
 12253                              <1> 	; 08/02/2021
 12254                              <1> 	; 07/02/2021
 12255                              <1> 	; BL = 4 -> read pixels from user defined positions
 12256                              <1> 	; BL = 5 -> write single color pixels to user defined pos.
 12257                              <1> 	; BL = 6 -> write multi color pixels to user defined pos.
 12258                              <1> 	; ECX = color (CL, CX, ECX)
 12259                              <1> 	; EDX = number of pixels
 12260                              <1> 	; ESI = user buffer contains dword pixel positions
 12261                              <1> 	;	 (and dword colors for BL input = 6)
 12262                              <1> 	; EDI = user's pixel color buff (destination) for BL = 4
 12263                              <1> 
 12264 00010270 890D[9A120300]      <1> 	mov	[maskcolor], ecx
 12265 00010276 89D5                <1> 	mov	ebp, edx ; number of pixels    
 12266 00010278 803D[DA6F0000]FF    <1> 	cmp	byte [CRT_MODE], 0FFh ; SVGA flag
 12267 0001027F 7317                <1> 	jnb	short sysvideo_39_33 ; SVGA (VESA VBE mode)
 12268                              <1> 	; Standard VGA mode
 12269 00010281 B900000100          <1> 	mov	ecx, 65536 ; Video page size (maximum)
 12270 00010286 39CA                <1> 	cmp	edx, ecx
 12271 00010288 7709                <1> 	ja	short sysvideo_39_32 ; abnormal value !
 12272 0001028A B800000A00          <1> 	mov	eax, 0A0000h ; Video page start address
 12273 0001028F B708                <1> 	mov	bh, 8  ; 8 bits per pixel (256 colors)
 12274 00010291 EB35                <1> 	jmp	short sysvideo_39_34
 12275                              <1> sysvideo_39_32:
 12276                              <1> 	; nonsense! (edx has abnormal value)
 12277 00010293 E974D6FFFF          <1> 	jmp	sysret	
 12278                              <1> sysvideo_39_33:
 12279                              <1> 	; 06/03/2021
 12280 00010298 8A3D[38120300]      <1> 	mov	bh, [LFB_Info+LFBINFO.bpp]
 12281 0001029E 80FF08              <1> 	cmp	bh, 8
 12282 000102A1 7412                <1> 	je	short sysvideo_39_81 ; 8bpp
 12283 000102A3 89D0                <1> 	mov	eax, edx
 12284 000102A5 80FF10              <1> 	cmp	bh, 16
 12285 000102A8 7409                <1> 	je	short sysvideo_39_80 ; 16bpp
 12286 000102AA D1E2                <1> 	shl	edx, 1
 12287 000102AC 80FF20              <1> 	cmp	bh, 32
 12288 000102AF 7502                <1> 	jne	short sysvideo_39_80 ; 24bpp
 12289 000102B1 D1E0                <1> 	shl	eax, 1
 12290                              <1> sysvideo_39_80:	
 12291 000102B3 01C2                <1> 	add	edx, eax
 12292                              <1> 	; edx = number of bytes
 12293                              <1> sysvideo_39_81:
 12294                              <1> 	; get LFB address
 12295 000102B5 A1[2C120300]        <1> 	mov	eax, [LFB_ADDR] ; [LFB_Info+LFBINFO.LFB_addr]
 12296 000102BA 09C0                <1> 	or	eax, eax
 12297 000102BC 74D5                <1> 	jz	short sysvideo_39_32 ; LFB is not ready !
 12298 000102BE 8B0D[30120300]      <1> 	mov	ecx, [LFB_SIZE]
 12299 000102C4 39CA                <1> 	cmp	edx, ecx 
 12300 000102C6 77CB                <1> 	ja	short sysvideo_39_32 ; abnormal value !
 12301                              <1> 
 12302                              <1> 	; 02/03/2021
 12303                              <1> 	; 08/02/2021
 12304                              <1> 	;mov	ebp, edx ; pixel count  
 12305                              <1> 	;shl	ebp, 2 ; byte count (pixel pos: 4 bytes)
 12306                              <1> 
 12307                              <1> 	; 06/03/2021
 12308                              <1> 	; bits per pixel (pixel color size)
 12309                              <1> 	;mov	bh, [LFB_Info+LFBINFO.bpp]	
 12310                              <1> sysvideo_39_34:
 12311 000102C8 C1E502              <1> 	shl	ebp, 2 ; 15/02/2021 (byte count)	
 12312 000102CB A3[8A120300]        <1> 	mov	[v_mem], eax ; Save video page start address
 12313 000102D0 88DE                <1> 	mov	dh, bl ; sub function
 12314                              <1> 	; 06/03/2021
 12315 000102D2 883D[89120300]      <1> 	mov	[v_bpp], bh ; bits per pixel (color size)
 12316                              <1> 	;mov	ebx, [LFB_SIZE]
 12317 000102D8 89CB                <1> 	mov	ebx, ecx ; [LFB_SIZE]
 12318                              <1> 
 12319 000102DA B900080000          <1> 	mov	ecx, 2048
 12320 000102DF 39CD                <1> 	cmp	ebp, ecx
 12321 000102E1 7302                <1> 	jnb	short sysvideo_39_35 	
 12322 000102E3 89E9                <1> 	mov	ecx, ebp ; fix to requested byte count	
 12323                              <1> sysvideo_39_35:
 12324 000102E5 80FE04              <1> 	cmp	dh, 4 ; 08/02/2021
 12325                              <1> 	;cmp	bl, 4 ; read pixels from user defined positions 
 12326 000102E8 7605                <1> 	jna	short sysvideo_39_36
 12327 000102EA E9B2000000          <1> 	jmp	sysvideo_39_52
 12328                              <1> 	; 08/02/2021
 12329                              <1> 	;mov	[buffer8], edi  ; user's destination buff addr
 12330                              <1> sysvideo_39_36:
 12331                              <1> 	; 08/02/2021
 12332                              <1> 	; read pixel positions 
 12333                              <1> 	; as defined in user's source buffer 
 12334 000102EF 893D[A2120300]      <1> 	mov	[buffer8], edi  ; user's destination buff addr
 12335 000102F5 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; kernel buffer for
 12336                              <1> 					  ; 2028 byte data
 12337                              <1> 	; esi = user's source buffer for pixel positions
 12338                              <1> 	; ecx = byte count
 12339 000102FA E8AF180000          <1> 	call	transfer_from_user_buffer
 12340 000102FF 7292                <1> 	jc	short sysvideo_39_32 ; error
 12341                              <1> 	; ecx  = transfer count (bytes)
 12342                              <1> 
 12343 00010301 57                  <1> 	push	edi ; *
 12344 00010302 56                  <1> 	push	esi ; **
 12345 00010303 51                  <1> 	push	ecx ; ***
 12346                              <1> 
 12347 00010304 89FE                <1> 	mov	esi, edi ; kernel buffer
 12348 00010306 8B15[8A120300]      <1> 	mov	edx, [v_mem] ; video memory
 12349 0001030C C1E902              <1> 	shr	ecx, 2 ; pixel count (within buffer capacity)
 12350                              <1> 
 12351 0001030F 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 12352 00010316 7753                <1> 	ja	short sysvideo_39_49
 12353                              <1> sysvideo_39_37:
 12354                              <1> 	; 8bpp
 12355 00010318 AD                  <1> 	lodsd
 12356 00010319 39D8                <1> 	cmp	eax, ebx ; < [LFB_SIZE]
 12357 0001031B 7309                <1> 	jnb	short sysvideo_39_39
 12358 0001031D 0FB60402            <1> 	movzx	eax, byte [edx+eax]
 12359                              <1> sysvideo_39_38:
 12360 00010321 AB                  <1> 	stosd
 12361 00010322 E2F4                <1> 	loop	sysvideo_39_37
 12362 00010324 EB49                <1> 	jmp	short sysvideo_39_50
 12363                              <1> sysvideo_39_39:
 12364                              <1> 	; write black color for improper positions
 12365 00010326 31C0                <1> 	xor	eax, eax
 12366 00010328 EBF7                <1> 	jmp	short sysvideo_39_38
 12367                              <1> sysvideo_39_40:
 12368 0001032A 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 12369 00010331 772A                <1> 	ja	short sysvideo_39_47 ; 32bpp
 12370 00010333 7216                <1> 	jb	short sysvideo_39_44 ; 16bpp
 12371                              <1> sysvideo_39_41: 
 12372                              <1> 	; 24bpp
 12373 00010335 AD                  <1> 	lodsd
 12374 00010336 39D8                <1> 	cmp	eax, ebx ; < [LFB_SIZE]
 12375 00010338 730D                <1> 	jnb	short sysvideo_39_43
 12376 0001033A 8B0402              <1> 	mov	eax, [edx+eax]
 12377 0001033D 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
 12378                              <1> sysvideo_39_42:
 12379 00010342 AB                  <1> 	stosd
 12380 00010343 E2F0                <1> 	loop	sysvideo_39_41
 12381 00010345 EB28                <1> 	jmp	short sysvideo_39_50
 12382                              <1> sysvideo_39_43:
 12383                              <1> 	; write black color for improper positions
 12384 00010347 31C0                <1> 	xor	eax, eax
 12385 00010349 EBF7                <1> 	jmp	short sysvideo_39_42
 12386                              <1> sysvideo_39_44:
 12387                              <1> 	; 16bpp
 12388 0001034B AD                  <1> 	lodsd
 12389 0001034C 39D8                <1> 	cmp	eax, ebx ; < [LFB_SIZE]
 12390 0001034E 7309                <1> 	jnb	short sysvideo_39_46
 12391 00010350 0FB70402            <1> 	movzx	eax, word [edx+eax]
 12392                              <1> sysvideo_39_45:
 12393 00010354 AB                  <1> 	stosd
 12394 00010355 E2F4                <1> 	loop	sysvideo_39_44
 12395 00010357 EB16                <1> 	jmp	short sysvideo_39_50
 12396                              <1> sysvideo_39_46:
 12397                              <1> 	; write black color for improper positions
 12398 00010359 31C0                <1> 	xor	eax, eax
 12399 0001035B EBF7                <1> 	jmp	short sysvideo_39_45
 12400                              <1> sysvideo_39_47:
 12401                              <1> 	; 32bpp
 12402 0001035D AD                  <1> 	lodsd
 12403 0001035E 39D8                <1> 	cmp	eax, ebx ; < [LFB_SIZE]
 12404 00010360 7309                <1> 	jnb	short sysvideo_39_49
 12405 00010362 0FB70402            <1> 	movzx	eax, word [edx+eax]
 12406                              <1> sysvideo_39_48:
 12407 00010366 AB                  <1> 	stosd
 12408 00010367 E2F4                <1> 	loop	sysvideo_39_47
 12409 00010369 EB04                <1> 	jmp	short sysvideo_39_50
 12410                              <1> sysvideo_39_49:
 12411                              <1> 	; write black color for improper positions
 12412 0001036B 31C0                <1> 	xor	eax, eax
 12413 0001036D EBF7                <1> 	jmp	short sysvideo_39_48
 12414                              <1> sysvideo_39_50:
 12415 0001036F 59                  <1> 	pop	ecx ; transfer count in bytes
 12416 00010370 5E                  <1> 	pop	esi ; ** ; kernel buffer
 12417                              <1>  	;mov	esi, VBE3SAVERESTOREBLOCK ; kernel buffer for
 12418                              <1> 					  ; 2048 byte data
 12419 00010371 8B3D[A2120300]      <1> 	mov	edi, [buffer8]
 12420                              <1> 	; edi = user's destination buffer for pixel colors
 12421                              <1> 	; ecx = byte count
 12422 00010377 E8E8170000          <1> 	call	transfer_to_user_buffer
 12423 0001037C 5E                  <1> 	pop	esi ; *
 12424 0001037D 7266                <1> 	jc	short sysvideo_39_56 ; error
 12425                              <1> 	; ecx  = transfer count (bytes)
 12426 0001037F 89C8                <1> 	mov	eax, ecx
 12427 00010381 C1E802              <1> 	shr	eax, 2
 12428 00010384 0105[64030300]      <1> 	add	[u.r0], eax ; transfer count (in pixels)
 12429                              <1> 		
 12430 0001038A 29CD                <1> 	sub	ebp, ecx
 12431 0001038C 7657                <1> 	jna	short sysvideo_39_56 ; completed/finished
 12432 0001038E 01CE                <1> 	add	esi, ecx ; next position in source buffer
 12433                              <1> 	;add	[buffer8], ecx ; next pos in destination buff
 12434 00010390 01CF                <1> 	add	edi, ecx
 12435 00010392 66B90008            <1> 	mov	cx, 2048 ; new count, limit: kernel buff size
 12436 00010396 39CD                <1> 	cmp	ebp, ecx ; remain >= limit ?
 12437 00010398 7302                <1> 	jnb	short sysvideo_39_51 ; yes
 12438 0001039A 89E9                <1> 	mov	ecx, ebp ; fix byte count to remain bytes
 12439                              <1> sysvideo_39_51:
 12440 0001039C E94EFFFFFF          <1> 	jmp	sysvideo_39_36 
 12441                              <1> 
 12442                              <1> sysvideo_39_52:
 12443 000103A1 80FE05              <1> 	cmp	dh, 5 ; 08/02/2021
 12444                              <1> 	;cmp	bl, 5 ; write pixels to user defined positions 
 12445 000103A4 7605                <1> 	jna	short sysvideo_39_53
 12446 000103A6 E9A1000000          <1> 	jmp	sysvideo_39_66
 12447                              <1> sysvideo_39_53:
 12448                              <1> 	; single color pixel writing
 12449 000103AB BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; kernel buffer for
 12450                              <1> 					  ; 2028 byte data
 12451                              <1> 	; esi = user's source buffer for pixel positions
 12452                              <1> 	; ecx = byte count
 12453 000103B0 E8F9170000          <1> 	call	transfer_from_user_buffer
 12454 000103B5 722E                <1> 	jc	short sysvideo_39_56 ; error
 12455                              <1> 	; ecx = transfer count (bytes)
 12456                              <1> 
 12457                              <1> 	; write pixels by using (user) defined positions
 12458                              <1> 	; ecx = byte count (1,2,3,4 times pixel count)	
 12459                              <1> 	; edi = system buffer address
 12460                              <1> 
 12461 000103B7 56                  <1> 	push	esi ; *
 12462 000103B8 51                  <1> 	push	ecx ; **
 12463                              <1> 
 12464 000103B9 89FE                <1> 	mov	esi, edi
 12465 000103BB 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
 12466                              <1> 
 12467                              <1> 	; 08/02/2021
 12468 000103C1 C1E902              <1> 	shr	ecx, 2 ; pixel count
 12469 000103C4 8B15[9A120300]      <1> 	mov	edx, [maskcolor]
 12470                              <1> 	;mov	ebx, [v_siz]
 12471                              <1> 
 12472 000103CA 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 12473 000103D1 7717                <1> 	ja	short sysvideo_39_57
 12474                              <1> sysvideo_39_54:
 12475                              <1> 	; 8bpp
 12476 000103D3 AD                  <1> 	lodsd
 12477 000103D4 39D8                <1> 	cmp	eax, ebx ; < [v_siz]
 12478 000103D6 7309                <1> 	jnb	short sysvideo_39_55
 12479 000103D8 881407              <1> 	mov	[edi+eax], dl
 12480                              <1> 	; 06/03/2021
 12481 000103DB FF05[64030300]      <1> 	inc	dword [u.r0]
 12482                              <1> sysvideo_39_55:
 12483 000103E1 E2F0                <1> 	loop	sysvideo_39_54
 12484 000103E3 EB50                <1> 	jmp	short sysvideo_39_64
 12485                              <1> sysvideo_39_56:
 12486 000103E5 E922D5FFFF          <1> 	jmp	sysret
 12487                              <1> sysvideo_39_57:
 12488 000103EA 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 12489 000103F1 7732                <1> 	ja	short sysvideo_39_62 ; 32bpp
 12490 000103F3 721D                <1> 	jb	short sysvideo_39_60 ; 16bpp
 12491                              <1> sysvideo_39_58: 
 12492                              <1> 	; 24bpp
 12493 000103F5 AD                  <1> 	lodsd
 12494 000103F6 39D8                <1> 	cmp	eax, ebx ; < [v_siz]
 12495 000103F8 7314                <1> 	jnb	short sysvideo_39_59
 12496 000103FA 881407              <1> 	mov	[edi+eax], dl
 12497 000103FD 40                  <1> 	inc	eax
 12498 000103FE C1CA08              <1> 	ror	edx, 8
 12499 00010401 66891407            <1> 	mov	[edi+eax], dx
 12500 00010405 C1C208              <1> 	rol	edx, 8
 12501 00010408 FF05[64030300]      <1> 	inc	dword [u.r0]
 12502                              <1> sysvideo_39_59:
 12503 0001040E E2E5                <1> 	loop	sysvideo_39_58
 12504 00010410 EB23                <1> 	jmp	short sysvideo_39_64
 12505                              <1> sysvideo_39_60:
 12506                              <1> 	; 16bpp
 12507 00010412 AD                  <1> 	lodsd
 12508 00010413 39D8                <1> 	cmp	eax, ebx ; < [v_siz]
 12509 00010415 730A                <1> 	jnb	short sysvideo_39_61
 12510 00010417 66891407            <1> 	mov	[edi+eax], dx
 12511 0001041B FF05[64030300]      <1> 	inc	dword [u.r0]
 12512                              <1> sysvideo_39_61:	
 12513 00010421 E2EF                <1> 	loop	sysvideo_39_60
 12514 00010423 EB10                <1> 	jmp	short sysvideo_39_64	
 12515                              <1> sysvideo_39_62:
 12516                              <1> 	; 32bpp
 12517 00010425 AD                  <1> 	lodsd
 12518 00010426 39D8                <1> 	cmp	eax, ebx ; < [v_siz]
 12519 00010428 7309                <1> 	jnb	short sysvideo_39_63
 12520 0001042A 891407              <1> 	mov	[edi+eax], edx
 12521 0001042D FF05[64030300]      <1> 	inc	dword [u.r0]
 12522                              <1> sysvideo_39_63:	
 12523 00010433 E2F0                <1> 	loop	sysvideo_39_62
 12524                              <1> sysvideo_39_64:
 12525 00010435 59                  <1> 	pop	ecx ; **
 12526 00010436 5E                  <1> 	pop	esi ; *	
 12527 00010437 29CD                <1> 	sub	ebp, ecx
 12528 00010439 76AA                <1> 	jna	short sysvideo_39_56
 12529 0001043B 01CE                <1> 	add	esi, ecx
 12530 0001043D 66B90008            <1> 	mov	cx, 2048
 12531 00010441 39CD                <1> 	cmp	ebp, ecx
 12532 00010443 7302                <1> 	jnb	short sysvideo_39_65
 12533 00010445 89E9                <1> 	mov	ecx, ebp
 12534                              <1> sysvideo_39_65:
 12535 00010447 E95FFFFFFF          <1> 	jmp	sysvideo_39_53
 12536                              <1> 
 12537                              <1> sysvideo_39_66:
 12538                              <1> 	; 15/02/2021
 12539 0001044C D1E5                <1> 	shl	ebp, 1 ; 8 bytes per pixel (position&color)
 12540                              <1> sysvideo_39_67: 	
 12541 0001044E 66B90008            <1> 	mov	cx, 2048
 12542 00010452 39CD                <1> 	cmp	ebp, ecx
 12543 00010454 7302                <1> 	jnb	short sysvideo_39_68
 12544 00010456 89E9                <1> 	mov	ecx, ebp
 12545                              <1> sysvideo_39_68:
 12546                              <1> 	; multi colors pixel writing
 12547 00010458 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; kernel buffer for
 12548                              <1> 					  ; 2048 byte data
 12549                              <1> 	; esi = user's source buffer for pixel positions
 12550                              <1> 	; ecx = byte count
 12551 0001045D E84C170000          <1> 	call	transfer_from_user_buffer
 12552 00010462 7281                <1> 	jc	short sysvideo_39_56 ; error
 12553                              <1> 	; ecx  = transfer count
 12554                              <1> 	
 12555                              <1> 	; write pixels & colors as defined in user buffer 
 12556                              <1> 	; ecx = byte count (2,4,6,8 times pixel count)	
 12557                              <1> 	; edi = system buffer address
 12558                              <1> 
 12559 00010464 56                  <1> 	push	esi ; **
 12560 00010465 51                  <1> 	push	ecx ; *
 12561                              <1> 
 12562 00010466 89FE                <1> 	mov	esi, edi
 12563 00010468 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
 12564                              <1> 
 12565                              <1> 	; 08/02/2021
 12566 0001046E C1E903              <1> 	shr	ecx, 3 ; pixel count
 12567                              <1> 
 12568                              <1> 	;mov	ebx, [v_siz]
 12569                              <1> 
 12570 00010471 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 12571 00010478 7715                <1> 	ja	short sysvideo_39_71
 12572                              <1> sysvideo_39_69:
 12573                              <1> 	; 8bpp
 12574 0001047A AD                  <1> 	lodsd	; position
 12575 0001047B 89C2                <1> 	mov	edx, eax
 12576 0001047D AD                  <1> 	lodsd	; color
 12577 0001047E 39DA                <1> 	cmp	edx, ebx ; < [v_siz]
 12578 00010480 7309                <1> 	jnb	short sysvideo_39_70
 12579 00010482 880417              <1> 	mov	[edi+edx], al
 12580                              <1> 	; 06/03/2021
 12581 00010485 FF05[64030300]      <1> 	inc	dword [u.r0]
 12582                              <1> sysvideo_39_70:
 12583 0001048B E2ED                <1> 	loop	sysvideo_39_69
 12584 0001048D EB51                <1> 	jmp	short sysvideo_39_78
 12585                              <1> sysvideo_39_71:
 12586 0001048F 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 12587 00010496 7735                <1> 	ja	short sysvideo_39_76 ; 32bpp
 12588 00010498 721D                <1> 	jb	short sysvideo_39_74 ; 16bpp
 12589                              <1> sysvideo_39_72:
 12590                              <1> 	; 24bpp 
 12591 0001049A AD                  <1> 	lodsd	; position
 12592 0001049B 89C2                <1> 	mov	edx, eax
 12593 0001049D AD                  <1> 	lodsd	; color
 12594 0001049E 39DA                <1> 	cmp	edx, ebx ; < [v_siz]
 12595 000104A0 7311                <1> 	jnb	short sysvideo_39_73
 12596 000104A2 880417              <1> 	mov	[edi+edx], al
 12597 000104A5 42                  <1> 	inc	edx
 12598 000104A6 C1E808              <1> 	shr	eax, 8
 12599 000104A9 66890417            <1> 	mov	[edi+edx], ax
 12600 000104AD FF05[64030300]      <1> 	inc	dword [u.r0]
 12601                              <1> sysvideo_39_73:	
 12602 000104B3 E2E5                <1> 	loop	sysvideo_39_72
 12603 000104B5 EB29                <1> 	jmp	short sysvideo_39_78
 12604                              <1> sysvideo_39_74:
 12605                              <1> 	; 16bpp
 12606 000104B7 AD                  <1> 	lodsd	; position
 12607 000104B8 89C2                <1> 	mov	edx, eax
 12608 000104BA AD                  <1> 	lodsd	; color
 12609 000104BB 39DA                <1> 	cmp	edx, ebx ; < [v_siz]
 12610 000104BD 730A                <1> 	jnb	short sysvideo_39_75
 12611 000104BF 66890417            <1> 	mov	[edi+edx], ax
 12612 000104C3 FF05[64030300]      <1> 	inc	dword [u.r0]
 12613                              <1> sysvideo_39_75:	
 12614 000104C9 E2EC                <1> 	loop	sysvideo_39_74
 12615 000104CB EB13                <1> 	jmp	short sysvideo_39_78
 12616                              <1> sysvideo_39_76:
 12617                              <1> 	; 32bpp
 12618 000104CD AD                  <1> 	lodsd	; position
 12619 000104CE 89C2                <1> 	mov	edx, eax
 12620 000104D0 AD                  <1> 	lodsd	; color
 12621 000104D1 39DA                <1> 	cmp	edx, ebx ; < [v_siz]
 12622 000104D3 7309                <1> 	jnb	short sysvideo_39_77
 12623 000104D5 890417              <1> 	mov	[edi+edx], eax
 12624 000104D8 FF05[64030300]      <1> 	inc	dword [u.r0]
 12625                              <1> sysvideo_39_77:	
 12626 000104DE E2ED                <1> 	loop	sysvideo_39_76
 12627                              <1> sysvideo_39_78:
 12628 000104E0 59                  <1> 	pop	ecx ; *
 12629 000104E1 5E                  <1> 	pop	esi ; **	
 12630                              <1> 
 12631 000104E2 29CD                <1> 	sub	ebp, ecx
 12632 000104E4 762A                <1> 	jna	short sysvideo_39_79
 12633 000104E6 01CE                <1> 	add	esi, ecx
 12634 000104E8 E961FFFFFF          <1> 	jmp	sysvideo_39_67
 12635                              <1> ;sysvideo_39_79:
 12636                              <1> ;	jmp	sysret
 12637                              <1> 		
 12638                              <1> sysvideo_16:
 12639                              <1> 	; 06/03/2021
 12640                              <1> 	; 23/11/2020
 12641 000104ED 80FF04              <1> 	cmp	bh, 4
 12642 000104F0 0F8251FCFFFF        <1> 	jb	sysvideo_39 ; bh = 3, pixel r/w
 12643 000104F6 771D                <1> 	ja	short sysvideo_17
 12644                              <1> 	
 12645                              <1> 	; BH = 4
 12646                              <1> 	; Direct User Access for CGA video memory.
 12647                              <1> 	; Setup user's page tables for direct access to 0B8000h.
 12648                              <1> 	;
 12649                              <1> 	; Permission checks are not implemented yet !
 12650                              <1> 	; (11/07/2016)
 12651                              <1> 
 12652 000104F8 B800800B00          <1> 	mov	eax, 0B8000h
 12653 000104FD B908000000          <1> 	mov	ecx, 8 ; 8 pages (8*4K=32K)
 12654 00010502 89C3                <1> 	mov	ebx, eax ; 12/05/2017 ; virtual = physical
 12655 00010504 E8F961FFFF          <1> 	call	direct_memory_access	
 12656                              <1> 	;jc	sysret
 12657 00010509 7205                <1> 	jc	short sysvideo_39_79 ; 06/03/2021
 12658                              <1> 	; eax = 0B8000h if there is not an error
 12659 0001050B A3[64030300]        <1> 	mov	[u.r0], eax
 12660                              <1> sysvideo_39_79: ; 08/01/2021
 12661 00010510 E9F7D3FFFF          <1> 	jmp	sysret
 12662                              <1> 
 12663                              <1> sysvideo_17:
 12664                              <1> 	; 23/12/2020
 12665                              <1> 	; 11/12/2020
 12666                              <1> 	; 10/12/2020
 12667                              <1> 	; 23/11/2020
 12668 00010515 80FF06              <1> 	cmp	bh, 6
 12669 00010518 740B                <1> 	je	short sysvideo_17_0
 12670 0001051A 0F82B9000000        <1> 	jb	sysvideo_18
 12671 00010520 E913010000          <1> 	jmp	sysvideo_20 ; ja
 12672                              <1> 
 12673                              <1> sysvideo_17_0:
 12674                              <1> 	; BH = 6
 12675                              <1> 	; Direct User Access to Linear Frame Buffer.
 12676                              <1> 	; Setup user's page tables for direct access to LFB.
 12677                              <1> 	;
 12678                              <1> 	; Permission checks are not implemented yet !
 12679                              <1> 	; (10/12/2020)
 12680                              <1> 
 12681 00010525 80FBFF              <1> 	cmp	bl, 0FFh ; current video mode
 12682 00010528 722C                <1> 	jb	short sysvideo_17_2 ; for desired video mode
 12683                              <1> 
 12684 0001052A 381D[DA6F0000]      <1> 	cmp	[CRT_MODE], bl ; VESA VBE video mode ?
 12685 00010530 750E                <1> 	jne	short sysvideo_17_1
 12686 00010532 668B0D[1E120300]    <1> 	mov	cx, [video_mode]
 12687 00010539 6681E1FF01          <1> 	and	cx, 1FFh
 12688 0001053E EB29                <1> 	jmp	short sysvideo_17_3
 12689                              <1> sysvideo_17_1:
 12690                              <1> 	; 11/12/2020
 12691 00010540 88DF                <1> 	mov	bh, bl ; 0FFh
 12692 00010542 8A1D[DA6F0000]      <1> 	mov	bl, [CRT_MODE] ; VGA/CGA video mode
 12693 00010548 8B2D[60030300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
 12694                              <1> 	; 23/12/2020
 12695 0001054E 895D10              <1> 	mov	[ebp+16], ebx ; return to user with EBX value 
 12696 00010551 E9B6D3FFFF          <1> 	jmp	sysret ; return to user with EAX = 0
 12697                              <1> sysvideo_17_2:
 12698                              <1> 	; bl = VESA video mode - 100h
 12699 00010556 B701                <1> 	mov	bh, 1 ; bx = 1XXh
 12700 00010558 53                  <1> 	push	ebx ; requested vesa video mode
 12701 00010559 E85536FFFF          <1> 	call	vbe_biosfn_return_current_mode
 12702 0001055E 59                  <1> 	pop	ecx ; requested vesa video mode
 12703 0001055F 6681E3FF01          <1> 	and	bx, 1FFh
 12704 00010564 6639D9              <1> 	cmp	cx, bx
 12705 00010567 7564                <1> 	jne	short sysvideo_17_8
 12706                              <1> sysvideo_17_3:
 12707 00010569 663B0D[2A120300]    <1> 	cmp	cx, [LFB_Info+LFBINFO.mode]
 12708 00010570 755B                <1> 	jne	short sysvideo_17_8
 12709                              <1> sysvideo_17_4:
 12710                              <1> 	; 11/12/2020
 12711 00010572 A1[2C120300]        <1> 	mov	eax, [LFB_Info+LFBINFO.LFB_addr]
 12712                              <1> 	; 21/12/2020
 12713 00010577 09C0                <1> 	or	eax, eax
 12714 00010579 744D                <1> 	jz	short sysvideo_17_7
 12715                              <1> 	;
 12716 0001057B 8B0D[30120300]      <1> 	mov	ecx, [LFB_Info+LFBINFO.LFB_size] ; buff size
 12717 00010581 89C3                <1> 	mov 	ebx, eax ; user's address = physical address
 12718                              <1> 	;push	ebx
 12719 00010583 51                  <1> 	push	ecx
 12720                              <1> 	; 21/12/2020
 12721 00010584 81C1FF0F0000        <1> 	add	ecx, 4095  ; PAGESIZE - 1
 12722                              <1> 	; 14/12/2020
 12723 0001058A C1E90C              <1> 	shr	ecx, 12  ; convert bytes to pages
 12724 0001058D E87061FFFF          <1> 	call	direct_memory_access
 12725 00010592 5A                  <1> 	pop	edx  ; linear frame buffer size in bytes
 12726                              <1> 	;pop	eax  ; linear frame buffer address (physical)
 12727 00010593 7233                <1> 	jc	short sysvideo_17_7 ; [u.r0] = eax = 0
 12728                              <1> sysvideo_17_5:
 12729 00010595 668B0D[36120300]    <1> 	mov	cx, [LFB_Info+LFBINFO.Y_res] ; screen height
 12730 0001059C C1E110              <1> 	shl	ecx, 16
 12731 0001059F 668B0D[34120300]    <1> 	mov	cx,  [LFB_Info+LFBINFO.X_res] ; screen width
 12732 000105A6 31DB                <1> 	xor	ebx, ebx
 12733 000105A8 8A1D[38120300]      <1> 	mov	bl, [LFB_Info+LFBINFO.bpp] ; bits per pixel
 12734 000105AE 8A3D[2A120300]      <1> 	mov	bh, [LFB_Info+LFBINFO.mode] ; XX part of 1XXh
 12735                              <1> sysvideo_26_4: ; 23/12/2020	
 12736 000105B4 8B2D[60030300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
 12737 000105BA 895514              <1> 	mov	[ebp+20], edx ; return to user with EDX value 
 12738 000105BD 895D10              <1> 	mov	[ebp+16], ebx ; EBX
 12739 000105C0 894D18              <1> 	mov	[ebp+24], ecx ; ECX
 12740                              <1> sysvideo_17_6:
 12741 000105C3 A3[64030300]        <1> 	mov	[u.r0], eax ; LFB address
 12742                              <1> sysvideo_17_7:
 12743 000105C8 E93FD3FFFF          <1> 	jmp	sysret 
 12744                              <1> sysvideo_17_8:
 12745                              <1> 	; cx = mode
 12746                              <1> 	; 21/12/2020
 12747 000105CD 80CD40              <1> 	or	ch, 40h  ; Linear frame buffer flag	
 12748 000105D0 E80034FFFF          <1> 	call	_vbe_biosfn_return_mode_info
 12749 000105D5 72F1                <1> 	jc	short sysvideo_17_7
 12750 000105D7 EB99                <1> 	jmp	short sysvideo_17_4
 12751                              <1> 	
 12752                              <1> sysvideo_18:
 12753                              <1> 	; BH = 5
 12754                              <1> 	; Direct User Access for VGA video memory.
 12755                              <1> 	; Setup user's page tables for direct access to 0A0000h.
 12756                              <1> 	;
 12757                              <1> 	; Permission checks are not implemented yet !
 12758                              <1> 	; (11/07/2016)
 12759                              <1> 
 12760 000105D9 B800000A00          <1> 	mov	eax, 0A0000h
 12761 000105DE B910000000          <1> 	mov	ecx, 16 ; 16 pages (16*4K=64K)
 12762 000105E3 89C3                <1> 	mov	ebx, eax ; 12/05/2017 ; virtual = physical
 12763 000105E5 E81861FFFF          <1> 	call	direct_memory_access	
 12764 000105EA 0F821CD3FFFF        <1> 	jc	sysret
 12765                              <1> 	; eax = 0A0000h if there is not an error
 12766 000105F0 A3[64030300]        <1> 	mov	[u.r0], eax
 12767 000105F5 E912D3FFFF          <1> 	jmp	sysret
 12768                              <1> 
 12769                              <1> sysvideo_19:
 12770                              <1> 	; 22/01/2021
 12771                              <1> 	; 12/12/2020
 12772                              <1> 	; 11/12/2020
 12773                              <1> 	; 23/11/2020
 12774                              <1> 	; BH = 7
 12775                              <1> 	; Get (Super/Extended VGA) mode
 12776                              <1> 	; and Linear Frame Buffer info.
 12777                              <1> 	
 12778                              <1> 	; 22/01/2021
 12779 000105FA B3FF                <1> 	mov	bl, 0FFh
 12780                              <1> 	; 11/12/2020
 12781                              <1> 	;cmp	byte [CRT_MODE], 0FFh ; (extended mode?)
 12782                              <1> 	; 22/01/2021
 12783 000105FC 381D[DA6F0000]      <1> 	cmp	[CRT_MODE], bl  ; 0FFh
 12784                              <1> 	;jb	sysvideo_17_1	; not a VESA VBE mode
 12785                              <1> 	; 12/12/2020
 12786 00010602 7305                <1> 	jnb	short sysvideo_19_0
 12787 00010604 E937FFFFFF          <1> 	jmp	sysvideo_17_1
 12788                              <1> 
 12789                              <1> sysvideo_19_0:
 12790 00010609 E8A535FFFF          <1> 	call	vbe_biosfn_return_current_mode
 12791 0001060E 6681E3FF01          <1> 	and	bx, 1FFh
 12792 00010613 663B1D[2A120300]    <1> 	cmp	bx, [LFB_Info+LFBINFO.mode]
 12793 0001061A 7510                <1> 	jne	short sysvideo_19_2
 12794                              <1> sysvideo_19_1:
 12795 0001061C A1[2C120300]        <1> 	mov	eax, [LFB_Info+LFBINFO.LFB_addr]
 12796 00010621 8B15[30120300]      <1> 	mov	edx, [LFB_Info+LFBINFO.LFB_size]
 12797 00010627 E969FFFFFF          <1> 	jmp	sysvideo_17_5
 12798                              <1> sysvideo_19_2:
 12799 0001062C E8A433FFFF          <1> 	call	_vbe_biosfn_return_mode_info
 12800 00010631 73E9                <1> 	jnc	short sysvideo_19_1
 12801 00010633 E9D4D2FFFF          <1> 	jmp	sysret
 12802                              <1> 
 12803                              <1> sysvideo_20:
 12804                              <1> 	; 11/12/2020
 12805                              <1> 	; 23/11/2020
 12806 00010638 80FF08              <1> 	cmp	bh, 8
 12807 0001063B 72BD                <1> 	jb	short sysvideo_19 ; video mode & lfb info
 12808 0001063D 0F8780000000        <1> 	ja	sysvideo_21 ; 12/12/2020
 12809                              <1> 
 12810                              <1> 	; BH = 8
 12811                              <1> 	; Set (Super/Extended VGA) mode & return LFB info
 12812                              <1> 	;
 12813                              <1> 	
 12814                              <1> 	; 11/12/2020
 12815 00010643 80FBFF              <1> 	cmp	bl, 0FFh  ; CGA/VGA mode ?
 12816 00010646 7318                <1> 	jnb	short sysvideo_20_1
 12817                              <1> 
 12818                              <1> 	;xor	ah, ah
 12819 00010648 88D8                <1> 	mov	al, bl
 12820                              <1> sysvideo_20_0:
 12821 0001064A E82211FFFF          <1> 	call	_int10h  ; uses vbe3 pmi32 option
 12822 0001064F 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh ; -1
 12823 00010652 7459                <1> 	je	short sysvideo_20_3 ; error
 12824                              <1> 	
 12825                              <1> 	; 11/12/2020
 12826                              <1> 	; alternative (it does not use vbe3 pmi32)
 12827                              <1> 	;push	eax
 12828                              <1> 	;call	_set_mode
 12829                              <1> 	;pop	eax
 12830                              <1> 	;jc	short sysvideo_20_3
 12831                              <1> 	
 12832                              <1> 	;inc	eax
 12833 00010654 FEC0                <1> 	inc	al
 12834                              <1> 	;mov	[u.r0], ax ; video mode + 1	
 12835 00010656 A2[64030300]        <1> 	mov	[u.r0], al
 12836 0001065B E9ACD2FFFF          <1> 	jmp	sysret
 12837                              <1> 
 12838                              <1> sysvideo_20_1:
 12839                              <1> 	; cx = vesa video mode
 12840 00010660 6689C8              <1> 	mov	ax, cx
 12841 00010663 663D0001            <1> 	cmp	ax, 100h
 12842 00010667 72E1                <1> 	jb	short sysvideo_20_0 ; VGA/CGA mode
 12843 00010669 663DFF01            <1> 	cmp	ax, 1FFh
 12844                              <1> 	;ja	short sysvideo_20_4 ; not valid
 12845 0001066D 773E                <1> 	ja	short sysvideo_20_3
 12846 0001066F 50                  <1> 	push	eax
 12847 00010670 6689C3              <1> 	mov	bx, ax
 12848 00010673 66B8024F            <1> 	mov	ax, 4F02h
 12849                              <1> 
 12850                              <1> 	; simulate _int10h (int 31h) for func 4F02h
 12851                              <1> 	;pushfd
 12852                              <1> 	;push	cs
 12853                              <1> 	;push	sysvideo_20_1_retn 
 12854                              <1> 	;push	es ; *
 12855                              <1> 	;push	ds ; **	; SAVE WORK AND PARAMETER REGISTERS
 12856                              <1> 	;jmp	VBE_func
 12857                              <1> ;sysvideo_20_1_retn:	
 12858                              <1> 	
 12859 00010677 E8F510FFFF          <1> 	call	_int10h ; simulate int 10h (int 31h)
 12860                              <1> 
 12861 0001067C 6683F84F            <1> 	cmp	ax, 004Fh
 12862 00010680 58                  <1> 	pop	eax
 12863 00010681 752A                <1> 	jne	short sysvideo_20_3 ; error
 12864                              <1> 	;pop	eax
 12865 00010683 40                  <1> 	inc	eax
 12866 00010684 A3[64030300]        <1> 	mov	[u.r0], eax ; video mode + 1
 12867 00010689 09D2                <1> 	or	edx, edx ; is LFBINFO requested by user ?	
 12868                              <1> 	;jz	short sysvideo_20_4
 12869 0001068B 7420                <1> 	jz	short sysvideo_20_3 ; no
 12870                              <1> 
 12871                              <1> 	; 11/12/2020
 12872                              <1> 	; Check LFBINFO table/structure
 12873                              <1> 	; (it is set by vbe2 'vbe_biosfn_set_mode'
 12874                              <1> 	; but if vbe3 vbios pmi is in use,
 12875                              <1> 	; it will not set LFBINFO table)
 12876                              <1> 
 12877 0001068D 52                  <1> 	push	edx
 12878 0001068E 48                  <1> 	dec	eax  ; video mode
 12879 0001068F BE[2A120300]        <1> 	mov	esi, LFB_Info
 12880 00010694 663B06              <1> 	cmp	ax, [esi+LFBINFO.mode]
 12881 00010697 7407                <1> 	je	short sysvideo_20_2
 12882                              <1> 
 12883 00010699 E83733FFFF          <1> 	call	_vbe_biosfn_return_mode_info
 12884                              <1> 	;jnc	short sysvideo_20_2
 12885 0001069E 7212                <1> 	jc	short sysvideo_20_4 ; edx = 0	
 12886                              <1> 
 12887                              <1> 	;; clear LFBINFO table for invalidating	
 12888                              <1> 	;mov	ecx, LFBINFO.size ; 16
 12889                              <1> 	;mov	edi, esi ; LFB_Info table address
 12890                              <1> 	;xor	eax, eax
 12891                              <1> 	;rep	stosb
 12892                              <1> 
 12893                              <1> sysvideo_20_2:
 12894                              <1> 	;pop	ecx
 12895                              <1> 	;mov	edi, ecx ; user buffer
 12896 000106A0 5F                  <1> 	pop	edi
 12897 000106A1 B910000000          <1> 	mov	ecx, LFBINFO.size ; 16
 12898 000106A6 E8B9140000          <1> 	call	transfer_to_user_buffer ; fast transfer
 12899 000106AB 7206                <1> 	jc	short sysvideo_20_5
 12900                              <1> 	
 12901                              <1> 	;jmp	sysret
 12902                              <1> sysvideo_20_3:	
 12903                              <1> 	;pop	eax ; [u.r0] = 0		
 12904                              <1> ;sysvideo_20_4:
 12905 000106AD E95AD2FFFF          <1> 	jmp	sysret
 12906                              <1> 
 12907                              <1> sysvideo_20_4:
 12908 000106B2 5A                  <1> 	pop	edx
 12909                              <1> sysvideo_20_5:
 12910 000106B3 31D2                <1> 	xor	edx, edx ; 0
 12911                              <1> 	; edx = 0 -> invalid LFBINFO data
 12912 000106B5 8B2D[60030300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
 12913 000106BB 895514              <1> 	mov	[ebp+20], edx ; return to user with EDX value 
 12914 000106BE E949D2FFFF          <1> 	jmp	sysret
 12915                              <1> 
 12916                              <1> sysvideo_21:
 12917                              <1> 	; 04/01/2021
 12918                              <1> 	; 03/12/2020
 12919 000106C3 80FF0A              <1> 	cmp	bh, 10
 12920 000106C6 0F82AA010000        <1> 	jb	sysvideo_22 ; VESA VBE3 pmi parms
 12921                              <1> 	; 23/12/2020
 12922 000106CC 0F845F020000        <1> 	je	sysvideo_26 ; Video memory mapping	
 12923                              <1> 	
 12924                              <1> 	; 04/01/2020
 12925 000106D2 80FF0B              <1> 	cmp	bh, 11
 12926 000106D5 0F87E1020000        <1> 	ja	sysvideo_27
 12927                              <1> 		
 12928                              <1> 	; BH = 11
 12929                              <1> 	; set/read DAC color registers (for 8bpp)
 12930                              <1> 	
 12931 000106DB 80FB04              <1> 	cmp	bl, 4
 12932 000106DE 0F83AB000000        <1> 	jnb	sysvideo_21_7	; BMP file type palette
 12933                              <1> 				; handling	
 12934 000106E4 F6C301              <1> 	test	bl, 1
 12935 000106E7 7555                <1> 	jnz	short sysvideo_21_4 ; set/write DAC colors
 12936                              <1> 		
 12937                              <1> 	; Read DAC color register or all DAC color registers
 12938 000106E9 F6C302              <1> 	test	bl, 2  ; read single DAC color register
 12939 000106EC 7424                <1> 	jz	short sysvideo_21_2 ; read all DAC color regs	
 12940                              <1> 
 12941                              <1> 	; read single DAC color register
 12942                              <1> 	; CL = DAC color register (index)
 12943                              <1>  	
 12944 000106EE 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
 12945 000106F2 88C8                <1> 	mov	al, cl	; DAC color register
 12946 000106F4 31C9                <1> 	xor	ecx, ecx ; (this may not be necessary)
 12947 000106F6 EE                  <1> 	out	dx, al
 12948                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 12949 000106F7 B2C9                <1> 	mov	dl, 0C9h
 12950 000106F9 EC                  <1> 	in	al, dx
 12951 000106FA 88C4                <1> 	mov	ah, al	; red
 12952 000106FC EC                  <1> 	in	al, dx
 12953 000106FD 88C1                <1> 	mov	cl, al	; green
 12954 000106FF EC                  <1> 	in	al, dx
 12955 00010700 88C5                <1> 	mov	ch, al	; blue
 12956 00010702 C1E108              <1> 	shl	ecx, 8
 12957 00010705 88E1                <1> 	mov	cl, ah	; red	
 12958                              <1> 	; CL = Red, CH = Green, byte 3 = Blue, byte 4 = 0
 12959                              <1> sysvideo_21_0:
 12960 00010707 890D[64030300]      <1> 	mov	[u.r0], ecx
 12961                              <1> sysvideo_21_1:
 12962 0001070D E9FAD1FFFF          <1> 	jmp	sysret
 12963                              <1> sysvideo_21_2:
 12964                              <1> 	; read all DAC color registers
 12965 00010712 89CB                <1> 	mov	ebx, ecx ; user's buffer address
 12966 00010714 BF00600900          <1> 	mov	edi, VBE3STACKADDR
 12967 00010719 89FE                <1> 	mov	esi, edi
 12968 0001071B B900030000          <1> 	mov	ecx, 768 ; 256*3
 12969 00010720 51                  <1> 	push	ecx
 12970 00010721 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
 12971 00010725 28C0                <1> 	sub	al, al ; 0
 12972 00010727 EE                  <1> 	out	dx, al
 12973                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 12974 00010728 B2C9                <1> 	mov	dl, 0C9h
 12975                              <1> sysvideo_21_3:
 12976 0001072A EC                  <1> 	in	al, dx
 12977 0001072B AA                  <1> 	stosb
 12978 0001072C EC                  <1> 	in	al, dx
 12979 0001072D AA                  <1> 	stosb
 12980 0001072E EC                  <1> 	in	al, dx
 12981 0001072F AA                  <1> 	stosb
 12982 00010730 E2F8                <1> 	loop	sysvideo_21_3
 12983 00010732 59                  <1> 	pop	ecx
 12984                              <1> 
 12985 00010733 89DF                <1> 	mov	edi, ebx ; user's buffer address
 12986                              <1> 	;mov	esi, VBE3STACKADDR
 12987                              <1> 	;mov	ecx, 256*3 = 768
 12988 00010735 E82A140000          <1> 	call	transfer_to_user_buffer
 12989 0001073A 72D1                <1> 	jc	short sysvideo_21_1
 12990                              <1> 	;mov	[u.r0], ecx ; actual transfer count
 12991 0001073C EBC9                <1> 	jmp	short sysvideo_21_0
 12992                              <1> 
 12993                              <1> sysvideo_21_4:
 12994                              <1> 	; Set/Write DAC color register or all registers
 12995 0001073E F6C302              <1> 	test	bl, 2 ; write/set single DAC color register
 12996 00010741 741C                <1> 	jz	short sysvideo_21_5 ; set all DAC color regs
 12997                              <1> 
 12998                              <1> 	; set single DAC color register
 12999                              <1> 	; CL = DAC color register (index)
 13000                              <1> 	; (byte 1 = Red, byte 2 = Green, byte 3 = Blue) 
 13001                              <1> 
 13002 00010743 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
 13003 00010747 89C8                <1> 	mov	eax, ecx ; DAC color register (index)
 13004 00010749 C1E910              <1> 	shr	ecx, 16  ; CL = green, AH = Red
 13005 0001074C EE                  <1> 	out	dx, al
 13006                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 13007 0001074D FEC2                <1> 	inc	dl
 13008 0001074F 88E0                <1> 	mov	al, ah	; Red
 13009 00010751 EE                  <1> 	out	dx, al
 13010 00010752 88C8                <1> 	mov	al, cl	; Green
 13011 00010754 EE                  <1> 	out	dx, al
 13012 00010755 88E8                <1> 	mov	al, ch	; Blue
 13013 00010757 EE                  <1> 	out	dx, al	
 13014                              <1> 	;rol	ecx, 8
 13015 00010758 C1E108              <1> 	shl	ecx, 8	; 21/02/2021
 13016 0001075B 88E1                <1> 	mov	cl, ah	; Red
 13017                              <1> 		; ecx = 00BBGGRRh	
 13018 0001075D EBA8                <1> 	jmp	short sysvideo_21_0
 13019                              <1> 
 13020                              <1> sysvideo_21_5:
 13021                              <1> 	; write/set all DAC color registers
 13022 0001075F 89CE                <1> 	mov	esi, ecx ; user's buffer address
 13023 00010761 BF00600900          <1> 	mov	edi, VBE3STACKADDR
 13024 00010766 89FB                <1> 	mov	ebx, edi
 13025 00010768 B900030000          <1> 	mov	ecx, 768 ; 256*3
 13026 0001076D E83C140000          <1> 	call	transfer_from_user_buffer
 13027 00010772 7299                <1> 	jc	short sysvideo_21_1
 13028 00010774 890D[64030300]      <1> 	mov	[u.r0], ecx ; actual transfer count
 13029                              <1> 
 13030 0001077A 89DE                <1> 	mov	esi, ebx ; VBE3STACKADDR
 13031 0001077C 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
 13032 00010780 28C0                <1> 	sub	al, al ; 0
 13033 00010782 EE                  <1> 	out	dx, al
 13034                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 13035 00010783 FEC2                <1> 	inc	dl
 13036                              <1> sysvideo_21_6:
 13037 00010785 AC                  <1> 	lodsb
 13038 00010786 EE                  <1> 	out	dx, al
 13039 00010787 AC                  <1> 	lodsb
 13040 00010788 EE                  <1> 	out	dx, al
 13041 00010789 AC                  <1> 	lodsb
 13042 0001078A EE                  <1> 	out	dx, al
 13043 0001078B E2F8                <1> 	loop	sysvideo_21_6
 13044 0001078D EB30                <1> 	jmp	short sysvideo_21_9
 13045                              <1> 
 13046                              <1> sysvideo_21_7:	
 13047                              <1> 	; BMP file type palette handling	
 13048                              <1> 	
 13049 0001078F F6C301              <1> 	test	bl, 1
 13050 00010792 756E                <1> 	jnz	short sysvideo_21_12 ; set/write DAC colors
 13051                              <1> 		
 13052                              <1> 	; Read DAC color register or all DAC color registers
 13053 00010794 F6C302              <1> 	test	bl, 2  ; read single DAC color register
 13054 00010797 742B                <1> 	jz	short sysvideo_21_10 ; read all DAC color regs	
 13055                              <1> 
 13056                              <1> 	; read single DAC color register
 13057                              <1> 	; CL = DAC color register (index)
 13058                              <1>  	
 13059 00010799 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
 13060 0001079D 88C8                <1> 	mov	al, cl	; DAC color register
 13061 0001079F 31C9                <1> 	xor	ecx, ecx
 13062 000107A1 EE                  <1> 	out	dx, al
 13063                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 13064 000107A2 B2C9                <1> 	mov	dl, 0C9h
 13065 000107A4 EC                  <1> 	in	al, dx
 13066 000107A5 C0E002              <1> 	shl	al, 2
 13067 000107A8 88C5                <1> 	mov	ch, al	; red
 13068 000107AA EC                  <1> 	in	al, dx
 13069 000107AB C0E002              <1> 	shl	al, 2
 13070 000107AE 88C1                <1> 	mov	cl, al	; green
 13071 000107B0 EC                  <1> 	in	al, dx
 13072 000107B1 C0E002              <1> 	shl	al, 2
 13073                              <1> 	; 21/02/2021
 13074 000107B4 C1E108              <1> 	shl	ecx, 8
 13075 000107B7 88C1                <1> 	mov	cl, al	; blue
 13076                              <1> 	; CL = Blue, CH = Green, byte 3 = Red, byte 4 = 0
 13077                              <1> sysvideo_21_8:
 13078 000107B9 890D[64030300]      <1> 	mov	[u.r0], ecx
 13079                              <1> sysvideo_21_9:
 13080 000107BF E948D1FFFF          <1> 	jmp	sysret
 13081                              <1> sysvideo_21_10:
 13082                              <1> 	; read all DAC color registers
 13083 000107C4 89CD                <1> 	mov	ebp, ecx ; user's buffer address
 13084 000107C6 BF00600900          <1> 	mov	edi, VBE3STACKADDR
 13085 000107CB 89FE                <1> 	mov	esi, edi
 13086 000107CD B900040000          <1> 	mov	ecx, 1024 ; 256*4
 13087 000107D2 51                  <1> 	push	ecx
 13088 000107D3 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
 13089 000107D7 28C0                <1> 	sub	al, al ; 0
 13090 000107D9 EE                  <1> 	out	dx, al
 13091                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 13092 000107DA B2C9                <1> 	mov	dl, 0C9h
 13093                              <1> sysvideo_21_11:
 13094 000107DC 31DB                <1> 	xor	ebx, ebx
 13095 000107DE EC                  <1> 	in	al, dx	; Red
 13096 000107DF C0E002              <1> 	shl	al, 2
 13097 000107E2 88C7                <1> 	mov	bh, al
 13098 000107E4 EC                  <1> 	in	al, dx	; Green
 13099 000107E5 C0E002              <1> 	shl	al, 2
 13100 000107E8 88C3                <1> 	mov	bl, al
 13101 000107EA EC                  <1> 	in	al, dx	; Blue
 13102 000107EB C0E002              <1> 	shl	al, 2
 13103 000107EE C1E308              <1> 	shl	ebx, 8
 13104 000107F1 89D8                <1> 	mov	eax, ebx ; 00RRGGBBh
 13105 000107F3 AB                  <1> 	stosd	
 13106 000107F4 E2E6                <1> 	loop	sysvideo_21_11
 13107 000107F6 59                  <1> 	pop	ecx
 13108                              <1> 
 13109 000107F7 89EF                <1> 	mov	edi, ebp ; user's buffer address
 13110                              <1> 	;mov	esi, VBE3STACKADDR
 13111                              <1> 	;mov	ecx, 1024 = 4*256
 13112 000107F9 E866130000          <1> 	call	transfer_to_user_buffer
 13113 000107FE 72BF                <1> 	jc	short sysvideo_21_9
 13114                              <1> 	;mov	[u.r0], ecx ; actual transfer count
 13115 00010800 EBB7                <1> 	jmp	short sysvideo_21_8
 13116                              <1> 
 13117                              <1> sysvideo_21_12:
 13118                              <1> 	; Set/Write DAC color register or all registers
 13119 00010802 F6C302              <1> 	test	bl, 2 ; write/set single DAC color register
 13120 00010805 7427                <1> 	jz	short sysvideo_21_13 ; set all DAC color regs
 13121                              <1> 
 13122                              <1> 	; set single DAC color register
 13123                              <1> 	; CL = DAC color register (index)
 13124                              <1> 	; (byte 1 = Blue, byte 2 = Green, byte 3 = Red) 
 13125                              <1> 
 13126 00010807 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
 13127 0001080B 88C8                <1> 	mov	al, cl	; DAC color register (index)
 13128 0001080D 88EC                <1> 	mov	ah, ch	; Blue 
 13129 0001080F C1E910              <1> 	shr	ecx, 16
 13130 00010812 EE                  <1> 	out	dx, al
 13131                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 13132 00010813 FEC2                <1> 	inc	dl
 13133 00010815 88E8                <1> 	mov	al, ch	; Red
 13134 00010817 C0E802              <1> 	shr	al, 2
 13135 0001081A EE                  <1> 	out	dx, al
 13136 0001081B 88C8                <1> 	mov	al, cl	; Green
 13137 0001081D C0E802              <1> 	shr	al, 2
 13138 00010820 EE                  <1> 	out	dx, al
 13139 00010821 88E0                <1> 	mov	al, ah	; Blue
 13140 00010823 C0E802              <1> 	shr	al, 2
 13141 00010826 EE                  <1> 	out	dx, al	
 13142                              <1> 	;rol	ecx, 8
 13143 00010827 C1E108              <1> 	shl	ecx, 8 ; 21/02/2021 
 13144 0001082A 88E1                <1> 	mov	cl, ah
 13145 0001082C EB8B                <1> 	jmp	short sysvideo_21_8
 13146                              <1> 
 13147                              <1> sysvideo_21_13:
 13148                              <1> 	; write/set all DAC color registers
 13149 0001082E 89CE                <1> 	mov	esi, ecx ; user's buffer address
 13150 00010830 BF00600900          <1> 	mov	edi, VBE3STACKADDR
 13151 00010835 89FB                <1> 	mov	ebx, edi
 13152 00010837 B900040000          <1> 	mov	ecx, 1024 ; 256*4
 13153 0001083C E86D130000          <1> 	call	transfer_from_user_buffer
 13154 00010841 722E                <1> 	jc	short sysvideo_21_15
 13155 00010843 890D[64030300]      <1> 	mov	[u.r0], ecx ; actual transfer count
 13156                              <1> 
 13157 00010849 89DE                <1> 	mov	esi, ebx ; VBE3STACKADDR
 13158 0001084B 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
 13159 0001084F 28C0                <1> 	sub	al, al ; 0
 13160 00010851 EE                  <1> 	out	dx, al
 13161                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 13162 00010852 FEC2                <1> 	inc	dl
 13163                              <1> sysvideo_21_14:
 13164 00010854 AD                  <1> 	lodsd
 13165                              <1> 	; byte 0 = Blue, byte 1 = Green, byte 2 = Red
 13166                              <1> 	; 21/02/2021
 13167 00010855 89C3                <1> 	mov	ebx, eax ; BL = Blue, BH = Green
 13168 00010857 C1CB08              <1> 	ror	ebx, 8 ; BL = Green, BH = Red
 13169 0001085A 88F8                <1> 	mov	al, bh
 13170 0001085C C0E802              <1> 	shr	al, 2
 13171 0001085F EE                  <1> 	out	dx, al ; Red
 13172 00010860 88D8                <1> 	mov	al, bl
 13173 00010862 C0E802              <1> 	shr	al, 2	
 13174 00010865 EE                  <1> 	out	dx, al ; Green
 13175 00010866 C1C308              <1> 	rol	ebx, 8 ; BL = Blue
 13176 00010869 88D8                <1> 	mov	al, bl
 13177 0001086B C0E802              <1> 	shr	al, 2
 13178 0001086E EE                  <1> 	out	dx, al ; Blue 
 13179 0001086F E2E3                <1> 	loop	sysvideo_21_14
 13180                              <1> sysvideo_21_15:
 13181 00010871 E996D0FFFF          <1> 	jmp	sysret
 13182                              <1> 
 13183                              <1> sysvideo_22:
 13184                              <1> 	; 28/02/2021
 13185                              <1> 	; 22/01/2021
 13186                              <1> 	; 17/01/2021
 13187                              <1> 	; 04/12/2020
 13188                              <1> 	; 03/12/2020
 13189                              <1> 	; BH = 9
 13190                              <1> 	; Set/Get VESA VBE3 protected mode interface params
 13191                              <1> 
 13192                              <1> 	; 22/01/2021
 13193                              <1> 	;cmp	byte [vbe3], 3
 13194                              <1> 	;jne	short sysvideo_25 ; not applicable if
 13195                              <1> 				; vbe3 compatible video bios
 13196                              <1> 				; is not detected by kernel	
 13197 00010876 80FB02              <1> 	cmp	bl, 2
 13198                              <1> 	;ja	short sysvideo_25 ; bl > 2 not implemented
 13199                              <1> 	; 17/01/2021
 13200 00010879 7716                <1> 	ja	short sysvideo_22_0 ; srvs flag sub function
 13201                              <1> 	;jb	short sysvideo_23
 13202                              <1> 
 13203                              <1> 	; 21/01/2021
 13204 0001087B 803D[5C090000]03    <1> 	cmp	byte [vbe3], 3
 13205                              <1> 	;jne	short sysvideo_25 ; not applicable if
 13206                              <1> 				; vbe3 compatible video bios
 13207                              <1> 				; is not detected by kernel
 13208 00010882 75ED                <1> 	jne	short sysvideo_21_15 ; 28/02/2021
 13209                              <1> 	
 13210 00010884 80FB01              <1> 	cmp	bl, 1
 13211 00010887 7673                <1> 	jna	short sysvideo_23
 13212                              <1> 
 13213 00010889 8A1D[1C120300]      <1> 	mov	bl, [pmi32] ; Video bios 32 bit PMI functions
 13214 0001088F EB78                <1> 	jmp	short sysvideo_24
 13215                              <1> 
 13216                              <1> sysvideo_22_0:
 13217                              <1> 	; 17/01/2021
 13218                              <1> 	; save/restore video state user permission
 13219 00010891 80FB05              <1> 	cmp	bl, 5
 13220 00010894 771E                <1> 	ja	short sysvideo_22_2
 13221 00010896 7208                <1> 	jb	short sysvideo_22_1
 13222                              <1> 	; get srvs flag value/status
 13223 00010898 8A1D[80120300]      <1> 	mov	bl, [srvsf] ; 0 = disabled, 1 = enabled
 13224 0001089E EB2C                <1> 	jmp	short sysvideo_22_3
 13225                              <1> 
 13226                              <1> sysvideo_22_1:
 13227                              <1> 	; permission (root and multi tasking) check
 13228 000108A0 E836000000          <1> 	call	sysvideo_22_4
 13229 000108A5 736A                <1> 	jnc	short sysvideo_25 ; not permitted !
 13230                              <1> 	; cf = 1
 13231 000108A7 80EB03              <1> 	sub	bl, 3 ; disable = 0, enable = 1
 13232                              <1> 	; 22/01/2021
 13233 000108AA 881D[80120300]      <1> 	mov	[srvsf], bl
 13234 000108B0 FEC3                <1> 	inc	bl ; 1 = disabled, 2 = enabled
 13235 000108B2 EB18                <1> 	jmp	short sysvideo_22_3
 13236                              <1> 
 13237                              <1> sysvideo_22_2:
 13238 000108B4 80FB06              <1> 	cmp	bl, 6
 13239                              <1> 	;ja	short sysvideo_25 ; invalid/unimplemented
 13240                              <1> 	; 28/02/2021
 13241 000108B7 7733                <1> 	ja	short sysvideo_22_6
 13242                              <1> 	; get VESA VBE number/status
 13243 000108B9 8A25[5C090000]      <1> 	mov	ah, [vbe3] ; vbe3 = 3, vbe2 = 2, others = 0
 13244 000108BF A0[5D090000]        <1> 	mov	al, [vbe2bios] ; bochs/qemu/vbox emulator status
 13245 000108C4 66A3[64030300]      <1> 	mov	[u.r0], ax
 13246 000108CA EB45                <1> 	jmp	short sysvideo_25
 13247                              <1> 
 13248                              <1> sysvideo_22_3:
 13249                              <1> 	; 22/01/2021
 13250 000108CC 8A3D[81120300]      <1> 	mov	bh, [srvso] ; state options (> 80h -> svga)
 13251 000108D2 66891D[64030300]    <1> 	mov	[u.r0], bx ; function result is return value 
 13252 000108D9 EB36                <1> 	jmp	short sysvideo_25 
 13253                              <1> 
 13254                              <1> sysvideo_22_4:
 13255                              <1> 	; 17/01/2021 - permission will be given by root only
 13256 000108DB 803D[C2960100]00    <1> 	cmp	byte [multi_tasking], 0 ; in single user mode
 13257 000108E2 7707                <1> 	ja	short sysvideo_22_5
 13258                              <1> 	; 19/01/2021
 13259 000108E4 803D[B0030300]01    <1>  	cmp	byte [u.uid], 1 ; ([u.uid] = 0 -> root)
 13260                              <1> sysvideo_22_5:
 13261                              <1> 	; [multi_tasking] = 0 & [u.uid] = 0 -> CF = 1
 13262                              <1> 	; otherwise -> CF = 0 
 13263 000108EB C3                  <1> 	retn
 13264                              <1> 
 13265                              <1> sysvideo_22_6:
 13266                              <1> 	; 28/02/2021
 13267 000108EC 80FB09              <1> 	cmp	bl, 9
 13268 000108EF 7720                <1> 	ja	short sysvideo_25 ; invalid/unimplemented
 13269 000108F1 7436                <1> 	je	short sysvideo_22_9
 13270 000108F3 80FB08              <1> 	cmp	bl, 8
 13271 000108F6 721E                <1> 	jb	short sysvideo_22_7
 13272                              <1> 
 13273                              <1> 	; BL = 8
 13274                              <1> 	; Set default true color bpp to 24
 13275                              <1> 
 13276 000108F8 B318                <1> 	mov	bl, 24
 13277                              <1> 	;mov	[truecolor], al	; 24bpp (RRGGBBh)
 13278                              <1> 	;mov	[u.r0], al
 13279                              <1> 	;jmp	short sysvideo_25
 13280 000108FA EB25                <1> 	jmp	short sysvideo_22_8
 13281                              <1> 
 13282                              <1> sysvideo_23:
 13283                              <1> 	; 17/01/2021
 13284                              <1> 	; permission (root and multi tasking) check
 13285 000108FC E8DAFFFFFF          <1> 	call	sysvideo_22_4
 13286 00010901 730E                <1> 	jnc	short sysvideo_25 ; not permitted !
 13287                              <1> 
 13288 00010903 881D[1C120300]      <1> 	mov	[pmi32], bl ; 1 = enabled, 0 = disabled 
 13289                              <1> sysvideo_24:
 13290 00010909 FEC3                <1> 	inc	bl
 13291                              <1> sysvideo_22_10:	; 28/02/2021
 13292 0001090B 881D[64030300]      <1> 	mov	[u.r0], bl ; function result is return value 
 13293                              <1> sysvideo_25:
 13294 00010911 E9F6CFFFFF          <1> 	jmp	sysret
 13295                              <1> 
 13296                              <1> sysvideo_22_7:
 13297                              <1> 	; BL = 7
 13298                              <1> 	; Set default true color bpp to 32
 13299                              <1> 	; (it will set if [VBE3]=3)
 13300                              <1> 
 13301                              <1> 	; Note: This sub function is used to set 24bpp
 13302                              <1> 	; VESA VBE video modes to 32bpp.. because,
 13303                              <1> 	; old hardware uses 24 bpp but new video hardware
 13304                              <1> 	; uses 32bpp for same VESA VBE truecolor modes.
 13305                              <1> 	; (For example: VBE mode 112h is 640*480, 24bpp but
 13306                              <1> 	; new hardware uses/apply it as 640*480, 32bpp.)  	
 13307                              <1> 	; So, TRDOS 386 v2.0.3 kernel will check [truecolor]
 13308                              <1> 	; status is 32 bpp or not and it will change 24bpp
 13309                              <1> 	; to 32bpp if default [truecolor] value is 32, for
 13310                              <1> 	; same video mode number.
 13311                              <1> 
 13312 00010916 803D[5C090000]03    <1> 	cmp	byte [vbe3], 3
 13313 0001091D 75F2                <1> 	jne	short sysvideo_25 ; Only applicable 
 13314                              <1> 				  ; for VBE3 video hardware!
 13315 0001091F B320                <1> 	mov	bl, 32
 13316                              <1> sysvideo_22_8:
 13317 00010921 881D[F7860100]      <1> 	mov	[truecolor], bl	; 32bpp (00RRGGBBh)
 13318                              <1> 	;mov	[u.r0], bl
 13319                              <1> 	;jmp	short sysvideo_25
 13320 00010927 EBE2                <1> 	jmp	short sysvideo_22_10
 13321                              <1> 
 13322                              <1> sysvideo_22_9:
 13323                              <1> 	; BL = 9
 13324                              <1> 	; Return default true color bpp
 13325 00010929 8A1D[F7860100]      <1> 	mov	bl, [truecolor]
 13326 0001092F EBDA                <1> 	jmp	short sysvideo_22_10
 13327                              <1> ;sysvideo_22_10:
 13328                              <1> 	;mov	[u.r0], bl
 13329                              <1> 	;jmp	sysret
 13330                              <1> 
 13331                              <1> sysvideo_26:
 13332                              <1> 	; 23/12/2020
 13333                              <1> 	; BH = 10
 13334                              <1> 	; Map video memory to user's buffer
 13335                              <1> 	; (multiuser/owner r/w permisions are ignored
 13336                              <1> 	;  for current TRDOS 386 version !)
 13337                              <1> 
 13338 00010931 6681E100F0          <1> 	and	cx, ~4095  ; clear low 12 bits
 13339 00010936 09C9                <1> 	or	ecx, ecx ; start address of user's buffer
 13340 00010938 74D7                <1> 	jz	short sysvideo_25 ; error !
 13341                              <1> 	
 13342 0001093A 80FB01              <1> 	cmp	bl, 1  ; VGA memory mapping ?
 13343 0001093D 740E                <1> 	je	short sysvideo_26_1
 13344 0001093F 7718                <1> 	ja	short sysvideo_26_2
 13345                              <1> sysvideo_26_0:
 13346                              <1> 	; BL = 0 : CGA memory (0B8000h) map (32K)
 13347 00010941 B800800B00          <1> 	mov	eax, 0B8000h	
 13348 00010946 BB00800000          <1> 	mov	ebx, 32768
 13349 0001094B EB37                <1> 	jmp	short sysvideo_26_3
 13350                              <1> sysvideo_26_1:
 13351                              <1> 	; BL = 1 : VGA memory (0A0000h) map (64K)
 13352 0001094D B800000A00          <1> 	mov	eax, 0A0000h	
 13353 00010952 BB00000100          <1> 	mov	ebx, 65536
 13354 00010957 EB2B                <1> 	jmp	short sysvideo_26_3
 13355                              <1> sysvideo_26_2:
 13356                              <1> 	; BL = 2 : SVGA memory (LFB) map to user's buffer
 13357 00010959 803D[5C090000]02    <1> 	cmp	byte [vbe3], 2  ; VESA VBE 2/3 vbios ready ?
 13358 00010960 72AF                <1> 	jb	short sysvideo_25  ; no, error !
 13359 00010962 6681E200F0          <1> 	and	dx, ~4095 ; clear low 12 bits
 13360 00010967 09D2                <1> 	or	edx, edx  ; buffer size in bytes	
 13361 00010969 74A6                <1> 	jz	short sysvideo_25  ; error
 13362 0001096B 89D3                <1> 	mov	ebx, edx
 13363 0001096D A1[2C120300]        <1> 	mov	eax, [LFB_ADDR] ; [LFB_Info+LFBINFO.LFB_addr]
 13364 00010972 21C0                <1> 	and	eax, eax
 13365 00010974 7425                <1> 	jz	short sysvideo_26_5
 13366                              <1> 				; (LFB parms are not set yet)
 13367 00010976 3B1D[30120300]      <1> 	cmp	ebx, [LFB_SIZE] ; [LFB_Info+LFBINFO.LFB_size]
 13368 0001097C 7606                <1> 	jna	short sysvideo_26_3
 13369 0001097E 8B1D[30120300]      <1> 	mov	ebx, [LFB_SIZE]
 13370                              <1> sysvideo_26_3: 
 13371 00010984 52                  <1> 	push	edx
 13372 00010985 53                  <1> 	push	ebx	; buffer size in bytes
 13373 00010986 51                  <1> 	push	ecx	; user's buffer address
 13374 00010987 87D9                <1> 	xchg	ebx, ecx
 13375 00010989 C1E90C              <1> 	shr	ecx, 12 ; convert buffer size to page count
 13376 0001098C E8715DFFFF          <1> 	call	direct_memory_access
 13377 00010991 59                  <1> 	pop	ecx	; user's buffer address
 13378 00010992 5B                  <1> 	pop	ebx	; buffer size
 13379 00010993 5A                  <1> 	pop	edx
 13380                              <1> 	;jc	short sysvideo_25 ; error !
 13381                              <1> 				  ; [u.r0] = 0
 13382                              <1> 	; 28/02/2021
 13383 00010994 7234                <1> 	jc	short sysvideo_27_0 ; error !	
 13384                              <1> 
 13385                              <1> ;sysvideo_26_4:
 13386                              <1> 	;mov	ebp, [u.usp] ; ebp points to user's registers
 13387                              <1> 	;mov	[ebp+20], edx ; return to user with EDX value 
 13388                              <1> 	;mov	[ebp+16], ebx ; EBX
 13389                              <1> 	;mov	[ebp+24], ecx ; ECX
 13390                              <1> 	; eax = physical address of video memory (LFB)
 13391                              <1> 	;mov	[u.r0], eax
 13392                              <1> 	;jmp	sysret
 13393 00010996 E919FCFFFF          <1> 	jmp	sysvideo_26_4
 13394                              <1> 
 13395                              <1> sysvideo_26_5:
 13396 0001099B 66A1[EB0E0000]      <1> 	mov	ax, [def_LFB_addr] ; default LFB for mode 118h
 13397                              <1> 	; ah must be 0C0h or 0D0h or E0h
 13398                              <1> 	; others are nonsence !?
 13399 000109A1 08E4                <1>  	or	ah, ah
 13400                              <1> 	;jz	short sysvideo_25 ; invalid lfb addr or
 13401                              <1> 			  	; it is not a vbe2 -bochs emu- 
 13402                              <1> 			  	; or vbe3 -real- video bios
 13403                              <1> 	; 28/02/2021
 13404 000109A3 7425                <1> 	jz	short sysvideo_27_0 ; invalid LFB address
 13405                              <1>  
 13406 000109A5 80FCF0              <1> 	cmp	ah, 0F0h  
 13407                              <1> 	;jnb	short sysvideo_25 ; nonsence !?
 13408                              <1> 	; 28/02/2021
 13409 000109A8 7320                <1> 	jnb	short sysvideo_27_0 ; nonsence !?
 13410                              <1> 
 13411 000109AA C1E010              <1> 	shl	eax, 16
 13412                              <1> 	;jz	short sysvideo_25 ; eax = 0 
 13413                              <1> 
 13414 000109AD 81FB00907E00        <1> 	cmp	ebx, 1920*1080*4 ; maximum value of possible
 13415                              <1> 				 ; buffer sizes
 13416 000109B3 76CF                <1> 	jna	short sysvideo_26_3  ; buffer size is proper
 13417                              <1> 	; resize buffer to fit 4GB limit
 13418 000109B5 BB00907E00          <1> 	mov	ebx, 1920*1080*4
 13419 000109BA EBC8                <1> 	jmp	short sysvideo_26_3
 13420                              <1> 
 13421                              <1> sysvideo_27:
 13422                              <1> 	; 16/02/2021
 13423                              <1> 	; 18/01/2021
 13424 000109BC 80FF0C              <1> 	cmp	bh, 12
 13425 000109BF 0F8778010000        <1> 	ja	sysvideo_28 ; 19/01/2021
 13426                              <1> 
 13427                              <1> 	; BH = 12
 13428                              <1> 	; Font sub functions.
 13429                              <1> 	; 12/02/2021
 13430                              <1> 	; 11/01/2021
 13431                              <1> 	; 10/01/2021
 13432                              <1> 	;   BL = 0 : Disable system font overwrite
 13433                              <1> 	;   BL = 1 : Enable system font overwrite
 13434                              <1> 	;   BL = 2 : Read system font 8x8
 13435                              <1> 	;   BL = 3 : Read system font 8x14
 13436                              <1> 	;   BL = 4 : Read system font 8x16
 13437                              <1> 	;   BL = 5 : Read user defined font 8x8
 13438                              <1> 	;   BL = 6 : Read user defined font 8x16
 13439                              <1> 	;   BL = 7 : Write system font 8x8
 13440                              <1> 	;   BL = 8 : Write system font 8x14
 13441                              <1> 	;   BL = 9 : Write system font 8x16
 13442                              <1> 	;   BL = 10 : Write user defined font 8x8
 13443                              <1> 	;   BL = 11 : Write user defined font 8x16
 13444                              <1> 	;
 13445                              <1> 	;  BL > 11 : invalid (not implemented)
 13446                              <1> 	;
 13447                              <1> 	; For BL = 1 to 11
 13448                              <1> 	;   ECX = number of characters (<= 256)
 13449                              <1> 	;   EDX = first character (ascii code in DL)
 13450                              <1> 	;   ESI = user's buffer address
 13451                              <1> 	;
 13452                              <1> 	; Return: EAX = character count 
 13453                              <1> 
 13454 000109C5 80FB0B              <1> 	cmp	bl, 11
 13455 000109C8 7605                <1> 	jna	short sysvideo_27_1
 13456                              <1> sysvideo_27_0:
 13457 000109CA E93DCFFFFF          <1> 	jmp	sysret ; not implemented yet !		
 13458                              <1> sysvideo_27_1:
 13459 000109CF 66B80001            <1> 	mov	ax, 256
 13460 000109D3 08DB                <1> 	or	bl, bl
 13461 000109D5 750E                <1>  	jnz	short sysvideo_27_3
 13462                              <1> 	
 13463                              <1> 	; bl = 0
 13464                              <1> 	; disable system font overwrite 
 13465                              <1> 
 13466 000109D7 8025[7E120300]7F    <1> 	and	byte [ufont], 7Fh ; clear bit 7
 13467                              <1> sysvideo_27_2:
 13468                              <1> 	;mov	word [u.r0], 256  ; > 0 -> successful
 13469 000109DE A3[64030300]        <1> 	mov	[u.r0], eax ; 256
 13470 000109E3 EBE5                <1> 	jmp	short sysvideo_27_0
 13471                              <1> sysvideo_27_3:
 13472 000109E5 80FB01              <1> 	cmp	bl, 1
 13473 000109E8 7710                <1> 	ja	short sysvideo_27_4
 13474                              <1> 
 13475                              <1> 	; bl = 1
 13476                              <1> 	; enable system font overwrite 
 13477                              <1> 	;	if [multi_tasking]= 0 and [u.uid] = 0
 13478                              <1> 
 13479                              <1> 	;cmp	byte [multi_tasking], 0 
 13480                              <1> 	;			; multi tasking enabled ?
 13481                              <1> 	;ja	short sysvideo_27_0 ; yes
 13482                              <1> 	;; 19/01/2021 
 13483                              <1> 	;; system maintenance or single user mode
 13484                              <1> 	;cmp	byte [u.uid], 0  ; root ?
 13485                              <1> 	;ja	short sysvideo_27_0 ; no
 13486                              <1> 
 13487                              <1> 	; 19/01/2021
 13488                              <1> 	; multi tasking & root check
 13489 000109EA E8ECFEFFFF          <1> 	call	sysvideo_22_4
 13490 000109EF 73D9                <1> 	jnc	short sysvideo_27_0 ; not permitted
 13491                              <1> 
 13492                              <1> 	; [multi_tasking]= 0 and [u.uid] = 0
 13493                              <1> 
 13494 000109F1 800D[7E120300]80    <1> 	or	byte [ufont], 80h ; set bit 7
 13495                              <1> 		
 13496 000109F8 EBE4                <1>  	jmp	short sysvideo_27_2
 13497                              <1> 
 13498                              <1> sysvideo_27_4:
 13499 000109FA 09C9                <1> 	or	ecx, ecx
 13500 000109FC 74CC                <1> 	jz	short sysvideo_27_0
 13501 000109FE 21D2                <1> 	and	edx, edx
 13502 00010A00 7410                <1> 	jz	short sysvideo_27_4_0
 13503                              <1> 	;mov	ax, 256
 13504 00010A02 39C1                <1> 	cmp	ecx, eax ; 256
 13505 00010A04 77C4                <1> 	ja	short sysvideo_27_0
 13506 00010A06 48                  <1> 	dec	eax
 13507 00010A07 39C2                <1> 	cmp	edx, eax ; 255
 13508 00010A09 77BF                <1> 	ja	short sysvideo_27_0
 13509 00010A0B 40                  <1> 	inc	eax
 13510 00010A0C 29D0                <1> 	sub	eax, edx ; 256 - DX
 13511 00010A0E 39C8                <1> 	cmp	eax, ecx
 13512 00010A10 72B8                <1> 	jb	short sysvideo_27_0
 13513                              <1> 
 13514                              <1> sysvideo_27_4_0:
 13515 00010A12 89F5                <1> 	mov	ebp, esi
 13516                              <1> 
 13517 00010A14 80FB06              <1> 	cmp	bl, 6
 13518 00010A17 776C                <1> 	ja	short sysvideo_27_13
 13519 00010A19 7210                <1> 	jb	short sysvideo_27_5
 13520                              <1> 	; bl = 6
 13521 00010A1B F605[7E120300]10    <1> 	test	byte [ufont], 16 ; 8x16 user font loaded ?
 13522 00010A22 74A6                <1> 	jz	short sysvideo_27_0
 13523                              <1> 	; read 8x16 user defined font
 13524 00010A24 BE00400900          <1> 	mov	esi, VGAFONT16USER
 13525 00010A29 EB0C                <1> 	jmp	short sysvideo_27_6
 13526                              <1> sysvideo_27_5:
 13527 00010A2B 80FB04              <1> 	cmp	bl, 4
 13528 00010A2E 723D                <1> 	jb	short sysvideo_27_11
 13529 00010A30 7723                <1> 	ja	short sysvideo_27_9
 13530                              <1> 	; bl = 4
 13531                              <1> 	; read 8x16 system font
 13532 00010A32 BE[C4760100]        <1> 	mov	esi, vgafont16
 13533                              <1> sysvideo_27_6:
 13534                              <1> 	; read 8x16 font
 13535 00010A37 66C1E204            <1> 	shl	dx, 4 ; * 16
 13536 00010A3B 66C1E104            <1> 	shl	cx, 4 ; * 16 ; 16 bytes per char
 13537                              <1> sysvideo_27_7:
 13538 00010A3F 89EF                <1> 	mov	edi, ebp
 13539                              <1> 	;add	edi, edx ; 16/02/2021
 13540 00010A41 01D6                <1> 	add	esi, edx
 13541                              <1> 	; ecx = byte count
 13542                              <1> 	; esi = source (in system memory)
 13543                              <1> 	; edi = destination (in user memory)
 13544 00010A43 E81C110000          <1> 	call	transfer_to_user_buffer
 13545 00010A48 7206                <1> 	jc	short sysvideo_27_8
 13546 00010A4A 890D[64030300]      <1> 	mov	[u.r0], ecx	
 13547                              <1> sysvideo_27_8:
 13548 00010A50 E9B7CEFFFF          <1> 	jmp	sysret
 13549                              <1> sysvideo_27_9:
 13550                              <1> 	; bl = 5
 13551 00010A55 F605[7E120300]08    <1> 	test	byte [ufont], 8 ; 8x8 user font loaded ?
 13552 00010A5C 74F2                <1> 	jz	short sysvideo_27_8
 13553                              <1> 	; read 8x8 user defined font
 13554 00010A5E BE00500900          <1> 	mov	esi, VGAFONT8USER
 13555                              <1> sysvideo_27_10:
 13556                              <1> 	; read 8x8 font
 13557 00010A63 66C1E203            <1> 	shl	dx, 3 ; * 8
 13558 00010A67 66C1E103            <1> 	shl	cx, 3 ; * 8 ; 8 bytes per char
 13559 00010A6B EBD2                <1> 	jmp	short sysvideo_27_7
 13560                              <1> 
 13561                              <1> sysvideo_27_11:
 13562 00010A6D 80FB03              <1> 	cmp	bl, 3  ; 8x14 system font
 13563 00010A70 720C                <1> 	jb	short sysvideo_27_12 ; 8x8 system font
 13564                              <1> 	; bl = 3
 13565                              <1> 	; read 8x14 system font 
 13566                              <1> 	;mov	al, 14
 13567                              <1> 	;mul	dl
 13568                              <1> 	;mov	dx, ax
 13569                              <1> 	;push	edx
 13570                              <1> 	;mov	ax, 14
 13571                              <1> 	;mul	cx
 13572                              <1> 	;mov	cx, ax
 13573                              <1> 	;pop	edx
 13574 00010A72 E8A9000000          <1> 	call	sysvideo_27_14
 13575 00010A77 BE[C4680100]        <1> 	mov	esi, vgafont14
 13576 00010A7C EBC1                <1> 	jmp	short sysvideo_27_7	
 13577                              <1> 	
 13578                              <1> sysvideo_27_12:
 13579                              <1> 	; bl = 2
 13580                              <1> 	; read 8x8 system font 
 13581 00010A7E BE[C4600100]        <1> 	mov	esi, vgafont8
 13582 00010A83 EBDE                <1> 	jmp	short sysvideo_27_10
 13583                              <1> 
 13584                              <1> sysvideo_27_13:
 13585                              <1> 	; overwrite font
 13586 00010A85 80FB0A              <1> 	cmp	bl, 10
 13587 00010A88 7772                <1> 	ja	short sysvideo_27_22 ; 8x16 user font
 13588 00010A8A 7224                <1> 	jb	short sysvideo_27_15
 13589                              <1> 	; bl = 10
 13590 00010A8C BF00500900          <1> 	mov	edi, VGAFONT8USER
 13591 00010A91 F605[7E120300]08    <1> 	test	byte [ufont], 8 ; 8x8 user font loaded ?
 13592 00010A98 7558                <1> 	jnz	short sysvideo_27_21 ; yes
 13593 00010A9A 08ED                <1> 	or	ch, ch ; cx = 256
 13594                              <1> 	;jnz	short sysvideo_27_21 ; 256 chars
 13595 00010A9C 7406                <1> 	jz	short sysvideo_27_13_0
 13596 00010A9E 66B90008            <1> 	mov	cx, 8*256
 13597 00010AA2 EB37                <1> 	jmp	short sysvideo_27_18_0
 13598                              <1> sysvideo_27_13_0:
 13599                              <1> 	; copy system font to user font before overwrite
 13600 00010AA4 BE[C4600100]        <1> 	mov	esi, vgafont8
 13601                              <1> 	;push	edi
 13602                              <1> 	;push	ecx
 13603                              <1> 	;mov	cl, 64
 13604                              <1> 	;rep	movsd
 13605                              <1> 	;pop	ecx
 13606                              <1> 	;pop	edi
 13607                              <1> 	;mov	esi, ebp ; user's font buffer
 13608 00010AA9 E884000000          <1> 	call	sysvideo_27_23
 13609 00010AAE EB42                <1> 	jmp	short sysvideo_27_21
 13610                              <1> 
 13611                              <1> sysvideo_27_15:
 13612                              <1> 	; check system font overwrite permission
 13613 00010AB0 F605[7E120300]80    <1> 	test	byte [ufont], 80h
 13614 00010AB7 7497                <1> 	jz	short sysvideo_27_8
 13615                              <1> 
 13616 00010AB9 80FB08              <1> 	cmp	bl, 8
 13617 00010ABC 773E                <1> 	ja	short sysvideo_27_22 ; 8x16 system font
 13618 00010ABE 722D                <1> 	jb	short sysvideo_27_20 ; 8x8 system font
 13619                              <1> 	; bl = 8
 13620                              <1> 	; overwrite 8x14 system font 
 13621                              <1> 	;mov	al, 14
 13622                              <1> 	;mul	dl
 13623                              <1> 	;mov	dx, ax
 13624                              <1> 	;push	edx
 13625                              <1> 	;mov	ax, 14
 13626                              <1> 	;mul	cx
 13627                              <1> 	;mov	cx, ax
 13628                              <1> 	;pop	edx
 13629 00010AC0 E85B000000          <1> 	call	sysvideo_27_14
 13630 00010AC5 BF[C4680100]        <1> 	mov	edi, vgafont14
 13631 00010ACA EB0D                <1> 	jmp	short sysvideo_27_18
 13632                              <1> sysvideo_27_16:
 13633                              <1> 	; bl = 9
 13634                              <1> 	; overwrite 8x16 system font
 13635 00010ACC BF[C4760100]        <1> 	mov	edi, vgafont16
 13636                              <1> sysvideo_27_17:
 13637                              <1> 	; overwrite 8x16 font
 13638 00010AD1 66C1E204            <1> 	shl	dx, 4 ; * 16
 13639 00010AD5 66C1E104            <1> 	shl	cx, 4 ; * 16 ; 16 bytes per char
 13640                              <1> sysvideo_27_18:
 13641 00010AD9 01D7                <1> 	add	edi, edx
 13642                              <1> 	;add	esi, edx ; 16/02/2021
 13643                              <1> sysvideo_27_18_0:
 13644                              <1> 	; ecx = byte count
 13645                              <1> 	; esi = source (in user memory)
 13646                              <1> 	; edi = destination (in system memory)
 13647 00010ADB E8CE100000          <1> 	call	transfer_from_user_buffer
 13648 00010AE0 7206                <1> 	jc	short sysvideo_27_19
 13649 00010AE2 890D[64030300]      <1> 	mov	[u.r0], ecx	
 13650                              <1> sysvideo_27_19:
 13651 00010AE8 E91FCEFFFF          <1> 	jmp	sysret
 13652                              <1> sysvideo_27_20:
 13653                              <1> 	; bl = 7
 13654                              <1> 	; overwrite 8x8 system font
 13655 00010AED BF[C4600100]        <1> 	mov	edi, vgafont8
 13656                              <1> sysvideo_27_21:
 13657                              <1> 	; write 8x8 font
 13658 00010AF2 66C1E203            <1> 	shl	dx, 3 ; * 8
 13659 00010AF6 66C1E103            <1> 	shl	cx, 3 ; * 8 ; 8 bytes per char
 13660 00010AFA EBDD                <1> 	jmp	short sysvideo_27_18
 13661                              <1> sysvideo_27_22:
 13662                              <1> 	; bl = 11
 13663                              <1> 	; overwrite 8x16 user defined font
 13664 00010AFC BF00400900          <1> 	mov	edi, VGAFONT16USER
 13665 00010B01 F605[7E120300]10    <1> 	test	byte [ufont], 16 ; 8x16 user font loaded ?
 13666 00010B08 75C7                <1> 	jnz	short sysvideo_27_17 ; yes
 13667 00010B0A 08ED                <1> 	or	ch, ch ; cx = 256
 13668                              <1> 	;jnz	short sysvideo_27_17 ; 256 chars
 13669 00010B0C 7406                <1> 	jz	short sysvideo_27_22_0
 13670 00010B0E 66B90010            <1> 	mov	cx, 16*256
 13671 00010B12 EBC7                <1> 	jmp	short sysvideo_27_18_0
 13672                              <1> sysvideo_27_22_0:
 13673                              <1> 	; copy system font to user font before overwrite
 13674 00010B14 BE[C4760100]        <1> 	mov	esi, vgafont16
 13675                              <1> 	;push	edi
 13676                              <1> 	;push	ecx
 13677                              <1> 	;mov	cl, 64
 13678                              <1> 	;rep	movsd
 13679                              <1> 	;pop	ecx
 13680                              <1> 	;pop	edi
 13681                              <1> 	;mov	esi, ebp ; user's font buffer
 13682 00010B19 E814000000          <1> 	call	sysvideo_27_23
 13683 00010B1E EBB1                <1> 	jmp	short sysvideo_27_17
 13684                              <1> 
 13685                              <1> sysvideo_27_14:
 13686                              <1> 	; 16/02/2021
 13687 00010B20 52                  <1> 	push	edx
 13688 00010B21 66B80E00            <1> 	mov	ax, 14	
 13689 00010B25 66F7E1              <1> 	mul	cx
 13690 00010B28 89C1                <1> 	mov	ecx, eax
 13691 00010B2A 5A                  <1> 	pop	edx
 13692 00010B2B B00E                <1> 	mov	al, 14
 13693 00010B2D F6E2                <1> 	mul	dl
 13694 00010B2F 89C2                <1> 	mov	edx, eax
 13695 00010B31 C3                  <1> 	retn
 13696                              <1> 
 13697                              <1> 	;mov	al, 14
 13698                              <1> 	;mul	dl
 13699                              <1> 	;mov	dx, ax
 13700                              <1> 	;push	edx
 13701                              <1> 	;; 12/02/2021
 13702                              <1> 	;mov	ax, 14
 13703                              <1> 	;;mov	eax, 14
 13704                              <1> 	;;mul	cx
 13705                              <1> 	;mul	ecx
 13706                              <1> 	;;mov	cx, ax
 13707                              <1> 	;mov	ecx, eax
 13708                              <1> 	;pop	edx
 13709                              <1> 	;retn	
 13710                              <1> 
 13711                              <1> sysvideo_27_23:
 13712 00010B32 57                  <1> 	push	edi
 13713 00010B33 51                  <1> 	push	ecx
 13714 00010B34 B140                <1> 	mov	cl, 64
 13715 00010B36 F3A5                <1> 	rep	movsd
 13716 00010B38 59                  <1> 	pop	ecx
 13717 00010B39 5F                  <1> 	pop	edi
 13718 00010B3A 89EE                <1> 	mov	esi, ebp ; user's font buffer
 13719 00010B3C C3                  <1> 	retn
 13720                              <1> 
 13721                              <1> sysvideo_28:
 13722                              <1> 	; 24/01/2021
 13723                              <1> 	; 23/01/2021
 13724                              <1> 	; 18/01/2021
 13725 00010B3D 80FF0E              <1> 	cmp	bh, 14
 13726 00010B40 0F8275010000        <1> 	jb	sysvideo_29
 13727 00010B46 0F8754020000        <1> 	ja	sysvideo_30
 13728                              <1> 
 13729                              <1> 	; BH = 14
 13730                              <1> 	; Save/Restore Super VGA video state
 13731                              <1> 	
 13732                              <1> 	; BL = options
 13733                              <1> 	;	bit 0 - Save (0) or Restore (1)	
 13734                              <1> 	;	bit 1 - controller hardware state
 13735                              <1> 	;	bit 2 - BIOS data state
 13736                              <1> 	;	bit 3 - DAC state
 13737                              <1> 	;	bit 4 - (extended) Register state
 13738                              <1> 	;	bit 5 - system (0) or user (1) memory
 13739                              <1> 	;	bit 6 - verify without transfer
 13740                              <1> 	;	bit 7 - not used (must be 0)
 13741                              <1> 
 13742                              <1> 	; ECX = Buffer address or VideoStateID
 13743                              <1> 
 13744 00010B4C 803D[5C090000]02    <1> 	cmp	byte [vbe3], 2 ;  VESA VBE2 or VBE3 ?
 13745 00010B53 7717                <1> 	ja	short sysvideo_28_0 ; yes
 13746 00010B55 7210                <1> 	jb	short sysvideo_28_16 ; not a SVGA sys !
 13747                              <1> 
 13748                              <1> 	; == VBE2 ==
 13749                              <1> 	; Check Bochs/Qemu/VirtualBox PC emulator
 13750                              <1> 	; (vbe2 is usable only for emulator's vbios)
 13751 00010B57 8A25[5D090000]      <1> 	mov	ah, [vbe2bios]
 13752 00010B5D 80FCC0              <1> 	cmp	ah, 0C0h	
 13753 00010B60 7205                <1> 	jb	short sysvideo_28_16 ; unknown vbios !
 13754 00010B62 80FCC5              <1> 	cmp	ah, 0C5h
 13755 00010B65 7605                <1> 	jna	short sysvideo_28_0
 13756                              <1> 		; Use kernel's vbios functions (video.s)
 13757                              <1> sysvideo_28_16:
 13758                              <1> 	; unknown vbios !
 13759 00010B67 E9A0CDFFFF          <1> 	jmp	sysret	
 13760                              <1> 
 13761                              <1> sysvideo_28_0:
 13762 00010B6C 80FB7F              <1> 	cmp	bl, 7Fh
 13763 00010B6F 77F6                <1> 	ja	short sysvideo_28_16 ; unknown options
 13764                              <1> 
 13765 00010B71 88DA                <1> 	mov	dl, bl
 13766 00010B73 80E21F              <1> 	and	dl, 1Fh 
 13767 00010B76 D0EA                <1> 	shr	dl, 1
 13768 00010B78 74ED                <1> 	jz	short sysvideo_28_16 ; invalid !
 13769                              <1> 	; DL = VBE Function 4F04h Save/Restore options 	
 13770                              <1> 	;  bit 0 : controller hardware state
 13771                              <1> 	;  bit 1 : BIOS data state
 13772                              <1> 	;  bit 2 : DAC state
 13773                              <1> 	;  bit 3 : (extended) Register state
 13774                              <1> 	
 13775 00010B7A F6C320              <1> 	test	bl, 32 ; bit 5
 13776 00010B7D 0F85B1000000        <1> 	jnz	sysvideo_28_7 ; user buffer
 13777                              <1> 
 13778                              <1> 	; source or destination is kernel/system buffer
 13779                              <1> 
 13780 00010B83 803D[80120300]00    <1> 	cmp	byte [srvsf], 0 ; srs permission flag
 13781 00010B8A 76DB                <1> 	jna	short sysvideo_28_16 ; not permitted
 13782                              <1> 
 13783 00010B8C F6C301              <1> 	test	bl, 1
 13784 00010B8F 743A                <1> 	jz	short sysvideo_28_4 ; Save
 13785                              <1> 
 13786                              <1> 	; Restore
 13787 00010B91 3B0D[82120300]      <1> 	cmp	ecx, [VideoStateID]
 13788 00010B97 75CE                <1> 	jne	short sysvideo_28_16 ; not correct ID !
 13789                              <1> 		
 13790 00010B99 0FB6CA              <1> 	movzx	ecx, dl
 13791 00010B9C 80CA80              <1> 	or	dl, 80h
 13792 00010B9F 3A15[81120300]      <1> 	cmp	dl, [srvso]
 13793 00010BA5 75C0                <1> 	jne	short sysvideo_28_16 ; not correct !
 13794                              <1> 
 13795 00010BA7 88DA                <1> 	mov	dl, bl
 13796                              <1> 
 13797                              <1> 	; ecx = cl = options
 13798 00010BA9 E8C930FFFF          <1> 	call	vbe_srs_gbs
 13799                              <1> 	; ebx = state buffer size (data size)
 13800                              <1> 
 13801 00010BAE 891D[64030300]      <1> 	mov	[u.r0], ebx
 13802                              <1> 
 13803 00010BB4 F6C240              <1> 	test	dl, 64 ; verify without transfer
 13804 00010BB7 75AE                <1> 	jnz	short sysvideo_28_16 ; yes
 13805                              <1> 
 13806 00010BB9 BE00580900          <1> 	mov	esi, VBE3VIDEOSTATE	
 13807 00010BBE BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
 13808 00010BC3 87CB                <1> 	xchg	ecx, ebx
 13809 00010BC5 F3A4                <1> 	rep	movsb
 13810                              <1> 	
 13811 00010BC7 88D9                <1> 	mov	cl, bl
 13812                              <1> 
 13813                              <1> 	; 23/01/2021
 13814 00010BC9 EB44                <1> 	jmp	short sysvideo_28_10
 13815                              <1> 
 13816                              <1> sysvideo_28_4:
 13817 00010BCB 53                  <1> 	push	ebx	
 13818                              <1> 	; 24/01/2021
 13819 00010BCC 31DB                <1> 	xor	ebx, ebx ; 0 ; use kernel's buffer
 13820 00010BCE 881D[81120300]      <1> 	mov	[srvso], bl ; 0 ; invalidate
 13821 00010BD4 891D[82120300]      <1> 	mov	[VideoStateID], ebx ; 0 ; invalidate
 13822 00010BDA 0FB6CA              <1> 	movzx	ecx, dl ; options
 13823 00010BDD B201                <1> 	mov	dl, 1 ; save state		
 13824 00010BDF E890000000          <1> 	call	sysvideo_28_11 ; 23/01/2021
 13825                              <1> 	; Note: VBE3 BIOS data save option will be
 13826                              <1> 	;	disabled.. ; 24/01/2021
 13827 00010BE4 89CA                <1> 	mov	edx, ecx ; state (save) options
 13828 00010BE6 5B                  <1> 	pop	ebx
 13829                              <1> 	
 13830 00010BE7 6683F84F            <1> 	cmp	ax, 4Fh ; successful ?
 13831 00010BEB 7536                <1> 	jne	short sysvideo_28_3 ; no !
 13832                              <1> 
 13833 00010BED F6C340              <1> 	test	bl, 64 ; verify without transfer
 13834 00010BF0 7536                <1> 	jnz	short sysvideo_28_6 ; yes
 13835                              <1> 
 13836                              <1> 	; ecx = cl = options
 13837 00010BF2 E88030FFFF          <1> 	call	vbe_srs_gbs
 13838                              <1> 	; ebx = state buffer size (data size)
 13839                              <1> 
 13840 00010BF7 BE00760900          <1> 	mov	esi, VBE3SAVERESTOREBLOCK
 13841 00010BFC BF00580900          <1> 	mov	edi, VBE3VIDEOSTATE	
 13842 00010C01 89D9                <1> 	mov	ecx, ebx
 13843 00010C03 F3A4                <1> 	rep	movsb
 13844                              <1> 
 13845 00010C05 88D1                <1> 	mov	cl, dl
 13846 00010C07 80C980              <1> 	or	cl, 80h ; SVGA (VESA VBE) flag
 13847                              <1> 	;mov	[srvso], dl
 13848                              <1> 
 13849 00010C0A E908010000          <1> 	jmp	sysvideo_28_15
 13850                              <1> 
 13851                              <1> 	; 23/01/2021
 13852                              <1> sysvideo_28_10:
 13853                              <1> 	; CL = VESA VBE3 Save/Restore options
 13854                              <1> 
 13855 00010C0F B202                <1> 	mov	dl, 2 ; restore state
 13856                              <1> 
 13857 00010C11 E85C000000          <1> 	call	sysvideo_28_1
 13858                              <1> 
 13859 00010C16 6683F84F            <1> 	cmp	ax, 4Fh ; successful ?
 13860 00010C1A 7407                <1> 	je	short sysvideo_28_3
 13861                              <1> 	;jmp	short sysvideo_28_9 
 13862                              <1> 
 13863                              <1> sysvideo_28_9:
 13864                              <1> 	; return zero size (error) to user
 13865 00010C1C 29C0                <1> 	sub	eax, eax
 13866                              <1> sysvideo_28_5:
 13867 00010C1E A3[64030300]        <1> 	mov	[u.r0], eax
 13868                              <1> sysvideo_28_3:
 13869 00010C23 E9E4CCFFFF          <1> 	jmp	sysret
 13870                              <1> 
 13871                              <1> sysvideo_28_6:
 13872                              <1> 	; use timer ticks as VideoStateID
 13873 00010C28 A1[B08A0100]        <1> 	mov	eax, [TIMER_LH]
 13874 00010C2D 09C0                <1> 	or 	eax, eax
 13875 00010C2F 75ED                <1> 	jnz	short sysvideo_28_5
 13876 00010C31 40                  <1> 	inc	eax
 13877 00010C32 EBEA                <1> 	jmp	short sysvideo_28_5
 13878                              <1> 
 13879                              <1> sysvideo_28_7:
 13880                              <1> 	; save/restore to/from user buffer
 13881                              <1> 
 13882                              <1> 	; 23/01/2021
 13883 00010C34 89CE                <1> 	mov	esi, ecx ; user's vstate buffer
 13884 00010C36 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
 13885                              <1> 
 13886 00010C3B 0FB6CA              <1> 	movzx	ecx, dl ; VESA VBE func 4F04h options
 13887                              <1> 
 13888                              <1> 	; source or destination is user buffer
 13889 00010C3E F6C301              <1> 	test	bl, 1
 13890 00010C41 7444                <1> 	jz	short sysvideo_28_12  ; Save
 13891                              <1> 
 13892                              <1> 	; Restore
 13893 00010C43 803D[80120300]00    <1> 	cmp	byte [srvsf], 0 ; srs permission flag
 13894 00010C4A 766A                <1> 	jna	short sysvideo_28_14 ; not permitted
 13895                              <1> 
 13896 00010C4C 88DA                <1> 	mov	dl, bl ; 'sysvideo' options
 13897                              <1> 
 13898                              <1> 	; ecx = cl = options
 13899 00010C4E E82430FFFF          <1> 	call	vbe_srs_gbs
 13900                              <1> 	; ebx = state buffer size (data size)
 13901                              <1> 
 13902 00010C53 891D[64030300]      <1> 	mov	[u.r0], ebx ; transfer count
 13903                              <1> 
 13904 00010C59 F6C240              <1> 	test	dl, 64 ; verify without transfer
 13905 00010C5C 7558                <1> 	jnz	short sysvideo_28_14 ; yes
 13906                              <1>  
 13907 00010C5E 6681FB0008          <1> 	cmp	bx, 2048
 13908 00010C63 73B7                <1> 	jnb	short sysvideo_28_9 ; invalid
 13909                              <1> 
 13910 00010C65 87CB                <1> 	xchg	ecx, ebx
 13911                              <1> 	; esi = user buffer
 13912                              <1> 	; edi = VBE3SAVERESTOREBLOCK
 13913                              <1> 
 13914 00010C67 E8420F0000          <1> 	call	transfer_from_user_buffer
 13915 00010C6C 72AE                <1> 	jc	short sysvideo_28_9 ; error 
 13916                              <1> 
 13917 00010C6E 89D9                <1> 	mov	ecx, ebx ; Function 4F04h options
 13918 00010C70 EB9D                <1> 	jmp	short sysvideo_28_10 ; 23/01/2021
 13919                              <1> 
 13920                              <1> sysvideo_28_1:
 13921 00010C72 31DB                <1> 	xor	ebx, ebx ; 0 ; use kernel's buffer
 13922                              <1> sysvideo_28_11:
 13923                              <1> 	; 24/01/2021
 13924 00010C74 803D[5C090000]03    <1> 	cmp	byte [vbe3], 3
 13925 00010C7B 7405                <1> 	je	short sysvideo_28_2
 13926                              <1> 
 13927                              <1> 	; VESA VBE2 (BOCHS/QEMU/VBOX) video bios
 13928 00010C7D E95E2FFFFF          <1> 	jmp	_vbe_biosfn_save_restore_state
 13929                              <1> sysvideo_28_2:
 13930                              <1> 	;24/01/2021
 13931                              <1> 	;mov	eax, 4F04h  ; Save/Restore vstate
 13932                              <1> 	; VESA VBE3 video bios
 13933 00010C82 E9B70DFFFF          <1> 	jmp	_vbe3_pmfn_save_restore_state
 13934                              <1> 	
 13935                              <1> sysvideo_28_12:
 13936                              <1> 	; Save
 13937                              <1> 	;mov	edi, VBE3SAVERESTOREBLOCK
 13938                              <1> 
 13939                              <1> 	;movzx	ecx, dl ; options
 13940 00010C87 56                  <1> 	push	esi
 13941 00010C88 53                  <1> 	push	ebx
 13942                              <1> 	; 23/01/2021
 13943 00010C89 B201                <1> 	mov	dl, 1 ; save state
 13944 00010C8B E8E2FFFFFF          <1> 	call	sysvideo_28_1
 13945 00010C90 5A                  <1> 	pop	edx ; 'sysvideo' options
 13946 00010C91 5F                  <1> 	pop	edi ; user's video state buffer
 13947                              <1> 
 13948 00010C92 6683F84F            <1> 	cmp	ax, 4Fh ; successful ?
 13949 00010C96 751E                <1> 	jne	short sysvideo_28_14 ; no !
 13950                              <1> 
 13951                              <1> 	; ecx = cl = options
 13952 00010C98 E8DA2FFFFF          <1> 	call	vbe_srs_gbs
 13953                              <1> 	; ebx = state buffer size (data size)
 13954                              <1> 
 13955 00010C9D 89D9                <1> 	mov	ecx, ebx ; transfer count
 13956                              <1> 
 13957 00010C9F F6C240              <1> 	test	dl, 64 ; verify without transfer
 13958 00010CA2 750C                <1> 	jnz	short sysvideo_28_13 ; yes
 13959                              <1> 		
 13960                              <1> 	;mov	edi, esi
 13961 00010CA4 BE00760900          <1> 	mov	esi, VBE3SAVERESTOREBLOCK
 13962 00010CA9 E8B60E0000          <1> 	call	transfer_to_user_buffer
 13963 00010CAE 7206                <1> 	jc	short sysvideo_28_14
 13964                              <1> sysvideo_28_13:
 13965 00010CB0 890D[64030300]      <1> 	mov	[u.r0], ecx
 13966                              <1> sysvideo_28_14:
 13967 00010CB6 E951CCFFFF          <1> 	jmp	sysret
 13968                              <1> 
 13969                              <1> sysvideo_29:
 13970                              <1> 	; 18/01/2021
 13971                              <1> 	; BH = 13
 13972                              <1> 	; Save/Restore std VGA video state
 13973                              <1> 
 13974                              <1> 	; bl = 0..3
 13975                              <1> 	;	save to or restore from
 13976                              <1> 	;	system buffer, VBE3VIDEOSTATE
 13977                              <1> 	;	ECX = VideoStateID for restoring	
 13978                              <1> 	; bl = 4..7
 13979                              <1> 	;	save to or restore from
 13980                              <1> 	;	user buffer pointed by ECX
 13981                              <1> 		   	
 13982 00010CBB 80FB03              <1> 	cmp	bl, 3
 13983 00010CBE 7776                <1> 	ja	short sysvideo_29_6
 13984                              <1> 
 13985                              <1> 	; source or destination is kernel/system buffer
 13986                              <1> 
 13987 00010CC0 803D[80120300]00    <1> 	cmp	byte [srvsf], 0 ; srs permission flag
 13988 00010CC7 7668                <1> 	jna	short sysvideo_29_5 ; not permitted
 13989                              <1> 
 13990 00010CC9 F6C301              <1> 	test	bl, 1
 13991 00010CCC 7437                <1> 	jz	short sysvideo_29_2  ; Save
 13992                              <1> 
 13993                              <1> 	; Restore
 13994 00010CCE 3B0D[82120300]      <1> 	cmp	ecx, [VideoStateID]
 13995 00010CD4 755B                <1> 	jne	short sysvideo_29_5 ; not correct ID !
 13996 00010CD6 80FB01              <1> 	cmp	bl, 1
 13997 00010CD9 7709                <1> 	ja	short sysvideo_29_0
 13998                              <1> 	; bl = 1
 13999 00010CDB BB6E000000          <1> 	mov	ebx, 110 
 14000 00010CE0 B103                <1> 	mov	cl, 3 ; ctrl, vbios data
 14001 00010CE2 EB07                <1> 	jmp	short sysvideo_29_1
 14002                              <1> sysvideo_29_0:
 14003                              <1>  	; bl  = 3
 14004 00010CE4 BB72030000          <1> 	mov	ebx, 882 
 14005 00010CE9 B107                <1> 	mov	cl, 7 ; ctrl, vbios data, dac
 14006                              <1> sysvideo_29_1:
 14007 00010CEB 3A0D[81120300]      <1> 	cmp	cl, [srvso]
 14008 00010CF1 753E                <1> 	jne	short sysvideo_29_5 ; not correct !
 14009                              <1> 
 14010 00010CF3 BE00580900          <1> 	mov	esi, VBE3VIDEOSTATE ; 22/01/2021
 14011 00010CF8 E81431FFFF          <1> 	call	biosfn_restore_video_state
 14012 00010CFD 891D[64030300]      <1> 	mov	[u.r0], ebx ; video state size (bytes)
 14013                              <1> 	;jmp	sysret
 14014 00010D03 EB2C                <1> 	jmp	short sysvideo_29_5	
 14015                              <1> sysvideo_29_2:
 14016                              <1> 	;mov	esi, ecx
 14017 00010D05 BF00580900          <1> 	mov	edi, VBE3VIDEOSTATE
 14018                              <1> 	
 14019 00010D0A B107                <1> 	mov	cl, 7 ; ctrl, vbios data, dac
 14020 00010D0C 08DB                <1> 	or	bl, bl
 14021 00010D0E 7502                <1> 	jnz	short sysvideo_29_3 ; bl = 2
 14022                              <1> 	; bl = 0 
 14023 00010D10 B103                <1> 	mov	cl, 3 ; ctrl, vbios data
 14024                              <1> sysvideo_29_3:
 14025 00010D12 E88C2FFFFF          <1> 	call	biosfn_save_video_state
 14026                              <1> sysvideo_28_15:
 14027                              <1> 	; use timer ticks as VideoStateID
 14028 00010D17 A1[B08A0100]        <1> 	mov	eax, [TIMER_LH]
 14029 00010D1C 21C0                <1> 	and 	eax, eax
 14030 00010D1E 7501                <1> 	jnz	short sysvideo_29_4
 14031 00010D20 40                  <1> 	inc	eax
 14032                              <1> sysvideo_29_4:
 14033 00010D21 880D[81120300]      <1> 	mov	[srvso], cl
 14034 00010D27 A3[82120300]        <1> 	mov	[VideoStateID], eax
 14035 00010D2C A3[64030300]        <1> 	mov	[u.r0], eax
 14036                              <1> sysvideo_29_5:
 14037 00010D31 E9D6CBFFFF          <1> 	jmp	sysret
 14038                              <1> 
 14039                              <1> sysvideo_29_6:
 14040 00010D36 80FB07              <1> 	cmp	bl, 7
 14041 00010D39 77F6                <1> 	ja	short sysvideo_29_5 ; invalid sub function 
 14042                              <1> 
 14043 00010D3B 89CE                <1> 	mov	esi, ecx
 14044 00010D3D BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
 14045                              <1> 
 14046                              <1> 	; source or destination is user buffer
 14047 00010D42 F6C301              <1> 	test	bl, 1
 14048 00010D45 7434                <1> 	jz	short sysvideo_29_9  ; Save
 14049                              <1> 
 14050                              <1> 	; Restore
 14051 00010D47 803D[80120300]00    <1> 	cmp	byte [srvsf], 0 ; srs permission flag
 14052 00010D4E 76E1                <1> 	jna	short sysvideo_29_5 ; not permitted
 14053                              <1> 	
 14054                              <1> 	;mov	esi, ecx
 14055                              <1> 	;mov	edi, VBE3SAVERESTOREBLOCK
 14056                              <1> 	
 14057 00010D50 80FB07              <1> 	cmp	bl, 7
 14058 00010D53 7409                <1> 	je	short sysvideo_29_7
 14059                              <1> 	; bl = 5 
 14060 00010D55 B303                <1> 	mov	bl, 3
 14061 00010D57 B96E000000          <1> 	mov	ecx, 110
 14062 00010D5C EB05                <1> 	jmp	short sysvideo_29_8
 14063                              <1> sysvideo_29_7:
 14064                              <1> 	; bl = 7
 14065 00010D5E B972030000          <1> 	mov	ecx, 882
 14066                              <1> sysvideo_29_8:
 14067 00010D63 E8460E0000          <1> 	call	transfer_from_user_buffer
 14068 00010D68 72C7                <1> 	jc	short sysvideo_29_5
 14069 00010D6A 890D[64030300]      <1> 	mov	[u.r0], ecx
 14070 00010D70 88D9                <1> 	mov	cl, bl ; mov cl,7 (mov cl,3)
 14071 00010D72 89FE                <1> 	mov	esi, edi ; VBE3SAVERESTOREBLOCK
 14072                              <1> 	; cl = 3 or 7  	
 14073 00010D74 E89830FFFF          <1> 	call	biosfn_restore_video_state
 14074 00010D79 EBB6                <1> 	jmp	sysvideo_29_5
 14075                              <1> 	;jmp	sysret
 14076                              <1> sysvideo_29_9:
 14077                              <1> 	; Save
 14078                              <1> 	;mov	edi, VBE3SAVERESTOREBLOCK
 14079                              <1> 
 14080 00010D7B 80FB06              <1> 	cmp	bl, 6
 14081 00010D7E 7409                <1> 	je	short sysvideo_29_10
 14082                              <1> 	; bl = 4
 14083 00010D80 BB6E000000          <1> 	mov	ebx, 110
 14084 00010D85 B103                <1> 	mov	cl, 3 ; ctrl, vbios data
 14085 00010D87 EB07                <1> 	jmp	short sysvideo_29_11
 14086                              <1> sysvideo_29_10:
 14087                              <1> 	; bl = 6
 14088 00010D89 BB72030000          <1> 	mov	ebx, 882
 14089 00010D8E B107                <1> 	mov	cl, 7 ; ctrl, vbios data, dac
 14090                              <1> sysvideo_29_11:
 14091 00010D90 E80E2FFFFF          <1> 	call	biosfn_save_video_state
 14092                              <1> 
 14093 00010D95 89D9                <1> 	mov	ecx, ebx ; transfer count
 14094 00010D97 89F7                <1> 	mov	edi, esi
 14095 00010D99 BE00760900          <1> 	mov	esi, VBE3SAVERESTOREBLOCK
 14096                              <1> 
 14097                              <1> 	;call	transfer_to_user_buffer
 14098                              <1> 	;jc	short sysvideo_29_5
 14099                              <1> 	;mov	[u.r0], ecx ; transfer count
 14100                              <1> 	;;jmp	sysret
 14101                              <1> 	;jmp	short sysvideo_29_5
 14102                              <1>  
 14103 00010D9E EB1A                <1> 	jmp	short sysvideo_29_12
 14104                              <1> 
 14105                              <1> sysvideo_30:	 
 14106 00010DA0 80FF0F              <1> 	cmp	bh, 15
 14107 00010DA3 7722                <1> 	ja	short sysvideo_31 ; invalid function
 14108                              <1> 	
 14109                              <1> 	; BH = 15
 14110                              <1> 	; Copy VESA EDID to user's buffer
 14111                              <1> 	
 14112 00010DA5 803D[37430000]4F    <1> 	cmp	byte [edid], 4Fh
 14113 00010DAC 7519                <1> 	jne	short sysvideo_31 ; not ready ! 
 14114                              <1> 
 14115                              <1> 	;and	ecx, ecx
 14116                              <1> 	;jz	short sysvideo_31
 14117                              <1> 
 14118                              <1> 	; ecx = user's buffer address
 14119 00010DAE 89CF                <1> 	mov	edi, ecx
 14120 00010DB0 BE[9C110300]        <1> 	mov	esi, edid_info
 14121 00010DB5 B980000000          <1> 	mov	ecx, 128 ; 128 bytes
 14122                              <1> sysvideo_29_12:
 14123 00010DBA E8A50D0000          <1> 	call	transfer_to_user_buffer
 14124 00010DBF 7206                <1> 	jc	short sysvideo_31
 14125                              <1> 
 14126 00010DC1 890D[64030300]      <1> 	mov	[u.r0], ecx ; EDID size, 128 bytes
 14127                              <1> sysvideo_31:
 14128 00010DC7 E940CBFFFF          <1> 	jmp	sysret
 14129                              <1> 
 14130                              <1> mkdir:
 14131                              <1> 	; 04/12/2015 (14 byte directory names)
 14132                              <1> 	; 12/10/2015
 14133                              <1> 	; 17/06/2015 (Retro UNIX 386 v1 - Beginning)
 14134                              <1> 	; 29/04/2013 - 01/08/2013 (Retro UNIX 8086 v1)
 14135                              <1> 	;
 14136                              <1> 	; 'mkdir' makes a directory entry from the name pointed to
 14137                              <1> 	; by u.namep into the current directory.
 14138                              <1> 	;
 14139                              <1> 	; INPUTS ->
 14140                              <1> 	;    u.namep - points to a file name 
 14141                              <1> 	;	           that is about to be a directory entry.
 14142                              <1> 	;    ii - current directory's i-number.	
 14143                              <1> 	; OUTPUTS ->
 14144                              <1> 	;    u.dirbuf+2 - u.dirbuf+10 - contains file name. 
 14145                              <1> 	;    u.off - points to entry to be filled 
 14146                              <1> 	;	     in the current directory		
 14147                              <1> 	;    u.base - points to start of u.dirbuf.
 14148                              <1> 	;    r1 - contains i-number of current directory 
 14149                              <1> 	;	
 14150                              <1> 	; ((AX = R1)) output
 14151                              <1> 	;
 14152                              <1> 	;    (Retro UNIX Prototype : 11/11/2012, UNIXCOPY.ASM)
 14153                              <1>         ;    ((Modified registers: eAX, eDX, eBX, eCX, eSI, eDI, eBP))  
 14154                              <1> 	;
 14155                              <1> 
 14156                              <1> 	; 17/06/2015 - 32 bit modifications (Retro UNIX 386 v1)
 14157 00010DCC 31C0                <1> 	xor 	eax, eax
 14158 00010DCE BF[9A030300]        <1> 	mov     edi, u.dirbuf+2
 14159 00010DD3 89FE                <1> 	mov	esi, edi
 14160 00010DD5 AB                  <1> 	stosd
 14161 00010DD6 AB                  <1> 	stosd
 14162                              <1> 	; 04/12/2015 (14 byte directory names)
 14163 00010DD7 AB                  <1> 	stosd
 14164 00010DD8 66AB                <1> 	stosw
 14165                              <1> 		; jsr r0,copyz; u.dirbuf+2; u.dirbuf+10. / clear this
 14166 00010DDA 89F7                <1> 	mov	edi, esi ; offset to u.dirbuf
 14167                              <1> 	; 12/10/2015 ([u.namep] -> ebp)
 14168                              <1> 	;mov 	ebp, [u.namep]
 14169 00010DDC E80D030000          <1> 	call	trans_addr_nmbp ; convert virtual address to physical
 14170                              <1> 		; esi = physical address (page start + offset)
 14171                              <1> 		; ecx = byte count in the page (1 - 4096)
 14172                              <1> 	; edi = offset to u.dirbuf (edi is not modified in trans_addr_nm)
 14173                              <1> 		; mov u.namep,r2 / r2 points to name of directory entry
 14174                              <1> 		; mov $u.dirbuf+2,r3 / r3 points to u.dirbuf+2
 14175                              <1> mkdir_1: ; 1: 
 14176 00010DE1 45                  <1> 	inc	ebp ; 12/10/2015
 14177                              <1> 	;
 14178                              <1> 	; / put characters in the directory name in u.dirbuf+2 - u.dirbuf+10
 14179                              <1> 	 ; 01/08/2013
 14180 00010DE2 AC                  <1> 	lodsb
 14181                              <1> 		; movb (r2)+,r1 / move character in name to r1
 14182 00010DE3 20C0                <1> 	and 	al, al
 14183 00010DE5 7427                <1> 	jz 	short mkdir_3 	  
 14184                              <1> 		; beq 1f / if null, done
 14185 00010DE7 3C2F                <1> 	cmp	al, '/'
 14186                              <1> 		; cmp r1,$'/ / is it a "/"?
 14187 00010DE9 7414                <1> 	je	short mkdir_err
 14188                              <1> 	;je	error
 14189                              <1> 		; beq error9 / yes, error
 14190                              <1> 	; 12/10/2015
 14191 00010DEB 6649                <1> 	dec	cx
 14192 00010DED 7505                <1> 	jnz	short mkdir_2
 14193                              <1> 	; 12/10/2015 ([u.namep] -> ebp)
 14194 00010DEF E800030000          <1> 	call	trans_addr_nm ; convert virtual address to physical
 14195                              <1> 		; esi = physical address (page start + offset)
 14196                              <1> 		; ecx = byte count in the page
 14197                              <1> 	; edi = offset to u.dirbuf (edi is not modified in trans_addr_nm)
 14198                              <1> mkdir_2:
 14199 00010DF4 81FF[A8030300]      <1> 	cmp     edi, u.dirbuf+16 ; ; 04/12/2015 (10 -> 16) 
 14200                              <1> 		; cmp r3,$u.dirbuf+10. / have we reached the last slot for
 14201                              <1> 				     ; / a char?
 14202 00010DFA 74E5                <1> 	je	short mkdir_1
 14203                              <1> 		; beq 1b / yes, go back
 14204 00010DFC AA                  <1> 	stosb
 14205                              <1> 		; movb r1,(r3)+ / no, put the char in the u.dirbuf
 14206 00010DFD EBE2                <1> 	jmp 	short mkdir_1
 14207                              <1> 		; br 1b / get next char
 14208                              <1> mkdir_err:
 14209                              <1> 	; 17/06/2015
 14210 00010DFF C705[C8030300]1300- <1> 	mov	dword [u.error], ERR_NOT_DIR ; 'not a valid directory !'
 14210 00010E07 0000                <1>
 14211 00010E09 E9DECAFFFF          <1> 	jmp	error
 14212                              <1> 
 14213                              <1> mkdir_3: ; 1:
 14214 00010E0E A1[78030300]        <1> 	mov	eax, [u.dirp]
 14215 00010E13 A3[80030300]        <1> 	mov	[u.off], eax
 14216                              <1> 		; mov u.dirp,u.off / pointer to empty current directory
 14217                              <1> 				 ; / slot to u.off
 14218                              <1> wdir: ; 29/04/2013
 14219 00010E18 C705[84030300]-     <1>         mov     dword [u.base], u.dirbuf
 14219 00010E1E [98030300]          <1>
 14220                              <1> 		; mov $u.dirbuf,u.base / u.base points to created file name
 14221 00010E22 C705[88030300]1000- <1>         mov     dword [u.count], 16 ; 04/12/2015 (10 -> 16) 
 14221 00010E2A 0000                <1>
 14222                              <1> 		; mov $10.,u.count / u.count = 10
 14223 00010E2C 66A1[51040300]      <1> 	mov	ax, [ii] 
 14224                              <1> 		; mov ii,r1 / r1 has i-number of current directory
 14225 00010E32 B201                <1> 	mov	dl, 1 ; owner flag mask ; RETRO UNIX 8086 v1 modification !
 14226 00010E34 E8741D0000          <1> 	call 	access
 14227                              <1> 		; jsr r0,access; 1 / get i-node and set its file up 
 14228                              <1> 				 ; / for writing
 14229                              <1> 	; AX = i-number of current directory
 14230                              <1> 	; 01/08/2013
 14231 00010E39 FE05[C6030300]      <1> 	inc     byte [u.kcall] ; the caller is 'mkdir' sign	
 14232 00010E3F E8820F0000          <1> 	call	writei
 14233                              <1> 		; jsr r0,writei / write into directory
 14234 00010E44 C3                  <1> 	retn	
 14235                              <1> 		; rts r0
 14236                              <1> 
 14237                              <1> sysexec:
 14238                              <1> 	; 18/11/2017
 14239                              <1> 	; 14/11/2017
 14240                              <1> 	; 13/11/2017
 14241                              <1> 	; 24/10/2016, 04/01/2017
 14242                              <1> 	; 24/04/2016 - TRDOS 386 (TRDOS v2.0)
 14243                              <1> 	; 23/06/2015 - 23/10/2015 (Retro UNIX 386 v1)
 14244                              <1> 	; 03/06/2013 - 06/12/2013 (Retro UNIX 8086 v1)
 14245                              <1> 	;
 14246                              <1> 	; 'sysexec' initiates execution of a file whose path name if
 14247                              <1> 	; pointed to by 'name' in the sysexec call. 
 14248                              <1> 	; 'sysexec' performs the following operations:
 14249                              <1> 	;    1. obtains i-number of file to be executed via 'namei'.
 14250                              <1> 	;    2. obtains i-node of file to be exceuted via 'iget'.
 14251                              <1> 	;    3. sets trap vectors to system routines.
 14252                              <1> 	;    4. loads arguments to be passed to executing file into
 14253                              <1> 	;	highest locations of user's core
 14254                              <1> 	;    5. puts pointers to arguments in locations immediately
 14255                              <1> 	;	following arguments.
 14256                              <1> 	;    6.	saves number of arguments in next location.
 14257                              <1> 	;    7. intializes user's stack area so that all registers
 14258                              <1> 	;	will be zeroed and the PS is cleared and the PC set
 14259                              <1> 	;	to core when 'sysret' restores registers 
 14260                              <1> 	;	and does an rti.
 14261                              <1> 	;    8. inializes u.r0 and u.sp
 14262                              <1> 	;    9. zeros user's core down to u.r0
 14263                              <1> 	;   10.	reads executable file from storage device into core
 14264                              <1> 	;	starting at location 'core'.
 14265                              <1> 	;   11.	sets u.break to point to end of user's code with
 14266                              <1> 	;	data area appended.
 14267                              <1> 	;   12.	calls 'sysret' which returns control at location
 14268                              <1> 	;	'core' via 'rti' instruction. 		  		
 14269                              <1> 	;
 14270                              <1> 	; Calling sequence:
 14271                              <1> 	;	sysexec; namep; argp
 14272                              <1> 	; Arguments:
 14273                              <1> 	;	namep - points to pathname of file to be executed
 14274                              <1> 	;	argp  - address of table of argument pointers
 14275                              <1> 	;	argp1... argpn - table of argument pointers
 14276                              <1> 	;	argp1:<...0> ... argpn:<...0> - argument strings
 14277                              <1> 	; Inputs: (arguments)
 14278                              <1> 	; Outputs: -	
 14279                              <1> 	; ...............................................................
 14280                              <1> 	;
 14281                              <1> 	; Retro UNIX 386 v1 modification: 
 14282                              <1> 	;	User application runs in it's own virtual space 
 14283                              <1> 	;	which is izolated from kernel memory (and other
 14284                              <1> 	;	memory pages) via 80386	paging in ring 3 
 14285                              <1> 	;	privilige mode. Virtual start address is always 0.
 14286                              <1> 	;	User's core memory starts at linear address 400000h
 14287                              <1> 	;	(the end of the 1st 4MB).
 14288                              <1> 	;
 14289                              <1> 	; Retro UNIX 8086 v1 modification: 
 14290                              <1> 	;	user/application segment and system/kernel segment
 14291                              <1> 	;	are different and sysenter/sysret/sysrele routines
 14292                              <1> 	;	are different (user's registers are saved to 
 14293                              <1> 	;	and then restored from system's stack.)
 14294                              <1> 	;
 14295                              <1> 	;	NOTE: Retro UNIX 8086 v1 'arg2' routine gets these
 14296                              <1> 	;	      arguments which were in these registers;
 14297                              <1> 	;	      but, it returns by putting the 1st argument
 14298                              <1> 	;	      in 'u.namep' and the 2nd argument
 14299                              <1> 	;	      on top of stack. (1st argument is offset of the
 14300                              <1> 	;	      file/path name in the user's program segment.)		 	
 14301                              <1> 	
 14302                              <1> 	;call	arg2
 14303                              <1> 	; * name - 'u.namep' points to address of file/path name
 14304                              <1> 	;          in the user's program segment ('u.segmnt')
 14305                              <1> 	;          with offset in BX register (as sysopen argument 1).
 14306                              <1> 	; * argp - sysexec argument 2 is in CX register 
 14307                              <1> 	;          which is on top of stack.
 14308                              <1> 	;
 14309                              <1> 		; jsr r0,arg2 / arg0 in u.namep,arg1 on top of stack
 14310                              <1> 
 14311                              <1> 	; 23/06/2015 (32 bit modifications)
 14312                              <1> 
 14313                              <1> 	;; 13/11/2017
 14314                              <1> 	;;mov	[u.namep], ebx ; argument 1
 14315                              <1>         ; 18/10/2015
 14316 00010E45 890D[4C040300]      <1> 	mov     [argv], ecx  ; * ; argument 2
 14317                              <1> 
 14318                              <1> 	; 13/11/2017
 14319 00010E4B 89DE                <1> 	mov	esi, ebx
 14320 00010E4D E88E210000          <1> 	call	set_working_path_x
 14321 00010E52 7319                <1> 	jnc	short sysexec_0
 14322                              <1> 
 14323                              <1> 	;; 'bad command or file name'
 14324                              <1> 	;mov	eax, ERR_BAD_CMD_ARG ; 01h ; TRDOS 8086
 14325                              <1> 	
 14326                              <1> 	; 'file not found !' error
 14327 00010E54 B802000000          <1> 	mov	eax, ERR_NOT_FOUND ; 02h ; TRDOS 8086
 14328                              <1> sysexec_not_found_err:
 14329                              <1> sysexec_access_error:
 14330                              <1> sysexec_ext_error:
 14331 00010E59 A3[64030300]        <1> 	mov	[u.r0], eax
 14332 00010E5E A3[C8030300]        <1> 	mov	[u.error], eax
 14333 00010E63 E84D220000          <1> 	call 	reset_working_path
 14334 00010E68 E97FCAFFFF          <1> 	jmp	error
 14335                              <1> 
 14336                              <1> sysexec_0:
 14337                              <1> 	; 13/11/2017
 14338                              <1> 	;mov	esi, FindFile_Name
 14339 00010E6D 66B80018            <1>         mov	ax, 1800h ; Only files 
 14340 00010E71 E81B86FFFF          <1> 	call	find_first_file
 14341 00010E76 72E1                <1> 	jc	short sysexec_not_found_err ; eax = 2
 14342                              <1> 
 14343                              <1> 	; check_ file attributes
 14344                              <1> 	; (attribute bits = 00ADVSHR) ; 18h = Directory+Volume
 14345                              <1> 	; BL = Attributes byte
 14346                              <1> 	
 14347 00010E78 F6C306              <1>         test	bl, 6  ; system file or hidden file (S+H) 
 14348                              <1> 	;jz	short sysexec_0ext
 14349 00010E7B 7417                <1> 	jz	short sysexec_1 ; yes
 14350                              <1> 
 14351                              <1> 	; 13/11/2017 
 14352                              <1> 	; /// TRDOS386 permission check for multiuser mode ///
 14353                              <1> 	; SYSTEM file or HIDDEN file !!
 14354                              <1> 	; (Only super user has permission to run this file.)
 14355                              <1> 	
 14356                              <1> 	; ([u.uid]=0 for super user or root in multiuser mode)  
 14357                              <1> 	; ([u.uid]=0 for any users in singleuser mode) 
 14358 00010E7D 803D[B0030300]00    <1> 	cmp 	byte [u.uid], 0 ; Super User ([u.uid]=0) ?
 14359                              <1> 	;jna	short sysexec_0ext
 14360 00010E84 760E                <1> 	jna	short sysexec_1 ; yes 
 14361                              <1> 
 14362                              <1> 	; 'permission denied !' error  
 14363 00010E86 B80B000000          <1>         mov	eax, ERR_FILE_ACCESS  ; 11 = ERR_PERM_DENIED
 14364 00010E8B EBCC                <1>         jmp	short sysexec_access_error
 14365                              <1> 
 14366                              <1> sysexec_not_exf:
 14367                              <1> 	; 'not executable file !' error
 14368 00010E8D B816000000          <1> 	mov	eax, ERR_NOT_EXECUTABLE
 14369 00010E92 EBC5                <1> 	jmp	sysexec_ext_error
 14370                              <1> 
 14371                              <1> ;sysexec_0ext:
 14372                              <1> sysexec_1:
 14373                              <1> 	; 18/11/2017
 14374 00010E94 BE[D8930100]        <1> 	mov	esi, FindFile_Name
 14375                              <1> 	; 13/11/2017
 14376                              <1> 	; check program file name extension
 14377                              <1> 	; ('.PRG' for current TRDOS version)
 14378 00010E99 E896A0FFFF          <1> 	call	check_prg_filename_ext
 14379 00010E9E 72ED                <1> 	jc	short sysexec_not_exf
 14380                              <1> 	
 14381                              <1> 	; 18/11/2017
 14382 00010EA0 3C50                <1> 	cmp	al, 'P'
 14383 00010EA2 75E9                <1> 	jne	short sysexec_not_exf	
 14384                              <1> 
 14385                              <1> 	; '.PRG' extension is OK.
 14386                              <1> 	; Only '.PRG' files are valid program files
 14387                              <1> 	; for current TRDOS 386 version.
 14388                              <1> 
 14389 00010EA4 8B15[04940100]      <1> 	mov	edx, [FindFile_DirEntry+DirEntry_FileSize]
 14390 00010EAA 66A1[FC930100]      <1> 	mov	ax, [FindFile_DirEntry+DirEntry_FstClusHI]
 14391 00010EB0 C1E010              <1> 	shl	eax, 16
 14392 00010EB3 66A1[02940100]      <1> 	mov	ax, [FindFile_DirEntry+DirEntry_FstClusLO]
 14393                              <1> 	; EAX = First Cluster number
 14394                              <1> 	; EDX = File Size
 14395                              <1> 
 14396 00010EB9 A3[51040300]        <1> 	mov	[ii], eax
 14397 00010EBE 8915[55040300]      <1> 	mov	[i.size], edx
 14398                              <1> 
 14399                              <1> ;sysexec_1:
 14400                              <1> 	; 13/11/2017 - TRDOS 386 (TRDOS v2.0)
 14401                              <1> 	; 24/06/2015 - 23/10/2015 (Retro UNIX 386 v1)
 14402                              <1>         ; Moving arguments to the end of [u.upage]
 14403                              <1> 	; (by regarding page borders in user's memory space)
 14404                              <1> 	;
 14405                              <1> 	; 10/10/2015
 14406                              <1> 	; 21/07/2015
 14407 00010EC4 89E5                <1> 	mov	ebp, esp ; (**)
 14408                              <1> 	; 18/10/2015
 14409 00010EC6 89EF                <1> 	mov 	edi, ebp
 14410 00010EC8 B900010000          <1> 	mov 	ecx, MAX_ARG_LEN ; 256
 14411                              <1> 	;sub	edi, MAX_ARG_LEN ; 256
 14412 00010ECD 29CF                <1> 	sub	edi, ecx
 14413 00010ECF 89FC                <1> 	mov	esp, edi ; *!*
 14414 00010ED1 31C0                <1> 	xor	eax, eax
 14415 00010ED3 A3[8C030300]        <1> 	mov 	[u.nread], eax ; 0
 14416 00010ED8 66A3[4A040300]      <1> 	mov	[argc], ax ; 0 ; 13/11/2017
 14417 00010EDE 49                  <1> 	dec	ecx ; 256 - 1
 14418 00010EDF 890D[88030300]      <1> 	mov 	[u.count], ecx ; MAX_ARG_LEN - 1 ; 255
 14419                              <1> 	;mov 	dword [u.count], MAX_ARG_LEN - 1 ; 255
 14420                              <1> sysexec_2:
 14421 00010EE5 8B35[4C040300]      <1> 	mov	esi, [argv] ; 18/10/2015 
 14422 00010EEB E866000000          <1> 	call	get_argp
 14423 00010EF0 B904000000          <1> 	mov	ecx, 4 ; mov ecx, 4
 14424                              <1> sysexec_3:
 14425 00010EF5 21C0                <1> 	and	eax, eax
 14426 00010EF7 0F846F050000        <1>         jz      sysexec_6
 14427                              <1> 	; 18/10/2015
 14428 00010EFD 010D[4C040300]      <1> 	add	[argv], ecx ; 4
 14429 00010F03 66FF05[4A040300]    <1> 	inc	word [argc]
 14430                              <1> 	;
 14431 00010F0A A3[84030300]        <1> 	mov	[u.base], eax
 14432                              <1>  	; 23/10/2015
 14433 00010F0F 66C705[C4030300]00- <1> 	mov	word [u.pcount], 0
 14433 00010F17 00                  <1>
 14434                              <1> sysexec_4:
 14435 00010F18 E8E70B0000          <1> 	call	cpass ; get a character from user's core memory
 14436 00010F1D 750E                <1>         jnz	short sysexec_5
 14437                              <1> 		; (max. 255 chars + null)
 14438                              <1> 	; 18/10/2015
 14439 00010F1F 28C0                <1> 	sub 	al, al
 14440 00010F21 AA                  <1> 	stosb
 14441 00010F22 FF05[8C030300]      <1> 	inc	dword [u.nread]
 14442 00010F28 E93F050000          <1> 	jmp	sysexec_6 ; 24/04/2016
 14443                              <1> sysexec_5:
 14444 00010F2D AA                  <1> 	stosb
 14445 00010F2E 20C0                <1> 	and 	al, al
 14446 00010F30 75E6                <1> 	jnz	short sysexec_4
 14447 00010F32 B904000000          <1> 	mov	ecx, 4
 14448 00010F37 390D[48040300]      <1> 	cmp	[ncount], ecx ; 4
 14449 00010F3D 72A6                <1> 	jb	short sysexec_2
 14450 00010F3F 8B35[44040300]      <1> 	mov	esi, [nbase]
 14451 00010F45 010D[44040300]      <1> 	add	[nbase], ecx ; 4	
 14452 00010F4B 66290D[48040300]    <1> 	sub	[ncount], cx 
 14453 00010F52 8B06                <1> 	mov	eax, [esi]
 14454 00010F54 EB9F                <1> 	jmp	short sysexec_3
 14455                              <1> 
 14456                              <1> get_argp:
 14457                              <1> 	; 14/11/2017 - TRDOS 386 (TRDOS v2.0)
 14458                              <1> 	; 18/10/2015 (nbase, ncount)
 14459                              <1> 	; 21/07/2015
 14460                              <1> 	; 24/06/2015 (Retro UNIX 386 v1)
 14461                              <1> 	; Get (virtual) address of argument from user's core memory
 14462                              <1> 	;
 14463                              <1> 	; INPUT:
 14464                              <1> 	;	esi = virtual address of argument pointer
 14465                              <1> 	; OUTPUT:
 14466                              <1> 	;	eax = virtual address of argument
 14467                              <1> 	;
 14468                              <1> 	; Modified registers: EAX, EBX, ECX, EDX, ESI 
 14469                              <1> 	;
 14470 00010F56 833D[BC030300]00    <1>  	cmp     dword [u.ppgdir], 0 ; /etc/init ?
 14471                              <1> 				    ; (the caller is kernel)
 14472 00010F5D 7667                <1>         jna     short get_argpk 
 14473                              <1> 	;
 14474 00010F5F 89F3                <1>      	mov	ebx, esi
 14475 00010F61 E88A53FFFF          <1> 	call	get_physical_addr ; get physical address
 14476 00010F66 0F8289000000        <1>         jc      get_argp_err
 14477 00010F6C A3[44040300]        <1> 	mov 	[nbase], eax ; physical address	
 14478 00010F71 66890D[48040300]    <1> 	mov	[ncount], cx ; remain byte count in page (1-4096)
 14479 00010F78 B804000000          <1> 	mov	eax, 4 ; 21/07/2015
 14480 00010F7D 6639C1              <1> 	cmp	cx, ax ; 4
 14481 00010F80 735D                <1> 	jnb	short get_argp2
 14482 00010F82 89F3                <1> 	mov	ebx, esi
 14483 00010F84 01CB                <1> 	add	ebx, ecx
 14484 00010F86 E86553FFFF          <1> 	call	get_physical_addr ; get physical address
 14485 00010F8B 7268                <1> 	jc	short get_argp_err
 14486                              <1> 	;push	esi
 14487 00010F8D 89C6                <1> 	mov	esi, eax
 14488 00010F8F 66870D[48040300]    <1> 	xchg	cx, [ncount]
 14489 00010F96 8735[44040300]      <1> 	xchg	esi, [nbase]
 14490 00010F9C B504                <1> 	mov	ch, 4
 14491 00010F9E 28CD                <1> 	sub	ch, cl
 14492                              <1> get_argp0:
 14493 00010FA0 AC                  <1> 	lodsb
 14494 00010FA1 6650                <1> 	push	ax
 14495 00010FA3 FEC9                <1> 	dec	cl
 14496 00010FA5 75F9                <1>         jnz     short get_argp0
 14497 00010FA7 8B35[44040300]      <1> 	mov	esi, [nbase]
 14498                              <1> 	; 21/07/2015
 14499 00010FAD 0FB6C5              <1> 	movzx	eax, ch
 14500 00010FB0 0105[44040300]      <1> 	add	[nbase], eax
 14501 00010FB6 662905[48040300]    <1> 	sub	[ncount], ax
 14502                              <1> get_argp1:
 14503 00010FBD AC                  <1> 	lodsb
 14504 00010FBE FECD                <1> 	dec	ch
 14505 00010FC0 7447                <1>         jz      short get_argp3
 14506 00010FC2 6650                <1>         push	ax
 14507 00010FC4 EBF7                <1> 	jmp     short get_argp1
 14508                              <1> get_argpk:
 14509                              <1> 	; Argument is in kernel's memory space
 14510 00010FC6 66C705[48040300]00- <1> 	mov	word [ncount], PAGE_SIZE ; 4096
 14510 00010FCE 10                  <1>
 14511 00010FCF 8935[44040300]      <1> 	mov	[nbase], esi
 14512 00010FD5 8305[44040300]04    <1> 	add	dword [nbase], 4
 14513 00010FDC 8B06                <1> 	mov	eax, [esi] ; virtual addr. = physical addr.
 14514 00010FDE C3                  <1> 	retn
 14515                              <1> get_argp2:
 14516                              <1> 	; 21/07/2015
 14517                              <1> 	;mov	eax, 4
 14518 00010FDF 8B15[44040300]      <1> 	mov 	edx, [nbase] ; 18/10/2015
 14519 00010FE5 0105[44040300]      <1> 	add	[nbase], eax
 14520 00010FEB 662905[48040300]    <1> 	sub	[ncount], ax
 14521                              <1> 	;
 14522 00010FF2 8B02                <1> 	mov	eax, [edx]
 14523 00010FF4 C3                  <1> 	retn
 14524                              <1> get_argp_err:
 14525 00010FF5 A3[C8030300]        <1> 	mov	[u.error], eax
 14526                              <1> 	; 14/11/2017
 14527 00010FFA B801000000          <1> 	mov	eax, ERR_BAD_CMD_ARG ; 01h ; TRDOS 8086
 14528 00010FFF A3[64030300]        <1> 	mov	[u.r0], eax
 14529 00011004 E9E3C8FFFF          <1> 	jmp	error
 14530                              <1> get_argp3:
 14531 00011009 B103                <1> 	mov	cl, 3
 14532                              <1> get_argp4:
 14533 0001100B C1E008              <1> 	shl	eax, 8
 14534 0001100E 665A                <1> 	pop	dx
 14535 00011010 88D0                <1> 	mov 	al, dl
 14536 00011012 E2F7                <1>         loop    get_argp4
 14537                              <1> 	;pop	esi
 14538 00011014 C3                  <1> 	retn	
 14539                              <1> 
 14540                              <1> sysstat: 
 14541                              <1> 	; 13/01/2017 - TRDOS 386 (TRDOS v2.0)
 14542                              <1> 	; temporary !
 14543 00011015 B801000000          <1> 	mov	eax, ERR_INV_FNUMBER ; 'invalid function number !'
 14544 0001101A A3[C8030300]        <1>         mov     [u.error], eax
 14545 0001101F A3[64030300]        <1>         mov     [u.r0], eax 
 14546 00011024 E9C3C8FFFF          <1> 	jmp	error
 14547                              <1> 
 14548                              <1> sysfstat: 
 14549                              <1> 	; 13/01/2017 - TRDOS 386 (TRDOS v2.0)
 14550                              <1> 	; temporary !
 14551 00011029 B801000000          <1> 	mov	eax, ERR_INV_FNUMBER ; 'invalid function number !'
 14552 0001102E A3[C8030300]        <1>         mov     [u.error], eax
 14553 00011033 A3[64030300]        <1>         mov     [u.r0], eax 
 14554 00011038 E9AFC8FFFF          <1> 	jmp	error
 14555                              <1> 
 14556                              <1> fclose:
 14557                              <1> 	; 06/10/2016 (TRDOS 386 = TRDOS v2.0)
 14558                              <1> 	;
 14559                              <1> 	; 18/06/2015 (Retro UNIX 386 v1 - Beginning)
 14560                              <1> 	;            (32 bit offset pointer modification)
 14561                              <1> 	; 19/04/2013 - 12/01/2014 (Retro UNIX 8086 v1)
 14562                              <1> 	;
 14563                              <1> 	; Given the file descriptor (index to the u.fp list)
 14564                              <1> 	; 'fclose' first gets the i-number of the file via 'getf'.
 14565                              <1> 	; If i-node is active (i-number > 0) the entry in 
 14566                              <1> 	; u.fp list is cleared. If all the processes that opened
 14567                              <1> 	; that file close it, then fsp etry is freed and the file
 14568                              <1> 	; is closed. If not a return is taken. 
 14569                              <1> 	; If the file has been deleted while open, 'anyi' is called
 14570                              <1> 	; to see anyone else has it open, i.e., see if it is appears
 14571                              <1> 	; in another entry in the fsp table. Upon return from 'anyi'
 14572                              <1> 	; a check is made to see if the file is special.	
 14573                              <1> 	;
 14574                              <1> 	; INPUTS ->
 14575                              <1> 	;    r1 - contains the file descriptor (value=0,1,2...)
 14576                              <1> 	;    u.fp - list of entries in the fsp table
 14577                              <1> 	;    fsp - table of entries (4 words/entry) of open files.	 
 14578                              <1> 	; OUTPUTS ->
 14579                              <1> 	;    r1 - contains the same file descriptor
 14580                              <1> 	;    r2 - contains i-number
 14581                              <1> 	;
 14582                              <1> 	; ((AX = R1))
 14583                              <1> 	; ((Modified registers: eDX, eBX, eCX, eSI, eDI, eBP))
 14584                              <1> 	;
 14585                              <1> 	; Retro UNIX 8086 v1 modification : CF = 1
 14586                              <1> 	;              if i-number of the file is 0. (error)  	
 14587                              <1> 	;
 14588                              <1> 	; TRDOS 386 (06/10/2016)
 14589                              <1> 	; 
 14590                              <1> 	; INPUT:
 14591                              <1> 	;	EAX = File Handle (File Descriptor, File Index)
 14592                              <1> 	;
 14593                              <1> 	; OUTPUT:
 14594                              <1> 	;	CF = 1 -> File not open !
 14595                              <1> 	;	CF = 0 -> OK!
 14596                              <1> 	;	     EBX = File Number (System)
 14597                              <1> 	;	     [cdev] = Logical DOS Drive Number
 14598                              <1> 	;	     EAX = File Handle/Number (user) 	
 14599                              <1> 	;
 14600                              <1> 	; Modified Registers: EBX
 14601                              <1> 
 14602 0001103D 50                  <1> 	push	eax ; File handle
 14603                              <1> 	
 14604 0001103E E846000000          <1> 	call	getf
 14605 00011043 0F8245240000        <1> 	jc	device_close ; eax = device number
 14606                              <1> 
 14607 00011049 80BB[569A0100]01    <1> 	cmp	byte [ebx+OF_MODE], 1 ; open mode ; 0 = empty entry
 14608 00011050 722E                <1> 	jb	short fclose_1	      ; 1 = read, 2 = write
 14609                              <1> 	
 14610 00011052 83F801              <1> 	cmp	eax, 1 ; is the first cluster number > 0
 14611 00011055 7229                <1> 	jb	short fclose_1 ; no, this is empty entry
 14612                              <1> 
 14613                              <1> fclose_0:
 14614 00011057 FE8B[6A9A0100]      <1> 	dec	byte [ebx+OF_OPENCOUNT] ; decrement the number of processes 
 14615                              <1> 			                ; that have opened the file
 14616 0001105D 7921                <1> 	jns	short fclose_1 ; jump if not negative (jump if bit 7 is 0)	 
 14617                              <1> 			; if all processes haven't closed the file, return
 14618                              <1> 	;
 14619                              <1> 	; eax ; First cluster
 14620 0001105F 31C0                <1> 	xor	eax, eax ; 0
 14621 00011061 8883[569A0100]      <1> 	mov	[ebx+OF_MODE], al ; 0 = empty entry
 14622                              <1> 	;mov	[ebx+OF_STATUS], al ; 0 = empty entry
 14623 00011067 66C1E302            <1> 	shl	bx, 2 
 14624 0001106B 8983[249A0100]      <1> 	mov	[ebx+OF_FCLUSTER], eax ; 0
 14625 00011071 8983[3C9B0100]      <1> 	mov	[ebx+OF_CCLUSTER], eax ; 0
 14626                              <1> 	;mov	[ebx+OF_CCINDEX], eax ; 0
 14627 00011077 A3[74030300]        <1> 	mov	[u.fofp], eax ; 0
 14628 0001107C 66C1EB02            <1> 	shr	bx, 2
 14629                              <1> fclose_1: ; 1:
 14630 00011080 58                  <1> 	pop	eax ; File handle (File Descriptor, File Index)
 14631 00011081 C680[6A030300]00    <1> 	mov	byte [eax+u.fp], 0 ; clear that entry in the u.fp list
 14632 00011088 C3                  <1> 	retn
 14633                              <1> 
 14634                              <1> getf:
 14635                              <1> 	; 12/10/2016
 14636                              <1> 	; 11/10/2016
 14637                              <1> 	; 08/10/2016
 14638                              <1> 	; 06/10/2016 (TRDOS 386 = TRDOS v2.0)
 14639                              <1> 	; / get the device number and the i-number of an open file
 14640                              <1> 	; 13/05/2015
 14641                              <1> 	; 11/05/2015 (Retro UNIX 386 v1 - Beginning)
 14642                              <1> 	; 19/04/2013 - 18/11/2013 (Retro UNIX 8086 v1)
 14643                              <1> 	;
 14644 00011089 89C3                <1> 	mov	ebx, eax
 14645                              <1> getf1: 
 14646 0001108B 83FB0A              <1> 	cmp	ebx, 10
 14647 0001108E 730A                <1>         jnb	short getf2
 14648 00011090 8A9B[6A030300]      <1> 	mov	bl, [ebx+u.fp]
 14649 00011096 08DB                <1> 	or	bl, bl
 14650 00011098 7503                <1> 	jnz	short getf3
 14651                              <1> getf2:
 14652                              <1> 	; 'File not open !' error (ax=0)
 14653 0001109A 29C0                <1> 	sub	eax, eax
 14654 0001109C C3                  <1> 	retn
 14655                              <1> getf3:	
 14656 0001109D F6C380              <1> 	test	bl, 80h
 14657 000110A0 7530                <1> 	jnz	short getf5 ; device
 14658 000110A2 FECB                <1> 	dec	bl ; 0 based
 14659 000110A4 8A83[4C9A0100]      <1> 	mov	al, [ebx+OF_DRIVE]
 14660 000110AA A2[46030300]        <1> 	mov	[cdev], al
 14661 000110AF C0E302              <1> 	shl	bl, 2 ; *4 (dword offset)
 14662 000110B2 8B83[9C9A0100]      <1> 	mov	eax, [ebx+OF_SIZE]
 14663 000110B8 A3[55040300]        <1> 	mov	[i.size], eax ; file size
 14664 000110BD 8D83[749A0100]      <1> 	lea	eax, [ebx+OF_POINTER] ;12/10/2016
 14665 000110C3 A3[74030300]        <1> 	mov	[u.fofp], eax
 14666 000110C8 8B83[249A0100]      <1> 	mov	eax, [ebx+OF_FCLUSTER]
 14667 000110CE C0EB02              <1> 	shr	bl, 2 ; /4 (byte offset) 
 14668                              <1> getf4:
 14669 000110D1 C3                  <1> 	retn
 14670                              <1> getf5: 
 14671                              <1> 	; get device number
 14672 000110D2 80E37F              <1> 	and	bl, 7Fh ; 1 to 7Fh
 14673 000110D5 FECB                <1> 	dec	bl ; 0 based (0 to 7Eh)
 14674 000110D7 8A83[7E980100]      <1> 	mov	al, [ebx+DEV_DRIVER]
 14675 000110DD 8AAB[E8970100]      <1> 	mov	ch, [ebx+DEV_ACCESS]
 14676 000110E3 8A8B[9C980100]      <1> 	mov	cl, [ebx+DEV_OPENMODE]
 14677 000110E9 80E5FE              <1> 	and	ch, 0FEh ; reset bit 0 ; dev_close
 14678 000110EC F9                  <1> 	stc ; cf = 1 
 14679 000110ED C3                  <1> 	retn	
 14680                              <1> 
 14681                              <1> trans_addr_nmbp:
 14682                              <1> 	; 18/10/2015
 14683                              <1> 	; 12/10/2015
 14684 000110EE 8B2D[7C030300]      <1> 	mov 	ebp, [u.namep]
 14685                              <1> trans_addr_nm: 
 14686                              <1> 	; Convert virtual (pathname) address to physical address
 14687                              <1> 	; (Retro UNIX 386 v1 feature only !)
 14688                              <1> 	; 18/10/2015
 14689                              <1> 	; 12/10/2015 (u.pnbase & u.pncount has been removed from code)
 14690                              <1> 	; 02/07/2015
 14691                              <1> 	; 17/06/2015
 14692                              <1> 	; 16/06/2015
 14693                              <1> 	;
 14694                              <1> 	; INPUTS: 
 14695                              <1> 	;	ebp = pathname address (virtual) ; [u.namep]
 14696                              <1> 	;	[u.pgdir] = user's page directory
 14697                              <1> 	; OUTPUT:
 14698                              <1> 	;       esi = physical address of the pathname
 14699                              <1> 	;	ecx = remain byte count in the page
 14700                              <1> 	;
 14701                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX, ESI)
 14702                              <1> 	;
 14703 000110F4 833D[BC030300]00    <1>         cmp     dword [u.ppgdir], 0  ; /etc/init ? (sysexec)
 14704 000110FB 7618                <1> 	jna	short trans_addr_nmk ; the caller is os kernel;
 14705                              <1> 				     ; it is already physical address
 14706 000110FD 50                  <1>    	push	eax	
 14707 000110FE 89EB                <1> 	mov	ebx, ebp ; [u.namep] ; pathname address (virtual)
 14708 00011100 E8EB51FFFF          <1>        	call	get_physical_addr ; get physical address
 14709 00011105 7204                <1> 	jc	short tr_addr_nm_err
 14710                              <1> 	; 18/10/2015
 14711                              <1> 	; eax = physical address 
 14712                              <1> 	; cx = remain byte count in page (1-4096) 
 14713                              <1> 		; 12/10/2015 (cx = [u.pncount])
 14714 00011107 89C6                <1> 	mov	esi, eax ; 12/10/2015 (esi=[u.pnbase])
 14715 00011109 58                  <1> 	pop	eax 
 14716 0001110A C3                  <1> 	retn
 14717                              <1> 
 14718                              <1> tr_addr_nm_err:
 14719 0001110B A3[C8030300]        <1> 	mov	[u.error], eax
 14720                              <1> 	;pop 	eax
 14721 00011110 E9D7C7FFFF          <1> 	jmp	error
 14722                              <1> 
 14723                              <1> trans_addr_nmk:
 14724                              <1> 	; 12/10/2015
 14725                              <1> 	; 02/07/2015
 14726 00011115 8B35[7C030300]      <1> 	mov	esi, [u.namep]  ; [u.pnbase]
 14727 0001111B 66B90010            <1> 	mov	cx, PAGE_SIZE ; 4096 ; [u.pncount]
 14728 0001111F C3                  <1> 	retn
 14729                              <1> 
 14730                              <1> sysbreak:
 14731                              <1> 	; 18/10/2015
 14732                              <1> 	; 07/10/2015
 14733                              <1> 	; 23/06/2015 (Retro UNIX 386 v1 - Beginning)
 14734                              <1> 	; 20/06/2013 - 24/03/2014 (Retro UNIX 8086 v1)
 14735                              <1> 	;
 14736                              <1> 	; 'sysbreak' sets the programs break points. 
 14737                              <1> 	; It checks the current break point (u.break) to see if it is
 14738                              <1> 	; between "core" and the stack (sp). If it is, it is made an
 14739                              <1> 	; even address (if it was odd) and the area between u.break
 14740                              <1> 	; and the stack is cleared. The new breakpoint is then put
 14741                              <1> 	; in u.break and control is passed to 'sysret'.
 14742                              <1> 	;
 14743                              <1> 	; Calling sequence:
 14744                              <1> 	;	sysbreak; addr
 14745                              <1> 	; Arguments: -
 14746                              <1> 	;	
 14747                              <1> 	; Inputs: u.break - current breakpoint
 14748                              <1> 	; Outputs: u.break - new breakpoint 
 14749                              <1> 	;	area between old u.break and the stack (sp) is cleared.
 14750                              <1> 	; ...............................................................
 14751                              <1> 	;	
 14752                              <1> 	; Retro UNIX 8086 v1 modification:
 14753                              <1> 	;	The user/application program puts breakpoint address
 14754                              <1> 	;       in BX register as 'sysbreak' system call argument.
 14755                              <1> 	; 	(argument transfer method 1)
 14756                              <1> 	;
 14757                              <1> 	;  NOTE: Beginning of core is 0 in Retro UNIX 8086 v1 !
 14758                              <1> 	; 	((!'sysbreak' is not needed in Retro UNIX 8086 v1!))
 14759                              <1> 	;  NOTE:
 14760                              <1> 	; 	'sysbreak' clears extended part (beyond of previous
 14761                              <1> 	;	'u.break' address) of user's memory for original unix's
 14762                              <1> 	;	'bss' compatibility with Retro UNIX 8086 v1 (19/11/2013)
 14763                              <1> 
 14764                              <1> 		; mov u.break,r1 / move users break point to r1
 14765                              <1> 		; cmp r1,$core / is it the same or lower than core?
 14766                              <1> 		; blos 1f / yes, 1f
 14767                              <1> 	; 23/06/2015
 14768 00011120 8B2D[90030300]      <1> 	mov	ebp, [u.break] ; virtual address (offset)
 14769                              <1> 	;and	ebp, ebp
 14770                              <1> 	;jz	short sysbreak_3 
 14771                              <1> 	; Retro UNIX 386 v1 NOTE: u.break points to virtual address !!!
 14772                              <1> 	; (Even break point address is not needed for Retro UNIX 386 v1)
 14773 00011126 8B15[5C030300]      <1> 	mov	edx, [u.sp] ; kernel stack at the beginning of sys call
 14774 0001112C 83C20C              <1> 	add	edx, 12 ; EIP -4-> CS -4-> EFLAGS -4-> ESP (user) 
 14775                              <1> 	; 07/10/2015
 14776 0001112F 891D[90030300]      <1> 	mov	[u.break], ebx ; virtual address !!!
 14777                              <1> 	;
 14778 00011135 3B1A                <1> 	cmp	ebx, [edx] ; compare new break point with 
 14779                              <1> 			   ; with top of user's stack (virtual!)
 14780 00011137 7323                <1> 	jnb	short sysbreak_3
 14781                              <1> 		; cmp r1,sp / is it the same or higher 
 14782                              <1> 			  ; / than the stack?
 14783                              <1> 		; bhis 1f / yes, 1f
 14784 00011139 89DE                <1> 	mov	esi, ebx
 14785 0001113B 29EE                <1> 	sub	esi, ebp ; new break point - old break point
 14786 0001113D 761D                <1> 	jna	short sysbreak_3 
 14787                              <1> 	;push	ebx
 14788                              <1> sysbreak_1:
 14789 0001113F 89EB                <1> 	mov	ebx, ebp  
 14790 00011141 E8AA51FFFF          <1> 	call	get_physical_addr ; get physical address
 14791 00011146 72C3                <1> 	jc	tr_addr_nm_err
 14792                              <1> 	; 18/10/2015
 14793 00011148 89C7                <1> 	mov	edi, eax 
 14794 0001114A 29C0                <1> 	sub	eax, eax ; 0
 14795                              <1> 		 ; ECX = remain byte count in page (1-4096)
 14796 0001114C 39CE                <1> 	cmp	esi, ecx
 14797 0001114E 7302                <1> 	jnb	short sysbreak_2
 14798 00011150 89F1                <1> 	mov	ecx, esi
 14799                              <1> sysbreak_2:
 14800 00011152 29CE                <1> 	sub	esi, ecx
 14801 00011154 01CD                <1> 	add	ebp, ecx
 14802 00011156 F3AA                <1> 	rep 	stosb
 14803 00011158 09F6                <1> 	or	esi, esi
 14804 0001115A 75E3                <1> 	jnz	short sysbreak_1
 14805                              <1> 	;
 14806                              <1> 		; bit $1,r1 / is it an odd address
 14807                              <1> 		; beq 2f / no, its even
 14808                              <1> 		; clrb (r1)+ / yes, make it even
 14809                              <1> 	; 2: / clear area between the break point and the stack
 14810                              <1> 		; cmp r1,sp / is it higher or same than the stack
 14811                              <1> 		; bhis 1f / yes, quit
 14812                              <1> 		; clr (r1)+ / clear word
 14813                              <1> 		; br 2b / go back
 14814                              <1> 	;pop	ebx
 14815                              <1> sysbreak_3: ; 1:
 14816                              <1> 	;mov	[u.break], ebx ; virtual address !!!
 14817                              <1> 		; jsr r0,arg; u.break / put the "address" 
 14818                              <1> 			; / in u.break (set new break point)
 14819                              <1> 		; br sysret4 / br sysret
 14820 0001115C E9ABC7FFFF          <1> 	jmp	sysret
 14821                              <1> 
 14822                              <1> sysseek: ; / moves read write pointer in an fsp entry
 14823                              <1> 	; 06/11/2016 - TRDOS 386 (TRDOS v2.0)
 14824                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 14825                              <1> 	; 07/07/2013 - 05/08/2013 (Retro UNIX 8086 v1)
 14826                              <1> 	;
 14827                              <1> 	; 'sysseek' changes the r/w pointer of (3rd word of in an
 14828                              <1> 	; fsp entry) of an open file whose file descriptor is in u.r0.
 14829                              <1> 	; The file descriptor refers to a file open for reading or
 14830                              <1> 	; writing. The read (or write) pointer is set as follows:
 14831                              <1> 	;	* if 'ptrname' is 0, the pointer is set to offset.
 14832                              <1> 	;	* if 'ptrname' is 1, the pointer is set to its
 14833                              <1> 	;	  current location plus offset.
 14834                              <1> 	;	* if 'ptrname' is 2, the pointer is set to the
 14835                              <1> 	;	  size of file plus offset.
 14836                              <1> 	; The error bit (e-bit) is set for an undefined descriptor.
 14837                              <1> 	;
 14838                              <1> 	; Calling sequence:
 14839                              <1> 	;	sysseek; offset; ptrname
 14840                              <1> 	; Arguments:
 14841                              <1> 	;	offset - number of bytes desired to move 
 14842                              <1> 	;		 the r/w pointer
 14843                              <1> 	;	ptrname - a switch indicated above
 14844                              <1> 	;
 14845                              <1> 	; Inputs: r0 - file descriptor 
 14846                              <1> 	; Outputs: -
 14847                              <1> 	; ...............................................................
 14848                              <1> 	;	
 14849                              <1> 	; Retro UNIX 8086 v1 modification: 
 14850                              <1> 	;       'sysseek' system call has three arguments; so,
 14851                              <1> 	;	* 1st argument, file descriptor is in BX (BL) register
 14852                              <1> 	;	* 2nd argument, offset is in CX register
 14853                              <1> 	;	* 3rd argument, ptrname/switch is in DX (DL) register	
 14854                              <1> 
 14855 00011161 E821000000          <1> 	call	seektell
 14856                              <1> 	; EAX = Current R/W pointer of the file
 14857                              <1> 	; EBX = [u.fofp]
 14858                              <1> 	; [u.base] = offset (ECX input)
 14859                              <1> 
 14860 00011166 0305[84030300]      <1> 	add	eax, [u.base]
 14861 0001116C 8903                <1> 	mov	[ebx], eax
 14862 0001116E E999C7FFFF          <1> 	jmp	sysret
 14863                              <1> 
 14864                              <1> systell: ; / get the r/w pointer
 14865                              <1> 	; 06/11/2016 - TRDOS 386 (TRDOS v2.0) - temporary !-
 14866                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 14867                              <1> 	; 07/07/2013 - 05/08/2013 (Retro UNIX 8086 v1)
 14868                              <1> 	;
 14869                              <1> 	; Retro UNIX 8086 v1 modification:
 14870                              <1> 	; ! 'systell' does not work in original UNIX v1,
 14871                              <1> 	; 	    it returns with error !
 14872                              <1> 	; Inputs: r0 - file descriptor 
 14873                              <1> 	; Outputs: r0 - file r/w pointer
 14874                              <1> 
 14875                              <1> 	;xor	ecx, ecx ; 0
 14876 00011173 BA01000000          <1> 	mov	edx, 1 ; 05/08/2013
 14877                              <1> 	;call 	seektell
 14878 00011178 E810000000          <1> 	call 	seektell0 ; 05/08/2013
 14879                              <1> 	;; 06/11/2016
 14880                              <1> 	;; mov	eax, [ebx]
 14881 0001117D A3[64030300]        <1> 	mov	[u.r0], eax
 14882 00011182 E985C7FFFF          <1> 	jmp	sysret
 14883                              <1> 
 14884                              <1> ; Original unix v1 'systell' system call:
 14885                              <1> 		; jsr r0,seektell
 14886                              <1> 		; br error4
 14887                              <1> 
 14888                              <1> seektell:
 14889                              <1> 	; 06/11/2016 - TRDOS 386 (TRDOS v2.0)
 14890                              <1> 	; 03/01/2016
 14891                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 14892                              <1> 	; 07/07/2013 - 05/08/2013 (Retro UNIX 8086 v1)
 14893                              <1> 	;
 14894                              <1> 	; 'seektell' puts the arguments from sysseek and systell
 14895                              <1> 	; call in u.base and u.count. It then gets the i-number of
 14896                              <1> 	; the file from the file descriptor in u.r0 and by calling
 14897                              <1> 	; getf. The i-node is brought into core and then u.count
 14898                              <1> 	; is checked to see it is a 0, 1, or 2.
 14899                              <1> 	; If it is 0 - u.count stays the same
 14900                              <1> 	;          1 - u.count = offset (u.fofp)
 14901                              <1> 	;	   2 - u.count = i.size (size of file)
 14902                              <1> 	; 	 		
 14903                              <1> 	; !! Retro UNIX 8086 v1 modification:
 14904                              <1> 	;	Argument 1, file descriptor is in BX;
 14905                              <1> 	;	Argument 2, offset is in CX;
 14906                              <1> 	;	Argument 3, ptrname/switch is in DX register.	
 14907                              <1> 	;
 14908                              <1> 	; ((Return -> eax = base for offset (position= base+offset))
 14909                              <1> 	;
 14910 00011187 890D[84030300]      <1> 	mov 	[u.base], ecx ; offset
 14911                              <1> seektell0:
 14912 0001118D 8915[88030300]      <1> 	mov 	[u.count], edx
 14913                              <1> 	; EBX = file descriptor (file number)
 14914 00011193 E8F3FEFFFF          <1> 	call	getf1
 14915                              <1> 	; EAX = First cluster of the file
 14916                              <1> 	; EBX = File number (Open file number)
 14917                              <1> 	; [u.fofp] = Pointer to File pointer
 14918                              <1> 	; [i.size] = File size
 14919                              <1> 
 14920 00011198 09C0                <1> 	or	eax, eax
 14921 0001119A 7514                <1> 	jnz	short seektell1
 14922                              <1> 
 14923 0001119C B80A000000          <1> 	mov	eax, ERR_FILE_NOT_OPEN
 14924 000111A1 A3[64030300]        <1> 	mov	[u.r0], eax 
 14925 000111A6 A3[C8030300]        <1> 	mov	dword [u.error], eax ; 'file not open !'
 14926 000111AB E93CC7FFFF          <1> 	jmp	error
 14927                              <1> 
 14928                              <1> seektell1:
 14929 000111B0 8B1D[74030300]      <1>         mov     ebx, [u.fofp]
 14930 000111B6 803D[88030300]01    <1> 	cmp	byte [u.count], 1
 14931 000111BD 7705                <1> 	ja	short seektell2
 14932 000111BF 7409                <1> 	je	short seektell3
 14933 000111C1 31C0                <1> 	xor	eax, eax
 14934 000111C3 C3                  <1> 	retn
 14935                              <1> 
 14936                              <1> seektell2:
 14937 000111C4 A1[55040300]        <1>         mov   	eax, [i.size]
 14938 000111C9 C3                  <1> 	retn
 14939                              <1> 
 14940                              <1> seektell3:
 14941 000111CA 8B03                <1> 	mov	eax, [ebx]
 14942 000111CC C3                  <1> 	retn
 14943                              <1> 
 14944                              <1> sysintr: ; / set interrupt handling
 14945                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 14946                              <1> 	; 07/07/2013 (Retro UNIX 8086 v1)
 14947                              <1> 	;
 14948                              <1> 	; 'sysintr' sets the interrupt handling value. It puts
 14949                              <1> 	; argument of its call in u.intr then branches into 'sysquit'
 14950                              <1> 	; routine. u.tty is checked if to see if a control tty exists.
 14951                              <1> 	; If one does the interrupt character in the tty buffer is
 14952                              <1> 	; cleared and 'sysret'is called. If one does not exits
 14953                              <1> 	; 'sysret' is just called.	
 14954                              <1> 	;
 14955                              <1> 	; Calling sequence:
 14956                              <1> 	;	sysintr; arg
 14957                              <1> 	; Argument:
 14958                              <1> 	;	arg - if 0, interrupts (ASCII DELETE) are ignored.
 14959                              <1> 	;	    - if 1, intterupts cause their normal result
 14960                              <1> 	;		 i.e force an exit.
 14961                              <1> 	;	    - if arg is a location within the program,
 14962                              <1> 	;		control is passed to that location when
 14963                              <1> 	;		an interrupt occurs.	
 14964                              <1> 	; Inputs: -
 14965                              <1> 	; Outputs: -
 14966                              <1> 	; ...............................................................
 14967                              <1> 	;	
 14968                              <1> 	; Retro UNIX 8086 v1 modification: 
 14969                              <1> 	;       'sysintr' system call sets u.intr to value of BX
 14970                              <1> 	;	then branches into sysquit.
 14971                              <1> 	;
 14972 000111CD 66891D[AA030300]    <1> 	mov	[u.intr], bx
 14973                              <1> 		; jsr r0,arg; u.intr / put the argument in u.intr
 14974                              <1> 		; br 1f / go into quit routine
 14975 000111D4 E933C7FFFF          <1> 	jmp	sysret
 14976                              <1> 
 14977                              <1> sysquit:
 14978                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 14979                              <1> 	; 07/07/2013 (Retro UNIX 8086 v1)
 14980                              <1> 	;
 14981                              <1> 	; 'sysquit' turns off the quit signal. it puts the argument of
 14982                              <1> 	; the call in u.quit. u.tty is checked if to see if a control 
 14983                              <1> 	; tty exists. If one does the interrupt character in the tty
 14984                              <1> 	; buffer is cleared and 'sysret'is called. If one does not exits
 14985                              <1> 	; 'sysret' is just called.	
 14986                              <1> 	;
 14987                              <1> 	; Calling sequence:
 14988                              <1> 	;	sysquit; arg
 14989                              <1> 	; Argument:
 14990                              <1> 	;	arg - if 0, this call diables quit signals from the
 14991                              <1> 	;		typewriter (ASCII FS)
 14992                              <1> 	;	    - if 1, quits are re-enabled and cause execution to
 14993                              <1> 	;		cease and a core image to be produced.
 14994                              <1> 	;		 i.e force an exit.
 14995                              <1> 	;	    - if arg is an addres in the program,
 14996                              <1> 	;		a quit causes control to sent to that
 14997                              <1> 	;		location.	
 14998                              <1> 	; Inputs: -
 14999                              <1> 	; Outputs: -
 15000                              <1> 	; ...............................................................
 15001                              <1> 	;	
 15002                              <1> 	; Retro UNIX 8086 v1 modification: 
 15003                              <1> 	;       'sysquit' system call sets u.quit to value of BX
 15004                              <1> 	;	then branches into 'sysret'.
 15005                              <1> 	;
 15006 000111D9 66891D[AC030300]    <1> 	mov	[u.quit], bx
 15007 000111E0 E927C7FFFF          <1> 	jmp	sysret
 15008                              <1> 		; jsr r0,arg; u.quit / put argument in u.quit
 15009                              <1> 	;1:
 15010                              <1> 		; mov u.ttyp,r1 / move pointer to control tty buffer
 15011                              <1> 			      ; / to r1
 15012                              <1> 		; beq sysret4 / return to user
 15013                              <1> 		; clrb 6(r1) / clear the interrupt character 
 15014                              <1> 			   ; / in the tty buffer
 15015                              <1> 		; br sysret4 / return to user
 15016                              <1> 
 15017                              <1> anyi: 
 15018                              <1> 	; 06/10/2016 (TRDOS 386 = TRDOS v2.0)
 15019                              <1> 	; Major Modification!
 15020                              <1> 	; TRDOS 386 does not permit to delete a file while it is open 
 15021                              <1> 	; The role of 'anyi' procedure has beeen changed to ensure that.
 15022                              <1> 	; 	
 15023                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 15024                              <1> 	; 25/04/2013 (Retro UNIX 8086 v1)
 15025                              <1> 	;
 15026                              <1> 	; 'anyi' is called if a file deleted while open.
 15027                              <1> 	; "anyi" checks to see if someone else has opened this file.
 15028                              <1> 	;
 15029                              <1> 	; INPUTS ->
 15030                              <1> 	;    r1 - contains an i-number
 15031                              <1> 	;    fsp - start of table containing open files
 15032                              <1> 	;
 15033                              <1> 	; OUTPUTS ->
 15034                              <1> 	;    "deleted" flag set in fsp entry of another occurrence of
 15035                              <1> 	;	   this file and r2 points 1st word of this fsp entry.
 15036                              <1> 	;    if file not found - bit in i-node map is cleared
 15037                              <1> 	;    			 (i-node is freed)
 15038                              <1> 	;               all blocks related to i-node are freed
 15039                              <1> 	;	        all flags in i-node are cleared
 15040                              <1> 	; ((AX = R1)) input
 15041                              <1> 	;
 15042                              <1> 	;    (Retro UNIX Prototype : 02/12/2012, UNIXCOPY.ASM)
 15043                              <1>         ;    ((Modified registers: eDX, eCX, eBX, eSI, eDI, eBP))  
 15044                              <1> 	;
 15045                              <1> 	; / r1 contains an i-number
 15046                              <1> 
 15047                              <1> 	; TRDOS 386 (06/10/2016)
 15048                              <1> 	; 
 15049                              <1> 	; INPUT:
 15050                              <1> 	;	EAX = First Cluster
 15051                              <1> 	;	 DL = Logical DOS Drive Number
 15052                              <1> 	;
 15053                              <1> 	; OUTPUT:
 15054                              <1> 	;	CF = 1 -> EBX = File Handle/Number/Index
 15055                              <1> 	;	CF = 0 -> EBX = 0
 15056                              <1> 	;
 15057                              <1> 	; Modified Registers: EBX
 15058                              <1> 
 15059 000111E5 31DB                <1> 	xor	ebx, ebx
 15060                              <1> anyi_0: 
 15061 000111E7 80BB[569A0100]00    <1> 	cmp	byte [ebx+OF_MODE], 0 ; 0 = empty entry
 15062 000111EE 770A                <1> 	ja	short anyi_2 ; 1 (r), 2 (w) or 3 (r&w)
 15063                              <1> anyi_1:
 15064 000111F0 FEC3                <1> 	inc	bl
 15065 000111F2 80FB0A              <1> 	cmp	bl, OPENFILES ; max. count of open files
 15066 000111F5 72F0                <1> 	jb	short anyi_0
 15067 000111F7 31C0                <1> 	xor	eax, eax
 15068 000111F9 C3                  <1> 	retn 
 15069                              <1> anyi_2:
 15070 000111FA 3A93[4C9A0100]      <1> 	cmp	dl, [ebx+OF_DRIVE]
 15071 00011200 75EE                <1> 	jne	short anyi_1
 15072 00011202 66C1E302            <1> 	shl	bx, 2 ; *4 (dword offset)
 15073 00011206 3B83[249A0100]      <1> 	cmp	eax, [ebx+OF_FCLUSTER]
 15074 0001120C 7406                <1> 	je	short anyi_3
 15075 0001120E 66C1EB02            <1> 	shr	bx, 2 ; /4 (byte offset)
 15076 00011212 EBDC                <1> 	jmp	short anyi_1 	
 15077                              <1> anyi_3:
 15078 00011214 66C1EB02            <1> 	shr	bx, 2 ; /4 (bytes offset) (index)
 15079 00011218 F9                  <1> 	stc
 15080 00011219 C3                  <1> 	retn
 15081                              <1> 
 15082                              <1> ; Retro UNIX 386 v1 Kernel (v0.2) - SYS9.INC
 15083                              <1> ; Last Modification: 09/12/2015
 15084                              <1> 
 15085                              <1> syssleep:
 15086                              <1> 	; 29/06/2015 - (Retro UNIX 386 v1)
 15087                              <1> 	; 11/06/2014 - (Retro UNIX 8086 v1)
 15088                              <1> 	;
 15089                              <1> 	; Retro UNIX 8086 v1 feature only
 15090                              <1> 	; (INPUT -> none)
 15091                              <1> 	;
 15092 0001121A 0FB61D[B3030300]    <1> 	movzx	ebx, byte [u.uno] ; process number
 15093 00011221 8AA3[7F000300]      <1> 	mov	ah, [ebx+p.ttyc-1] ; current/console tty
 15094 00011227 E881190000          <1> 	call	sleep
 15095 0001122C E9DBC6FFFF          <1> 	jmp	sysret
 15096                              <1> 
 15097                              <1> _vp_clr:
 15098                              <1> 	; Reset/Clear Video Page
 15099                              <1> 	;
 15100                              <1> 	; 30/06/2015 - (Retro UNIX 386 v1)
 15101                              <1> 	; 21/05/2013 - 30/10/2013(Retro UNIX 8086 v1) (U0.ASM)
 15102                              <1> 	;
 15103                              <1> 	; Retro UNIX 8086 v1 feature only !
 15104                              <1> 	;
 15105                              <1> 	; INPUTS -> 
 15106                              <1> 	;   BH = video page number	 
 15107                              <1> 	;
 15108                              <1> 	; OUTPUT ->
 15109                              <1> 	;   none
 15110                              <1> 	; ((Modified registers: eAX, BH, eCX, eDX, eSI, eDI))
 15111                              <1> 	;
 15112                              <1> 	; 04/12/2013
 15113 00011231 28C0                <1> 	sub	al, al
 15114                              <1> 	; al = 0 (clear video page)
 15115                              <1> 	; bh = video page ; 13/05/2016
 15116 00011233 B407                <1> 	mov	ah, 07h
 15117                              <1> 	; ah = 7 (attribute/color)
 15118 00011235 6631C9              <1> 	xor 	cx, cx ; 0, left upper column (cl) & row (cl)
 15119 00011238 66BA4F18            <1> 	mov	dx, 184Fh ; right lower column & row (dl=24, dh=79)
 15120 0001123C E8040EFFFF          <1> 	call	_scroll_up
 15121                              <1> 	; bh = video page
 15122 00011241 6631D2              <1> 	xor	dx, dx ; 0 (cursor position) 
 15123 00011244 E95611FFFF          <1> 	jmp 	_set_cpos
 15124                              <1> 
 15125                              <1> sysmsg:
 15126                              <1> 	; 07/12/2020
 15127                              <1> 	; 05/12/2020
 15128                              <1> 	; 13/05/2016
 15129                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 15130                              <1> 	; 01/07/2015 - 11/11/2015 (Retro UNIX 386 v1)
 15131                              <1> 	; Print user-application message on user's console tty
 15132                              <1> 	;
 15133                              <1> 	; Input -> EBX = Message address
 15134                              <1> 	;	   ECX = Message length (max. 255)
 15135                              <1> 	;	   DL = Color (IBM PC Rombios color attributes)
 15136                              <1> 	;
 15137 00011249 81F9FF000000        <1> 	cmp	ecx, MAX_MSG_LEN ; 255
 15138 0001124F 0F87B7C6FFFF        <1> 	ja	sysret ; nothing to do with big message size
 15139 00011255 08C9                <1> 	or	cl, cl
 15140 00011257 0F84AFC6FFFF        <1> 	jz	sysret
 15141 0001125D 20D2                <1> 	and	dl, dl
 15142 0001125F 7502                <1> 	jnz	short sysmsg0
 15143 00011261 B207                <1> 	mov	dl, 07h ; default color
 15144                              <1> 		; (black background, light gray character) 
 15145                              <1> sysmsg0:
 15146 00011263 891D[84030300]      <1> 	mov	[u.base], ebx
 15147 00011269 8815[5F8A0100]      <1> 	mov	[ccolor], dl ; color attributes
 15148 0001126F 89E5                <1> 	mov	ebp, esp
 15149 00011271 31DB                <1> 	xor	ebx, ebx ; 0
 15150 00011273 891D[8C030300]      <1> 	mov	[u.nread], ebx ; 0
 15151                              <1> 	;
 15152 00011279 381D[C6030300]      <1> 	cmp	[u.kcall], bl ; 0
 15153 0001127F 776F                <1> 	ja	short sysmsgk ; Temporary (01/07/2015)
 15154                              <1> 	;
 15155 00011281 890D[88030300]      <1> 	mov	[u.count], ecx
 15156                              <1> 	;inc	ecx ; + 00h ; ASCIIZ
 15157                              <1> 	;
 15158                              <1> 	; 07/12/2020
 15159                              <1> 	;add	ecx, 3
 15160 00011287 6683C103            <1> 	add	cx, 3
 15161 0001128B 80E1FC              <1> 	and	cl, ~3  ; not 3
 15162                              <1> 	;
 15163 0001128E 29CC                <1> 	sub	esp, ecx
 15164 00011290 89E7                <1> 	mov	edi, esp
 15165 00011292 89E6                <1> 	mov	esi, esp
 15166 00011294 66891D[C4030300]    <1> 	mov	[u.pcount], bx ; reset page (phy. addr.) counter
 15167                              <1> 	; 11/11/2015
 15168 0001129B 8A25[94030300]      <1> 	mov 	ah, [u.ttyp] ; recent open tty
 15169                              <1> 	; 0 = none
 15170 000112A1 FECC                <1> 	dec	ah
 15171 000112A3 790C                <1> 	jns	short sysmsg1 
 15172 000112A5 8A1D[B3030300]      <1> 	mov	bl, [u.uno] ; process number	
 15173 000112AB 8AA3[7F000300]      <1> 	mov	ah, [ebx+p.ttyc-1] ; user's (process's) console tty
 15174                              <1> sysmsg1:
 15175 000112B1 8825[96030300]      <1> 	mov	[u.ttyn], ah
 15176                              <1> sysmsg2:
 15177 000112B7 E848080000          <1> 	call	cpass
 15178 000112BC 7416                <1> 	jz	short sysmsg5
 15179 000112BE AA                  <1> 	stosb
 15180 000112BF 20C0                <1> 	and	al, al
 15181 000112C1 75F4                <1> 	jnz	short sysmsg2
 15182                              <1> sysmsg3:
 15183 000112C3 80FC07              <1> 	cmp	ah, 7 ; tty number
 15184 000112C6 7711                <1> 	ja	short sysmsg6 ; serial port
 15185 000112C8 E83E000000          <1> 	call	print_cmsg ; 05/12/2020
 15186                              <1> sysmsg4:
 15187 000112CD 89EC                <1> 	mov	esp, ebp	
 15188 000112CF E938C6FFFF          <1> 	jmp	sysret
 15189                              <1> sysmsg5:
 15190 000112D4 C60700              <1> 	mov	byte [edi], 0
 15191 000112D7 EBEA                <1> 	jmp	short sysmsg3
 15192                              <1> sysmsg6:
 15193 000112D9 8A06                <1> 	mov	al, [esi]
 15194 000112DB E8CD180000          <1> 	call	sndc
 15195 000112E0 72EB                <1> 	jc	short sysmsg4
 15196 000112E2 803E00              <1> 	cmp	byte [esi], 0  ; 0 is stop character
 15197 000112E5 76E6                <1> 	jna	short sysmsg4
 15198 000112E7 46                  <1> 	inc 	esi
 15199 000112E8 8A25[96030300]      <1> 	mov	ah, [u.ttyn]
 15200 000112EE EBE9                <1> 	jmp	short sysmsg6
 15201                              <1> 
 15202                              <1> sysmsgk: ; Temporary (01/07/2015)
 15203                              <1> 	; The message has been sent by Kernel (ASCIIZ string)
 15204                              <1> 	; (ECX -character count- will not be considered)
 15205 000112F0 8B35[84030300]      <1> 	mov	esi, [u.base]
 15206 000112F6 8A25[5E8A0100]      <1> 	mov	ah, [ptty] ; present/current screen (video page)
 15207 000112FC 8825[96030300]      <1> 	mov	[u.ttyn], ah
 15208 00011302 C605[C6030300]00    <1> 	mov	byte [u.kcall], 0
 15209 00011309 EBB8                <1> 	jmp	short sysmsg3
 15210                              <1> 	
 15211                              <1> print_cmsg: 
 15212                              <1> 	; 08/12/2020
 15213                              <1> 	; 07/12/2020
 15214                              <1> 	; 05/12/2020
 15215                              <1> 	; 18/11/2017
 15216                              <1> 	; 13/05/2016 - TRDOS 386 (TRDOS v2.0)
 15217                              <1> 	; 01/07/2015 (Retro UNIX 386 v1)
 15218                              <1> 	;
 15219                              <1> 	; print message (on user's console tty) 
 15220                              <1> 	;	with requested color
 15221                              <1> 	;
 15222                              <1> 	; INPUTS:
 15223                              <1> 	;	esi = message address
 15224                              <1> 	;	[u.ttyn] = tty number (0 to 7)
 15225                              <1> 	;	[ccolor] = color attributes (IBM PC BIOS colors)
 15226                              <1> 	;
 15227                              <1> 	; Modified registers: eax, ebx, ecx, edx, esi, edi
 15228                              <1> 	; (ebp must be preserved)
 15229                              <1> 
 15230                              <1> 	;mov	bh, ah
 15231 0001130B 8A3D[96030300]      <1> 	mov	bh, [u.ttyn]
 15232 00011311 8A1D[5F8A0100]      <1> 	mov	bl, [ccolor] ; * ; 05/12/2020
 15233                              <1> 
 15234                              <1> 	; 05/12/2020
 15235 00011317 803D[1C120300]00    <1> 	cmp	byte [pmi32], 0 ; is vbios's 32 bit pmi enabled ?
 15236 0001131E 772E                <1> 	ja	short pcmsg5 ; yes
 15237                              <1> pcmsg1:
 15238                              <1> 	; 08/12/2020
 15239 00011320 8A1D[5F8A0100]      <1> 	mov	bl, [ccolor] ; * (video.s 'u11'&'beep' change BL)
 15240                              <1> 	
 15241 00011326 AC                  <1> 	lodsb
 15242 00011327 20C0                <1> 	and 	al, al  ; 0
 15243 00011329 743A                <1> 	jz 	short pcmsg2
 15244                              <1> pcmsg7:
 15245 0001132B 56                  <1> 	push 	esi
 15246                              <1> 	;mov	bl, [ccolor] ; * (video.s 'u11'&'beep' change BL)
 15247                              <1> 	; 05/12/2020
 15248                              <1> 	;;mov	bh, [u.ttyn]
 15249                              <1> 	;call 	_write_tty
 15250                              <1> 	;pop	esi
 15251                              <1> 	;jmp	short pcmsg1
 15252                              <1> ;pcmsg2:
 15253                              <1> 	;retn
 15254                              <1> 
 15255                              <1> 	; 07/12/2020
 15256 0001132C 803D[DA6F0000]03    <1> 	cmp     byte [CRT_MODE], 3
 15257 00011333 7708                <1> 	ja 	short pcmsg4
 15258                              <1> pcmsg3:
 15259 00011335 E8DE0FFFFF          <1> 	call	_write_tty_m3
 15260 0001133A 5E                  <1> 	pop	esi
 15261 0001133B EBE3                <1> 	jmp	short pcmsg1
 15262                              <1> pcmsg4:
 15263 0001133D 803D[DA6F0000]07    <1>         cmp     byte [CRT_MODE], 7
 15264 00011344 76EF                <1> 	jna 	short pcmsg3
 15265 00011346 E8F11CFFFF          <1> 	call	vga_write_teletype
 15266 0001134B 5E                  <1> 	pop	esi
 15267 0001134C EBD2                <1> 	jmp	short pcmsg1
 15268                              <1> pcmsg5:
 15269                              <1> 	; 07/12/2020
 15270 0001134E 803D[DA6F0000]07    <1>         cmp     byte [CRT_MODE], 7
 15271 00011355 76C9                <1> 	jna 	short pcmsg1
 15272                              <1> 
 15273                              <1> 	; 05/12/2020
 15274                              <1> 	; writing message by using
 15275                              <1> 	; VESA VBE3 video bios protected mode interface
 15276                              <1> 	
 15277 00011357 B40E                <1> 	mov	ah, 0Eh
 15278                              <1> pcmsg6:
 15279 00011359 AC                  <1> 	lodsb
 15280 0001135A 20C0                <1> 	and 	al, al  ; 0
 15281 0001135C 7407                <1> 	jz 	short pcmsg2
 15282                              <1> 	; bh = video page
 15283                              <1> 	; ah = 0Eh 
 15284                              <1> 	; al = character
 15285                              <1> 	; bl = color
 15286 0001135E E8AF06FFFF          <1> 	call	int10h_32bit_pmi
 15287 00011363 EBF4                <1> 	jmp	short pcmsg6
 15288                              <1> pcmsg2:
 15289 00011365 C3                  <1> 	retn
 15290                              <1> 
 15291                              <1> sysgeterr:
 15292                              <1> 	; 09/12/2015
 15293                              <1> 	; 21/09/2015 - (Retro UNIX 386 v1 feature only!)
 15294                              <1> 	; Get last error number or page fault count
 15295                              <1> 	; (for debugging)
 15296                              <1> 	;
 15297                              <1> 	; Input -> EBX = return type
 15298                              <1> 	;	   0 = last error code (which is in 'u.error')	
 15299                              <1> 	;	   FFFFFFFFh = page fault count for running process
 15300                              <1> 	;	   FFFFFFFEh = total page fault count
 15301                              <1> 	;	   1 .. FFFFFFFDh = undefined 
 15302                              <1> 	;
 15303                              <1> 	; Output -> EAX = last error number or page fault count
 15304                              <1> 	;	   (depending on EBX input)
 15305                              <1> 	; 	
 15306 00011366 21DB                <1> 	and 	ebx, ebx
 15307 00011368 750B                <1> 	jnz	short glerr_2
 15308                              <1> glerr_0:
 15309 0001136A A1[C8030300]        <1> 	mov	eax, [u.error]
 15310                              <1> glerr_1:
 15311 0001136F A3[64030300]        <1> 	mov	[u.r0], eax
 15312 00011374 C3                  <1>  	retn
 15313                              <1> glerr_2:
 15314 00011375 43                  <1> 	inc	ebx ; FFFFFFFFh -> 0, FFFFFFFEh -> FFFFFFFFh
 15315 00011376 74FD                <1> 	jz	short glerr_2 ; page fault count for process
 15316 00011378 43                  <1> 	inc	ebx ; FFFFFFFFh -> 0	
 15317 00011379 75EF                <1> 	jnz	short glerr_0
 15318 0001137B A1[80050300]        <1> 	mov	eax, [PF_Count] ; total page fault count
 15319 00011380 EBED                <1>         jmp     short glerr_1
 15320                              <1> glerr_3:
 15321 00011382 A1[CC030300]        <1> 	mov 	eax, [u.pfcount]
 15322 00011387 EBE6                <1> 	jmp	short glerr_1
 15323                              <1> 
 15324                              <1> load_and_run_file:
 15325                              <1> 	; 18/11/2017
 15326                              <1> 	; 22/01/2017
 15327                              <1> 	; 04/01/2017, 07/01/2017
 15328                              <1> 	; 24/10/2016
 15329                              <1> 	; 24/04/2016, 02/05/2016, 03/05/2016, 06/05/2016
 15330                              <1> 	; 23/04/2016 (TRDOS 386 = TRDOS v2.0)
 15331                              <1> 	; 23/10/2015 (Retro UNIX 386 v1, 'sysexec')
 15332                              <1> 	; 23/06/2015 (Retro UNIX 386 v1 - Beginning)
 15333                              <1> 	; 03/06/2013 - 06/12/2013 (Retro UNIX 8086 v1)
 15334                              <1> 	; EAX = First Cluster number
 15335                              <1> 	; EDX = File Size
 15336                              <1> 	; ESI = Argument list address
 15337                              <1> 	; [argc] = argument count
 15338                              <1> 	; [u.nread] = argument list length
 15339                              <1> 	; [esp] = return address to the caller (*)
 15340                              <1> 	;
 15341 00011389 8935[4C040300]      <1> 	mov	[argv], esi
 15342 0001138F 8915[55040300]      <1> 	mov	[i.size], edx
 15343 00011395 A3[51040300]        <1> 	mov	[ii], eax
 15344                              <1> 
 15345                              <1> 	;sti	; 07/01/2017
 15346                              <1> 	;mov	eax, [k_page_dir]
 15347                              <1> 	;mov	[u.pgdir], eax
 15348 0001139A 31C0                <1> 	xor 	eax, eax ; clc ; *** ; 04/01/2017
 15349                              <1> 	;mov	[u.r0], eax ; 0 ; 07/01/2017
 15350                              <1> 
 15351                              <1> 	; 06/05/2016
 15352                              <1> 	; Set 'sysexit' return order to MainProg
 15353                              <1> 	;
 15354 0001139C 58                  <1> 	pop	eax ; * 'loc_load_and_run_file_8:' address
 15355                              <1> 	;; 22/01/2017
 15356                              <1> 	;;cli ; 07/01/2017
 15357 0001139D 8B25[CC890100]      <1> 	mov	esp, [tss.esp0]
 15358                              <1> 	;
 15359                              <1> 	; 'loc_load_run_file_8' address has 
 15360                              <1> 	; 'jmp loc_file_rw_restore_retn' instruction
 15361                              <1> 	; 'loc_file_rw_restore_retn:' will return to
 15362                              <1> 	; [mainprog_return_addr] 
 15363                              <1> 	; just after 'call command_interpreter'
 15364                              <1> 	;
 15365 000113A3 68[43750000]        <1> 	push	_end_of_mainprog ; we must not return to here !
 15366 000113A8 FF35[B0960100]      <1> 	push	dword [mainprog_return_addr]
 15367 000113AE 89E5                <1> 	mov	ebp, esp ; **
 15368                              <1> 	;	
 15369 000113B0 9C                  <1> 	pushfd  ; EFLAGS      ; IRETD ; ***
 15370 000113B1 6A08                <1> 	push	KCODE ; cs    ; IRETD
 15371 000113B3 50                  <1> 	push	eax ; * (eip) ; IRETD
 15372 000113B4 8925[5C030300]      <1> 	mov	[u.sp], esp
 15373                              <1> 	;mov	byte [u.quant], time_count
 15374 000113BA 1E                  <1> 	push	ds
 15375 000113BB 06                  <1> 	push	es
 15376 000113BC 0FA0                <1> 	push	fs
 15377 000113BE 0FA8                <1> 	push	gs	
 15378                              <1> 	;mov	eax, [u.r0]
 15379 000113C0 29C0                <1> 	sub	eax, eax
 15380 000113C2 60                  <1> 	pushad
 15381 000113C3 68[0CD90000]        <1> 	push	sysret
 15382                              <1> 	;push	sysrel1 ; 07/01/2017
 15383 000113C8 8925[60030300]      <1> 	mov	[u.usp], esp
 15384                              <1> 	;
 15385 000113CE E845060000          <1> 	call	wswap ; Save MainProg (process 1) 'u' structure
 15386                              <1> 		      ; and registers for return (from program)	
 15387 000113D3 89EC                <1> 	mov	esp, ebp ; **
 15388                              <1> 	;;22/01/2017
 15389                              <1> 	;;sti ; 07/01/2017
 15390 000113D5 50                  <1> 	push	eax  ; * 'loc_load_and_run_file_8:' address
 15391                              <1> 	;
 15392                              <1> 	;;; 02/05/2016
 15393                              <1> 	;;; Create a new process (parent: MainProg)	
 15394 000113D6 31F6                <1> 	xor 	esi, esi
 15395                              <1> cnpm_1: ; search p.stat table for unused process number
 15396 000113D8 46                  <1> 	inc	esi
 15397 000113D9 80BE[AF000300]00    <1> 	cmp	byte [esi+p.stat-1], 0 ; SFREE
 15398                              <1> 				; is process active, unused, dead
 15399 000113E0 760B                <1> 	jna	short cnpm_2	; it's unused so branch
 15400 000113E2 6683FE10            <1> 	cmp	si, nproc 	; all processes checked
 15401 000113E6 72F0                <1> 	jb	short cnpm_1    ; no, branch back
 15402 000113E8 E9DE61FFFF          <1> 	jmp	panic 
 15403                              <1> cnpm_2:
 15404 000113ED A1[B8030300]        <1> 	mov	eax, [u.pgdir] ; page directory of MainProg
 15405 000113F2 A3[BC030300]        <1> 	mov	[u.ppgdir], eax ; parent's page directory
 15406 000113F7 E8DF47FFFF          <1> 	call	allocate_page
 15407 000113FC 0F82C961FFFF        <1> 	jc	panic
 15408                              <1> 	; EAX = UPAGE (user structure page) address
 15409 00011402 A3[B4030300]        <1> 	mov	[u.upage], eax ; memory page for 'user' struct (child)
 15410 00011407 89F7                <1> 	mov	edi, esi
 15411 00011409 66C1E702            <1> 	shl	di, 2
 15412 0001140D 8987[BC000300]      <1> 	mov	[edi+p.upage-4], eax ; memory page for 'user' struct
 15413 00011413 E83D48FFFF          <1> 	call	clear_page ; 03/05/2016
 15414                              <1> 	;movzx	eax, byte [p.ttyc] ; console tty (for MainProg)
 15415 00011418 6629C0              <1> 	sub	ax, ax ; 0
 15416 0001141B 668986[7F000300]    <1> 	mov     [esi+p.ttyc-1], ax ; al - set child's console tty
 15417                              <1> 				   ; ah - reset child's wait channel	
 15418 00011422 89F0                <1> 	mov	eax, esi
 15419 00011424 A2[B3030300]        <1> 	mov	[u.uno], al ; child process number
 15420 00011429 FE86[AF000300]      <1>         inc     byte [esi+p.stat-1] ; 1, SRUN
 15421 0001142F 66D1E6              <1> 	shl	si, 1 ; multiply si by 2 to get index into p.pid table
 15422 00011432 66FF05[4E030300]    <1> 	inc	word [mpid] ; increment m.pid; get a new process name
 15423 00011439 66A1[4E030300]      <1> 	mov	ax, [mpid]
 15424 0001143F 668986[1E000300]    <1> 	mov	[esi+p.pid-2], ax ; put new process name 
 15425                              <1> 				  ; in child process' name slot
 15426                              <1> 	;mov	ax, [p.pid]  ; get process name of MainProg
 15427 00011446 66B80100            <1> 	mov	ax, 1
 15428 0001144A 668986[3E000300]    <1> 	mov	[esi+p.ppid-2], ax ; put parent process name 
 15429                              <1> 			           ; in parent process slot for child
 15430 00011451 6648                <1> 	dec	ax ; 0
 15431 00011453 66A3[94030300]      <1> 	mov 	[u.ttyp], ax ; 0
 15432                              <1> 	;;;
 15433 00011459 A1[51040300]        <1> 	mov 	eax,  [ii]
 15434                              <1> 	; Retro UNIX 386 v1, 'sysexec' (u2.s)
 15435 0001145E E84A170000          <1> 	call	iopen
 15436                              <1> 	; 06/06/2016
 15437 00011463 C605[A9030300]01    <1> 	mov	byte [u.pri], 1 ; normal priority
 15438                              <1> 	;
 15439 0001146A EB16                <1> 	jmp	short sysexec_7 ; 02/05/2016
 15440                              <1> 
 15441                              <1> sysexec_6:
 15442                              <1> 	; 19/11/2017
 15443                              <1> 	; 18/11/2017
 15444                              <1> 	; 14/11/2017
 15445                              <1> 	; 13/11/2017
 15446 0001146C 8925[4C040300]      <1> 	mov	[argv], esp ; *!* ; start address of argument list 
 15447                              <1> 
 15448                              <1> 	; 04/01/2017
 15449                              <1> 	; 24/10/2016
 15450                              <1> 	;;02/05/2016
 15451                              <1> 	; 23/04/2016 (TRDOS 386)
 15452                              <1> 	; 18/10/2015 ('sysexec_6')
 15453                              <1> 	; 23/06/2015
 15454 00011472 A1[B8030300]        <1> 	mov	eax, [u.pgdir] ; physical address of page directory
 15455                              <1> 	;cmp 	eax, [k_page_dir] ; TRDOS MainProg ? 
 15456                              <1> 	;je	short sysexec_7
 15457                              <1> 	; 19/11/2017
 15458 00011477 8B1D[BC030300]      <1> 	mov	ebx, [u.ppgdir] ; phy addr of the parent's page dir
 15459 0001147D E89248FFFF          <1> 	call	deallocate_page_dir
 15460                              <1> sysexec_7:
 15461 00011482 E8C247FFFF          <1> 	call	make_page_dir
 15462 00011487 0F823E61FFFF        <1> 	jc	panic  ; allocation error 
 15463                              <1> 		       ; after a deallocation would be nonsence !?
 15464                              <1> 	; 24/07/2015
 15465                              <1> 	; map kernel pages (1st 4MB) to PDE 0
 15466                              <1> 	;     of the user's page directory
 15467                              <1> 	;     (It is needed for interrupts!)
 15468                              <1> 	; 18/10/2015
 15469 0001148D 8B15[308A0100]      <1> 	mov	edx, [k_page_dir] ; Kernel's page directory
 15470 00011493 8B02                <1> 	mov	eax, [edx] ; physical address of
 15471                              <1> 			   ; kernel's first page table (1st 4 MB)
 15472                              <1> 			   ; (PDE 0 of kernel's page directory)
 15473 00011495 8B15[B8030300]      <1> 	mov 	edx, [u.pgdir]
 15474 0001149B 8902                <1> 	mov	[edx], eax ; PDE 0 (1st 4MB)
 15475                              <1> 	;
 15476                              <1> 	; 20/07/2015
 15477 0001149D BB00004000          <1> 	mov	ebx, CORE ; start address = 0 (virtual) + CORE
 15478                              <1> 	; 18/10/2015
 15479 000114A2 BE[3C040300]        <1> 	mov	esi, pcore ; physical start address
 15480                              <1> sysexec_8:	
 15481 000114A7 B907000000          <1> 	mov	ecx, PDE_A_USER + PDE_A_WRITE + PDE_A_PRESENT
 15482 000114AC E8B647FFFF          <1> 	call	make_page_table
 15483 000114B1 0F821461FFFF        <1> 	jc	panic
 15484                              <1> 	;mov	ecx, PTE_A_USER + PTE_A_WRITE + PTE_A_PRESENT
 15485 000114B7 E8B947FFFF          <1> 	call	make_page ; make new page, clear and set the pte 
 15486 000114BC 0F820961FFFF        <1> 	jc	panic
 15487                              <1> 	;
 15488 000114C2 8906                <1> 	mov	[esi], eax ; 24/06/2015
 15489                              <1> 	; ebx = virtual address (24/07/2015)
 15490 000114C4 E8514DFFFF          <1> 	call 	add_to_swap_queue
 15491                              <1> 	; 18/10/2015
 15492 000114C9 81FE[40040300]      <1> 	cmp	esi, ecore ; user's stack (last) page ?
 15493 000114CF 740C                <1> 	je	short sysexec_9 ; yes
 15494 000114D1 BE[40040300]        <1> 	mov	esi, ecore  ; physical address of the last page 
 15495                              <1> 	; 20/07/2015
 15496 000114D6 BB00F0FFFF          <1> 	mov	ebx, (ECORE - PAGE_SIZE) + CORE
 15497                              <1> 	; ebx = virtual end address + segment base address - 4K
 15498 000114DB EBCA                <1>         jmp     short sysexec_8
 15499                              <1> sysexec_9:
 15500                              <1> 	; 19/11/2017 
 15501                              <1> 	; 24/04/2016 (TRDOS 386 = TRDOS v2.0)
 15502                              <1> 	; 25/06/2015, 26/08/2015, 18/10/2015
 15503                              <1> 	; move arguments from kernel stack to [ecore]
 15504                              <1> 	; (argument list/line will be copied from kernel stack
 15505                              <1> 	; frame to the last (stack) page of user's core memory)
 15506                              <1> 	; 18/10/2015
 15507 000114DD 8B3D[40040300]      <1> 	mov	edi, [ecore]
 15508 000114E3 81C700100000        <1> 	add	edi, PAGE_SIZE
 15509                              <1> 	; 19/11/2017
 15510 000114E9 83EF04              <1> 	sub	edi, 4
 15511 000114EC C70700000000        <1> 	mov	dword [edi], 0 
 15512 000114F2 89FB                <1> 	mov	ebx, edi
 15513                              <1> 	;
 15514 000114F4 0FB705[4A040300]    <1> 	movzx	eax, word [argc]
 15515 000114FB 09C0                <1> 	or	eax, eax
 15516 000114FD 7445                <1> 	jz	short sysexec_13 ; 19/11/2017
 15517                              <1> 	;jnz	short sysexec_10
 15518                              <1> 	;mov 	ebx, edi
 15519                              <1> 	;sub	ebx, 4 
 15520                              <1> 	;mov	[ebx], eax ; 0
 15521                              <1> 	;jmp 	short sysexec_13
 15522                              <1> sysexec_10:
 15523 000114FF 8B0D[8C030300]      <1> 	mov	ecx, [u.nread]
 15524                              <1> 	; 13/11/2017
 15525                              <1> 	;mov	esi, TextBuffer ; 'load_and_execute_file'
 15526                              <1> 	;mov	esi, esp  	; 'sysexec'
 15527 00011505 8B35[4C040300]      <1> 	mov	esi, [argv] ; 24/04/2016 (TRDOS 386  = TRDOS v2.0)
 15528                              <1> 	;sub	edi, ecx ; page end address - argument list length
 15529 0001150B 29CB                <1> 	sub	ebx, ecx ; 19/11/2017
 15530 0001150D 89C2                <1> 	mov	edx, eax
 15531 0001150F FEC2                <1> 	inc	dl ; argument count + 1 for argc value  
 15532 00011511 C0E202              <1> 	shl 	dl, 2  ; 4 * (argument count + 1)
 15533                              <1> 	;mov	ebx, edi
 15534 00011514 89DF                <1> 	mov	edi, ebx ; 19//11/2017
 15535 00011516 80E3FC              <1> 	and	bl, 0FCh ; 32 bit (dword) alignment
 15536 00011519 29D3                <1> 	sub 	ebx, edx
 15537 0001151B 89FA                <1> 	mov	edx, edi
 15538 0001151D F3A4                <1> 	rep	movsb
 15539 0001151F 89D6                <1> 	mov 	esi, edx
 15540 00011521 89DF                <1> 	mov 	edi, ebx
 15541 00011523 BA00F0BFFF          <1> 	mov	edx, ECORE - PAGE_SIZE ; virtual addr. of the last page
 15542 00011528 2B15[40040300]      <1> 	sub 	edx, [ecore] ; difference (virtual - physical) 
 15543 0001152E AB                  <1> 	stosd	; eax = argument count	
 15544                              <1> sysexec_11:
 15545 0001152F 89F0                <1> 	mov	eax, esi
 15546 00011531 01D0                <1> 	add	eax, edx
 15547 00011533 AB                  <1> 	stosd  ; eax = virtual address
 15548                              <1> 	;dec	byte [argc]
 15549 00011534 66FF0D[4A040300]    <1> 	dec	word [argc] ; 14/11/2017
 15550 0001153B 7407                <1> 	jz	short sysexec_13
 15551                              <1> sysexec_12:
 15552 0001153D AC                  <1> 	lodsb
 15553 0001153E 20C0                <1> 	and	al, al
 15554 00011540 75FB                <1> 	jnz	short sysexec_12
 15555 00011542 EBEB                <1> 	jmp	short sysexec_11
 15556                              <1> sysexec_13:
 15557                              <1> 	; 24/10/2016
 15558                              <1> 	; 24/04/2016 - TRDOS 386 (TRDOS v2.0)
 15559                              <1> 	; 23/06/2015 - 19/10/2015 (Retro UNIX 386 v1, 'sysexec_13')
 15560                              <1> 	;
 15561                              <1> 	; moving arguments to [ecore] is OK here..
 15562                              <1> 	;
 15563                              <1> 	; ebx = beginning addres of argument list pointers
 15564                              <1> 		;	in user's stack
 15565 00011544 2B1D[40040300]      <1> 	sub 	ebx, [ecore]
 15566 0001154A 81C300F0BFFF        <1> 	add     ebx, (ECORE - PAGE_SIZE)
 15567                              <1> 			; end of core - 4096 (last page)
 15568                              <1> 			; (virtual address)
 15569 00011550 891D[4C040300]      <1> 	mov	[argv], ebx
 15570 00011556 891D[90030300]      <1> 	mov	[u.break], ebx ; available user memory
 15571                              <1> 	;
 15572 0001155C 29C0                <1> 	sub	eax, eax
 15573 0001155E C705[88030300]2000- <1> 	mov	dword [u.count], 32 ; Executable file header size
 15573 00011566 0000                <1>
 15574 00011568 C705[74030300]-     <1> 	mov	dword [u.fofp], u.off
 15574 0001156E [80030300]          <1>
 15575 00011572 A3[80030300]        <1> 	mov	[u.off], eax ; 0
 15576 00011577 A3[84030300]        <1> 	mov	[u.base], eax ; 0, start of user's core (virtual)
 15577                              <1> 	; 24/10/2016
 15578 0001157C A0[F68A0100]        <1> 	mov	al, [Current_Drv]
 15579 00011581 A2[46030300]        <1> 	mov	[cdev], al
 15580                              <1> 	;
 15581 00011586 A1[51040300]        <1> 	mov	eax, [ii] ; Fist Cluster of the Program (PRG) file
 15582                              <1> 	; EAX = First cluster of the executable file
 15583 0001158B E80A010000          <1> 	call	readi
 15584                              <1> 
 15585 00011590 8B0D[90030300]      <1> 	mov	ecx, [u.break] ; top of user's stack (physical addr.)
 15586 00011596 890D[88030300]      <1> 	mov	[u.count], ecx ; save for overrun check
 15587                              <1> 	;
 15588 0001159C 8B0D[8C030300]      <1> 	mov	ecx, [u.nread]
 15589 000115A2 890D[90030300]      <1> 	mov	[u.break], ecx ; virtual address (offset from start)
 15590 000115A8 80F920              <1> 	cmp	cl, 32
 15591 000115AB 7540                <1>         jne     short sysexec_15
 15592                              <1> 	;:
 15593                              <1> 	; Retro UNIX 386 v1 (32 bit) executable file header format
 15594 000115AD 8B35[3C040300]      <1> 	mov	esi, [pcore] ; start address of user's core memory 
 15595                              <1> 		             ; (phys. start addr. of the exec. file)
 15596 000115B3 AD                  <1> 	lodsd
 15597 000115B4 663DEB1E            <1> 	cmp	ax, 1EEBh ; EBH, 1Eh -> jump to +32
 15598 000115B8 7533                <1> 	jne	short sysexec_15
 15599 000115BA AD                  <1> 	lodsd
 15600 000115BB 89C1                <1> 	mov	ecx, eax ; text (code) section size
 15601 000115BD AD                  <1> 	lodsd
 15602 000115BE 01C1                <1> 	add	ecx, eax ; + data section size (initialized data)
 15603 000115C0 89CB                <1> 	mov	ebx, ecx
 15604 000115C2 AD                  <1> 	lodsd	
 15605 000115C3 01C3                <1> 	add	ebx, eax ; + bss section size (for overrun checking)
 15606 000115C5 3B1D[88030300]      <1> 	cmp	ebx, [u.count]
 15607 000115CB 7711                <1> 	ja	short sysexec_14  ; program overruns stack !
 15608                              <1> 	;
 15609                              <1> 	; add bss section size to [u.break]
 15610 000115CD 0105[90030300]      <1> 	add 	[u.break], eax
 15611                              <1> 	;
 15612 000115D3 83E920              <1> 	sub	ecx, 32  ; header size (already loaded)
 15613                              <1> 	;cmp	ecx, [u.count]
 15614                              <1> 	;jnb	short sysexec_16
 15615 000115D6 890D[88030300]      <1> 	mov	[u.count], ecx ; required read count
 15616 000115DC EB29                <1> 	jmp	short sysexec_16
 15617                              <1> sysexec_14:
 15618                              <1> 	; insufficient (out of) memory
 15619 000115DE C705[C8030300]0400- <1> 	mov	dword [u.error], ERR_MINOR_IM ; 1
 15619 000115E6 0000                <1>
 15620 000115E8 E9FFC2FFFF          <1> 	jmp	error
 15621                              <1> sysexec_15:
 15622 000115ED 8B15[55040300]      <1>         mov	edx, [i.size] ; file size
 15623 000115F3 29CA                <1> 	sub	edx, ecx ; file size - loaded bytes
 15624 000115F5 7626                <1> 	jna	short sysexec_17 ; no need to next read
 15625 000115F7 01D1                <1> 	add	ecx, edx ; [i.size]
 15626 000115F9 3B0D[88030300]      <1> 	cmp	ecx, [u.count] ; overrun check (!)
 15627 000115FF 77DD                <1> 	ja	short sysexec_14
 15628 00011601 8915[88030300]      <1> 	mov	[u.count], edx
 15629                              <1> sysexec_16:
 15630 00011607 A1[51040300]        <1> 	mov	eax, [ii] ; first cluster
 15631 0001160C E889000000          <1> 	call	readi
 15632 00011611 8B0D[8C030300]      <1> 	mov	ecx, [u.nread]
 15633 00011617 010D[90030300]      <1> 	add	[u.break], ecx
 15634                              <1> sysexec_17:
 15635 0001161D A1[51040300]        <1> 	mov	eax, [ii] ; first cluster
 15636 00011622 E886150000          <1> 	call	iclose
 15637 00011627 31C0                <1> 	xor     eax, eax
 15638 00011629 FEC0                <1> 	inc	al
 15639 0001162B 66A3[AA030300]      <1> 	mov	[u.intr], ax ; 1 (interrupt/time-out is enabled)
 15640 00011631 66A3[AC030300]      <1> 	mov	[u.quit], ax ; 1 ('crtl+brk' signal is enabled) 
 15641 00011637 833D[BC030300]00    <1>         cmp	dword [u.ppgdir], 0  ; is the caller MainProg (kernel) ?
 15642 0001163E 770C                <1> 	ja	short sysexec_18 ; no, the caller is user process
 15643                              <1> 	; If the caller is kernel (MainProg), 'sysexec' will come here
 15644 00011640 8B15[308A0100]      <1> 	mov	edx, [k_page_dir] ; kernel's page directory
 15645 00011646 8915[BC030300]      <1> 	mov	[u.ppgdir], edx ; next time 'sysexec' must not come here 
 15646                              <1> sysexec_18:
 15647                              <1> 	; 02/05/2016
 15648                              <1> 	; 24/04/2016 (TRDOS 386 = TRDOS v2.0)
 15649                              <1> 	; 18/10/2015 (Retro UNIX 386 v1)
 15650                              <1> 	; 05/08/2015
 15651                              <1> 	; 29/07/2015
 15652                              <1> 
 15653                              <1> ;	; **** arguments list test start - 19/11/2017
 15654                              <1> ;	mov	ebp, [argv]
 15655                              <1> ;	sub	ebp, ECORE - 4096
 15656                              <1> ;	add	ebp, [ecore]
 15657                              <1> ;
 15658                              <1> ;	mov	ebx, [ebp]
 15659                              <1> ;	mov	[argc], bx
 15660                              <1> ;	add	ebp, 4
 15661                              <1> ;	mov	byte [ccolor], 1Fh
 15662                              <1> ;_zx0:
 15663                              <1> ;	cmp	word [argc], 0
 15664                              <1> ;	jna	short _zx2	
 15665                              <1> ;_zx1:
 15666                              <1> ;	push	ebp
 15667                              <1> ;	mov	esi, [ebp]
 15668                              <1> ;
 15669                              <1> ;	sub	esi, ECORE - 4096
 15670                              <1> ;	add	esi, [ecore]
 15671                              <1> ;
 15672                              <1> ;	call	print_cmsg
 15673                              <1> ;
 15674                              <1> ;	dec	word [argc]
 15675                              <1> ;	jz	short _zx2
 15676                              <1> ;
 15677                              <1> ;	mov	al, '.'
 15678                              <1> ;	mov	bl, 07h
 15679                              <1> ;	mov	bh, [u.ttyn]
 15680                              <1> ;	call 	_write_tty 
 15681                              <1> ;
 15682                              <1> ;	pop	ebp
 15683                              <1> ;	add	ebp, 4
 15684                              <1> ;	jmp	short _zx1			
 15685                              <1> ;_zx2:
 15686                              <1> ;	pop	ebp
 15687                              <1> ;	mov	byte [ccolor], 07h
 15688                              <1> ;	mov	eax, 1
 15689                              <1> ;	; **** arguments list test stop
 15690                              <1> ;	Test result is OK! (there is not a wrong thing) - 19/11/2017
 15691                              <1> 
 15692 0001164C 8B2D[4C040300]      <1> 	mov	ebp, [argv] ; user's stack pointer must point to argument
 15693                              <1> 			    ; list pointers (argument count)
 15694 00011652 FA                  <1> 	cli
 15695 00011653 8B25[CC890100]      <1>         mov     esp, [tss.esp0] ; ring 0 (kernel) stack pointer
 15696                              <1> 	;mov   	esp, [u.sp] ; Restore Kernel stack
 15697                              <1> 			    ; for this process	 
 15698                              <1> 	;add	esp, 20 ; --> EIP, CS, EFLAGS, ESP, SS
 15699                              <1> 	;xor	eax, eax ; 0
 15700 00011659 FEC8                <1> 	dec	al ; eax = 0
 15701                              <1> 	;mov	edx, UDATA
 15702                              <1> 	; 18/11/2017
 15703 0001165B 6A23                <1> 	push	UDATA ; user's stack segment
 15704                              <1> 	;push	edx
 15705 0001165D 55                  <1> 	push	ebp ; user's stack pointer
 15706                              <1> 		    ; (points to number of arguments)
 15707                              <1> 	
 15708                              <1> 	; 04/01/2017
 15709                              <1> 	; MainProg comes here while [sysflg]= 0FFh
 15710                              <1> 	; (but sysexec comes here while [sysflg]= 0)
 15711 0001165E C605[5B030300]00    <1> 	mov	byte [sysflg], 0 ; 04/01/2017
 15712                              <1> 				 ; (timer_int sysflg control)
 15713 00011665 FB                  <1> 	sti
 15714 00011666 9C                  <1> 	pushfd	; EFLAGS
 15715                              <1> 		; Set IF for enabling interrupts in user mode	
 15716                              <1> 	;or	dword [esp], 200h 
 15717                              <1> 	;
 15718                              <1> 	;mov	bx, UCODE
 15719                              <1> 	;push	bx ; user's code segment
 15720 00011667 6A1B                <1> 	push	UCODE
 15721                              <1> 	;push	0
 15722 00011669 50                  <1> 	push	eax ; EIP (=0) - start address -	
 15723 0001166A 8925[5C030300]      <1> 	mov	[u.sp], esp ; 29/07/2015
 15724                              <1> 	; 05/08/2015
 15725                              <1> 	; Remedy of a General Protection Fault during 'iretd' is here !
 15726                              <1> 	; ('push dx' would cause to general protection fault, 
 15727                              <1> 	; after 'pop ds' etc.)
 15728                              <1> 	;
 15729                              <1> 	;; push dx ; ds (UDATA)
 15730                              <1> 	;; push dx ; es (UDATA)
 15731                              <1> 	;; push dx ; fs (UDATA)
 15732                              <1> 	;; push dx ; gs (UDATA)
 15733                              <1> 	;
 15734                              <1> 	; This is a trick to prevent general protection fault
 15735                              <1> 	; during 'iretd' intruction at the end of 'sysrele' (in u1.s):
 15736 00011670 66BA2300            <1> 	mov	dx, UDATA ; 19/11/2017
 15737 00011674 8EC2                <1> 	mov 	es, dx ; UDATA
 15738 00011676 06                  <1> 	push 	es ; ds (UDATA)
 15739 00011677 06                  <1> 	push 	es ; es (UDATA)
 15740 00011678 06                  <1> 	push 	es ; fs (UDATA)
 15741 00011679 06                  <1> 	push	es ; gs (UDATA)
 15742 0001167A 66BA1000            <1> 	mov	dx, KDATA
 15743 0001167E 8EC2                <1> 	mov	es, dx
 15744                              <1> 	;
 15745                              <1> 	;; pushad simulation
 15746 00011680 89E5                <1> 	mov	ebp, esp ; esp before pushad
 15747 00011682 50                  <1> 	push	eax ; eax (0)
 15748 00011683 50                  <1> 	push	eax ; ecx (0)
 15749 00011684 50                  <1> 	push	eax ; edx (0)
 15750 00011685 50                  <1> 	push	eax ; ebx (0)
 15751 00011686 55                  <1> 	push	ebp ; esp before pushad
 15752 00011687 50                  <1> 	push	eax ; ebp (0)
 15753 00011688 50                  <1> 	push	eax ; esi (0)		
 15754 00011689 50                  <1> 	push	eax ; edi (0)	
 15755                              <1> 	;
 15756 0001168A A3[64030300]        <1> 	mov	[u.r0], eax ; eax = 0
 15757 0001168F 8925[60030300]      <1> 	mov	[u.usp], esp
 15758                              <1> 
 15759                              <1> 	; 14/11/2017
 15760 00011695 E974C2FFFF          <1> 	jmp	sysret0
 15761                              <1> 
 15762                              <1> ;	; 02/05/2016
 15763                              <1> ;	;inc	byte [sysflg] ; 0FFh -> 0
 15764                              <1> ;	;mov	byte [sysflg], 0 ; 04/01/2017
 15765                              <1> ;	movzx	ebx, byte [u.uno]
 15766                              <1> ;	shl	bl, 1 ; 13/11/2017 	
 15767                              <1> ;	cmp	word [ebx+p.ppid-2], 1 ; MainProg
 15768                              <1> ;	ja	sysret0 ; 03/05/2016
 15769                              <1> ;	push	sysret ; * 
 15770                              <1> ;	mov	[u.usp], esp
 15771                              <1> ;	call	wswap ; save child process 'u' structure and
 15772                              <1> ;		      ; registers
 15773                              <1> ;	add	dword [u.usp], 4 ; 03/05/2016 
 15774                              <1> ;sysexec_19: ; 02/05/2016
 15775                              <1> ;	retn ; * 'sysret' ; byte [sysflg] -> 0FFh
 15776                              <1> 
 15777                              <1> readi:
 15778                              <1> 	; 01/05/2016
 15779                              <1> 	; 25/04/2016 - TRDOS 386 (TRDOS v2.0)
 15780                              <1> 	; 20/05/2015 - Retro UNIX 386 v1
 15781                              <1> 	; 11/03/2013 - 31/07/2013 (Retro UNIX 8086 v1)
 15782                              <1> 	;
 15783                              <1> 	; Reads from a file whose the first cluster number in EAX
 15784                              <1> 	; 
 15785                              <1> 	; INPUTS ->
 15786                              <1> 	;    EAX - First cluster number of the file
 15787                              <1> 	;    u.count - byte count user desires
 15788                              <1> 	;    u.base - points to user buffer
 15789                              <1> 	;    u.fofp - points to dword with current file offset
 15790                              <1> 	;    i.size - file size
 15791                              <1> 	;    cdev - logical dos drive number of the file
 15792                              <1> 	; OUTPUTS ->
 15793                              <1> 	;    u.count - cleared
 15794                              <1> 	;    u.nread - accumulates total bytes passed back
 15795                              <1> 	;
 15796                              <1> 	; ((EAX)) input/output
 15797                              <1> 	; (Retro UNIX Prototype : 14/12/2012 - 01/03/2013, UNIXCOPY.ASM)
 15798                              <1>         ; ((Modified registers: edx, ebx, ecx, esi, edi))  
 15799                              <1> 
 15800 0001169A 31D2                <1> 	xor	edx, edx ; 0
 15801 0001169C 8915[8C030300]      <1> 	mov 	[u.nread], edx ; 0
 15802 000116A2 668915[C4030300]    <1> 	mov	[u.pcount], dx ; 19/05/2015
 15803 000116A9 3915[88030300]      <1> 	cmp 	[u.count], edx ; 0
 15804 000116AF 7701                <1> 	ja 	short readi_1
 15805 000116B1 C3                  <1> 	retn
 15806                              <1> readi_1:
 15807                              <1> dskr:
 15808                              <1> 	; 01/05/2016
 15809                              <1> 	; 25/04/2016 - TRDOS 386 (TRDOS v2.0)
 15810                              <1> 	; 24/05/2015 - 12/10/2015 (Retro UNIX 386 v1)
 15811                              <1> 	; 26/04/2013 - 03/08/2013 (Retro UNIX 8086 v1)
 15812                              <1> dskr_0:
 15813 000116B2 8B15[55040300]      <1>         mov	edx, [i.size]
 15814 000116B8 8B1D[74030300]      <1> 	mov	ebx, [u.fofp]
 15815 000116BE 2B13                <1> 	sub	edx, [ebx]
 15816 000116C0 7647                <1> 	jna	short dskr_4
 15817                              <1> 	;
 15818 000116C2 50                  <1> 	push	eax ; 01/05/2016
 15819 000116C3 3B15[88030300]      <1> 	cmp     edx, [u.count] 
 15820 000116C9 7306                <1> 	jnb	short dskr_1
 15821 000116CB 8915[88030300]      <1> 	mov	[u.count], edx
 15822                              <1> dskr_1:
 15823                              <1> 	; EAX = First Cluster
 15824                              <1> 	; [Current_Drv] = Physical drive number 
 15825 000116D1 E83B000000          <1> 	call	mget_r
 15826                              <1> 	; NOTE: in 'mget_r', relevant sector will be read in buffer
 15827                              <1> 	; if it is not already in buffer !
 15828 000116D6 BB[8C050300]        <1> 	mov	ebx, readi_buffer
 15829 000116DB 803D[C6030300]00    <1> 	cmp	byte [u.kcall], 0 ; the caller is 'namei' sign (=1)
 15830 000116E2 770F                <1> 	ja	short dskr_3	  ; zf=0 -> the caller is 'namei'
 15831 000116E4 66833D[C4030300]00  <1> 	cmp	word [u.pcount], 0
 15832 000116EC 7705                <1> 	ja	short dskr_3
 15833                              <1> dskr_2:
 15834                              <1> 	; [u.base] = virtual address to transfer (as destination address)
 15835 000116EE E894010000          <1> 	call	trans_addr_w ; translate virtual address to physical (w)
 15836                              <1> dskr_3:
 15837                              <1> 	; EBX (r5) = system (I/O) buffer address -physical-
 15838 000116F3 E8F7010000          <1> 	call	sioreg
 15839 000116F8 87F7                <1> 	xchg	esi, edi
 15840                              <1> 	; EDI = file (user data) offset
 15841                              <1> 	; ESI = sector (I/O) buffer offset
 15842                              <1> 	; ECX = byte count
 15843 000116FA F3A4                <1> 	rep	movsb
 15844                              <1> 	; eax = remain bytes in buffer
 15845                              <1>         ;       (check if remain bytes in the buffer > [u.pcount])
 15846 000116FC 09C0                <1> 	or	eax, eax
 15847 000116FE 75EE                <1> 	jnz	short dskr_2 ; (page end before system buffer end!)		
 15848 00011700 58                  <1> 	pop	eax  ; (first cluster number)
 15849 00011701 390D[88030300]      <1> 	cmp	[u.count], ecx ; 0
 15850 00011707 77A9                <1> 	ja	short dskr_0
 15851                              <1> dskr_4:
 15852 00011709 C605[C6030300]00    <1> 	mov	byte [u.kcall], 0
 15853 00011710 C3                  <1> 	retn
 15854                              <1> 
 15855                              <1> mget_r:
 15856                              <1> 	; 24/10/2016
 15857                              <1> 	; 22/10/2016
 15858                              <1> 	; 12/10/2016
 15859                              <1> 	; 29/04/2016
 15860                              <1> 	; 25/04/2016 - TRDOS 386 (TRDOS v2.0)
 15861                              <1> 	; 03/06/2015 (Retro UNIX 386 v1, 'mget', u.5s)
 15862                              <1> 	; 22/03/2013 - 31/07/2013 (Retro UNIX 8086 v1)
 15863                              <1> 	;
 15864                              <1> 	; Get existing or (allocate) a new disk block for file
 15865                              <1> 	; 
 15866                              <1> 	; INPUTS ->
 15867                              <1> 	;    [u.fofp] = file offset pointer
 15868                              <1> 	;    EAX = First Cluster
 15869                              <1> 	;    [cdev] = Logical dos drive number 	  
 15870                              <1> 	;    ([u.off] = file offset)
 15871                              <1> 	; OUTPUTS ->
 15872                              <1> 	;    EAX = logical sector number
 15873                              <1> 	;    ESI = Logical Dos Drive Description Table address	
 15874                              <1> 	;
 15875                              <1> 	; Modified registers: EDX, EBX, ECX, ESI, EDI
 15876                              <1> 
 15877 00011711 8B35[74030300]      <1> 	mov     esi, [u.fofp]
 15878 00011717 8B1E                <1> 	mov	ebx, [esi] ; (u.off)
 15879                              <1> 
 15880 00011719 29C9                <1> 	sub	ecx, ecx
 15881 0001171B 8A2D[46030300]      <1> 	mov	ch, [cdev]
 15882                              <1> 
 15883 00011721 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 15884 00011726 01CE                <1> 	add	esi, ecx
 15885                              <1> 
 15886 00011728 380D[64960100]      <1> 	cmp	[readi.valid], cl ; 0
 15887 0001172E 7649                <1> 	jna	short mget_r_0
 15888                              <1> 	
 15889 00011730 3A2D[65960100]      <1> 	cmp	ch, [readi.drv]
 15890 00011736 7541                <1> 	jne	short mget_r_0
 15891                              <1> 
 15892 00011738 3B05[78960100]      <1> 	cmp	eax, [readi.fclust]
 15893 0001173E 7565                <1> 	jne	short mget_r_3
 15894                              <1> 	
 15895 00011740 89D8                <1> 	mov	eax, ebx ; file offset
 15896 00011742 668B0D[6C960100]    <1> 	mov	cx, [readi.bpc]
 15897 00011749 41                  <1> 	inc	ecx ; <= 65536
 15898 0001174A 29D2                <1> 	sub	edx, edx
 15899 0001174C F7F1                <1> 	div	ecx
 15900                              <1> 
 15901 0001174E 8B3D[74960100]      <1> 	mov	edi, [readi.c_index] ; cluster index
 15902                              <1> 
 15903 00011754 39F8                <1> 	cmp	eax, edi
 15904 00011756 757A                <1>         jne     short mget_r_4  ; (*)
 15905                              <1> 
 15906                              <1> 	; edx = byte offset in cluster (<= 65535)
 15907 00011758 668915[6E960100]    <1> 	mov	[readi.offset], dx
 15908 0001175F 66C1EA09            <1> 	shr	dx, 9 ; / 512
 15909 00011763 8815[67960100]      <1> 	mov	[readi.s_index], dl ; sector index in cluster (0 to spc -1)
 15910                              <1> 	
 15911 00011769 A1[70960100]        <1> 	mov	eax, [readi.cluster]  ; > 0 if [readi.valid] = 1
 15912 0001176E 8B15[7C960100]      <1> 	mov	edx, [readi.fs_index]
 15913 00011774 E99A000000          <1>         jmp     mget_r_7
 15914                              <1> 	
 15915                              <1> mget_r_0:
 15916 00011779 882D[65960100]      <1> 	mov	[readi.drv], ch ; physical drive number
 15917 0001177F 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 15918 00011783 7707                <1> 	ja	short mget_r_1
 15919 00011785 8A4E12              <1> 	mov	cl, [esi+LD_FS_BytesPerSec+1]
 15920 00011788 D0E9                <1> 	shr	cl, 1 ;  ; 1 for 512 bytes, 4 for 2048 bytes
 15921 0001178A EB03                <1> 	jmp	short mget_r_2	
 15922                              <1> mget_r_1:
 15923 0001178C 8A4E13              <1> 	mov	cl, [esi+LD_BPB+BPB_SecPerClust]
 15924                              <1> mget_r_2:
 15925 0001178F 880D[66960100]      <1> 	mov	[readi.spc], cl  ; sectors per cluster
 15926                              <1> 	; NOTE: readi bytes per sector value is always 512 ! 
 15927 00011795 66C1E109            <1> 	shl	cx, 9 ; * 512
 15928 00011799 6649                <1> 	dec	cx ; bytes per cluster - 1
 15929 0001179B 66890D[6C960100]    <1> 	mov	[readi.bpc], cx
 15930 000117A2 6629C9              <1> 	sub	cx, cx
 15931                              <1> mget_r_3:
 15932 000117A5 A3[78960100]        <1> 	mov	[readi.fclust], eax ; first cluster (or FDT address)
 15933 000117AA 880D[64960100]      <1> 	mov	[readi.valid], cl ; 0 
 15934                              <1> 	;mov	[readi.s_index], cl ; 0
 15935                              <1> 	;mov	[readi.offset], cx ; 0
 15936 000117B0 890D[74960100]      <1> 	mov	[readi.c_index], ecx ; 0
 15937 000117B6 890D[70960100]      <1> 	mov	[readi.cluster], ecx ; 0
 15938 000117BC 890D[68960100]      <1> 	mov	[readi.sector], ecx ; 0
 15939                              <1> 	
 15940 000117C2 89D8                <1> 	mov	eax, ebx ; file offset
 15941 000117C4 668B0D[6C960100]    <1> 	mov	cx, [readi.bpc]
 15942 000117CB 41                  <1> 	inc	ecx ; <= 65536
 15943 000117CC 29D2                <1> 	sub	edx, edx
 15944 000117CE F7F1                <1> 	div	ecx
 15945                              <1> 	;mov	edi, [readi.c_index] ; previous cluster index
 15946 000117D0 29FF                <1> 	sub	edi, edi
 15947                              <1> mget_r_4:
 15948 000117D2 A3[74960100]        <1> 	mov	[readi.c_index], eax ; cluster index
 15949                              <1> 	; edx = byte offset in cluster (<= 65535)
 15950 000117D7 668915[6E960100]    <1> 	mov	[readi.offset], dx
 15951 000117DE 66C1EA09            <1> 	shr	dx, 9 ; / 512
 15952 000117E2 8815[67960100]      <1> 	mov	[readi.s_index], dl ; sector index in cluster (0 to spc -1)
 15953                              <1> 
 15954 000117E8 89C1                <1> 	mov	ecx, eax ; current cluster index
 15955 000117EA A1[78960100]        <1> 	mov	eax, [readi.fclust]
 15956 000117EF 09C9                <1> 	or	ecx, ecx ; cluster index
 15957 000117F1 741B                <1> 	jz	short mget_r_6
 15958                              <1> 
 15959 000117F3 39CF                <1> 	cmp	edi, ecx
 15960 000117F5 7710                <1> 	ja	short mget_r_5 ; old cluster index is higher
 15961 000117F7 8B15[70960100]      <1> 	mov	edx, [readi.cluster]
 15962 000117FD 21D2                <1> 	and	edx, edx
 15963 000117FF 7406                <1> 	jz	short mget_r_5
 15964                              <1> 	; valid 'readi' parameters (*)
 15965 00011801 89D0                <1> 	mov	eax, edx
 15966 00011803 29F9                <1> 	sub	ecx, edi
 15967 00011805 740C                <1> 	jz	short mget_r_7
 15968                              <1> mget_r_5:
 15969                              <1> 	; EAX = Beginning cluster
 15970                              <1> 	; EDX = Sector index in disk/file section
 15971                              <1> 	;	(Only for SINGLIX file system!)
 15972                              <1> 	; ECX = Cluster sequence number after the beginning cluster
 15973                              <1> 	; ESI = Logical DOS Drive Description Table address
 15974 00011807 E879BFFFFF          <1> 	call	get_cluster_by_index
 15975 0001180C 724E                <1> 	jc	short mget_r_err
 15976                              <1> 	; EAX = Cluster number		
 15977                              <1> mget_r_6:
 15978 0001180E A3[70960100]        <1> 	mov	[readi.cluster], eax ; FDT number for Singlix File System
 15979                              <1> mget_r_7:
 15980 00011813 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 15981 00011817 765F                <1> 	jna	short mget_r_12
 15982                              <1> 
 15983 00011819 83E802              <1> 	sub	eax, 2
 15984 0001181C 0FB615[66960100]    <1> 	movzx	edx, byte [readi.spc]
 15985 00011823 F7E2                <1> 	mul	edx
 15986                              <1> 
 15987 00011825 034668              <1> 	add	eax, [esi+LD_DATABegin]
 15988 00011828 8A15[67960100]      <1> 	mov	dl, [readi.s_index]
 15989 0001182E 01D0                <1> 	add	eax, edx
 15990                              <1> mget_r_8:
 15991                              <1> 	; eax = logical sector number
 15992 00011830 803D[64960100]00    <1> 	cmp	byte [readi.valid], 0
 15993 00011837 7608                <1> 	jna	short mget_r_9
 15994 00011839 3B05[68960100]      <1> 	cmp	eax, [readi.sector]
 15995 0001183F 7436                <1> 	je	short mget_r_11 ; sector is already in 'readi' buffer
 15996                              <1> mget_r_9:
 15997 00011841 A3[68960100]        <1> 	mov	[readi.sector], eax
 15998 00011846 BB[8C050300]        <1> 	mov	ebx, readi_buffer ; buffer address
 15999 0001184B B901000000          <1> 	mov	ecx, 1
 16000                              <1> 	; 29/04/2016
 16001                              <1> 	;xor	dl, dl
 16002                              <1> 
 16003                              <1> 	; EAX = Logical sector number
 16004                              <1> 	; ECX = Sector count
 16005                              <1> 	; EBX = Buffer address
 16006                              <1> 	; (EDX = 0)
 16007                              <1> 	; ESI = Logical DOS drive description table address	
 16008                              <1> 
 16009 00011850 E868130000          <1> 	call	disk_read
 16010 00011855 7314                <1> 	jnc	short mget_r_10
 16011                              <1> 
 16012                              <1> 	; 22/10/2016 (15h -> 17)
 16013 00011857 B811000000          <1> 	mov	eax, 17 ; Drive not ready or read error !
 16014                              <1> mget_r_err:
 16015 0001185C A3[C8030300]        <1> 	mov	[u.error], eax
 16016                              <1> 	; 12/10/2016
 16017 00011861 A3[64030300]        <1> 	mov	[u.r0], eax
 16018 00011866 E981C0FFFF          <1> 	jmp	error
 16019                              <1> mget_r_10:
 16020 0001186B C605[64960100]01    <1> 	mov	byte [readi.valid], 1 ; 24/10/2016
 16021 00011872 A1[68960100]        <1> 	mov	eax, [readi.sector]
 16022                              <1> mget_r_11:
 16023 00011877 C3                  <1> 	retn
 16024                              <1> mget_r_12:
 16025                              <1> 	; EAX = FDT number
 16026                              <1> 	; EDX = Sector index from FDT sector (0,1,2,3,4...)
 16027 00011878 40                  <1> 	inc	eax ; the first data sector in FS disk section	
 16028 00011879 8915[7C960100]      <1> 	mov	[readi.fs_index], edx
 16029 0001187F 01D0                <1> 	add	eax, edx
 16030 00011881 EBAD                <1> 	jmp	short mget_r_8
 16031                              <1> 
 16032                              <1> trans_addr_r:
 16033                              <1> 	; 12/10/2016
 16034                              <1> 	; 02/05/2016 - TRDOS 386 (TRDOS v2.0)
 16035                              <1> 	; Translate virtual address to physical address 
 16036                              <1> 	; for reading from user's memory space
 16037                              <1> 	; 04/06/2015 - 18/10/2015 (Retro UNIX 386 v1)
 16038                              <1> 
 16039 00011883 31D2                <1> 	xor	edx, edx ; 0 (read access sign)
 16040 00011885 EB04                <1> 	jmp 	short trans_addr_rw
 16041                              <1> 
 16042                              <1> trans_addr_w:
 16043                              <1> 	; 12/10/2016
 16044                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 16045                              <1> 	; Translate virtual address to physical address 
 16046                              <1> 	; for writing to user's memory space
 16047                              <1> 	; 04/06/2015 - 18/10/2015 (Retro UNIX 386 v1)
 16048                              <1> 	
 16049 00011887 29D2                <1> 	sub	edx, edx
 16050 00011889 FEC2                <1> 	inc	dl ; 1 (write access sign)
 16051                              <1> trans_addr_rw:
 16052 0001188B 50                  <1> 	push	eax
 16053 0001188C 53                  <1> 	push	ebx
 16054 0001188D 52                  <1> 	push 	edx ; r/w sign (in DL)
 16055                              <1> 	;
 16056 0001188E 8B1D[84030300]      <1> 	mov	ebx, [u.base]
 16057 00011894 E8574AFFFF          <1> 	call	get_physical_addr ; get physical address
 16058 00011899 730F                <1> 	jnc	short passc_0
 16059 0001189B A3[C8030300]        <1> 	mov	[u.error], eax
 16060 000118A0 A3[64030300]        <1> 	mov	[u.r0], eax ; 12/10/2016
 16061                              <1> 	;pop	edx
 16062                              <1> 	;pop 	ebx
 16063                              <1> 	;pop	eax
 16064 000118A5 E942C0FFFF          <1> 	jmp	error
 16065                              <1> passc_0:
 16066 000118AA F6C202              <1> 	test	dl, PTE_A_WRITE ; writable page
 16067 000118AD 5A                  <1> 	pop	edx
 16068 000118AE 751C                <1> 	jnz	short passc_1
 16069                              <1> 	
 16070 000118B0 20D2                <1> 	and 	dl, dl
 16071 000118B2 7418                <1> 	jz	short passc_1
 16072                              <1> 	; read only (duplicated) page -must be copied to a new page-
 16073                              <1> 	; EBX = linear address
 16074 000118B4 51                  <1> 	push 	ecx
 16075 000118B5 E8CF46FFFF          <1> 	call 	copy_page
 16076 000118BA 59                  <1> 	pop	ecx
 16077 000118BB 721E                <1> 	jc	short passc_2
 16078 000118BD 50                  <1> 	push	eax ; physical address of the new/allocated page
 16079 000118BE E85749FFFF          <1> 	call	add_to_swap_queue	
 16080 000118C3 58                  <1> 	pop	eax
 16081 000118C4 81E3FF0F0000        <1> 	and 	ebx, PAGE_OFF ; 0FFFh
 16082                              <1> 	;mov 	ecx, PAGE_SIZE
 16083                              <1> 	;sub	ecx, ebx 
 16084 000118CA 01D8                <1> 	add	eax, ebx  
 16085                              <1> passc_1: 
 16086 000118CC A3[C0030300]        <1> 	mov 	[u.pbase], eax ; physical address	
 16087 000118D1 66890D[C4030300]    <1> 	mov	[u.pcount], cx ; remain byte count in page (1-4096)
 16088 000118D8 5B                  <1> 	pop	ebx
 16089 000118D9 58                  <1> 	pop	eax
 16090 000118DA C3                  <1> 	retn
 16091                              <1> passc_2:
 16092 000118DB B804000000          <1> 	mov	eax, ERR_MINOR_IM ; "Insufficient memory !" error
 16093 000118E0 A3[64030300]        <1> 	mov	[u.r0], eax ; 12/10/2016
 16094 000118E5 A3[C8030300]        <1> 	mov	dword [u.error], eax
 16095                              <1> 	;pop 	ebx
 16096                              <1> 	;pop	eax
 16097 000118EA E9FDBFFFFF          <1> 	jmp	error
 16098                              <1> 
 16099                              <1> sioreg: 
 16100                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 16101                              <1> 	; 19/05/2015 - 25/07/2015 (Retro UNIX 386 v1)
 16102                              <1> 	; 12/03/2013 - 22/07/2013 (Retro UNIX 8086 v1)
 16103                              <1> 	; INPUTS -> 
 16104                              <1> 	;     EBX = system buffer (data) address (r5)
 16105                              <1> 	;     [u.fofp] = pointer to file offset pointer
 16106                              <1> 	;     [u.base] = virtual address of the user buffer
 16107                              <1> 	;     [u.pbase] = physical address of the user buffer
 16108                              <1> 	;     [u.count] = byte count
 16109                              <1> 	;     [u.pcount] = byte count within page frame 			
 16110                              <1> 	; OUTPUTS -> 
 16111                              <1> 	;     ESI = user data offset (r1)
 16112                              <1> 	;     EDI = system (I/O) buffer offset (r2)
 16113                              <1> 	;     ECX = byte count (r3)
 16114                              <1> 	;     EAX = remain bytes after byte count within page frame
 16115                              <1> 	;	(If EAX > 0, transfer will continue from the next page)
 16116                              <1>         ;
 16117                              <1> 	; ((Modified registers:  EDX))
 16118                              <1>  
 16119 000118EF 8B35[74030300]      <1>         mov     esi, [u.fofp]
 16120 000118F5 8B3E                <1>         mov     edi, [esi]
 16121 000118F7 89F9                <1> 	mov	ecx, edi
 16122 000118F9 81C900FEFFFF        <1> 	or	ecx, 0FFFFFE00h
 16123 000118FF 81E7FF010000        <1> 	and	edi, 1FFh
 16124 00011905 01DF                <1> 	add	edi, ebx ; EBX = system buffer (data) address
 16125 00011907 F7D9                <1> 	neg	ecx
 16126 00011909 3B0D[88030300]      <1> 	cmp	ecx, [u.count]
 16127 0001190F 7606                <1> 	jna	short sioreg_0
 16128 00011911 8B0D[88030300]      <1> 	mov	ecx, [u.count]
 16129                              <1> sioreg_0:
 16130 00011917 803D[C6030300]00    <1> 	cmp	byte [u.kcall], 0 
 16131 0001191E 7613                <1> 	jna	short sioreg_1
 16132                              <1> 	 ; the caller is 'mkdir' or 'namei'
 16133 00011920 A1[84030300]        <1> 	mov	eax, [u.base]
 16134 00011925 A3[C0030300]        <1> 	mov 	[u.pbase], eax ; physical address = virtual address
 16135 0001192A 66890D[C4030300]    <1> 	mov	word [u.pcount], cx ; remain bytes in buffer (1 sector)
 16136 00011931 EB0B                <1> 	jmp	short sioreg_2
 16137                              <1> sioreg_1:
 16138 00011933 0FB715[C4030300]    <1> 	movzx	edx, word [u.pcount]
 16139 0001193A 39D1                <1> 	cmp	ecx, edx	
 16140 0001193C 772A                <1> 	ja	short sioreg_4 ; transfer count > [u.pcount]
 16141                              <1> sioreg_2: ; 2:
 16142 0001193E 31C0                <1> 	xor 	eax, eax
 16143                              <1> sioreg_3:
 16144 00011940 010D[8C030300]      <1> 	add 	[u.nread], ecx
 16145 00011946 290D[88030300]      <1> 	sub 	[u.count], ecx
 16146 0001194C 010D[84030300]      <1> 	add 	[u.base], ecx
 16147 00011952 010E                <1>         add 	[esi], ecx 
 16148 00011954 8B35[C0030300]      <1> 	mov	esi, [u.pbase]
 16149 0001195A 66290D[C4030300]    <1> 	sub	[u.pcount], cx
 16150 00011961 010D[C0030300]      <1> 	add	[u.pbase], ecx
 16151 00011967 C3                  <1>         retn
 16152                              <1> sioreg_4:
 16153                              <1> 	; transfer count > [u.pcount] 
 16154                              <1> 	; (ecx > edx)
 16155 00011968 89C8                <1> 	mov	eax, ecx
 16156 0001196A 29D0                <1> 	sub	eax, edx ; remain bytes for 1 sector (block) transfer 
 16157 0001196C 89D1                <1> 	mov	ecx, edx ; current transfer count = [u.pcount]
 16158 0001196E EBD0                <1> 	jmp	short sioreg_3
 16159                              <1> 
 16160                              <1> tswitch: ; Retro UNIX 386 v1
 16161                              <1> tswap:
 16162                              <1> 	; 16/01/2017
 16163                              <1> 	; 21/05/2016 - TRDOS 386 (TRDOS v2.0)
 16164                              <1> 	; 10/05/2015 - 01/09/2015 (Retro UNIX 386 v1)
 16165                              <1> 	; 14/04/2013 - 14/02/2014 (Retro UNIX 8086 v1)
 16166                              <1> 	; time out swap, called when a user times out.
 16167                              <1> 	; the user is put on the low priority queue.
 16168                              <1> 	; This is done by making a link from the last user
 16169                              <1> 	; on the low priority queue to him via a call to 'putlu'.
 16170                              <1> 	; then he is swapped out.
 16171                              <1> 
 16172                              <1> 	; TRDOS 386 (TRDOS v2.0) modification ->  ** 21/05/2016 **
 16173                              <1> 	;     * when a high priority (event) process will be stopped
 16174                              <1> 	;	(swapped out, swithched out/off), 'tswap/tswitch' will
 16175                              <1> 	;	not add it to a run queue. 
 16176                              <1> 	;	/// What for: Process may be already in a run queue, 
 16177                              <1> 	;	it is unspeficied state because process might be started
 16178                              <1> 	;	by a timer event which does not regard previous priority
 16179                              <1> 	;	level and run queue of the process (for fast executing!).
 16180                              <1> 	;	After the 'run for event', process will be sequenced
 16181                              <1> 	;	to run by it's actual run queue. ///
 16182                              <1> 	;
 16183                              <1> 	; Retro UNIX 386 v1 modification ->
 16184                              <1> 	;       swap (software task switch) is performed by changing
 16185                              <1> 	;	user's page directory (u.pgdir) instead of segment change
 16186                              <1> 	;	as in Retro UNIX 8086 v1.
 16187                              <1> 	;
 16188                              <1> 	; RETRO UNIX 8086 v1 modification ->
 16189                              <1> 	;       'swap to disk' is replaced with 'change running segment'
 16190                              <1> 	;	according to 8086 cpu (x86 real mode) architecture.
 16191                              <1> 	;	pdp-11 was using 64KB uniform memory while IBM PC
 16192                              <1> 	;	compatibles was using 1MB segmented memory 
 16193                              <1> 	;	in 8086/8088 times.
 16194                              <1> 	;
 16195                              <1> 	; INPUTS ->
 16196                              <1> 	;    u.uno - users process number
 16197                              <1> 	;    runq+4 - lowest priority queue
 16198                              <1> 	; OUTPUTS ->
 16199                              <1> 	;    r0 - users process number
 16200                              <1> 	;    r2 - lowest priority queue address
 16201                              <1> 	;
 16202                              <1> 	; ((AX = R0, BX = R2)) output
 16203                              <1> 	; ((Modified registers: EDX, EBX, ECX, ESI, EDI))  	
 16204                              <1> 	;
 16205                              <1> 
 16206                              <1> 	NOTE:
 16207                              <1> 	;* [u.pri] priority level is specified by run queue which is process 
 16208                              <1> 	;  comes to run from.
 16209                              <1> 	;* Initial [u.pri] is 1 ('normal/regular') for programs 
 16210                              <1> 	;  (which are launched by MainProg or 'sysexec'), it is changed
 16211                              <1> 	;  to 2 ('high') by timer event, if program uses 'systimer' system call.
 16212                              <1> 	;* Program (Process) also can change it's running priority 
 16213                              <1> 	;  from 1 to 0 or up to 2 by using 'syspri' system call; but,
 16214                              <1> 	;  if program selects priority level 2 (high) for running, next time 
 16215                              <1> 	;  it is reduced to 1 (normal/regular) because 'syspri' adds this
 16216                              <1> 	;  program to 'run for normal' queue while running duration is a bit
 16217                              <1> 	;  protected from swap/switch out immediate, behalf of other high 
 16218                              <1> 	;  priority process in sequence. Program (with high priority) will not 
 16219                              <1> 	;  be swapped/switched out (by timer event) before it's time quantum 
 16220                              <1> 	;  will be elapsed, but, this will be temporary if program is not using 
 16221                              <1> 	;  timer event function.	  			 	
 16222                              <1> 
 16223                              <1> 	;For example:
 16224                              <1> 	;If a process frequently gets a timer event, it runs at high priority
 16225                              <1> 	;level but when it returns from running it returns to actual run queue,
 16226                              <1> 	;not to 'run for event' queue again.
 16227                              <1> 	;'tswap' will not change the sequence at return/stop(swap out) stage.
 16228                              <1> 	;But if priority level not high (=2, 'run for event'), 'tswap/tswitch'
 16229                              <1> 	;will add the stopping process to relevant run queue according to
 16230                              <1> 	;[u.pri] priority level.
 16231                              <1> 
 16232                              <1> 	; 16/01/2017
 16233 00011970 BB[54030300]        <1> 	mov	ebx, runq+2 	; 'runq_normal' ; normal/regular priority
 16234                              <1> 	; 21/05/2016
 16235                              <1> 	;cmp	byte [u.pri], 2	; high priority (run for event) ?
 16236                              <1> 	;jnb	short swap
 16237                              <1> 	; 16/01/2017
 16238                              <1> 	; (Normal and also high/event priority processes will be added to
 16239                              <1> 	; normal priority run queue for ensuring circular running sequence!)
 16240                              <1> 	; (Timer interrupt or 'syspri' system call may change priority and run
 16241                              <1> 	; queue to high/event level.)
 16242 00011975 803D[A9030300]00    <1> 	cmp	byte [u.pri], 0
 16243 0001197C 7702                <1> 	ja	short tswap_1	; normal priority run queue
 16244                              <1> 	;
 16245 0001197E 43                  <1> 	inc	ebx
 16246 0001197F 43                  <1> 	inc	ebx		; runq+4, 'runq_background', low priority
 16247                              <1> tswap_1:
 16248 00011980 A0[B3030300]        <1> 	mov 	al, [u.uno]
 16249                              <1> 	       	; movb u.uno,r1 / move users process number to r1
 16250                              <1> 		; mov  $runq+4,r2 
 16251                              <1> 			; / move lowest priority queue address to r2
 16252                              <1>       	; ebx = run queue
 16253 00011985 E8FE000000          <1> 	call 	putlu
 16254                              <1> 		; jsr r0,putlu / create link from last user on Q to 
 16255                              <1> 		             ; / u.uno's user
 16256                              <1> 
 16257                              <1> switch: ; Retro UNIX 386 v1
 16258                              <1> swap:
 16259                              <1> 	; 02/01/2017
 16260                              <1> 	; 21/05/2016
 16261                              <1> 	; 20/05/2016
 16262                              <1> 	; 02/05/2016
 16263                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 16264                              <1> 	; 10/05/2015 - 02/09/2015 (Retro UNIX 386 v1)
 16265                              <1> 	; 14/04/2013 - 08/03/2014 (Retro UNIX 8086 v1)
 16266                              <1> 	;
 16267                              <1> 	; 'swap' is routine that controls the swapping of processes
 16268                              <1> 	; in and out of core.
 16269                              <1> 	;
 16270                              <1> 	; TRDOS 386 (TRDOS v2.0) modification ->  ** 20/05/2016 **
 16271                              <1> 	;     * 3 different priority level is applied 
 16272                              <1> 	;	(just as original unix v1)
 16273                              <1> 	;	1) high priority (event) run queue, 'runq_event'
 16274                              <1> 	;	2) normal priority (regular) run queue, 'runq_normal'
 16275                              <1> 	;	3) low priority (background) run queue, 'runq_backgroud'
 16276                              <1> 	;	'swap' code will run a process which has max. priority
 16277                              <1>         ;       (for earliest event at first)
 16278                              <1> 	;
 16279                              <1> 	; Retro UNIX 386 v1 modification ->
 16280                              <1> 	;       swap (software task switch) is performed by changing
 16281                              <1> 	;	user's page directory (u.pgdir) instead of segment change
 16282                              <1> 	;	as in Retro UNIX 8086 v1.
 16283                              <1> 	;
 16284                              <1> 	; RETRO UNIX 8086 v1 modification ->
 16285                              <1> 	;       'swap to disk' is replaced with 'change running segment'
 16286                              <1> 	;	according to 8086 cpu (x86 real mode) architecture.
 16287                              <1> 	;	pdp-11 was using 64KB uniform memory while IBM PC
 16288                              <1> 	;	compatibles was using 1MB segmented memory 
 16289                              <1> 	;	in 8086/8088 times.
 16290                              <1> 	;
 16291                              <1> 	; INPUTS ->
 16292                              <1> 	;    runq table - contains processes to run.
 16293                              <1> 	;    p.link - contains next process in line to be run.
 16294                              <1> 	;    u.uno - process number of process in core	
 16295                              <1> 	;    s.stack - swap stack used as an internal stack for swapping.	
 16296                              <1> 	; OUTPUTS ->
 16297                              <1> 	;    (original unix v1 -> present process to its disk block)
 16298                              <1> 	;    (original unix v1 -> new process into core -> 
 16299                              <1> 	;	   Retro Unix 8086 v1 -> segment registers changed 
 16300                              <1> 	;	   for new process)
 16301                              <1> 	;    u.quant = 3 (Time quantum for a process)
 16302                              <1> 	; 	((INT 1Ch count down speed -> 18.2 times per second)	 	
 16303                              <1> 	;    RETRO UNIX 8086 v1 will use INT 1Ch (18.2 times per second)
 16304                              <1> 	;	 for now, it will swap the process if there is not
 16305                              <1> 	;	 a keyboard event (keystroke) (Int 15h, function 4Fh)
 16306                              <1> 	;	 or will count down from 3 to 0 even if there is a
 16307                              <1> 	;        keyboard event locking due to repetitive key strokes.
 16308                              <1> 	;	 u.quant will be reset to 3 for RETRO UNIX 8086 v1.
 16309                              <1> 	;
 16310                              <1> 	; ((Modified registers: EAX, EDX, EBX, ECX, ESI, EDI))  	
 16311                              <1> 
 16312                              <1> 	;NOTE:
 16313                              <1> 	;High priority queue is the first for selecting a process to run.
 16314                              <1> 	;If there is not a process in high priority level run queue,
 16315                              <1> 	;a process in normal priority run queue will be selected
 16316                              <1> 	;or a proces in low priority run queue will be selected if normal
 16317                              <1> 	;priority level run queue is empty.
 16318                              <1> 	
 16319                              <1> 	; 21/05/2016 -(3 priority levels, 3 run queues)
 16320 0001198A BE[52030300]        <1> 	mov	esi, runq ; 'runq_event' ; high priority, 'run for event'
 16321 0001198F C605[C0960100]03    <1> 	mov	byte [priority], 3 ; high priority + 1
 16322 00011996 31DB                <1> 	xor	ebx, ebx ; 02/01/2017
 16323                              <1> swap_0: ; 1: / search runq table for highest priority process
 16324 00011998 66AD                <1> 	lodsw  ; mov ax, [esi], add esi+2
 16325                              <1> 	;xor	ebx, ebx ; 02/05/2016
 16326 0001199A 6621C0              <1> 	and 	ax, ax ; are there any processes to run in this Q entry
 16327 0001199D 750E                <1> 	jnz	short swap_2 
 16328                              <1> 	; 21/05/2026
 16329                              <1> 	; runq_normal = runq+2, runq_background = runq+4
 16330 0001199F FE0D[C0960100]      <1> 	dec	byte [priority] ; 3 -> 3, 2 -> 1, 1-> 0
 16331 000119A5 75F1                <1> 	jnz	short swap_0	
 16332                              <1> 	;cmp	esi, runq+6  ; if zero compare address to end of table
 16333                              <1> 	;jb	short swap_0 ; if not at end, go back
 16334                              <1> swap_1:
 16335                              <1> 	; 02/05/2016
 16336                              <1> 	; 29/04/2016 (TRDOS 386 = TRDOS v2.0)
 16337                              <1> 	; No user process to run...
 16338                              <1> 	; Run the kernel process... MainProg: Internal Command Interpreter  
 16339 000119A7 FEC0                <1> 	inc	al ; mov al, 1  ; process number of MainProg
 16340 000119A9 FEC3                <1> 	inc	bl ; mov bl, al ; 1
 16341 000119AB EB1E                <1> 	jmp	short swap_4
 16342                              <1> swap_2:
 16343                              <1> 	; 21/05/2016
 16344 000119AD FE0D[C0960100]      <1> 	dec	byte [priority] ; priority level of present user/process
 16345                              <1> 			        ; 0, 1, 2	   
 16346 000119B3 4E                  <1> 	dec	esi
 16347 000119B4 4E                  <1>         dec     esi
 16348                              <1> 	;
 16349 000119B5 88C3                <1> 	mov	bl, al
 16350 000119B7 38E0                <1> 	cmp	al, ah ; is there only 1 process in the queue to be run
 16351 000119B9 740A                <1> 	je	short swap_3 ; yes
 16352 000119BB 8AA3[9F000300]      <1> 	mov	ah, [ebx+p.link-1] 
 16353 000119C1 8826                <1>        	mov	[esi], ah ; move next process in line into run queue
 16354 000119C3 EB06                <1> 	jmp	short swap_4
 16355                              <1> swap_3: 
 16356 000119C5 6631D2              <1> 	xor	dx, dx
 16357 000119C8 668916              <1> 	mov	[esi], dx ; zero the entry; no processes on the Q
 16358                              <1> swap_4: 
 16359 000119CB 8A25[B3030300]      <1> 	mov 	ah, [u.uno]
 16360 000119D1 38C4                <1> 	cmp	ah, al ; is this process the same as the process in core?
 16361 000119D3 743B                <1>        	je	short swap_8 ; yes, don't have to swap
 16362 000119D5 08E4                <1> 	or	ah, ah  ; is the process # = 0
 16363 000119D7 740D                <1>        	jz	short swap_6 ; 'sysexit'
 16364                              <1> 	;cmp	ah, al ;is this process the same as the process in core?
 16365                              <1>        	;je	short swap_8 ; yes, don't have to swap
 16366 000119D9 8925[60030300]      <1> 	mov	[u.usp], esp ; return  address for 'syswait' & 'sleep'
 16367 000119DF E834000000          <1> 	call	wswap   ; write out core to disk
 16368 000119E4 EB1C                <1> 	jmp 	short swap_7
 16369                              <1> swap_6:
 16370                              <1> 	; Deallocate memory pages belong to the process
 16371                              <1> 	; which is being terminated.
 16372                              <1> 	; (Retro UNIX 386 v1 modification !)
 16373                              <1> 	;
 16374 000119E6 53                  <1> 	push	ebx
 16375 000119E7 A1[B8030300]        <1> 	mov 	eax, [u.pgdir]  ; page directory of the process
 16376 000119EC 8B1D[BC030300]      <1> 	mov	ebx, [u.ppgdir] ; page directory of the parent process
 16377 000119F2 E81D43FFFF          <1> 	call	deallocate_page_dir
 16378 000119F7 A1[B4030300]        <1> 	mov	eax, [u.upage] ; 'user' structure page of the process
 16379 000119FC E8B843FFFF          <1> 	call	deallocate_page
 16380 00011A01 5B                  <1> 	pop	ebx
 16381                              <1> swap_7: 
 16382 00011A02 C0E302              <1> 	shl	bl, 2 ; * 4 
 16383 00011A05 8B83[BC000300]      <1> 	mov	eax, [ebx+p.upage-4] ; the 'u' page of the new process
 16384 00011A0B E840000000          <1> 	call	rswap ; read new process into core
 16385                              <1> swap_8: 
 16386                              <1> 	; Retro UNIX  8086 v1 modification !
 16387 00011A10 C605[A8030300]04    <1> 	mov	byte [u.quant], time_count 
 16388 00011A17 C3                  <1> 	retn
 16389                              <1> 
 16390                              <1> wswap:  ; < swap out, swap to disk >
 16391                              <1> 	; 28/02/2017 (fnsave)
 16392                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 16393                              <1> 	; 09/05/2015 (Retro UNIX 386 v1)
 16394                              <1> 	; 26/05/2013 - 08/03/2014 (Retro UNIX 8086 v1)
 16395                              <1> 	; 'wswap' writes out the process that is in core onto its 
 16396                              <1> 	; appropriate disk area.
 16397                              <1> 	;
 16398                              <1> 	; Retro UNIX 386 v1 modification ->
 16399                              <1> 	;       User (u) structure content and the user's register content
 16400                              <1> 	;	will be copied to the process's/user's UPAGE (a page for
 16401                              <1> 	;	saving 'u' structure and user registers for task switching).
 16402                              <1> 	;	u.usp - points to kernel stack address which contains
 16403                              <1> 	;		user's registers while entering system call.  
 16404                              <1> 	;	u.sp  - points to kernel stack address 
 16405                              <1> 	;		to return from system call -for IRET-.
 16406                              <1> 	;	[u.usp]+32+16 = [u.sp] 
 16407                              <1> 	;	[u.usp] -> edi, esi, ebp, esp (= [u.usp]+32), ebx, 
 16408                              <1> 	;		edx, ecx, eax, gs, fs, es, ds, -> [u.sp].
 16409                              <1> 	;
 16410                              <1> 	; Retro UNIX 8086 v1 modification ->
 16411                              <1> 	;       'swap to disk' is replaced with 'change running segment'
 16412                              <1> 	;	according to 8086 cpu (x86 real mode) architecture.
 16413                              <1> 	;	pdp-11 was using 64KB uniform memory while IBM PC
 16414                              <1> 	;	compatibles was using 1MB segmented memory 
 16415                              <1> 	;	in 8086/8088 times.
 16416                              <1> 	;
 16417                              <1> 	; INPUTS ->
 16418                              <1> 	;    u.break - points to end of program
 16419                              <1> 	;    u.usp - stack pointer at the moment of swap
 16420                              <1> 	;    core - beginning of process program		
 16421                              <1> 	;    ecore - end of core 	
 16422                              <1> 	;    user - start of user parameter area		
 16423                              <1> 	;    u.uno - user process number	
 16424                              <1> 	;    p.dska - holds block number of process	
 16425                              <1> 	; OUTPUTS ->
 16426                              <1> 	;    swp I/O queue
 16427                              <1> 	;    p.break - negative word count of process 
 16428                              <1> 	;    r1 - process disk address	
 16429                              <1> 	;    r2 - negative word count
 16430                              <1> 	;
 16431                              <1> 	; RETRO UNIX 8086 v1 input/output:
 16432                              <1> 	;
 16433                              <1> 	; INPUTS ->
 16434                              <1> 	;    u.uno - process number (to be swapped out)
 16435                              <1> 	; OUTPUTS ->
 16436                              <1> 	;    none
 16437                              <1> 	;
 16438                              <1> 	;   ((Modified registers: ECX, ESI, EDI))  
 16439                              <1> 	;
 16440                              <1> 
 16441                              <1> 	; 28/02/2017
 16442                              <1> 	;cmp	byte [multi_tasking], 0  ; Musti tasking mode ?
 16443                              <1> 	;jna	short wswp
 16444 00011A18 803D[DA030300]00    <1> 	cmp	byte [u.fpsave], 0 ; 28/02/2017
 16445 00011A1F 7606                <1> 	jna	short wswp
 16446 00011A21 DD35[DC030300]      <1> 	fnsave	[u.fpregs] ; save floating point registers (94 bytes)
 16447                              <1> wswp:
 16448 00011A27 8B3D[B4030300]      <1> 	mov	edi, [u.upage] ; process's user (u) structure page addr
 16449 00011A2D B938000000          <1> 	mov	ecx, (U_SIZE + 3) / 4
 16450 00011A32 BE[5C030300]        <1> 	mov	esi, user ; active user (u) structure	
 16451 00011A37 F3A5                <1> 	rep	movsd
 16452                              <1> 	;
 16453 00011A39 8B35[60030300]      <1> 	mov	esi, [u.usp] ; esp (system stack pointer, 
 16454                              <1> 			     ;      points to user registers)
 16455 00011A3F 8B0D[5C030300]      <1> 	mov	ecx, [u.sp]  ; return address from the system call
 16456                              <1> 			     ; (for IRET)
 16457                              <1> 			     ; [u.sp] -> EIP (user)
 16458                              <1> 			     ; [u.sp+4]-> CS (user)
 16459                              <1> 			     ; [u.sp+8] -> EFLAGS (user)
 16460                              <1> 			     ; [u.sp+12] -> ESP (user)
 16461                              <1> 			     ; [u.sp+16] -> SS (user)	
 16462 00011A45 29F1                <1> 	sub	ecx, esi     ; required space for user registers
 16463 00011A47 83C114              <1> 	add	ecx, 20	     ; +5 dwords to return from system call
 16464                              <1> 			     ; (for IRET) 	
 16465 00011A4A C1E902              <1> 	shr	ecx, 2	     		
 16466 00011A4D F3A5                <1> 	rep	movsd
 16467 00011A4F C3                  <1> 	retn
 16468                              <1> 
 16469                              <1> rswap:  ; < swap in, swap from disk >
 16470                              <1> 	; 28/02/2017 (frstor)
 16471                              <1> 	; 15/01/2017
 16472                              <1> 	; 14/01/2017
 16473                              <1> 	; 21/05/2016
 16474                              <1> 	; 03/05/2016
 16475                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 16476                              <1> 	; 09/05/2015 - 15/09/2015 (Retro UNIX 386 v1)
 16477                              <1> 	; 26/05/2013 - 08/03/2014 (Retro UNIX 8086 v1)
 16478                              <1> 	; 'rswap' reads a process whose number is in r1, 
 16479                              <1> 	; from disk into core.
 16480                              <1> 	;
 16481                              <1> 	; Retro UNIX 386 v1 modification ->
 16482                              <1> 	;       User (u) structure content and the user's register content
 16483                              <1> 	;	will be restored from process's/user's UPAGE (a page for
 16484                              <1> 	;	saving 'u' structure and user registers for task switching).
 16485                              <1> 	;	u.usp - points to kernel stack address which contains
 16486                              <1> 	;		user's registers while entering system call.  
 16487                              <1> 	;	u.sp  - points to kernel stack address 
 16488                              <1> 	;		to return from system call -for IRET-.
 16489                              <1> 	;	[u.usp]+32+16 = [u.sp] 
 16490                              <1> 	;	[u.usp] -> edi, esi, ebp, esp (= [u.usp]+32), ebx, 
 16491                              <1> 	;		edx, ecx, eax, gs, fs, es, ds, -> [u.sp].
 16492                              <1> 	;
 16493                              <1> 	; RETRO UNIX 8086 v1 modification ->
 16494                              <1> 	;       'swap to disk' is replaced with 'change running segment'
 16495                              <1> 	;	according to 8086 cpu (x86 real mode) architecture.
 16496                              <1> 	;	pdp-11 was using 64KB uniform memory while IBM PC
 16497                              <1> 	;	compatibles was using 1MB segmented memory 
 16498                              <1> 	;	in 8086/8088 times.
 16499                              <1> 	;
 16500                              <1> 	; INPUTS ->
 16501                              <1> 	;    r1 - process number of process to be read in
 16502                              <1> 	;    p.break - negative of word count of process 
 16503                              <1> 	;    p.dska - disk address of the process		
 16504                              <1> 	;    u.emt - determines handling of emt's 	
 16505                              <1> 	;    u.ilgins - determines handling of illegal instructions		
 16506                              <1> 	; OUTPUTS ->
 16507                              <1> 	;    8 = (u.ilgins)
 16508                              <1> 	;    24 = (u.emt)
 16509                              <1> 	;    swp - bit 10 is set to indicate read 
 16510                              <1> 	;		(bit 15=0 when reading is done)	
 16511                              <1> 	;    swp+2 - disk block address
 16512                              <1> 	;    swp+4 - negative word count 	
 16513                              <1> 	;      ((swp+6 - address of user structure)) 
 16514                              <1> 	;
 16515                              <1> 	; RETRO UNIX 8086 v1 input/output:
 16516                              <1> 	;
 16517                              <1> 	; INPUTS ->
 16518                              <1> 	;    AL	- new process number (to be swapped in)	 
 16519                              <1> 	; OUTPUTS ->
 16520                              <1> 	;    none
 16521                              <1> 	;
 16522                              <1> 	;   ((Modified registers: EAX, ECX, ESI, EDI, ESP)) 
 16523                              <1> 	;
 16524                              <1> 	; Retro UNIX 386 v1 - modification ! 14/05/2015
 16525 00011A50 89C6                <1> 	mov	esi, eax  ; process's user (u) structure page addr
 16526 00011A52 B938000000          <1> 	mov	ecx, (U_SIZE + 3) / 4
 16527 00011A57 BF[5C030300]        <1> 	mov	edi, user ; active user (u) structure	
 16528 00011A5C F3A5                <1> 	rep	movsd
 16529 00011A5E 58                  <1> 	pop	eax	; 'rswap' return address
 16530                              <1> 	; 
 16531                              <1> 	;cli
 16532 00011A5F 8B3D[60030300]      <1> 	mov	edi, [u.usp] ; esp (system stack pointer, 
 16533                              <1> 			     ;     points to user registers)
 16534 00011A65 89FC                <1> 	mov	esp, edi     ; 14/01/2017
 16535 00011A67 8B0D[5C030300]      <1> 	mov	ecx, [u.sp]  ; return address from the system call
 16536                              <1> 			     ; (for IRET)
 16537                              <1> 			     ; [u.sp] -> EIP (user)
 16538                              <1> 			     ; [u.sp+4]-> CS (user)
 16539                              <1> 			     ; [u.sp+8] -> EFLAGS (user)
 16540                              <1> 			     ; [u.sp+12] -> ESP (user)
 16541                              <1> 			     ; [u.sp+16] -> SS (user)		
 16542 00011A6D 29F9                <1> 	sub	ecx, edi     ; required space for user registers
 16543 00011A6F 83C114              <1> 	add	ecx, 20	     ; +5 dwords to return from system call
 16544                              <1> 			     ; (for IRET) 	
 16545 00011A72 C1E902              <1> 	shr	ecx, 2	       		
 16546 00011A75 F3A5                <1> 	rep	movsd
 16547                              <1> 	;mov	esp, [u.usp] ; 15/09/2015
 16548                              <1> 	;sti
 16549                              <1> 	; 28/02/2017
 16550                              <1> 	;cmp	byte [multi_tasking], 0  ; Musti tasking mode ?
 16551                              <1> 	;jna	short rswp_retn
 16552 00011A77 803D[DA030300]00    <1> 	cmp	byte [u.fpsave], 0
 16553 00011A7E 7606                <1> 	jna	short rswp_retn
 16554 00011A80 DD25[DC030300]      <1> 	frstor	[u.fpregs] ; restore floating point regs (94 bytes)
 16555                              <1> rswp_retn:
 16556 00011A86 50                  <1> 	push	eax	; 'rswap' return address
 16557 00011A87 C3                  <1> 	retn
 16558                              <1> 
 16559                              <1> putlu: 
 16560                              <1> 	; 20/05/2016
 16561                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 16562                              <1> 	; 10/05/2015 - 12/09/2015 (Retro UNIX 386 v1)
 16563                              <1> 	; 15/04/2013 - 23/02/2014 (Retro UNIX 8086 v1)
 16564                              <1> 	; 'putlu' is called with a process number in r1 and a pointer
 16565                              <1> 	; to lowest priority Q (runq+4) in r2. A link is created from
 16566                              <1> 	; the last process on the queue to process in r1 by putting
 16567                              <1> 	; the process number in r1 into the last process's link.
 16568                              <1> 	;
 16569                              <1> 	; INPUTS ->
 16570                              <1> 	;    r1 - user process number
 16571                              <1> 	;    r2 - points to lowest priority queue 
 16572                              <1> 	;    p.dska - disk address of the process		
 16573                              <1> 	;    u.emt - determines handling of emt's 	
 16574                              <1> 	;    u.ilgins - determines handling of illegal instructions		
 16575                              <1> 	; OUTPUTS ->
 16576                              <1> 	;    r3 - process number of last process on the queue upon
 16577                              <1> 	;	  entering putlu
 16578                              <1> 	;    p.link-1 + r3 - process number in r1
 16579                              <1> 	;    r2 - points to lowest priority queue
 16580                              <1> 	;
 16581                              <1> 	; ((Modified registers: EDX, EBX)) 
 16582                              <1> 	;
 16583                              <1> 	; / r1 = user process no.; r2 points to lowest priority queue
 16584                              <1> 
 16585                              <1> 	; EBX = r2
 16586                              <1> 	; EAX = r1 (AL=r1b)
 16587                              <1> 
 16588                              <1> 	; 20/05/2016
 16589                              <1> 	; AL = process number (1 to 16) // Retro UNIX 8086, 386 v1 // 
 16590                              <1> 	;     (max. 16 processes available for current kernel version) 
 16591                              <1> 	; EBX = run queue address ; 20/05/2016 (TRDOS 386)
 16592                              <1> 		; which is one of following addresses:
 16593                              <1> 		;  1) 'runq_event' high priority run queue	 	
 16594                              <1> 		;  2) 'runq_normal' normal/regular priority run queue
 16595                              <1> 		;  3) 'runq_background' low priority run queue
 16596                              <1> 
 16597                              <1> 	;mov	ebx, runq
 16598 00011A88 0FB613              <1> 	movzx  	edx, byte [ebx]
 16599 00011A8B 43                  <1> 	inc	ebx
 16600 00011A8C 20D2                <1> 	and	dl, dl
 16601                              <1> 		; tstb (r2)+ / is queue empty?
 16602 00011A8E 740A                <1>        	jz	short putlu_1
 16603                              <1> 		; beq 1f / yes, branch
 16604 00011A90 8A13                <1> 	mov 	dl, [ebx] ; 12/09/2015
 16605                              <1> 		; movb (r2),r3 / no, save the "last user" process number
 16606                              <1> 			     ; / in r3
 16607 00011A92 8882[9F000300]      <1>        	mov	[edx+p.link-1], al
 16608                              <1> 		; movb r1,p.link-1(r3) / put pointer to user on 
 16609                              <1> 			     ; / "last users" link
 16610 00011A98 EB03                <1> 	jmp	short putlu_2
 16611                              <1> 		; br 2f /
 16612                              <1> putlu_1: ; 1:
 16613 00011A9A 8843FF              <1> 	mov	[ebx-1], al
 16614                              <1>        		; movb r1,-1(r2) / user is only user; 
 16615                              <1> 			    ; / put process no. at beginning and at end
 16616                              <1> putlu_2: ; 2: 
 16617 00011A9D 8803                <1> 	mov	[ebx], al
 16618                              <1>        		; movb r1,(r2) / user process in r1 is now the last entry
 16619                              <1> 			     ; / on the queue
 16620 00011A9F 88C2                <1> 	mov	dl, al
 16621 00011AA1 88B2[9F000300]      <1>         mov     [edx+p.link-1], dh ; 0
 16622                              <1> 		; dec r2 / restore r2
 16623 00011AA7 C3                  <1>         retn
 16624                              <1> 		; rts r0
 16625                              <1> 
 16626                              <1> sysver:
 16627                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 16628 00011AA8 C705[64030300]0002- <1> 	mov	dword [u.r0], 200h ; AH = major version, AL = minor version 
 16628 00011AB0 0000                <1>
 16629 00011AB2 E955BEFFFF          <1> 	jmp	sysret
 16630                              <1> 
 16631                              <1> 
 16632                              <1> syspri: ; change running priority (of the process)
 16633                              <1> 	; 21/05/2016
 16634                              <1> 	; 20/05/2026 - TRDOS 386 (TRDOS v2.0)
 16635                              <1> 	; INPUT ->
 16636                              <1> 	;	BL = priority level
 16637                              <1> 	;	   0 = low running priority (running on background)
 16638                              <1> 	;	   1 = normal/regular priority (running as regular)
 16639                              <1> 	;	   2 = high/event priority (running for event)
 16640                              <1> 	;	   >2 = invalid, it will accepted as 2 (event)
 16641                              <1> 	;	   0FFh = get/return current running priority only	
 16642                              <1> 	; OUTPUT -> 	
 16643                              <1> 	;	* if current [u.pri] < 2
 16644                              <1> 	;	  if BL input < 0FFh ->
 16645                              <1> 	;	     [u.pri] is updated as in BL input (0,1,2)
 16646                              <1> 	;	  if BL input = 0FFh -> AL = [u.pri] (current)
 16647                              <1> 	;	      
 16648                              <1> 	;	* if current [u.pri] = 2
 16649                              <1> 	;	  if BL input < 0FFh -> cf = 1 & AL = 2
 16650                              <1> 	;	  if BL input = 0FFh -> cf = 0 & AL = 2  
 16651                              <1> 	;	
 16652                              <1> 	;	NOTE: 	
 16653                              <1> 	;	If [u.pri] = 2, it can not be changed to 1 or 0;
 16654                              <1> 	;	because, run queue of the running process is unspecified
 16655                              <1> 	;	at this	stage. Process might be started by a timer event
 16656                              <1> 	;	or priority might be changed to high by previous
 16657                              <1> 	;	'syspri' system	call. In both cases, the process is in
 16658                              <1> 	;	'runq_normal' or 'runq_background' queue.
 16659                              <1> 	;	As result of this fact, when the [u.quant] time quantum
 16660                              <1> 	;	of the process is elapsed or 'sysrele' system call is
 16661                              <1> 	;	instructed by the process, 'tswap' ('tswitch') procedure
 16662                              <1> 	;	will be called (to 'swap' or 'switch' out the procedure)
 16663                              <1> 	;	and it will not call 'putlu' to add the (stopping)
 16664                              <1> 	;	process to relevant run queue when [u.pri] = 2.
 16665                              <1> 	;	(Otherwise, it would be possible to add process to
 16666                              <1> 	;	a run queue while it is already in a run queue, wrongly.)
 16667                              <1>   	;
 16668                              <1> 	;	If [u.pri]< 2, 'tswap/tswitch' procedure will call 
 16669                              <1> 	;	'putlu' to add process to relevant run queue
 16670                              <1> 	;	according to [u.pri] value. ('runq_normal' for 1, 
 16671                              <1> 	;	'runq_background' for 0).
 16672                              <1> 	;
 16673                              <1> 	;	If BL input >= 2 and < 0FFh while [u.pri] < 2,
 16674                              <1> 	;	process will be added to 'runq_normal' queue and
 16675                              <1> 	;	[u.pri] will be set to 2. (in 'syspri' system call)
 16676                              <1> 	;
 16677                              <1> 
 16678 00011AB7 29C0                <1> 	sub	eax, eax ; 0
 16679 00011AB9 A3[C8030300]        <1> 	mov	[u.error], eax
 16680                              <1> 
 16681 00011ABE A0[A9030300]        <1> 	mov	al, [u.pri]
 16682 00011AC3 A3[64030300]        <1> 	mov	[u.r0], eax
 16683                              <1> 
 16684 00011AC8 FEC3                <1> 	inc	bl
 16685 00011ACA 0F843CBEFFFF        <1> 	jz	sysret ; 0FFh -> 0, get priority level
 16686                              <1> 	
 16687 00011AD0 3C02                <1> 	cmp	al, 2
 16688 00011AD2 0F8314BEFFFF        <1> 	jnb	error ; CF = 1 & AL = 2 (& last error = 0)
 16689                              <1> 
 16690 00011AD8 FECB                <1> 	dec	bl
 16691 00011ADA 80FB02              <1> 	cmp	bl, 2
 16692 00011ADD 7602                <1> 	jna	short syspri_1
 16693 00011ADF B302                <1> 	mov	bl, 2
 16694                              <1> syspri_1:
 16695 00011AE1 881D[A9030300]      <1> 	mov	[u.pri], bl
 16696 00011AE7 80FB02              <1> 	cmp	bl, 2
 16697 00011AEA 0F821CBEFFFF        <1>         jb      sysret
 16698                              <1> 
 16699                              <1> 	; here...
 16700                              <1> 	; Priority of current process has been changed to high
 16701                              <1> 	; ('run for event') but current process will be added to
 16702                              <1> 	; 'run as normal' queue. ('run for event' high priority
 16703                              <1> 	; queue is under control of timer -& RTC- interrupt only!) 
 16704                              <1> 	;
 16705                              <1> 	; (Otherwise, process can fall into black hole!
 16706                              <1> 	; e.g. if it is not in waiting list and it has not got 
 16707                              <1> 	; a timer event and it is not in a run queue!
 16708                              <1> 	; Because, when [u.pri] is 2, 'tswap/tswitch' will not 
 16709                              <1> 	; add the stopping process to a run queue.)
 16710                              <1> 
 16711 00011AF0 A0[B3030300]        <1> 	mov	al, [u.uno]
 16712 00011AF5 BB[54030300]        <1> 	mov	ebx, runq_normal ; normal priority !
 16713                              <1> 				 ; [u.pri] is set to high
 16714                              <1> 				 ; but 'runq_event' queue is set
 16715                              <1> 				 ; only by the kernel's timer
 16716                              <1> 				 ; event function (timer interrupt). 
 16717 00011AFA E889FFFFFF          <1> 	call	putlu
 16718 00011AFF E908BEFFFF          <1> 	jmp	sysret
 16719                              <1> 
 16720                              <1> cpass: ; / get next character from user area of core and put it in AL (r1)
 16721                              <1> 	; 02/05/2016 - TRDOS 386 (TRDOS v2.0)
 16722                              <1> 	; 19/05/2015 - 18/10/2015 (Retro UNIX 386 v1)
 16723                              <1> 	; 14/08/2013 - 20/09/2013 (Retro UNIX 8086 v1)
 16724                              <1> 	; INPUTS -> 
 16725                              <1> 	;     [u.base] = virtual address in user area
 16726                              <1> 	;     [u.count] = byte count (max.)
 16727                              <1> 	;     [u.pcount] = byte count in page (0 = reset)		
 16728                              <1> 	; OUTPUTS -> 
 16729                              <1> 	;     AL = the character which is pointed by [u.base]
 16730                              <1> 	;     zf = 1 -> transfer count has been completed	
 16731                              <1>         ;
 16732                              <1> 	; ((Modified registers:  EAX, EDX, ECX))
 16733                              <1> 	;
 16734 00011B04 833D[88030300]00    <1> 	cmp 	dword [u.count], 0  ; have all the characters been transferred
 16735                              <1> 			    	    ; i.e., u.count, # of chars. left
 16736 00011B0B 763F                <1> 	jna	short cpass_3	    ; to be transferred = 0?) yes, branch
 16737 00011B0D FF0D[88030300]      <1> 	dec	dword [u.count]	    ; no, decrement u.count
 16738                              <1>         ; 19/05/2015 
 16739                              <1> 	;(Retro UNIX 386 v1 - translation from user's virtual address
 16740                              <1> 	;		      to physical address
 16741 00011B13 66833D[C4030300]00  <1> 	cmp	word [u.pcount], 0 ; byte count in page = 0 (initial value)
 16742                              <1> 			     ; 1-4095 --> use previous physical base address
 16743                              <1> 			     ; in [u.pbase]
 16744 00011B1B 770E                <1> 	ja	short cpass_1
 16745 00011B1D 833D[BC030300]00    <1> 	cmp     dword [u.ppgdir], 0 ; is the caller os kernel
 16746 00011B24 7427                <1>         je      short cpass_k       ; (sysexec, '/etc/init') ?  (MainProg)
 16747 00011B26 E858FDFFFF          <1> 	call	trans_addr_r
 16748                              <1> cpass_1:
 16749 00011B2B 66FF0D[C4030300]    <1> 	dec	word [u.pcount]
 16750                              <1> cpass_2: 
 16751 00011B32 8B15[C0030300]      <1> 	mov	edx, [u.pbase]
 16752 00011B38 8A02                <1> 	mov	al, [edx]	; take the character pointed to 
 16753                              <1> 				; by u.base and put it in r1
 16754 00011B3A FF05[8C030300]      <1> 	inc	dword [u.nread] ; increment no. of bytes transferred
 16755 00011B40 FF05[84030300]      <1> 	inc	dword [u.base]  ; increment the buffer address to point to the
 16756                              <1> 			        ; next byte
 16757 00011B46 FF05[C0030300]      <1> 	inc	dword [u.pbase]
 16758                              <1> cpass_3:
 16759 00011B4C C3                  <1> 	retn
 16760                              <1> cpass_k:
 16761                              <1> 	; 02/07/2015
 16762                              <1> 	; The caller is os kernel 
 16763                              <1> 	; (get sysexec arguments from kernel's memory space)
 16764 00011B4D 8B1D[84030300]      <1> 	mov	ebx, [u.base]
 16765 00011B53 66C705[C4030300]00- <1>         mov     word [u.pcount], PAGE_SIZE ; 4096
 16765 00011B5B 10                  <1>
 16766 00011B5C 891D[C0030300]      <1> 	mov	[u.pbase], ebx
 16767 00011B62 EBCE                <1> 	jmp	short cpass_2
 16768                              <1> 
 16769                              <1> transfer_to_user_buffer: ; fast transfer
 16770                              <1> 	; 27/05/2016
 16771                              <1> 	; 16/05/2016 - TRDOS 386 (TRDOS v2.0)
 16772                              <1> 	;
 16773                              <1> 	; INPUT ->
 16774                              <1> 	;	ESI = source address in system space
 16775                              <1> 	;	EDI = user's buffer address
 16776                              <1> 	;	ECX = transfer (byte) count
 16777                              <1> 	;	[u.pgdir] = user's page directory
 16778                              <1> 	; OUTPUT ->
 16779                              <1> 	;	ECX = actual transfer count
 16780                              <1> 	;	cf = 1 -> error
 16781                              <1> 	;	[u.count] = remain byte count
 16782                              <1> 	;
 16783                              <1> 	; Modified registers: eax, ecx
 16784                              <1> 	;
 16785                              <1> 
 16786 00011B64 21C9                <1> 	and	ecx, ecx
 16787 00011B66 743B                <1> 	jz	short ttub_4
 16788                              <1> 
 16789 00011B68 890D[88030300]      <1> 	mov	[u.count], ecx
 16790                              <1> 	
 16791 00011B6E 57                  <1> 	push	edi
 16792 00011B6F 56                  <1> 	push	esi
 16793 00011B70 53                  <1> 	push	ebx
 16794 00011B71 52                  <1> 	push	edx
 16795 00011B72 51                  <1> 	push	ecx
 16796                              <1> 
 16797 00011B73 89FB                <1> 	mov	ebx, edi
 16798 00011B75 81C300004000        <1> 	add	ebx, CORE ; 27/05/2016
 16799                              <1> ttub_1:
 16800                              <1> 	; ebx = virtual (linear) address
 16801                              <1> 	; [u.pgdir] = user's page directory
 16802 00011B7B E87647FFFF          <1>        	call	get_physical_addr_x ; get physical address
 16803 00011B80 7222                <1> 	jc	short ttub_5
 16804                              <1> 	; eax = physical address 
 16805                              <1> 	; ecx = remain byte count in page (1-4096)
 16806 00011B82 89C7                <1> 	mov	edi, eax
 16807 00011B84 A1[88030300]        <1> 	mov	eax, [u.count]
 16808 00011B89 39C1                <1> 	cmp	ecx, eax
 16809 00011B8B 7602                <1> 	jna	short ttub_2
 16810 00011B8D 89C1                <1> 	mov	ecx, eax
 16811                              <1> ttub_2:	
 16812 00011B8F 29C8                <1> 	sub	eax, ecx
 16813 00011B91 01CB                <1> 	add	ebx, ecx
 16814 00011B93 F3A4                <1> 	rep	movsb
 16815 00011B95 A3[88030300]        <1> 	mov	[u.count], eax
 16816 00011B9A 09C0                <1> 	or	eax, eax
 16817 00011B9C 75DD                <1> 	jnz	short ttub_1
 16818                              <1> ttub_retn:
 16819                              <1> tfub_retn:
 16820 00011B9E 59                  <1> 	pop	ecx ; transfer count = actual transfer count
 16821                              <1> ttub_3:
 16822 00011B9F 5A                  <1> 	pop	edx
 16823 00011BA0 5B                  <1> 	pop	ebx
 16824 00011BA1 5E                  <1> 	pop	esi
 16825 00011BA2 5F                  <1> 	pop	edi
 16826                              <1> ttub_4:
 16827 00011BA3 C3                  <1> 	retn
 16828                              <1> ttub_5:
 16829 00011BA4 59                  <1> 	pop	ecx
 16830 00011BA5 2B0D[88030300]      <1> 	sub	ecx, [u.count] ; actual transfer count
 16831 00011BAB F9                  <1> 	stc
 16832 00011BAC EBF1                <1> 	jmp	short ttub_3
 16833                              <1> 
 16834                              <1> transfer_from_user_buffer: ; fast transfer
 16835                              <1> 	; 27/05/2016
 16836                              <1> 	; 16/05/2016 - TRDOS 386 (TRDOS v2.0)
 16837                              <1> 	;
 16838                              <1> 	; INPUT ->
 16839                              <1> 	;	ESI = user's buffer address
 16840                              <1> 	;	EDI = destination address in system space
 16841                              <1> 	;	ECX = transfer (byte) count
 16842                              <1> 	;	[u.pgdir] = user's page directory
 16843                              <1> 	; OUTPUT ->
 16844                              <1> 	;	ecx = actual transfer count
 16845                              <1> 	;	cf = 1 -> error
 16846                              <1> 	;	[u.count] = remain byte count
 16847                              <1> 	;
 16848                              <1> 	; Modified registers: eax, ecx
 16849                              <1> 	;
 16850                              <1> 
 16851 00011BAE 21C9                <1> 	and	ecx, ecx
 16852                              <1> 	;jz	short tfub_4
 16853 00011BB0 74F1                <1> 	jz	short ttub_4
 16854                              <1> 
 16855 00011BB2 890D[88030300]      <1> 	mov	[u.count], ecx
 16856                              <1> 	
 16857 00011BB8 57                  <1> 	push	edi
 16858 00011BB9 56                  <1> 	push	esi
 16859 00011BBA 53                  <1> 	push	ebx
 16860 00011BBB 52                  <1> 	push	edx
 16861 00011BBC 51                  <1> 	push	ecx
 16862                              <1> 
 16863 00011BBD 89F3                <1> 	mov	ebx, esi
 16864 00011BBF 81C300004000        <1> 	add	ebx, CORE ; 27/05/2016
 16865                              <1> tfub_1:
 16866                              <1> 	; ebx = virtual (linear) address
 16867                              <1> 	; [u.pgdir] = user's page directory
 16868 00011BC5 E82C47FFFF          <1>        	call	get_physical_addr_x ; get physical address
 16869                              <1> 	;jc	short tfub_5
 16870 00011BCA 72D8                <1> 	jc	short ttub_5
 16871                              <1> 	; eax = physical address 
 16872                              <1> 	; ecx = remain byte count in page (1-4096)
 16873 00011BCC 89C6                <1> 	mov	esi, eax
 16874 00011BCE A1[88030300]        <1> 	mov	eax, [u.count]
 16875 00011BD3 39C1                <1> 	cmp	ecx, eax
 16876 00011BD5 7602                <1> 	jna	short tfub_2
 16877 00011BD7 89C1                <1> 	mov	ecx, eax
 16878                              <1> tfub_2:	
 16879 00011BD9 29C8                <1> 	sub	eax, ecx
 16880 00011BDB 01CB                <1> 	add	ebx, ecx
 16881 00011BDD F3A4                <1> 	rep	movsb
 16882 00011BDF A3[88030300]        <1> 	mov	[u.count], eax
 16883 00011BE4 09C0                <1> 	or	eax, eax
 16884 00011BE6 75DD                <1> 	jnz	short tfub_1
 16885                              <1> 
 16886 00011BE8 EBB4                <1> 	jmp	short tfub_retn
 16887                              <1> 
 16888                              <1> ;tfub_retn:
 16889                              <1> ;	pop	ecx ; transfer count = actual transfer count
 16890                              <1> ;tfub_3:
 16891                              <1> ;	pop	edx
 16892                              <1> ;	pop	ebx
 16893                              <1> ;	pop	esi
 16894                              <1> ;	pop	edi
 16895                              <1> ;tfub_4:
 16896                              <1> ;	retn
 16897                              <1> ;tfub_5:
 16898                              <1> ;	pop	ecx
 16899                              <1> ;	sub	ecx, [u.count] ; actual transfer count
 16900                              <1> ;	stc
 16901                              <1> ;	jmp	short tfub_3
 16902                              <1> 
 16903                              <1> sysfff: ; <Find First File>
 16904                              <1> 	; 17/10/2016
 16905                              <1> 	; 16/10/2016
 16906                              <1> 	; 15/10/2016 TRDOS 386 (TRDOS v2.0) feature only ! 
 16907                              <1> 	;           -derived from TRDOS v1.0, INT_21H.ASM-
 16908                              <1> 	;            ("loc_INT21h_find_first_file")
 16909                              <1> 	; TRDOS 8086 (v1.0)
 16910                              <1>         ; 	07/08/2011 
 16911                              <1>         ;	Find First File
 16912                              <1> 	;	INPUT:
 16913                              <1>         ;	    CX= Attributes
 16914                              <1>         ;	    DS:DX= Pointer to filename
 16915                              <1> 	;	MSDOS OUTPUT:
 16916                              <1> 	;	    DTA: (Default address: PSP offset 80h)
 16917                              <1> 	;	    Offset  Descrription
 16918                              <1> 	;	    0	    Reserved for use find next file
 16919                              <1> 	;	    21	    Attribute of file found
 16920                              <1> 	;	    22	    Time stamp of file
 16921                              <1> 	;	    24	    Date stamp of file
 16922                              <1> 	;	    26	    File size in bytes
 16923                              <1> 	;	    30	    Filename and extension (zero terminated)
 16924                              <1> 	;	If cf = 1:
 16925                              <1> 	;	    Error Codes: (in AX)
 16926                              <1> 	;	    	2 - File not found
 16927                              <1> 	;	       18 - No more files  			
 16928                              <1>         ;
 16929                              <1> 	; TRDOS 386 (v2.0) 
 16930                              <1> 	; 15/10/2016
 16931                              <1> 	;	
 16932                              <1>         ; INPUT ->
 16933                              <1>         ;	   CL = File attributes
 16934                              <1> 	;     	      bit 0 (1) - Read only file (R)
 16935                              <1> 	;             bit 1 (1) - Hidden file (H)
 16936                              <1>         ;             bit 2 (1) - System file (R)
 16937                              <1> 	;             bit 3 (1) - Volume label/name (V)
 16938                              <1>         ;             bit 4 (1) - Subdirectory (D)
 16939                              <1> 	;	      bit 5 (1) - File has been archived (A)
 16940                              <1> 	;	   CH = 0 -> Return basic parameters (24 bytes)
 16941                              <1> 	;	   CH > 0 -> Return FindFile structure/table (128 bytes)
 16942                              <1>         ;          EBX = Pointer to filename (ASCIIZ) -path-
 16943                              <1> 	;	   EDX = File parameters buffer address
 16944                              <1> 	;		(buffer size = 24 bytes if CH input = 0)
 16945                              <1> 	;		(buffer size = 128 bytes if CH input > 0)
 16946                              <1> 	;		 
 16947                              <1> 	; OUTPUT ->
 16948                              <1> 	;	   EAX = 0 if CH input > 0
 16949                              <1> 	;	   EAX = First cluster number of file if CH input = 0	
 16950                              <1> 	;	   EDX = File parameters table/structure address
 16951                              <1> 	;	   Basic Parameters:
 16952                              <1> 	;		Offset  Description
 16953                              <1> 	;		------	---------------
 16954                              <1> 	;		0	File Attributes
 16955                              <1> 	;		1	Ambiguous filename chars are used sign
 16956                              <1> 	;			(0 = filename fits exactly with request)
 16957                              <1> 	;			(>0 = ambiguous filename chars are used)
 16958                              <1> 	;	      	2	Time stamp of file
 16959                              <1> 	;		4	Date stamp of file
 16960                              <1> 	;		6	File size in bytes
 16961                              <1> 	;		10	Short Filename (ASCIIZ, max. 13 bytes)
 16962                              <1> 	;		23	Longname Length (1-255) if existing 
 16963                              <1> 	;  
 16964                              <1> 	;          cf = 1 -> Error code in AL
 16965                              <1> 	;
 16966                              <1> 	; Modified Registers: EAX (at the return of system call)
 16967                              <1> 	;  
 16968                              <1> 	; TR-DOS FindFile (FFF) Structure (128 bytes):
 16969                              <1> 	; 09/10/2011 (DIR.ASM) - 10/02/2016 (trdoskx.s)
 16970                              <1> 	;	
 16971                              <1> 	; Offset	Parameter		Size
 16972                              <1> 	; ------	------------------	-------- 
 16973                              <1> 	; 0		FindFile_Drv		1 byte
 16974                              <1> 	; 1		FindFile_Directory	65 bytes
 16975                              <1> 	; 66		FindFile_Name		13 bytes
 16976                              <1> 	; 79		FindFile_LongNameEntryLength 1 byte
 16977                              <1> 	;Above 80 bytes form
 16978                              <1> 	;TR-DOS Source/Destination File FullName Format/Structure
 16979                              <1> 	; 80		FindFile_AttributesMask 1 word
 16980                              <1> 	; 82		FindFile_DirEntry	32 bytes (*)
 16981                              <1> 	; 114		FindFile_DirFirstCluster 1 double word
 16982                              <1> 	; 118		FindFile_DirCluster	1 double word
 16983                              <1> 	; 122		FindFile_DirEntryNumber 1 word
 16984                              <1> 	; 124		FindFile_MatchCounter	1 word
 16985                              <1> 	; 126		FindFile_Reserved	1 word
 16986                              <1>    	; (*) MS-DOS, FAT 12-16-32 classic directory entry (32 bytes)
 16987                              <1> 
 16988                              <1> 	;mov	[u.namep], ebx
 16989                              <1> 	; 16/10/2016
 16990 00011BEA 8915[E0960100]      <1> 	mov	[FFF_UBuffer], edx
 16991 00011BF0 66890D[E5960100]    <1> 	mov	[FFF_Attrib], cx ; [FFF_RType] = ch
 16992                              <1> 		    ; Attributes in CL, return data type in CH
 16993 00011BF7 89DE                <1> 	mov	esi, ebx
 16994                              <1> 	; file name is forced, change directory as temporary
 16995                              <1> 	;mov	ax, 1
 16996                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset ; 17/10/2016
 16997                              <1> 	;call	set_working_path 
 16998 00011BF9 E8E2130000          <1> 	call	set_working_path_x ; 17/10/2016	
 16999 00011BFE 731D                <1> 	jnc	short sysfff_0
 17000                              <1>  
 17001 00011C00 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 17002 00011C02 7505                <1> 	jnz	short sysfff_err
 17003                              <1> 
 17004                              <1> 	; eax = 0
 17005 00011C04 B80C000000          <1> 	mov	eax, ERR_DIR_NOT_FOUND ; Directory not found !
 17006                              <1> sysfff_err:
 17007 00011C09 A3[64030300]        <1> 	mov	[u.r0], eax
 17008 00011C0E A3[C8030300]        <1> 	mov	[u.error], eax
 17009 00011C13 E89D140000          <1>         call 	reset_working_path
 17010 00011C18 E9CFBCFFFF          <1> 	jmp	error
 17011                              <1> 
 17012                              <1> sysfff_0:
 17013                              <1> 	;sub	ah, ah ; ah = 0
 17014 00011C1D 8A0424              <1> 	mov	al, [esp]
 17015 00011C20 08C0                <1> 	or	al, al
 17016 00011C22 7412                <1> 	jz	short sysfff_2
 17017 00011C24 B410                <1> 	mov	ah, 10h
 17018 00011C26 A808                <1> 	test	al, 08h
 17019 00011C28 7503                <1> 	jnz	short sysfff_1
 17020 00011C2A 80CC08              <1> 	or	ah, 08h
 17021                              <1> sysfff_1:
 17022 00011C2D 2410                <1> 	and	al, 10h ; Directory
 17023 00011C2F 7405                <1> 	jz	short sysfff_2
 17024 00011C31 80E408              <1> 	and	ah, 08h
 17025 00011C34 30C0                <1> 	xor	al, al ; When a directory is searched,
 17026                              <1> 		       ; filename will be returned even if
 17027                              <1> 		       ; it is not a directory!
 17028                              <1> 		       ; Because: (in order to prevent
 17029                              <1> 		       ; creating a dir with existing file name)
 17030                              <1> 		       ; Dir and file names must not be same!
 17031                              <1> 		       ; (return attribute must be checked)  	  	 	
 17032                              <1> sysfff_2:
 17033                              <1> 	; AX = Attributes mask 
 17034                              <1> 		; AL = AND mask (result must be equal to AL)
 17035                              <1> 		; AH = Negative AND mask (result must be ZERO)			
 17036                              <1>  	; ESI = FindFile_Name address
 17037                              <1> 
 17038 00011C36 E85678FFFF          <1> 	call	find_first_file
 17039 00011C3B 72CC                <1> 	jc	short sysfff_err ; eax = 2 (File not found !)
 17040                              <1> 
 17041                              <1> 	; ESI = Directory Entry (FindFile_DirEntry) Location
 17042                              <1> 	; EDI = Directory Buffer Directory Entry Location
 17043                              <1> 	; EAX = File Size
 17044                              <1> 	;  BL = Attributes of The File/Directory
 17045                              <1> 	;  BH = Long Name Yes/No Status (>0 is YES)
 17046                              <1> 	;  DX > 0 : Ambiguous filename chars are used
 17047                              <1> 
 17048                              <1> sysfff_3:
 17049                              <1> 	; 16/10/2016
 17050 00011C3D 668B0D[E5960100]    <1> 	mov	cx, [FFF_Attrib]
 17051                              <1> 	; Attribs in CL, return data type in CH
 17052                              <1> 
 17053                              <1> 	;or	cl, cl
 17054                              <1> 	;jz	short sysfff_4 ; 0 = No filter
 17055 00011C44 80F1FF              <1> 	xor	cl, 0FFh
 17056 00011C47 20D9                <1> 	and	cl, bl
 17057 00011C49 7409                <1> 	jz	short sysfff_4
 17058                              <1> 
 17059                              <1> 	;mov	eax, 2 ; 'file not found !' error
 17060                              <1> 	;jmp	short sysfff_err_1
 17061                              <1> 
 17062                              <1> 	; 16/10/2016
 17063 00011C4B E8F078FFFF          <1> 	call	find_next_file
 17064 00011C50 72B7                <1> 	jc	short sysfff_err ; eax = 12 (no more files !)
 17065 00011C52 EBE9                <1> 	jmp	short sysfff_3
 17066                              <1> 
 17067                              <1> sysfff_4:
 17068 00011C54 20ED                <1> 	and	ch, ch ; [FFF_RType]
 17069 00011C56 7412                <1> 	jz	short sysfff_5
 17070 00011C58 B980000000          <1> 	mov	ecx, 128 ; ; transfer length
 17071 00011C5D 880D[E4960100]      <1> 	mov	[FFF_Valid], cl
 17072                              <1> sysfnf_11:
 17073 00011C63 BE[96930100]        <1> 	mov	esi, FindFile_Drv
 17074 00011C68 EB44                <1> 	jmp	short sysfff_6	
 17075                              <1> sysfff_5:
 17076                              <1> 	;mov	esi, FindFile_DirEntry
 17077 00011C6A B918000000          <1> 	mov	ecx, 24  ; transfer length
 17078 00011C6F 880D[E4960100]      <1> 	mov	[FFF_Valid], cl
 17079                              <1> sysfnf_12:
 17080 00011C75 BF[A09B0100]        <1> 	mov	edi, DTA ; FFF data transfer address
 17081                              <1> 	;mov	al, [esi+DirEntry_Attr] ; 11
 17082 00011C7A 88D8                <1> 	mov	al, bl ; File/Dir Attributes
 17083 00011C7C 887F17              <1> 	mov	[edi+23], bh ; Longname length (0= none)
 17084 00011C7F AA                  <1> 	stosb
 17085 00011C80 88D0                <1> 	mov	al, dl ; DL is for '?'
 17086 00011C82 00F0                <1> 	add	al, dh ; DH is for '*'
 17087                              <1> 	; AL > 0 if ambiguous file name wildcards are used
 17088 00011C84 AA                  <1> 	stosb
 17089 00011C85 8B4616              <1> 	mov	eax, [esi+DirEntry_WrtTime] ; 22	
 17090 00011C88 AB                  <1>         stosd	; DirEntry_WrtTime & DirEntry_WrtDate
 17091 00011C89 8B461C              <1>         mov	eax, [esi+DirEntry_FileSize] ; 28
 17092 00011C8C AB                  <1>         stosd
 17093 00011C8D 668B4614            <1> 	mov	ax, [esi+DirEntry_FstClusHI] ; 20
 17094 00011C91 66C1E010            <1> 	shl	ax, 16
 17095 00011C95 668B461A            <1> 	mov	ax, [esi+DirEntry_FstClusLO] ; 26 
 17096 00011C99 A3[64030300]        <1> 	mov	[u.r0], eax ; First Cluster
 17097                              <1> 
 17098                              <1>         ;mov	esi, FindFile_DirEntry
 17099 00011C9E E84F140000          <1> 	call	get_file_name
 17100                              <1> 
 17101 00011CA3 8A0D[E4960100]      <1> 	mov	cl, [FFF_Valid]
 17102 00011CA9 BE[A09B0100]        <1>        	mov	esi, DTA ; FFF data transfer address
 17103                              <1> sysfff_6:
 17104 00011CAE 8B3D[E0960100]      <1> 	mov	edi, [FFF_UBuffer] ; user's buffer address (edx)
 17105 00011CB4 E8ABFEFFFF          <1> 	call	transfer_to_user_buffer
 17106                              <1> 
 17107 00011CB9 890D[64030300]      <1> 	mov	[u.r0], ecx ; actual transfer count
 17108 00011CBF E8F1130000          <1>         call 	reset_working_path
 17109 00011CC4 E943BCFFFF          <1> 	jmp	sysret
 17110                              <1> 
 17111                              <1> sysfnf: ; <Find Next File>
 17112                              <1> 	; 16/10/2016 TRDOS 386 (TRDOS v2.0) feature only ! 
 17113                              <1> 	;           -derived from TRDOS v1.0, INT_21H.ASM-
 17114                              <1> 	;            ("loc_INT21h_find_next_file")
 17115                              <1> 	; TRDOS 8086 (v1.0)
 17116                              <1>         ; 	07/08/2011 
 17117                              <1>         ;	Find First File
 17118                              <1> 	;	INPUT:
 17119                              <1>         ;	    none
 17120                              <1> 	;	MSDOS OUTPUT:
 17121                              <1> 	;	    DTA: (Default address: PSP offset 80h)
 17122                              <1> 	;	    Offset  Descrription
 17123                              <1> 	;	    0	    Reserved for use find next file
 17124                              <1> 	;	    21	    Attribute of file found
 17125                              <1> 	;	    22	    Time stamp of file
 17126                              <1> 	;	    24	    Date stamp of file
 17127                              <1> 	;	    26	    File size in bytes
 17128                              <1> 	;	    30	    Filename and extension (zero terminated)
 17129                              <1> 	;	If cf = 1:
 17130                              <1> 	;	    Error Codes: (in AX)
 17131                              <1> 	;	       18 - No more files  			
 17132                              <1>         ;
 17133                              <1> 	; TRDOS 386 (v2.0) 
 17134                              <1> 	; 16/10/2016
 17135                              <1> 	;	
 17136                              <1>         ; INPUT ->
 17137                              <1>        	; 	   none
 17138                              <1> 	; OUTPUT ->
 17139                              <1> 	;	   EAX = 0 if CH input of 'Find First File' > 0
 17140                              <1> 	;	   EAX = First cluster number of file
 17141                              <1> 	;		 if CH input of 'Find First File' = 0	
 17142                              <1> 	;	   EDX = File parameters table/structure address
 17143                              <1> 	;
 17144                              <1> 	;          cf = 1 -> Error code in AL
 17145                              <1> 	;
 17146                              <1>  	; Modified Registers: EAX (at the return of system call)	
 17147                              <1> 
 17148                              <1> 	;	
 17149                              <1> 	; Note: If byte [FFF_Valid] = 0
 17150                              <1> 	;	'sysfnf' will return with 'no more files' error.
 17151                              <1> 	;	If byte [FFF_Valid] = 24
 17152                              <1> 	;	'sysfnf' will return with 32 bytes basic parameters
 17153                              <1> 	;	at the address which is in EDX.
 17154                              <1> 	;	If byte [FFF_Valid] = 128
 17155                              <1> 	;	'sysfnf' will return with 128 bytes Find File 
 17156                              <1> 	;	Structure/Table at the address which is in EDX.
 17157                              <1> 	
 17158 00011CC9 803D[E4960100]00    <1> 	cmp	byte [FFF_Valid], 0
 17159 00011CD0 7714                <1> 	ja	short stsfnf_0
 17160                              <1>  	; 'no more files !' error 
 17161 00011CD2 B80C000000          <1> 	mov	eax, ERR_NO_MORE_FILES ; 12
 17162 00011CD7 A3[64030300]        <1> 	mov	[u.r0], eax
 17163 00011CDC A3[C8030300]        <1> 	mov	[u.error], eax
 17164 00011CE1 E906BCFFFF          <1> 	jmp	error
 17165                              <1> stsfnf_0:
 17166                              <1> 	;cmp	byte [FFF_Valid], 128
 17167                              <1> 	;je	short stsfnf_1
 17168                              <1> 	;cmp	byte [FFF_Valid], 24
 17169                              <1> 	;je	short stsfnf_1
 17170                              <1> 	;mov	[FFF_Valid], 24 ; Default
 17171                              <1> stsfnf_1:
 17172 00011CE6 0FB61D[F68A0100]    <1> 	movzx	ebx, byte [Current_Drv]
 17173 00011CED 66891D[EA960100]    <1> 	mov	[SWP_DRV], bx
 17174 00011CF4 8A15[96930100]      <1> 	mov	dl, [FindFile_Drv]
 17175 00011CFA 38DA                <1> 	cmp	dl, bl
 17176 00011CFC 750B                <1> 	jne	short stsfnf_2
 17177 00011CFE 86FB                <1> 	xchg	bh, bl
 17178 00011D00 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 17179 00011D05 01DE                <1> 	add	esi, ebx
 17180 00011D07 EB0D                <1> 	jmp	short sysfnf_3
 17181                              <1> 
 17182                              <1> stsfnf_2:
 17183 00011D09 FE05[EB960100]      <1> 	inc	byte [SWP_DRV_chg]
 17184                              <1> 
 17185 00011D0F E8DA63FFFF          <1> 	call	change_current_drive
 17186 00011D14 7245                <1> 	jc	short sysfnf_err_1 ; read error ! 
 17187                              <1> 				   ; (do not stop, because
 17188                              <1> 				   ; we don't have a
 17189                              <1> 				   ; 'no more files'
 17190                              <1> 				   ; -file not found- error,	
 17191                              <1> 				   ; next sysfnf system call
 17192                              <1> 				   ; may solve the problem,
 17193                              <1> 				   ; after re-placing the disk)				
 17194                              <1> sysfnf_3:
 17195 00011D16 A1[0C940100]        <1> 	mov	eax, [FindFile_DirCluster]
 17196 00011D1B 21C0                <1> 	and	eax, eax
 17197 00011D1D 7550                <1> 	jnz	short sysfnf_6
 17198                              <1>         
 17199 00011D1F 803D[F58A0100]02    <1> 	cmp	byte [Current_FATType], 2
 17200 00011D26 772C                <1> 	ja	short sysfnf_err_0 ; invalid, we neeed to stop !?
 17201 00011D28 803D[F58A0100]01    <1> 	cmp	byte [Current_FATType], 1
 17202 00011D2F 7223                <1> 	jb	short sysfnf_err_0 ; invalid, we neeed to stop !?
 17203                              <1> 
 17204 00011D31 3805[1C920100]      <1> 	cmp	byte [DirBuff_ValidData], al ; 0
 17205 00011D37 7608                <1> 	jna	short sysfnf_4 
 17206                              <1> 
 17207 00011D39 3B05[21920100]      <1> 	cmp	eax, [DirBuff_Cluster] ; 0 ?
 17208 00011D3F 745E                <1> 	je	short sysfnf_9
 17209                              <1> 
 17210                              <1> 	;cmp	byte [Current_Dir_Level], 0
 17211                              <1>         ;ja	short sysfnf_4  
 17212                              <1>         ;jna	short sysfnf_9 
 17213                              <1> 
 17214                              <1> sysfnf_4:
 17215 00011D41 FE05[EB960100]      <1> 	inc	byte [SWP_DRV_chg]
 17216 00011D47 E885B1FFFF          <1> 	call 	load_FAT_root_directory
 17217 00011D4C 7351                <1> 	jnc	short sysfnf_9
 17218                              <1> 	; eax = error code (17, 'drv not ready or read error')
 17219 00011D4E EB0B                <1> 	jmp	short sysfnf_err_1 ; read error ! (no FNF stop)
 17220                              <1> 				   ; (if you want, try again, 
 17221                              <1> 				   ;  after re-placing the disk)
 17222                              <1> sysfnf_5:	
 17223 00011D50 3C0C                <1> 	cmp	al, 12 ; 'no more files' error
 17224 00011D52 7507                <1> 	jne	short sysfnf_err_1 ; (no FNF stop -sysfnf will try
 17225                              <1> 				   ;  to read the directory again,
 17226                              <1> 				   ;  if the user calls sysfnf
 17227                              <1> 				   ;  just after this error return-)
 17228                              <1> 	; (FNF stop -sysfnf will not try
 17229                              <1> 	;  to read the directory again-)	
 17230                              <1> 
 17231                              <1> sysfnf_err_0:
 17232 00011D54 C605[E4960100]00    <1> 	mov	byte [FFF_Valid], 0 ; FNF stop sign
 17233                              <1> sysfnf_err_1:
 17234 00011D5B A3[64030300]        <1> 	mov	[u.r0], eax
 17235 00011D60 A3[C8030300]        <1> 	mov	[u.error], eax
 17236 00011D65 E84B130000          <1> 	call	reset_working_path
 17237 00011D6A E97DBBFFFF          <1> 	jmp	error
 17238                              <1> 	  
 17239                              <1> sysfnf_6:
 17240 00011D6F 803D[1C920100]00    <1> 	cmp	byte [DirBuff_ValidData], 0
 17241 00011D76 7608                <1> 	jna	short sysfnf_7
 17242                              <1> 
 17243 00011D78 3B05[21920100]      <1> 	cmp	eax, [DirBuff_Cluster]
 17244 00011D7E 741F                <1> 	je	short sysfnf_9
 17245                              <1> 
 17246                              <1> sysfnf_7:
 17247 00011D80 FE05[EB960100]      <1> 	inc	byte [SWP_DRV_chg]
 17248 00011D86 803D[F58A0100]01    <1> 	cmp	byte [Current_FATType], 1
 17249 00011D8D 7309                <1> 	jnb	short sysfnf_8
 17250                              <1> 
 17251                              <1> 	; Singlix (TRFS) File System 
 17252                              <1> 	; (access via compatibility buffer)
 17253 00011D8F E805B2FFFF          <1> 	call	load_FS_sub_directory
 17254 00011D94 7309                <1> 	jnc	short sysfnf_9
 17255                              <1> 
 17256 00011D96 EBC3                <1> 	jmp	short sysfnf_err_1 ; read error (no FNF stop)
 17257                              <1> 
 17258                              <1> sysfnf_8:
 17259 00011D98 E8BFB1FFFF          <1> 	call	load_FAT_sub_directory	 
 17260 00011D9D 72BC                <1> 	jc	short sysfnf_err_1 ; read error (no FNF stop)
 17261                              <1> 
 17262                              <1> sysfnf_9:
 17263 00011D9F E89C77FFFF          <1> 	call	find_next_file
 17264 00011DA4 72AA                <1> 	jc	short sysfnf_5
 17265                              <1> 
 17266 00011DA6 A0[E5960100]        <1> 	mov	al, [FFF_Attrib]
 17267                              <1> 	;or	al, al
 17268                              <1> 	;jz	short sysfnf_10 ; 0 = No filter
 17269 00011DAB 34FF                <1> 	xor	al, 0FFh
 17270 00011DAD 20D8                <1> 	and	al, bl
 17271 00011DAF 75EE                <1> 	jnz	short sysfnf_9 ; search for next file until
 17272                              <1> 			       ; an error return from
 17273                              <1> 			       ; find_next_file procedure	
 17274                              <1> sysfnf_10:
 17275 00011DB1 0FB60D[E4960100]    <1>         movzx	ecx, byte [FFF_Valid]
 17276 00011DB8 80F980              <1> 	cmp	cl, 128 ; complete FindFile structure/table 
 17277 00011DBB 0F84A2FEFFFF        <1> 	je	sysfnf_11
 17278                              <1> 	;cmp	cl, 24  ; basic parameters
 17279                              <1> 	;je	sysfnf_12       
 17280 00011DC1 E9AFFEFFFF          <1> 	jmp	sysfnf_12
 17281                              <1> 
 17282                              <1> writei:
 17283                              <1> 	; 26/10/2016
 17284                              <1> 	; 25/10/2016
 17285                              <1> 	; 23/10/2016
 17286                              <1> 	; 22/10/2016
 17287                              <1> 	; 19/10/2016 - TRDOS 386 (TRDOS v2.0)
 17288                              <1> 	; 19/05/2015 - 20/05/2015 (Retro UNIX 386 v1)
 17289                              <1> 	; 12/03/2013 - 31/07/2013 (Retro UNIX 8086 v1)
 17290                              <1> 	;
 17291                              <1> 	; Write data to file with first cluster number in EAX
 17292                              <1> 	; 
 17293                              <1> 	; INPUTS ->
 17294                              <1> 	;    EAX - First cluster number of the file
 17295                              <1> 	;    EBX - File number (Open file index number)
 17296                              <1> 	;    u.count - byte count to be written
 17297                              <1> 	;    u.base - points to user buffer
 17298                              <1> 	;    u.fofp - points to dword with current file offset
 17299                              <1> 	;    i.size - file size
 17300                              <1> 	;    cdev - logical dos drive number of the file
 17301                              <1> 	; OUTPUTS ->
 17302                              <1> 	;    u.count - cleared
 17303                              <1> 	;    u.nread - accumulates total bytes passed back
 17304                              <1> 	;    i.size - new file size (if file byte offset overs file size)
 17305                              <1> 	;    u.fofp - points to u.off (with new offset value)	
 17306                              <1> 	;
 17307                              <1> 	; (Retro UNIX Prototype : 11/11/2012 - 18/11/2012, UNIXCOPY.ASM)
 17308                              <1> 	; ((Modified registers: eax, edx, ebx, ecx, esi, edi, ebp)) 	
 17309                              <1> 
 17310 00011DC6 31C9                <1> 	xor	ecx, ecx
 17311 00011DC8 890D[8C030300]      <1> 	mov 	[u.nread], ecx  ; 0
 17312 00011DCE 66890D[C4030300]    <1> 	mov	[u.pcount], cx ; 19/05/2015
 17313 00011DD5 390D[88030300]      <1> 	cmp 	[u.count], ecx
 17314 00011DDB 7701                <1> 	ja 	short writei_1 
 17315 00011DDD C3                  <1> 	retn
 17316                              <1> writei_1:
 17317 00011DDE 881D[A4960100]      <1> 	mov	[writei.ofn], bl ; Open file number
 17318 00011DE4 880D[DF960100]      <1> 	mov	[setfmod], cl ; 0 ; reset 'update lm date&time' sign
 17319                              <1> dskw_0: 
 17320                              <1> 	; 26/10/2016
 17321                              <1> 	; 22/10/2016, 23/10/2016, 25/10/2016
 17322                              <1> 	; 19/10/2016 - TRDOS 386 (TRDOS v2.0)
 17323                              <1> 	; 31/05/2015 - 25/07/2015 (Retro UNIX 386 v1)
 17324                              <1> 	; 26/04/2013 - 20/09/2013 (Retro UNIX 8086 v1)
 17325                              <1> 	;
 17326                              <1> 	; 01/08/2013 (mkdir_w check)
 17327 00011DEA E8D7000000          <1>  	call	mget_w
 17328                              <1> 	; eax = sector/block number
 17329                              <1> 
 17330 00011DEF 8B1D[74030300]      <1> 	mov     ebx, [u.fofp]
 17331 00011DF5 8B13                <1> 	mov	edx, [ebx]
 17332 00011DF7 81E2FF010000        <1> 	and	edx, 1FFh  ; / test the lower 9 bits of the file offset
 17333 00011DFD 750C                <1> 	jnz	short dskw_1 ; / if its non-zero, branch
 17334                              <1> 			     ; if zero, file offset = 0,
 17335                              <1> 		       	     ; / 512, 1024,...(i.e., start of new block)
 17336 00011DFF 813D[88030300]0002- <1> 	cmp	dword [u.count], 512
 17336 00011E07 0000                <1>
 17337                              <1> 				; / if zero, is there enough data to fill
 17338                              <1> 				; / an entire block? (i.e., no. of
 17339 00011E09 7337                <1> 	jnb	short dskw_2 ; / bytes to be written greater than 512.? 
 17340                              <1> 			     ; / Yes, branch. Don't have to read block
 17341                              <1> dskw_1: ; in as no past info. is to be saved 
 17342                              <1> 	; (the entire block will be overwritten).
 17343                              <1> 	; 23/10/2016
 17344                              <1> 
 17345 00011E0B BB[94070300]        <1> 	mov	ebx, writei_buffer
 17346                              <1> 	; esi = logical dos drive description table address
 17347                              <1> 	; eax = sector number
 17348                              <1> 	; ebx = buffer address (in kernel's memory space)
 17349                              <1> 	; ecx = sector count
 17350 00011E10 B901000000          <1> 	mov	ecx, 1
 17351 00011E15 E8A30D0000          <1> 	call	disk_read
 17352                              <1> 	;call	dskrd 	; / no, must retain old info.. 
 17353                              <1> 		       	; / Hence, read block 'r1' into an I/O buffer
 17354 00011E1A 7326                <1> 	jnc	short dskw_2
 17355                              <1> 
 17356                              <1> 	; disk read error
 17357 00011E1C B811000000          <1> 	mov	eax, 17 ; drive not ready or READ ERROR !
 17358                              <1> dskw_err: ; jump from disk write error
 17359 00011E21 A3[64030300]        <1> 	mov	[u.r0], eax
 17360 00011E26 A3[C8030300]        <1> 	mov	[u.error], eax
 17361                              <1> 
 17362 00011E2B 803D[DF960100]00    <1> 	cmp	byte [setfmod], 0
 17363 00011E32 0F86B4BAFFFF        <1> 	jna	error
 17364                              <1> 
 17365 00011E38 E8AF030000          <1> 	call	update_file_lmdt ; update last modif. date&time of the file
 17366                              <1> 	;mov	byte [setfmod], 0	
 17367                              <1> 
 17368 00011E3D E9AABAFFFF          <1> 	jmp	error
 17369                              <1> 
 17370                              <1> dskw_2: ; 3:
 17371                              <1> 	; 23/10/2016
 17372 00011E42 C605[80960100]01    <1> 	mov	byte [writei.valid], 1 ; writei buffer contains valid data
 17373 00011E49 56                  <1> 	push	esi ; logical dos drive description table address
 17374                              <1> 	; EAX (r1) = block/sector number
 17375                              <1> 	;call	wslot
 17376                              <1> 		; jsr r0,wslot / set write and inhibit bits in I/O queue, 
 17377                              <1> 			   ; / proc. status=0, r5 points to 1st word of data
 17378 00011E4A 803D[C6030300]00    <1> 	cmp	byte [u.kcall], 0
 17379 00011E51 770F                <1> 	ja	short dskw_4 ; zf=0 -> the caller is 'mkdir'
 17380                              <1> 	;
 17381 00011E53 66833D[C4030300]00  <1> 	cmp	word [u.pcount], 0
 17382 00011E5B 7705                <1> 	ja	short dskw_4
 17383                              <1> dskw_3:
 17384                              <1> 	; [u.base] = virtual address to transfer (as source address)
 17385 00011E5D E821FAFFFF          <1> 	call	trans_addr_r ; translate virtual address to physical (r)
 17386                              <1> dskw_4:
 17387 00011E62 BB[94070300]        <1> 	mov	ebx, writei_buffer
 17388                              <1> 	; EBX (r5) = system (I/O) buffer address
 17389 00011E67 E883FAFFFF          <1> 	call	sioreg
 17390                              <1> 	; ESI = file (user data) offset
 17391                              <1> 	; EDI = sector (I/O) buffer offset
 17392                              <1> 	; ECX = byte count
 17393                              <1> 	;
 17394 00011E6C F3A4                <1>   	rep	movsb
 17395                              <1> 	; 25/07/2015
 17396                              <1> 	; eax = remain bytes in buffer
 17397                              <1>         ;       (check if remain bytes in the buffer > [u.pcount])
 17398 00011E6E 09C0                <1> 	or	eax, eax
 17399 00011E70 75EB                <1> 	jnz	short dskw_3 ; (page end before system buffer end!)	
 17400                              <1> 
 17401                              <1> 	; 23/10/2016
 17402 00011E72 B101                <1> 	mov	cl, 1
 17403 00011E74 5E                  <1> 	pop	esi
 17404 00011E75 A1[84960100]        <1> 	mov	eax, [writei.sector]
 17405                              <1> 	; esi = logical dos drive description table address
 17406                              <1> 	; eax = sector number
 17407                              <1> 	; ebx = writei buffer address
 17408                              <1> 	; ecx = sector count
 17409 00011E7A E82F0D0000          <1> 	call	disk_write ; / yes, write the block
 17410 00011E7F 7307                <1> 	jnc	short dskw_5
 17411                              <1> 
 17412 00011E81 B812000000          <1> 	mov	eax, 18 ; drive not ready or WRITE ERROR !
 17413 00011E86 EB99                <1> 	jmp	short dskw_err
 17414                              <1> 
 17415                              <1> dskw_5:
 17416                              <1> 	; 26/10/2016
 17417 00011E88 0FB61D[A4960100]    <1> 	movzx	ebx, byte [writei.ofn] ; open file number
 17418 00011E8F C0E302              <1> 	shl	bl, 2 ; *4
 17419 00011E92 8B83[749A0100]      <1> 	mov	eax, [ebx+OF_POINTER]
 17420 00011E98 3B83[9C9A0100]      <1> 	cmp	eax, [ebx+OF_SIZE]
 17421 00011E9E 7606                <1> 	jna	short dskw_6
 17422 00011EA0 8983[9C9A0100]      <1> 	mov	[ebx+OF_SIZE], eax
 17423                              <1> dskw_6:
 17424                              <1> 	;shr	bl, 2
 17425 00011EA6 833D[88030300]00    <1>         cmp     dword [u.count], 0 ; / any more data to write?
 17426 00011EAD 760A                <1> 	jna	short dskw_7
 17427 00011EAF A1[94960100]        <1> 	mov	eax, [writei.fclust]
 17428 00011EB4 E931FFFFFF          <1> 	jmp	dskw_0 ; / yes, branch
 17429                              <1> dskw_7:
 17430                              <1>  	; update last modif. date&time of the file
 17431                              <1> 	; (also updates file size as OF_SIZE)
 17432 00011EB9 E82E030000          <1> 	call	update_file_lmdt
 17433                              <1> 	;mov	byte [setfmod], 0	
 17434                              <1> 
 17435                              <1> 	; 03/08/2013
 17436 00011EBE C605[C6030300]00    <1> 	mov	byte [u.kcall], 0
 17437                              <1> 	; 23/10/2016
 17438                              <1> 	;mov	eax, [writei.fclust]
 17439 00011EC5 C3                  <1> 	retn
 17440                              <1> 
 17441                              <1> mget_w:
 17442                              <1> 	; 02/11/2016
 17443                              <1> 	; 01/11/2016
 17444                              <1> 	; 23/10/2016, 31/10/2016
 17445                              <1> 	; 22/10/2016 - TRDOS 386 (TRDOS v2.0)
 17446                              <1> 	; 03/06/2015 (Retro UNIX 386 v1, 'mget', u.5s)
 17447                              <1> 	; 22/03/2013 - 31/07/2013 (Retro UNIX 8086 v1)
 17448                              <1> 	;
 17449                              <1> 	; Get existing or (allocate) a new disk block for file
 17450                              <1> 	; 
 17451                              <1> 	; INPUTS ->
 17452                              <1> 	;    [u.fofp] = file offset pointer
 17453                              <1> 	;    [i.size] = file size
 17454                              <1> 	;    [u.count] = byte count	 
 17455                              <1> 	;    EAX = First cluster
 17456                              <1> 	;    [cdev] = Logical dos drive number 	  
 17457                              <1> 	;    [writei.ofn] = File Number
 17458                              <1> 	;		   (Open file index, 0 based)
 17459                              <1> 	;    ([u.off] = file offset)
 17460                              <1> 	; OUTPUTS ->
 17461                              <1> 	;    EAX = logical sector number
 17462                              <1> 	;    ESI = Logical Dos Drive Description Table address
 17463                              <1> 	;
 17464                              <1> 	; Modified registers: EDX, EBX, ECX, ESI, EDI, EBP  
 17465                              <1> 
 17466 00011EC6 8B35[74030300]      <1>         mov     esi, [u.fofp]
 17467 00011ECC 8B2E                <1> 	mov	ebp, [esi] ; u.off (or EBX*4+OF_POINTER)
 17468                              <1> 
 17469 00011ECE 29C9                <1> 	sub	ecx, ecx
 17470 00011ED0 8A2D[46030300]      <1> 	mov	ch, [cdev]
 17471                              <1> 
 17472 00011ED6 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 17473 00011EDB 01CE                <1> 	add	esi, ecx
 17474                              <1> 
 17475                              <1> 	; 31/10/2016
 17476 00011EDD 89C3                <1> 	mov	ebx, eax ; First Cluster or FDT address
 17477                              <1> 
 17478 00011EDF 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 17479 00011EE3 0F86DD010000        <1> 	jna	mget_w_14 ; Singlix FS
 17480                              <1> 
 17481 00011EE9 0FB74611            <1> 	movzx	eax, word [esi+LD_BPB+BytesPerSec]
 17482 00011EED 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+SecPerClust]
 17483 00011EF1 8815[82960100]      <1> 	mov	[writei.spc], dl  ; sectors per cluster
 17484 00011EF7 F7E2                <1> 	mul	edx
 17485                              <1> 	; edx = 0
 17486                              <1> 	; eax = bytes per cluster (<= 65536)
 17487                              <1> 
 17488                              <1> 	; 02/11/2016
 17489 00011EF9 89C1                <1> 	mov	ecx, eax
 17490 00011EFB 48                  <1> 	dec	eax
 17491 00011EFC 66A3[88960100]      <1> 	mov	[writei.bpc], ax	
 17492                              <1> 	
 17493 00011F02 89E8                <1> 	mov	eax, ebp
 17494 00011F04 0305[88030300]      <1> 	add	eax, [u.count] ; next file position
 17495 00011F0A 3B05[55040300]      <1> 	cmp	eax, [i.size] ; <= file size ?
 17496 00011F10 0F86FC000000        <1> 	jna	mget_w_4 ; no
 17497                              <1> 
 17498 00011F16 F7F1                <1> 	div	ecx
 17499 00011F18 A3[90960100]        <1> 	mov	[writei.c_index], eax ; cluster index
 17500                              <1> 	; edx = byte offset in cluster (<= 65535)
 17501                              <1> 	;mov	[writei.offset], dx
 17502                              <1> 	;shr	dx, 9 ; / 512
 17503                              <1> 	;mov	[writei.s_index], dl ; sector index in cluster (0 to spc -1)
 17504                              <1> 
 17505 00011F1D 29D2                <1> 	sub	edx, edx ; 01/11/2016
 17506 00011F1F 8915[84960100]      <1> 	mov 	[writei.sector], edx ; 0
 17507 00011F25 668915[8A960100]    <1> 	mov	[writei.offset], dx  ; byte offset in cluster 
 17508 00011F2C 8815[83960100]      <1> 	mov	[writei.s_index], dl ; sector index in cluster (0 to spc -1)
 17509                              <1> 
 17510 00011F32 89D8                <1> 	mov	eax, ebx ; First Cluster
 17511                              <1> 
 17512                              <1> 	; is this the 1st mget_w or a next mget_w call ? (by 'writei')
 17513 00011F34 3815[80960100]      <1> 	cmp	byte [writei.valid], dl ; 0 
 17514 00011F3A 7624                <1> 	jna	short mget_w_0
 17515                              <1> 
 17516 00011F3C 8815[80960100]      <1> 	mov 	byte [writei.valid], dl ; 0 ; reset ('writei' will set it) 
 17517                              <1> 
 17518 00011F42 3B05[94960100]      <1> 	cmp	eax, [writei.fclust]
 17519 00011F48 7516                <1> 	jne	short mget_w_0
 17520                              <1> 
 17521 00011F4A 8A0D[46030300]      <1> 	mov	cl, [cdev]
 17522 00011F50 3A0D[81960100]      <1> 	cmp	cl, [writei.drv]
 17523 00011F56 7508                <1> 	jne	short mget_w_0
 17524                              <1>  	; [writei.l_clust] & [writei.l_index] are valid, 
 17525                              <1> 	;  we don't need to get last cluster & last cluster index
 17526 00011F58 8B0D[A0960100]      <1> 	mov	ecx, [writei.l_index]
 17527 00011F5E EB64                <1> 	jmp	short mget_w_2
 17528                              <1> mget_w_0:
 17529 00011F60 A3[94960100]        <1> 	mov	[writei.fclust], eax ; first cluster
 17530                              <1> 	; edx = 0
 17531 00011F65 A3[8C960100]        <1> 	mov	[writei.cluster], eax ; first cluster ; 01/11/2016
 17532 00011F6A 8915[98960100]      <1> 	mov 	[writei.fs_index], edx ; 0 ; curret cluster index
 17533                              <1> 
 17534                              <1> 	; FAT file system (FAT12, FAT16, FAT32)
 17535 00011F70 E8FCB5FFFF          <1> 	call	get_last_cluster
 17536 00011F75 0F822B010000        <1> 	jc	mget_w_err ; eax = error code
 17537                              <1> 		
 17538 00011F7B A3[9C960100]        <1> 	mov	[writei.lclust], eax ; last cluster
 17539                              <1> 
 17540 00011F80 8B0D[C0940100]      <1> 	mov	ecx, [glc_index] ; last cluster index
 17541 00011F86 890D[A0960100]      <1> 	mov	[writei.l_index], ecx
 17542                              <1> 
 17543 00011F8C A0[A4960100]        <1> 	mov	al, [writei.ofn]
 17544 00011F91 FEC0                <1> 	inc	al
 17545 00011F93 A2[DF960100]        <1> 	mov	[setfmod], al ; update lm date&time sign
 17546                              <1> 
 17547                              <1> mget_w_1:
 17548 00011F98 3B0D[90960100]      <1> 	cmp	ecx, [writei.c_index]  ; last cluster index
 17549 00011F9E 7324                <1> 	jnb	short mget_w_2 ; 01/11/2016
 17550                              <1> 
 17551 00011FA0 A1[9C960100]        <1> 	mov	eax, [writei.lclust]
 17552                              <1> 	; EAX = Last cluster
 17553 00011FA5 E8D5B6FFFF          <1> 	call	add_new_cluster
 17554 00011FAA 0F82F6000000        <1> 	jc	mget_w_err ; eax = error code
 17555                              <1> 	; edx = 0
 17556 00011FB0 A3[9C960100]        <1> 	mov	[writei.lclust], eax ; (new) last cluster
 17557 00011FB5 8B0D[A0960100]      <1> 	mov	ecx, [writei.l_index]
 17558 00011FBB 41                  <1> 	inc	ecx ; add 1 to last cluster index
 17559 00011FBC 890D[A0960100]      <1> 	mov	[writei.l_index], ecx ; current last cluster index
 17560                              <1> 
 17561 00011FC2 EBD4                <1> 	jmp	short mget_w_1
 17562                              <1> 
 17563                              <1> mget_w_2:
 17564 00011FC4 89E9                <1> 	mov	ecx, ebp
 17565 00011FC6 030D[88030300]      <1> 	add	ecx, [u.count]
 17566 00011FCC 890D[55040300]      <1> 	mov	[i.size], ecx ; save new file size
 17567                              <1> 	;sub	edx, edx ; 0
 17568                              <1> 
 17569 00011FD2 A0[46030300]        <1> 	mov	al, [cdev]
 17570 00011FD7 A2[81960100]        <1> 	mov	[writei.drv], al ; physical drive number
 17571                              <1> 	; edx = 0
 17572 00011FDC 89E8                <1> 	mov	eax, ebp ; file offset
 17573 00011FDE 0FB70D[88960100]    <1> 	movzx	ecx, word [writei.bpc] ; bytes per cluster - 1
 17574 00011FE5 41                  <1> 	inc	ecx ; bytes per cluster
 17575 00011FE6 F7F1                <1> 	div	ecx
 17576                              <1> 	; edx = byte offset in cluster (<= 65535)
 17577                              <1> 	; eax = cluster index
 17578 00011FE8 A3[90960100]        <1> 	mov	[writei.c_index], eax
 17579 00011FED 668915[8A960100]    <1> 	mov	[writei.offset], dx
 17580 00011FF4 66C1EA09            <1> 	shr	dx, 9 ; / 512
 17581 00011FF8 8815[83960100]      <1> 	mov	[writei.s_index], dl ; sector index in cluster (0 to spc -1)
 17582                              <1> 
 17583                              <1> mget_w_3:
 17584 00011FFE 3B05[A0960100]      <1> 	cmp	eax, [writei.l_index] ; last cluster index
 17585 00012004 752A                <1> 	jne	short mget_w_5
 17586                              <1> 
 17587 00012006 A3[98960100]        <1> 	mov	[writei.fs_index], eax ; cluster index (for next check)
 17588 0001200B A1[9C960100]        <1> 	mov	eax, [writei.lclust] ; last cluster
 17589 00012010 EB60                <1> 	jmp	short mget_w_10
 17590                              <1> 
 17591                              <1> mget_w_4: ; 02/11/2016
 17592                              <1> 	; eax = next file position
 17593 00012012 2B05[88030300]      <1> 	sub	eax, [u.count] ; current file position
 17594                              <1> 	; edx = 0
 17595                              <1> 	; ecx = bytes per cluster
 17596 00012018 F7F1                <1> 	div	ecx
 17597 0001201A A3[90960100]        <1> 	mov	[writei.c_index], eax ; cluster index
 17598 0001201F 668915[8A960100]    <1> 	mov	[writei.offset], dx
 17599 00012026 66C1EA09            <1> 	shr	dx, 9 ; / 512
 17600 0001202A 8815[83960100]      <1> 	mov	[writei.s_index], dl ; sector index in cluster (0 to spc -1)
 17601                              <1> 
 17602                              <1> mget_w_5:
 17603 00012030 21C0                <1> 	and	eax, eax ; 0 = First Cluster's index number
 17604 00012032 750C                <1> 	jnz	short mget_w_6
 17605                              <1> 
 17606 00012034 A3[98960100]        <1> 	mov	[writei.fs_index], eax ; cluster index (for next check)
 17607 00012039 A1[94960100]        <1> 	mov	eax, [writei.fclust] ; first cluster
 17608 0001203E EB32                <1> 	jmp	short mget_w_10
 17609                              <1> 
 17610                              <1> mget_w_6:
 17611 00012040 3B05[98960100]      <1> 	cmp	eax, [writei.fs_index] ; current cluster index (>0)
 17612 00012046 7507                <1> 	jne	short mget_w_7
 17613 00012048 A1[8C960100]        <1> 	mov	eax, [writei.cluster] ; current cluster 
 17614 0001204D EB3A                <1> 	jmp	short mget_w_11
 17615                              <1> 
 17616                              <1> mget_w_7:
 17617 0001204F 89C1                <1> 	mov	ecx, eax
 17618 00012051 2B0D[98960100]      <1> 	sub	ecx, [writei.fs_index]
 17619 00012057 730D                <1> 	jnc	short mget_w_8
 17620                              <1> 	; get cluster by index from the first cluster
 17621 00012059 A1[94960100]        <1> 	mov	eax, [writei.fclust]
 17622 0001205E 8B0D[90960100]      <1> 	mov	ecx, [writei.c_index]
 17623 00012064 EB05                <1> 	jmp	short mget_w_9
 17624                              <1> 
 17625                              <1> mget_w_8:
 17626 00012066 A1[8C960100]        <1> 	mov	eax, [writei.cluster] ; beginning cluster
 17627                              <1> 	; ecx = cluster sequence number after the beginning cluster
 17628                              <1> 	; sub	edx, edx ; 0
 17629                              <1> 
 17630                              <1> mget_w_9:
 17631                              <1> 	; EAX = Beginning cluster
 17632                              <1> 	; EDX = Sector index in disk/file section
 17633                              <1> 	;	(Only for SINGLIX file system!)
 17634                              <1> 	; ECX = Cluster sequence number after the beginning cluster
 17635                              <1> 	; ESI = Logical DOS Drive Description Table address
 17636 0001206B E815B7FFFF          <1> 	call	get_cluster_by_index
 17637 00012070 7234                <1> 	jc	short mget_w_err ; error code in EAX
 17638                              <1> 	; EAX = Cluster number		
 17639                              <1> mget_w_10:
 17640 00012072 A3[8C960100]        <1> 	mov	[writei.cluster], eax ; FDT number for Singlix File System
 17641                              <1> 
 17642 00012077 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 17643 0001207B 7638                <1> 	jna	short mget_w_13
 17644                              <1> 	; 01/11/2016
 17645 0001207D 8B15[90960100]      <1> 	mov	edx, [writei.c_index]
 17646 00012083 8915[98960100]      <1> 	mov	[writei.fs_index], edx
 17647                              <1> mget_w_11:
 17648 00012089 83E802              <1> 	sub	eax, 2
 17649 0001208C 0FB615[82960100]    <1> 	movzx	edx, byte [writei.spc]
 17650 00012093 F7E2                <1> 	mul	edx
 17651                              <1> 
 17652 00012095 034668              <1> 	add	eax, [esi+LD_DATABegin]
 17653 00012098 8A15[83960100]      <1> 	mov	dl, [writei.s_index]
 17654 0001209E 01D0                <1> 	add	eax, edx
 17655                              <1> mget_w_12:
 17656 000120A0 A3[84960100]        <1> 	mov	[writei.sector], eax
 17657                              <1> 	;; buffer validation must be done in writei
 17658                              <1> 	;;mov	byte [writei.valid], 1 
 17659 000120A5 C3                  <1> 	retn
 17660                              <1> 
 17661                              <1> mget_w_err:
 17662 000120A6 A3[C8030300]        <1> 	mov	[u.error], eax
 17663 000120AB A3[64030300]        <1> 	mov	[u.r0], eax
 17664 000120B0 E937B8FFFF          <1> 	jmp	error
 17665                              <1> 
 17666                              <1> mget_w_13:
 17667                              <1> 	; EAX = FDT number (Current Section)
 17668                              <1> 	; EDX = Sector index from the first section (0,1,2,3,4...)
 17669 000120B5 2B15[98960100]      <1> 	sub	edx, [writei.fs_index]	
 17670                              <1> 	; EDX = Sector index from current section
 17671 000120BB 8915[98960100]      <1> 	mov	[writei.fs_index], edx
 17672 000120C1 40                  <1> 	inc	eax ; the first data sector in FS disk section	
 17673 000120C2 01D0                <1> 	add	eax, edx
 17674 000120C4 EBDA                <1> 	jmp	short mget_w_12
 17675                              <1> 
 17676                              <1> mget_w_14:
 17677 000120C6 8A4E12              <1> 	mov	cl, [esi+LD_FS_BytesPerSec+1]
 17678 000120C9 D0E9                <1> 	shr	cl, 1 ;  ; 1 for 512 bytes, 4 for 2048 bytes
 17679 000120CB 880D[82960100]      <1> 	mov	[writei.spc], cl  ; sectors per cluster
 17680                              <1> 	; NOTE: writei bytes per sector value is always 512 ! 
 17681 000120D1 66C705[88960100]00- <1> 	mov	word [writei.bpc], 512
 17681 000120D9 02                  <1>
 17682                              <1> 
 17683 000120DA 89E9                <1> 	mov	ecx, ebp
 17684 000120DC 030D[88030300]      <1> 	add	ecx, [u.count] ; next file position
 17685 000120E2 3B0D[55040300]      <1> 	cmp	ecx, [i.size] ; <= file size ?
 17686 000120E8 0F86C8000000        <1> 	jna	mget_w_19 ; no
 17687                              <1> 
 17688 000120EE 29D2                <1> 	sub	edx, edx ; 0
 17689 000120F0 8915[84960100]      <1> 	mov 	[writei.sector], edx ; 0
 17690 000120F6 668915[8A960100]    <1> 	mov	[writei.offset], dx  ; byte offset in cluster 
 17691 000120FD 8815[83960100]      <1> 	mov	[writei.s_index], dl ; sector index in cluster (0 to spc -1)
 17692                              <1> 
 17693 00012103 C1E909              <1> 	shr	ecx, 9 ; 1 cluster = 512 bytes
 17694 00012106 890D[90960100]      <1> 	mov	[writei.c_index], ecx ; section/cluster index
 17695                              <1> 	
 17696 0001210C 89D8                <1> 	mov	eax, ebx ; FDT number (First FDT address)
 17697                              <1> 
 17698                              <1> 	; is this the 1st mget_w or a next mget_w call ? (by 'writei')
 17699 0001210E 3815[80960100]      <1> 	cmp	byte [writei.valid], dl ; 0 
 17700 00012114 7624                <1> 	jna	short mget_w_15
 17701                              <1> 
 17702 00012116 8815[80960100]      <1> 	mov 	byte [writei.valid], dl ; 0 ; reset ('writei' will set it) 
 17703                              <1> 
 17704 0001211C 3B05[94960100]      <1> 	cmp	eax, [writei.fclust]
 17705 00012122 7516                <1> 	jne	short mget_w_15
 17706                              <1> 
 17707 00012124 8A0D[46030300]      <1> 	mov	cl, [cdev]
 17708 0001212A 3A0D[81960100]      <1> 	cmp	cl, [writei.drv]
 17709 00012130 7508                <1> 	jne	short mget_w_15
 17710                              <1>  	; [writei.l_clust] & [writei.l_index] are valid, 
 17711                              <1> 	;  we don't need to get last cluster & last cluster index
 17712 00012132 8B0D[A0960100]      <1> 	mov	ecx, [writei.l_index]
 17713 00012138 EB49                <1> 	jmp	short mget_w_17
 17714                              <1> mget_w_15:
 17715 0001213A A3[94960100]        <1> 	mov	[writei.fclust], eax ; first section (FDT number)
 17716                              <1> 	; edx = 0
 17717 0001213F 8915[8C960100]      <1> 	mov	[writei.cluster], edx ; 0 ; current section
 17718 00012145 8915[98960100]      <1> 	mov 	[writei.fs_index], edx ; 0 ; curret section index
 17719                              <1> 
 17720                              <1> 	; eax = FDT number (section 0 header address)
 17721 0001214B E85FB6FFFF          <1> 	call	get_last_section
 17722 00012150 0F8250FFFFFF        <1> 	jc	mget_w_err ; eax = error code
 17723                              <1> 
 17724 00012156 8915[98960100]      <1> 	mov 	[writei.fs_index], edx ; sector index in last section
 17725                              <1> 		
 17726 0001215C A3[9C960100]        <1> 	mov	[writei.lclust], eax ; last section address
 17727                              <1> 
 17728 00012161 8B0D[C0940100]      <1> 	mov	ecx, [glc_index] ; last section index
 17729 00012167 890D[A0960100]      <1> 	mov	[writei.l_index], ecx
 17730                              <1> 
 17731 0001216D A0[A4960100]        <1> 	mov	al, [writei.ofn]
 17732 00012172 FEC0                <1> 	inc	al
 17733 00012174 A2[DF960100]        <1> 	mov	[setfmod], al ; update lm date&time sign
 17734                              <1> 
 17735                              <1> mget_w_16:
 17736                              <1> 	; edx = (existing) last section (sector) index
 17737 00012179 8B0D[90960100]      <1> 	mov	ecx, [writei.c_index] ; final section (sector) index
 17738 0001217F 29D1                <1> 	sub	ecx, edx
 17739 00012181 7633                <1> 	jna	short mget_w_19
 17740                              <1> 	 ; ecx = sector count
 17741                              <1> mget_w_17:
 17742 00012183 A1[9C960100]        <1> 	mov	eax, [writei.lclust]
 17743                              <1> 	; ESI = Logical dos drv desc. table address
 17744                              <1>         ; EAX = Last section
 17745                              <1>         ; (ECX = 0 for directory) 
 17746                              <1>         ; ECX = sector count (except FDT)
 17747 00012188 E8E5ABFFFF          <1> 	call	add_new_fs_section
 17748 0001218D 7312                <1> 	jnc	short mget_w_18
 17749                              <1> 
 17750                              <1> 	; If error number = 27h (insufficient disk space)
 17751                              <1> 	; it is needed to check free consequent sectors
 17752                              <1> 	; (1 data sector at least and +1 section header sector) 
 17753                              <1> 
 17754 0001218F 83F827              <1> 	cmp	eax, 27h
 17755 00012192 0F850EFFFFFF        <1> 	jne	mget_w_err ; eax = error code
 17756                              <1> 
 17757                              <1> 	; ecx = count of free consequent sectors
 17758                              <1> 	; ecx must be > 1 (1 data + 1 header sector)
 17759 00012198 49                  <1> 	dec	ecx
 17760 00012199 0F8407FFFFFF        <1> 	jz	mget_w_err
 17761 0001219F EBE2                <1> 	jmp	short mget_w_17
 17762                              <1> 
 17763                              <1> mget_w_18:
 17764 000121A1 A3[9C960100]        <1> 	mov	[writei.lclust], eax ; (new) last section
 17765                              <1> 	; ecx = sector count (except section header)
 17766 000121A6 8B15[A0960100]      <1> 	mov	edx, [writei.l_index]
 17767 000121AC 01CA                <1> 	add	edx, ecx ; add sector count to index
 17768 000121AE 8915[A0960100]      <1> 	mov	[writei.l_index], edx
 17769 000121B4 EBC3                <1> 	jmp	short mget_w_16
 17770                              <1> 
 17771                              <1> mget_w_19:
 17772 000121B6 89E9                <1> 	mov	ecx, ebp
 17773 000121B8 030D[88030300]      <1> 	add	ecx, [u.count]
 17774 000121BE 890D[55040300]      <1> 	mov	[i.size], ecx ; save new file size
 17775                              <1> 	;sub	edx, edx ; 0
 17776                              <1> 
 17777 000121C4 A0[46030300]        <1> 	mov	al, [cdev]
 17778 000121C9 A2[81960100]        <1> 	mov	[writei.drv], al ; physical drive number
 17779                              <1> 	; edx = 0
 17780 000121CE 89E8                <1> 	mov	eax, ebp ; file offset
 17781 000121D0 89C2                <1> 	mov	edx, eax
 17782                              <1> 	; 1 cluster = 512 bytes (for Singlix FS)
 17783 000121D2 C1E809              <1> 	shr	eax, 9  ; / 512
 17784 000121D5 81E2FF010000        <1> 	and	edx, 1FFh
 17785                              <1> 	; edx = byte offset in cluster/sector (<= 511)
 17786                              <1> 	; eax = section (sector/cluster) index
 17787 000121DB A3[90960100]        <1> 	mov	[writei.c_index], eax
 17788 000121E0 668915[8A960100]    <1> 	mov	[writei.offset], dx
 17789                              <1> 	;mov	byte [writei.s_index], 0 ; sector index in cluster
 17790 000121E7 E912FEFFFF          <1> 	jmp	mget_w_3
 17791                              <1> 
 17792                              <1> update_file_lmdt: ; & update file size
 17793                              <1> 	; 26/10/2016
 17794                              <1> 	; 24/10/2016
 17795                              <1> 	; 23/10/2016
 17796                              <1> 	; 22/10/2016 - TRDOS 386 (TRDOS v2.0)
 17797                              <1> 	;
 17798                              <1> 	; Update last modification date&time of file
 17799                              <1> 	; (call from syswrite -> writei)
 17800                              <1> 	; ((also updates file size)) // 26/10/2016
 17801                              <1> 	; 
 17802                              <1> 	; INPUT:
 17803                              <1> 	;      byte [setfmod] = open file number
 17804                              <1> 	; OUTPUT:
 17805                              <1> 	;      cf = 0 -> success !
 17806                              <1> 	;      cf = 1 -> lmdt update has been failed! 	 
 17807                              <1> 	;
 17808                              <1> 	; Modified registers: eax, ebx, ecx, edx, esi, edi       				
 17809                              <1> 	;
 17810                              <1> 
 17811                              <1> 	;cmp	byte [setfmod], 0
 17812                              <1> 	;jna	short uflmdt_2 ; nothing to do
 17813                              <1> 
 17814 000121EC 31C0                <1> 	xor	eax, eax
 17815                              <1> 
 17816 000121EE 0FB61D[DF960100]    <1> 	movzx	ebx, byte [setfmod]
 17817 000121F5 FECB                <1> 	dec	bl ; open file index number (0 based)
 17818                              <1> 
 17819 000121F7 8AA3[4C9A0100]      <1> 	mov	ah, [ebx+OF_DRIVE]
 17820 000121FD BE00010900          <1> 	mov	esi, Logical_DOSDisks
 17821 00012202 01C6                <1> 	add	esi, eax
 17822 00012204 C0E302              <1> 	shl	bl, 2 ; *4	
 17823 00012207 8B8B[249A0100]      <1> 	mov	ecx, [ebx+OF_FCLUSTER] ; first cluster
 17824 0001220D 8B93[EC9A0100]      <1> 	mov	edx, [ebx+OF_DIRCLUSTER] ; dir cluster
 17825                              <1> 
 17826 00012213 D0EB                <1> 	shr	bl, 1 ; /2
 17827 00012215 0FB7BB[8C9B0100]    <1> 	movzx	edi, word [ebx+OF_DIRENTRY]
 17828                              <1> 	
 17829 0001221C 803D[1C920100]01    <1> 	cmp	byte [DirBuff_ValidData], 1
 17830 00012223 726E                <1> 	jb	short uflmdt_4
 17831                              <1> 
 17832 00012225 A0[1A920100]        <1> 	mov	al, [DirBuff_DRV]
 17833 0001222A 2C41                <1> 	sub	al, 'A'	
 17834 0001222C 38E0                <1> 	cmp	al, ah
 17835 0001222E 7563                <1> 	jne	short uflmdt_4 ; different drive
 17836 00012230 8A4603              <1> 	mov	al, [esi+LD_FATType] 
 17837 00012233 3A05[1B920100]      <1> 	cmp	al, [DirBuff_FATType]
 17838 00012239 755B                <1> 	jne	short uflmdt_5 ; different FS type
 17839 0001223B 3B15[21920100]      <1> 	cmp	edx, [DirBuff_Cluster]
 17840 00012241 7553                <1> 	jne	short uflmdt_5 ; different cluster
 17841                              <1> 
 17842                              <1> uflmdt_1:
 17843                              <1> 	; Directory buffer is ready here!
 17844                              <1> 	; OF_FCLUSTER must be compared/verified
 17845 00012243 BE00000800          <1> 	mov	esi, Directory_Buffer
 17846 00012248 66C1E705            <1> 	shl	di, 5 ; dir entry index * 32
 17847 0001224C 01FE                <1> 	add	esi, edi ; offset
 17848                              <1> 	;
 17849 0001224E F6460B18            <1> 	test	byte [esi+DirEntry_Attr], 18h ; Vol & Dir
 17850 00012252 750F                <1> 	jnz	short uflmdt_2 ; not a valid file !
 17851 00012254 668B4614            <1> 	mov	ax, [esi+DirEntry_FstClusHI]
 17852 00012258 C1E010              <1> 	shl	eax, 16
 17853 0001225B 668B461A            <1> 	mov	ax, [esi+DirEntry_FstClusLO]
 17854 0001225F 39C8                <1> 	cmp	eax, ecx ; same first cluster ?
 17855 00012261 7407                <1> 	je	short uflmdt_3 ; yes, it is OK !!!	
 17856                              <1> 
 17857                              <1> uflmdt_2:	
 17858                              <1> 	; save directory buffer if has modified/changed sign
 17859                              <1> 	; (It is good to save dir buff even if the searched
 17860                              <1> 	; directory entry is not found !?)
 17861 00012263 E85E98FFFF          <1> 	call	save_directory_buffer
 17862 00012268 F9                  <1> 	stc	; update failed
 17863 00012269 C3                  <1> 	retn
 17864                              <1> 	
 17865                              <1> uflmdt_3:
 17866                              <1> 	; Update directory entry
 17867                              <1> 	; 26/10/2016
 17868 0001226A D0E3                <1> 	shl	bl, 1 ; *2 
 17869 0001226C 8B83[9C9A0100]      <1> 	mov	eax, [ebx+OF_SIZE] ; file size
 17870 00012272 89461C              <1> 	mov	[esi+DirEntry_FileSize], eax
 17871                              <1> 	;
 17872 00012275 E8AE97FFFF          <1> 	call	convert_current_date_time
 17873                              <1> 	; OUTPUT -> DX = Date in dos dir entry format
 17874                              <1>         ; 	    AX = Time in dos dir entry format	
 17875 0001227A 66894616            <1> 	mov	[esi+DirEntry_WrtTime], ax
 17876 0001227E 66895618            <1> 	mov	[esi+DirEntry_WrtDate], dx	
 17877 00012282 66895612            <1> 	mov	[esi+DirEntry_LastAccDate], dx
 17878 00012286 C605[1C920100]02    <1> 	mov	byte [DirBuff_ValidData], 2
 17879 0001228D E83498FFFF          <1> 	call	save_directory_buffer
 17880 00012292 C3                  <1> 	retn
 17881                              <1> 
 17882                              <1> uflmdt_4:
 17883                              <1> 	; Directory buffer sector read&write
 17884                              <1> 	; 23/10/2016
 17885                              <1> 	;
 17886 00012293 8A4603              <1> 	mov	al, [esi+LD_FATType]
 17887                              <1> uflmdt_5:
 17888 00012296 BB[9C090300]        <1> 	mov	ebx, rw_buffer ; Common r/w sector buffer addr
 17889                              <1> 		
 17890 0001229B 20C0                <1> 	and	al, al ; 0 = Singlix FS
 17891 0001229D 0F8492000000        <1> 	jz	uflmdt_11
 17892                              <1> 
 17893 000122A3 21D2                <1> 	and	edx, edx
 17894 000122A5 7521                <1> 	jnz	short uflmdt_9
 17895                              <1> 
 17896 000122A7 3C02                <1> 	cmp	al, 2  ; 3 = FAT32
 17897 000122A9 771A                <1> 	ja	short uflmdt_8
 17898                              <1> 
 17899 000122AB 89F8                <1> 	mov	eax, edi ; directory entry index number
 17900 000122AD 66C1E804            <1> 	shr	ax, 4 ; 16 entries per sector	 
 17901 000122B1 034664              <1> 	add	eax, [esi+LD_ROOTBegin]
 17902                              <1> 	; eax = root directory sector
 17903                              <1> uflmdt_6:
 17904 000122B4 50                  <1> 	push	eax ; * ; disk sector address
 17905 000122B5 51                  <1> 	push	ecx ; first cluster	
 17906 000122B6 B901000000          <1> 	mov	ecx, 1
 17907                              <1> 	; ecx = sector count
 17908 000122BB E8FD080000          <1> 	call	disk_read
 17909 000122C0 59                  <1> 	pop	ecx
 17910 000122C1 731A                <1> 	jnc	short uflmdt_10
 17911 000122C3 58                  <1> 	pop	eax ; *
 17912                              <1> uflmdt_7:
 17913 000122C4 C3                  <1> 	retn	
 17914                              <1> 
 17915                              <1> uflmdt_8:
 17916 000122C5 8B5632              <1> 	mov	edx, [esi+LD_BPB+FAT32_RootFClust]
 17917                              <1> uflmdt_9:
 17918 000122C8 83FA02              <1> 	cmp	edx, 2
 17919 000122CB 72F7                <1> 	jb	short uflmdt_7 ; invalid, nothing to do
 17920                              <1> 
 17921 000122CD 83EA02              <1> 	sub	edx, 2
 17922 000122D0 89D0                <1> 	mov	eax, edx
 17923 000122D2 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+SecPerClust]
 17924 000122D6 F7E2                <1> 	mul	edx
 17925 000122D8 034668              <1> 	add	eax, [esi+LD_DATABegin]
 17926                              <1> 	; eax = sub directory (data) sector 
 17927 000122DB EBD7                <1> 	jmp	short uflmdt_6
 17928                              <1> 
 17929                              <1> uflmdt_10:
 17930                              <1> 	; Directory sector buffer is ready here!
 17931                              <1> 	; OF_FCLUSTER must be compared/verified
 17932                              <1> 	; edi = dir entry index number (<= 2047)
 17933 000122DD 6683E70F            <1> 	and	di, 0Fh ; 16 entries per sector
 17934 000122E1 66C1E705            <1> 	shl	di, 5 ; dir entry index * 32
 17935 000122E5 81C7[9C090300]      <1> 	add	edi, rw_buffer
 17936                              <1> 	;
 17937 000122EB F6470B18            <1> 	test	byte [edi+DirEntry_Attr], 18h ; Vol & Dir
 17938 000122EF 0F856EFFFFFF        <1> 	jnz	uflmdt_2 ; not a valid file !
 17939 000122F5 668B5714            <1> 	mov	dx, [edi+DirEntry_FstClusHI]
 17940 000122F9 C1E210              <1> 	shl	edx, 16
 17941 000122FC 668B571A            <1> 	mov	dx, [edi+DirEntry_FstClusLO]
 17942 00012300 39CA                <1> 	cmp	edx, ecx ; same first cluster ?
 17943 00012302 0F855BFFFFFF        <1> 	jne	uflmdt_2 ; no !?
 17944                              <1> 
 17945                              <1> 	; Update directory entry
 17946 00012308 E81B97FFFF          <1> 	call	convert_current_date_time
 17947                              <1> 	; OUTPUT -> DX = Date in dos dir entry format
 17948                              <1>         ; 	    AX = Time in dos dir entry format	
 17949 0001230D 66894716            <1> 	mov	[edi+DirEntry_WrtTime], ax
 17950 00012311 66895718            <1> 	mov	[edi+DirEntry_WrtDate], dx	
 17951 00012315 66895712            <1> 	mov	[edi+DirEntry_LastAccDate], dx
 17952                              <1> 	
 17953 00012319 58                  <1> 	pop	eax ; *
 17954                              <1> 
 17955 0001231A BB[9C090300]        <1> 	mov	ebx, rw_buffer ; Common r/w sector buffer addr
 17956 0001231F B901000000          <1> 	mov	ecx, 1
 17957                              <1> 	; esi = logical dos description table address
 17958                              <1> 	; eax = disk sector number/address (LBA)
 17959                              <1> 	; ecx = sector count
 17960                              <1> 	; ebx = buffer address
 17961 00012324 E885080000          <1> 	call	disk_write
 17962 00012329 0F8234FFFFFF        <1> 	jc	uflmdt_2
 17963                              <1> 	
 17964                              <1> 	; save directory buffer if has modified/changed sign
 17965 0001232F E89297FFFF          <1> 	call	save_directory_buffer
 17966 00012334 C3                  <1> 	retn
 17967                              <1> 
 17968                              <1> uflmdt_11:
 17969                              <1> 	; 24/10/2016
 17970                              <1> 	; Update last modification date & time of a file
 17971                              <1> 	; on a disk with Singlix File System.
 17972                              <1> 	;
 17973                              <1> 	; (Method: Read the FDT -File Description Table-
 17974                              <1> 	; sector of the file and update the lmdt data fields,
 17975                              <1> 	; then write FDT sector to the disk.
 17976                              <1> 	; /// It is easy but there is compatibility buffer
 17977                              <1> 	; method also for changing directory entry data and
 17978                              <1> 	; also there are some programming issues for Singlix
 17979                              <1> 	; file system (TRFS), which are not completed yet!)
 17980                              <1> 	;
 17981                              <1> 	; Not ready yet ! (24/10/2016)
 17982                              <1> 	; /// Temporary code for error return ! ///
 17983 00012335 31C0                <1> 	xor	eax, eax
 17984 00012337 F9                  <1> 	stc
 17985 00012338 C3                  <1> 	retn
 17986                              <1> 
 17987                              <1> sysalloc:
 17988                              <1> 	; 14/10/2017
 17989                              <1> 	; 20/08/2017, 01/09/2017
 17990                              <1> 	; 20/02/2017, 04/03/2017, 15/05/2017
 17991                              <1> 	; 19/02/2017 - TRDOS 386 (TRDOS v2.0)
 17992                              <1> 	; (TRDOS 386 feature only!)
 17993                              <1> 	;
 17994                              <1> 	; Allocate Contiguous Memory Block/Pages (for user)
 17995                              <1> 	; (System call for DMA Buffer allocation etc.)	
 17996                              <1> 	;
 17997                              <1> 	; INPUT ->
 17998                              <1> 	;	EBX = Virtual address (for user)
 17999                              <1> 	;	     (Physical memory block/aperture
 18000                              <1> 	;	     will be mapped to this virtual address) 
 18001                              <1> 	;	ECX = Byte Count
 18002                              <1> 	;	     (will be rounded up to page border)
 18003                              <1> 	;	If ECX = 0
 18004                              <1> 	;	    System call will return with an error (cf=1)
 18005                              <1> 	;	    but ECX will contain maximum size of
 18006                              <1> 	;	    available memory aperture and physical
 18007                              <1> 	;	    (beginning) address of that aperture
 18008                              <1> 	;	    (which have maximum size) will be in EAX.
 18009                              <1> 	;	EDX = Upper limit of the requested physical memory
 18010                              <1> 	;	      block/pages.
 18011                              <1> 	;	     (The last byte address of the memory aperture 
 18012                              <1> 	;	      must not be equal to or above this limit.)	
 18013                              <1> 	;	If EDX = 0
 18014                              <1> 	; 	   there is NOLIMIT !
 18015                              <1> 	;	If EDX = 0FFFFFFFFh (-1) 
 18016                              <1> 	;	   ESI = Lower Limit !
 18017                              <1> 	;		(Beginning of the block must not be 'less'
 18018                              <1> 	;		than this.) (Must be equal to or above...)
 18019                              <1> 	;	   EDI = Upper Limit !
 18020                              <1> 	;		(End of the block must be !less! than this)
 18021                              <1> 	;		(The last byte addr of the memory aperture 
 18022                              <1> 	;		must not be equal to or above this limit.)
 18023                              <1> 	;
 18024                              <1> 	; OUTPUT ->
 18025                              <1> 	;	If CF = 0
 18026                              <1> 	;	EAX = Physical address of the allocated memory block
 18027                              <1> 	;	ECX = Allocated bytes (as rounded up to page borders)
 18028                              <1> 	;	EBX = Virtual address (as rounded up)
 18029                              <1> 	;	IF CF = 1
 18030                              <1> 	;	    Requested (size of) Memory block could not be 
 18031                              <1> 	;	    allocated to the user!	
 18032                              <1> 	;	IF CF = 1 & EAX = 0 (Insufficient memory error!)
 18033                              <1> 	;	   ECX = Total number of free bytes
 18034                              <1> 	;	         (not size of available contiguous bytes!)		 	
 18035                              <1> 	;	If CF = 1 & EAX > 0
 18036                              <1> 	;	   there is not a memory aperture with requested size
 18037                              <1> 	;	   but total free mem is not less than requested size.
 18038                              <1> 	;	   EAX = Physical addr of available memory aperture
 18039                              <1> 	;	   	 with max size 
 18040                              <1> 	;	        (but it doesn't fit to the conditions!) 	
 18041                              <1> 	;	   ECX = Size of available memory aperture in bytes.
 18042                              <1> 	;	If CF = 1 -> EAX = 0FFFFFFFFh	
 18043                              <1> 	;	   Conditions/Parameters are wrong !		 		
 18044                              <1> 	;	   ECX is same with input value.
 18045                              <1> 	;
 18046                              <1> 	; Note:	Previously allocated pages will be deallocated if
 18047                              <1> 	;       new allocation conditions are met.
 18048                              <1> 	;
 18049                              <1> 	; Note: u.break control may be included in future versions	
 18050                              <1> 	;
 18051                              <1> 
 18052 00012339 31C0                <1> 	xor	eax, eax ; 0
 18053                              <1> 	; 14/10/2017
 18054 0001233B 4A                  <1> 	dec	edx ; is there a limit ?
 18055 0001233C 7810                <1> 	js	short sysalloc_1 ;  0 -> 0FFFFFFFFh -> NO LIMIT
 18056 0001233E 42                  <1> 	inc	edx ; > 0
 18057                              <1> 	; Check upper address limit
 18058                              <1> 	;(round up to page borders)
 18059 0001233F 81C1FF0F0000        <1> 	add	ecx, PAGE_SIZE-1 ; 4095
 18060 00012345 6681E100F0          <1> 	and	cx, ~PAGE_OFF ; not 4095
 18061 0001234A 39CA                <1> 	cmp	edx, ecx ; upper limit - block size
 18062 0001234C 7224                <1> 	jb	short sysalloc_err
 18063                              <1> sysalloc_1:
 18064                              <1> 	; EAX = Beginning address (physical)
 18065                              <1> 	; EAX = 0 -> Allocate mem block from the 1st proper aperture	
 18066                              <1> 	; ECX = Number of bytes to be allocated		
 18067 0001234E E83241FFFF          <1> 	call	allocate_memory_block
 18068 00012353 721D                <1> 	jc	short sysalloc_err
 18069                              <1> 	; 01/09/2017
 18070 00012355 29C2                <1> 	sub	edx, eax ; upper limit address - beginning address
 18071 00012357 760F                <1> 	jna	short sysalloc_3 ; begin addr not less than the limit
 18072 00012359 39CA                <1> 	cmp	edx, ecx
 18073 0001235B 720B                <1> 	jb	short sysalloc_3 ; end address overs the limit
 18074                              <1> sysalloc_2:	
 18075                              <1> 	; EAX = Beginning (physical) addr of the allocated mem block
 18076                              <1> 	; ECX = Num of allocated bytes (rounded up to page borders) 
 18077 0001235D 50                  <1> 	push	eax ; * ; 04/03/2017	
 18078                              <1> 	; Here, requested contiquous memory pages have been allocated
 18079                              <1> 	; on Memory Allocation Table but user's page directory 
 18080                              <1> 	; and page tables have not been updated yet!
 18081 0001235E 51                  <1> 	push	ecx ; **
 18082                              <1> 	; ebx = virtual address (will be rounded up to page border)
 18083                              <1> 	; ecx = number of bytes to be deallocated
 18084                              <1> 	;	will be adjusted to ebx+ecx round down - ebx round up
 18085 0001235F E87C44FFFF          <1> 	call	deallocate_user_pages 
 18086 00012364 731F                <1> 	jnc	short sysalloc_4 ; EAX = Deallocated memory bytes
 18087 00012366 59                  <1> 	pop	ecx ; **
 18088 00012367 58                  <1> 	pop	eax ; *
 18089                              <1> sysalloc_3:
 18090                              <1> 	; error !
 18091                              <1> 	; restore Memory Allocation Table Content
 18092 00012368 E82543FFFF          <1> 	call	deallocate_memory_block
 18093 0001236D 31C0                <1> 	xor	eax, eax ; 0
 18094 0001236F 48                  <1> 	dec	eax ; 0FFFFFFFFh ; 15/05/2017
 18095 00012370 EB09                <1> 	jmp	short sysalloc_wrong
 18096                              <1> sysalloc_err:
 18097 00012372 8B2D[60030300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
 18098 00012378 894D18              <1> 	mov	[ebp+24], ecx ; return to user with ecx value 
 18099                              <1> sysalloc_wrong:
 18100                              <1> 	; eax = 0FFFFFFFFh
 18101 0001237B A3[64030300]        <1> 	mov	[u.r0], eax
 18102 00012380 E967B5FFFF          <1> 	jmp	error
 18103                              <1> sysalloc_4:
 18104 00012385 8B2D[60030300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
 18105 0001238B 894518              <1> 	mov	[ebp+24], eax ; return to user with ecx value 
 18106 0001238E 895D10              <1> 	mov	[ebp+16], ebx ; new value of ebx (rounded up)
 18107 00012391 89C1                <1> 	mov	ecx, eax ; byte count (from 'deallocate_user_pages')
 18108 00012393 5A                  <1> 	pop	edx ; ** ; discard (another) byte count
 18109 00012394 58                  <1> 	pop	eax ; *
 18110 00012395 A3[64030300]        <1> 	mov	[u.r0], eax ; physical address
 18111                              <1> 	
 18112 0001239A 51                  <1> 	push	ecx ; 20/08/2017
 18113                              <1> 	;
 18114                              <1> 	; Write newly allocated contiguous (physical) pages
 18115                              <1> 	; on page dir and page tables of current user/process	
 18116                              <1> 	; as PRESENT, USER, WRITABLE
 18117                              <1> 	; (then clear allocated pages)
 18118 0001239B E83545FFFF          <1> 	call	allocate_user_pages
 18119                              <1> 	;jnc	sysret ; OK! return to process with success...
 18120                              <1> 
 18121                              <1> 	; 20/08/2017 ('sysdma' modification)
 18122 000123A0 59                  <1> 	pop	ecx
 18123 000123A1 A1[64030300]        <1> 	mov	eax, [u.r0]   ; physical address (of the block)
 18124                              <1> 
 18125 000123A6 721D                <1> 	jc	short sysalloc_6
 18126                              <1> 
 18127 000123A8 833D[F4A00100]FF    <1> 	cmp	dword [dma_addr], 0FFFFFFFFh ; -1	
 18128 000123AF 0F8257B5FFFF        <1> 	jb	sysret
 18129                              <1> 
 18130 000123B5 A3[F4A00100]        <1> 	mov	[dma_addr], eax ; save dma address for sysdma
 18131 000123BA 890D[F8A00100]      <1> 	mov	[dma_size], ecx ; save dma buff size for sysdma
 18132                              <1> 
 18133 000123C0 E947B5FFFF          <1> 	jmp	sysret
 18134                              <1> 		
 18135                              <1> sysalloc_6:
 18136                              <1> 	;
 18137                              <1> 	; unexpected error ! insufficient memory !? conflict !?
 18138                              <1> 	; (!!?there is not a free page for a new page table?!!)
 18139                              <1> 	; We need to terminate process with error message !!!  
 18140                              <1> 	;
 18141 000123C5 8B2D[60030300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
 18142 000123CB 8B4D18              <1> 	mov	ecx, [ebp+24] ; byte count
 18143                              <1> 	
 18144                              <1> 	; 20/08/2017
 18145                              <1> 	;mov	eax, [u.r0]   ; physical address (of the block)
 18146                              <1> 	
 18147                              <1> 	;
 18148                              <1> 	; restore Memory Allocation Table Content
 18149 000123CE E8BF42FFFF          <1> 	call	deallocate_memory_block
 18150                              <1> 	;
 18151 000123D3 803D[DA6F0000]03    <1> 	cmp	byte [CRT_MODE], 3 ; 80x25 text mode?
 18152 000123DA 7407                <1> 	je	short sysalloc_7 ; yes
 18153                              <1> 	; Current mode is VGA (or CGA graphics) mode,
 18154                              <1> 	; We need to return to text mode for displaying
 18155                              <1> 	; error message just before 'sysexit'.  
 18156 000123DC B003                <1> 	mov	al, 3
 18157 000123DE E88DF7FEFF          <1> 	call	_set_mode
 18158                              <1> sysalloc_7:
 18159 000123E3 BE[24440100]        <1> 	mov	esi, beep_Insufficient_Memory ; error message
 18160 000123E8 E87851FFFF          <1> 	call	print_msg ; print/display the message
 18161 000123ED B801000000          <1> 	mov	eax, 1 ; ax=1 is needed for 'sysexit' procedure
 18162 000123F2 E99CB6FFFF          <1> 	jmp	sysexit ; and terminate the process !
 18163                              <1> 
 18164                              <1> sysdalloc:
 18165                              <1> 	; 19/02/2017 - TRDOS 386 (TRDOS v2.0)
 18166                              <1> 	; (TRDOS 386 feature only!)
 18167                              <1> 	;
 18168                              <1> 	; Deallocate Memory Block/Pages (for user)
 18169                              <1> 	; (Complementary call for sysalloc.)	
 18170                              <1> 	;
 18171                              <1> 	; INPUT ->
 18172                              <1> 	;	EBX = Virtual address (for user)
 18173                              <1> 	;	      (will be rounded up to page border)
 18174                              <1> 	;	ECX = Byte Count
 18175                              <1> 	;	     (will be adjusted to page borders)
 18176                              <1> 	;	If ICX = 0
 18177                              <1> 	;	   nothing to do
 18178                              <1> 	;	If EBX + ECX > User's ESP
 18179                              <1> 	;	   nothing to do		
 18180                              <1> 	; 
 18181                              <1> 	; Note: u.break control may be included in future versions	
 18182                              <1> 	;
 18183                              <1> 	; OUTPUT ->
 18184                              <1> 	;	If CF = 0
 18185                              <1> 	;	   EAX = Deallocated memory bytes
 18186                              <1> 	;	   EBX = Virtual address (as rounded up)	
 18187                              <1> 	;	IF CF = 1
 18188                              <1> 	;	   EAX = 0
 18189                              <1> 	;
 18190                              <1> 	; Note:	Main purpose of this call is to deallocate/release
 18191                              <1> 	;	previously allocated (physically) contiguous memory
 18192                              <1> 	;	pages but beginning (virtual) address may not be
 18193                              <1> 	;	followed by physically contiguous pages. So, this
 18194                              <1> 	;	system call will deallocate user's virtually
 18195                              <1> 	;	contiguous memory pages. Also, there is not any
 18196                              <1> 	;	objections to use this system call without sysalloc
 18197                              <1> 	;	system call; only possible objection is to lost data
 18198                              <1> 	;	within user's memory space, if the beginning address
 18199                              <1> 	;	and size is not proper.
 18200                              <1> 	;
 18201                              <1> 	; Note: Empty page tables will not be deallocated!!!
 18202                              <1> 	;       (they will be deallocated at process termination)
 18203                              <1> 	;
 18204                              <1> 	; Note: When the program terminates itself or when it is 
 18205                              <1> 	;	terminated by operating system kernel, all allocated
 18206                              <1> 	;	memory pages will be deallocated during termination
 18207                              <1> 	;	stage. So, 'sysdalloc' is not necessary except 
 18208                              <1> 	;	forgiving memory block to other programs/processes.
 18209                              <1> 	;	
 18210 000123F7 8B15[5C030300]      <1> 	mov	edx, [u.sp]
 18211 000123FD 8B420C              <1> 	mov	eax, [edx+12] ; user's stack pointer
 18212 00012400 29C8                <1> 	sub	eax, ecx ; esp - byte count
 18213 00012402 24FC                <1> 	and	al, 0FCh ; dword alignment
 18214 00012404 39D8                <1> 	cmp	eax, ebx
 18215 00012406 7220                <1> 	jb	short sysdalloc_err ; deallocation overlaps with stack 	
 18216                              <1> 
 18217 00012408 31C0                <1> 	xor	eax, eax
 18218 0001240A 21C9                <1> 	and	ecx, ecx
 18219 0001240C 7407                <1> 	jz	short sysdalloc_2
 18220                              <1> 	
 18221 0001240E E8CD43FFFF          <1> 	call	deallocate_user_pages
 18222 00012413 7213                <1> 	jc	short sysdalloc_err
 18223                              <1> 
 18224                              <1> sysdalloc_2:
 18225 00012415 A3[64030300]        <1> 	mov	[u.r0], eax
 18226 0001241A 8B2D[60030300]      <1> 	mov	ebp, [u.usp]
 18227 00012420 895D10              <1> 	mov	[ebp+16], ebx ; new value of ebx
 18228 00012423 E9E4B4FFFF          <1> 	jmp	sysret
 18229                              <1> 
 18230                              <1> sysdalloc_err:
 18231 00012428 A3[64030300]        <1> 	mov	[u.r0], eax ; 0
 18232 0001242D E9BAB4FFFF          <1> 	jmp	error
 18233                              <1> 
 18234                              <1> syscalbac:
 18235                              <1> 	; SYS CALLBACK
 18236                              <1> 	; 03/08/2020
 18237                              <1> 	; 16/04/2017
 18238                              <1> 	; 14/04/2017
 18239                              <1> 	; 13/04/2017
 18240                              <1> 	; 28/02/2017
 18241                              <1> 	; 26/02/2017
 18242                              <1> 	; 24/02/2017
 18243                              <1> 	; 21/02/2017 - TRDOS 386 (TRDOS v2.0)
 18244                              <1> 	; (TRDOS 386 feature only!)
 18245                              <1> 	;
 18246                              <1> 	; Link or unlink IRQ callback service to/from user (ring 3)	
 18247                              <1> 	;
 18248                              <1> 	; INPUT ->
 18249                              <1> 	;	BL = IRQ number (Hardware interrupt request number)
 18250                              <1> 	;	     (0 t0 15 but IRQ 0,1,2,6,8,14,15 are prohibited)
 18251                              <1> 	;	     IRQ numbers 3,4,5,7,9,10,11,12,13 are valid
 18252                              <1> 	;	     (numbers >15 are invalid)
 18253                              <1> 	;
 18254                              <1> 	;	BH = 0 = Unlink IRQ (in BL) from user (ring 3) service
 18255                              <1> 	;	     1 = Link IRQ by using Signal Response Byte method
 18256                              <1> 	;	     2 = Link IRQ by using Callback service method 		
 18257                              <1> 	;	     3 = Link IRQ by using Auto Increment S.R.B. method 	
 18258                              <1> 	;	    >3 = invalid 
 18259                              <1> 	;	
 18260                              <1> 	;	CL = Signal Return/Response Byte value 
 18261                              <1> 	;
 18262                              <1> 	;	If BH = 3, kernel will put a counter value  ; 03/08/2020
 18263                              <1> 	;	          (into the S.R.B. addr)
 18264                              <1> 	;		  between 0 to 255. (start value = CL+1)
 18265                              <1> 	;	
 18266                              <1> 	;	NOTE: counter value, for example: even and odd numbers
 18267                              <1> 	;	      may be used for -audio- DMA buffer switch 
 18268                              <1> 	;	      within double buffer method, etc. 		
 18269                              <1> 	;
 18270                              <1> 	;	EDX = Signal return (Response) byte address
 18271                              <1> 	;	       		  - or -
 18272                              <1> 	;	      Interrupt/Callback service/routine address
 18273                              <1> 	; 	
 18274                              <1> 	;	      (virtual address in user's memory space)
 18275                              <1> 	;
 18276                              <1> 	; OUTPUT ->
 18277                              <1> 	;	CF = 0 & EAX = 0 -> Successful setting
 18278                              <1> 	;	CF = 1 & EAX > 0 -> IRQ is prohibited or locked 
 18279                              <1> 	;			by another process
 18280                              <1> 	;		 eax = ERR_PERM_DENIED -> prohibited or locked
 18281                              <1> 	;		 eax = ERR_INV_PARAMETER -> 
 18282                              <1> 	;		       invalid parameter/option or bad address
 18283                              <1> 	;
 18284                              <1> 	;	NOTE: Timer callbacks are set by using 'systimer'
 18285                              <1> 	;	      system call (IRQ 0, PIT and IRQ 8, RTC)
 18286                              <1> 	;
 18287                              <1> 	;	      Direct keyboard access is performed by using
 18288                              <1> 	;	      Keyboard Interrupt (INT 32h)	 	
 18289                              <1> 	;	
 18290                              <1> 	;	      It is prohibited here because:
 18291                              <1> 	;		1) Signal Response Byte method has not advantage
 18292                              <1> 	;		   against INT 32h, function AH = 1. Also,
 18293                              <1> 	;		   keyboard service interrupt will return with
 18294                              <1> 	;		   ascii and scan codes (AL, AH) while
 18295                              <1> 	;		   SRB method has only 1 byte space for ascii code
 18296                              <1> 	;		   or scan code. One byte signal response is used 
 18297                              <1> 	;		   for ensuring very simple and very fast
 18298                              <1> 	;		   virtual to physical memory address conversion
 18299                              <1> 	;		   without any memory page crossover risk. 
 18300                              <1> 	;		   (Otherwise double page conversion or word 
 18301                              <1> 	;		   alignment would be needed.)
 18302                              <1> 	;		2) Badly written user code (callback code)
 18303                              <1> 	;		   can prevent keyboard and timesharing functions
 18304                              <1> 	;		   of the operating system via continuous and long
 18305                              <1> 	;		   keyboard event handling by callback service.
 18306                              <1> 	;		   (It can cause to lose immediate keystroke 
 18307                              <1> 	;		   response from hardware to user.)
 18308                              <1> 	;		3) If user will check any keyboard events, 'getkey'
 18309                              <1> 	;		   (or 'getchar') must have more priority than other
 18310                              <1> 	;		   (video etc.) events because only control ability
 18311                              <1> 	;		   on a procedural infinite loop is a keyboard or
 18312                              <1> 	;		   mouse event. So user can use keyboard function
 18313                              <1> 	;		   at the end or at the beginning of a loop.
 18314                              <1> 	;		   In this case, INT 32h is used for that purpose
 18315                              <1> 	;		   and timer interrupt etc. callbacks can be used
 18316                              <1> 	;		   for dynamic and synchronized data refresh/transfer
 18317                              <1> 	;		   while cpu is in a static loop (without polling).
 18318                              <1> 	;		   Keyboard Int callback is not more useful because 
 18319                              <1> 	;		   already a manual check (a key is pressed or not)
 18320                              <1> 	;		   can be performed (via INT 32h, AH = 1) efficiently
 18321                              <1> 	;		   in a loop to prevent a locked infinitive loop.
 18322                              <1> 	;
 18323                              <1> 	;	    Disk IRQs (6,14,15) have been phohibited from ring 3 
 18324                              <1> 	;	    callback because, disk operations (file system services
 18325                              <1> 	;	    etc.) are independent from user program, for fast disk r/w.
 18326                              <1> 	;	    They are not more useful at ring 3 while they are in use
 18327                              <1> 	;	    by standard diskio functions which are mandatory part of 
 18328                              <1> 	;	    (monolithic) OS kernel and mainprog command interpreter.
 18329                              <1> 	;	    INT 33h diskio functions are enough for user level disk
 18330                              <1> 	;	    r/w.				
 18331                              <1> 	;
 18332                              <1> 	; TRDOS 386 - IRQ CALLBACK structures (parameters):
 18333                              <1> 	;	
 18334                              <1> 	;	   [u.irqlock] = 1 word, IRQ flags (0-15) that indicates
 18335                              <1> 	;			which IRQs are locked by (that) user.
 18336                              <1> 	;		        Lock and unlock (by user) will change
 18337                              <1> 	;			these flags or 'terminate process' (sysexit)
 18338                              <1> 	;			will clear these flags and unlock those IRQs.
 18339                              <1> 	;			               
 18340                              <1> 	;		   	Bit 0 is for IRQ 0 and Bit 15 is for IRQ 15
 18341                              <1> 	;
 18342                              <1> 	;	   IRQ(x).owner	 : 1 byte, user, [u.uno], 0 = free (unlocked)	
 18343                              <1> 	;
 18344                              <1> 	;	   IRQ(x).method : 1 byte for callback method & status
 18345                              <1> 	;			   0 = Signal Response Byte method
 18346                              <1> 	;			   1 = Callback service method
 18347                              <1> 	;			   >1 = invalid for current 'syscalback'.
 18348                              <1> 	;			or(+) 80h = IRQ is in use by system (ring 0)
 18349                              <1> 	;			            function (audio etc.) or
 18350                              <1> 	;			   	    a device driver.	   	
 18351                              <1> 	;			(system function will ignore the lock/owner)
 18352                              <1> 	;
 18353                              <1> 	;	   IRQ(x).srb	: 1 byte, Signal Return/Response byte value
 18354                              <1> 	;			  (a fixed value by user or a counter value
 18355                              <1> 	;			 from 0 to 255, which is increased by every
 18356                              <1> 	;			 interrupt just before putting it into 
 18357                              <1> 	;			 the Signal Response byte address
 18358                              <1> 	;			 (This is not used in callback serv method)
 18359                              <1> 	;	    	  
 18360                              <1> 	;	   IRQ(x).addr	: 1 dword
 18361                              <1> 	;			  Signal Response Byte address (physical)
 18362                              <1> 	;			  		-or-
 18363                              <1> 	;			  Callback service address (virtual)
 18364                              <1> 	;
 18365                              <1> 	;	   IRQ(x).dev	: 1 byte
 18366                              <1> 	;			  0 = Default device or kernel function
 18367                              <1> 	;			  		-or-
 18368                              <1> 	;			  1-255 = Assigned device driver number
 18369                              <1> 	;
 18370                              <1> 	;	   (x) = 3,4,5,7,9,10,11,12,13
 18371                              <1> 	;
 18372                              <1> 	;	
 18373                              <1> 	;	NOTE: If user's process/program calls the kernel (INT 40h)
 18374                              <1> 	;	      while it is already running in a (ring 3) callback
 18375                              <1> 	;	      service, kernel will force (convert) system call to
 18376                              <1> 	;	      'sysrele' (sys release). So, this feature provides
 18377                              <1> 	;	      easy and simple usage of callback services without
 18378                              <1> 	;	      falling into deepless <please 'callback me' then 
 18379                              <1> 	;	      let me 'callback you'> cycles! (User must return
 18380                              <1> 	;	      from callback service by using 'sysrele' system
 18381                              <1> 	;	      call, without a significant delay. Otherwise user
 18382                              <1> 	;	      process/program may be late to catch the next event
 18383                              <1> 	;	      within same callback purpose.	    		 	
 18384                              <1> 	;
 18385                              <1> 
 18386 00012432 30C0                <1> 	xor	al, al ; the caller is 'syscalbac' sign/flag
 18387 00012434 E85F180000          <1>  	call	set_irq_callback_service
 18388                              <1> 	; 16/04/2017
 18389 00012439 A3[64030300]        <1> 	mov	[u.r0], eax
 18390 0001243E 0F83C8B4FFFF        <1> 	jnc	sysret
 18391 00012444 A3[C8030300]        <1> 	mov	dword [u.error], eax
 18392 00012449 E99EB4FFFF          <1> 	jmp	error
 18393                              <1> 
 18394                              <1> sysfpstat:
 18395                              <1> 	; 28/02/2017 - TRDOS 386 (TRDOS v2.0)
 18396                              <1> 	; (TRDOS 386 feature only!)
 18397                              <1> 	;
 18398                              <1> 	; Set or reset FPU registers save/restore option (for user)
 18399                              <1> 	;	       (during software task switching, wswap-rswap)
 18400                              <1> 	;
 18401                              <1> 	; INPUT ->
 18402                              <1> 	;	BL = 0 -> reset
 18403                              <1> 	;	BL = 1 -> set (FPU register will be saved and restored)
 18404                              <1> 	;	
 18405                              <1> 	; OUTPUT ->
 18406                              <1> 	;	cf = 0 -> no error, FPU is ready... 
 18407                              <1> 	;		  (EAX = 0)
 18408                              <1> 	;	Cf = 1 -> error, 80387 FPU is not ready !
 18409                              <1> 	;		  (EAX = 0FFFFFFFFh)
 18410                              <1> 
 18411 0001244E 31C0                <1> 	xor	eax, eax
 18412 00012450 803D[EC960100]00    <1> 	cmp	byte [fpready], 0
 18413 00012457 7613                <1> 	jna	short sysfpstat_err	
 18414                              <1> 
 18415 00012459 80E301              <1> 	and	bl, 1 ; use BIT 0 only !
 18416 0001245C 881D[DA030300]      <1> 	mov	[u.fpsave], bl
 18417 00012462 A3[64030300]        <1> 	mov	[u.r0], eax ; 0
 18418 00012467 E9A0B4FFFF          <1> 	jmp	sysret	 	
 18419                              <1> 
 18420                              <1> sysfpstat_err:
 18421 0001246C 48                  <1> 	dec 	eax ; 0FFFFFFFFh
 18422 0001246D A3[64030300]        <1> 	mov 	[u.r0], eax ; -1
 18423 00012472 E975B4FFFF          <1> 	jmp 	error
 18424                              <1> 
 18425                              <1> sysdelete: ; Delete (Remove, Unlink) File
 18426                              <1> 	; 29/12/2017 (TRDOS 386 = TRDOS v2.0) 
 18427                              <1> 	;	
 18428                              <1>         ; INPUT ->
 18429                              <1>         ;          EBX = File name (ASCIIZ string) address
 18430                              <1> 	; OUTPUT ->
 18431                              <1> 	;          cf = 0 -> eax = 0
 18432                              <1> 	;          cf = 1 -> Error code in AL
 18433                              <1> 	;
 18434                              <1> 	; Modified Registers: EAX (at the return of system call)
 18435                              <1> 	;   
 18436                              <1> 
 18437 00012477 89DE                <1> 	mov	esi, ebx
 18438                              <1> 	; file name is forced, change directory as temporary
 18439                              <1> 	;mov	ax, 1
 18440                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset
 18441                              <1> 	;call	set_working_path 
 18442 00012479 E8620B0000          <1> 	call	set_working_path_x
 18443 0001247E 731D                <1> 	jnc	short sysdelete_1
 18444                              <1> 
 18445 00012480 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 18446 00012482 7505                <1> 	jnz	short sysdelete_err
 18447                              <1> 	; eax = 0
 18448                              <1> sysdelete_path_err:
 18449 00012484 B813000000          <1> 	mov	eax, ERR_INV_PATH_NAME ; 'bad path name !'
 18450                              <1> sysdelete_err:
 18451 00012489 A3[64030300]        <1> 	mov	[u.r0], eax
 18452 0001248E A3[C8030300]        <1> 	mov	[u.error], eax
 18453 00012493 E81D0C0000          <1> 	call 	reset_working_path
 18454 00012498 E94FB4FFFF          <1> 	jmp	error
 18455                              <1> sysdelete_1:
 18456                              <1> 	;mov	esi, FindFile_Name
 18457 0001249D 66B80018            <1> 	mov	ax, 1800h ; Only files
 18458 000124A1 E8EB6FFFFF          <1> 	call	find_first_file
 18459 000124A6 72E1                <1> 	jc	short sysdelete_err
 18460                              <1> sysdelete_2:
 18461                              <1> 	; check file attributes
 18462                              <1> 
 18463                              <1> 	;test	bl, 17 ; system, hidden, readonly, directory
 18464 000124A8 F6C307              <1>         test	bl, 7 ; system, hidden, readonly 
 18465 000124AB 7407                <1>         jz	short sysdelete_3
 18466                              <1> 
 18467 000124AD B80B000000          <1>         mov	eax, ERR_FILE_ACCESS ; 11 = 'permission denied !'
 18468 000124B2 EBD5                <1>         jmp	short sysdelete_err
 18469                              <1> sysdelete_3:
 18470 000124B4 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
 18471 000124B7 7407                <1> 	jz	short sysdelete_4
 18472 000124B9 B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME ; 26 = 'invalid file name !'
 18473 000124BE EBC9                <1>         jmp	short sysdelete_err
 18474                              <1> sysdelete_4:
 18475                              <1> 	;mov	bh, [LongName_EntryLength]
 18476 000124C0 883D[5E940100]      <1> 	mov	[DelFile_LNEL], bh ; Long name entry length (if > 0)
 18477                              <1> 	; edi = Directory Entry Offset (DirBuff)
 18478                              <1> 	; esi = Directory Entry (FFF Structure)
 18479 000124C6 E84399FFFF          <1> 	call	remove_file
 18480 000124CB 72BC                <1> 	jc	short sysdelete_err
 18481                              <1> sysrmdir_5:
 18482 000124CD 31C0                <1> 	xor	eax, eax ; 0
 18483 000124CF A3[64030300]        <1> 	mov	[u.r0], eax
 18484                              <1> 	;mov	[u.error], eax
 18485 000124D4 E8DC0B0000          <1> 	call 	reset_working_path
 18486 000124D9 E92EB4FFFF          <1> 	jmp	sysret
 18487                              <1> 
 18488                              <1> 
 18489                              <1> sysrmdir: ; Remove (Unlink) Directory
 18490                              <1> 	; 19/01/2021
 18491                              <1> 	; 29/12/2017 (TRDOS 386 = TRDOS v2.0) 
 18492                              <1> 	;	
 18493                              <1>         ; INPUT ->
 18494                              <1>         ;          EBX = Pointer to directory name
 18495                              <1> 	; OUTPUT ->
 18496                              <1> 	;          cf = 0 -> eax = 0
 18497                              <1> 	;          cf = 1 -> Error code in AL
 18498                              <1> 	;
 18499                              <1> 	; Modified Registers: EAX (at the return of system call)
 18500                              <1> 	;  
 18501                              <1> 
 18502                              <1> 	; 19/01/2021
 18503 000124DE 803D[B0030300]00    <1> 	cmp	byte [u.uid], 0  ; root (super user) ?
 18504 000124E5 7614                <1> 	jna	short sysrmdir_0
 18505                              <1> 
 18506                              <1> 	;mov	dword [u.r0], ERR_PERM_DENIED
 18507 000124E7 B80B000000          <1> 	mov	eax, ERR_PERM_DENIED ; ERR_NOT_SUPERUSER
 18508 000124EC A3[64030300]        <1> 	mov	[u.r0], eax
 18509 000124F1 A3[C8030300]        <1> 	mov	[u.error], eax
 18510 000124F6 E9F1B3FFFF          <1> 	jmp	error
 18511                              <1> 
 18512                              <1> sysrmdir_0:
 18513 000124FB 89DE                <1> 	mov	esi, ebx
 18514                              <1> 	; file name is forced, change directory as temporary
 18515                              <1> 	;mov	ax, 1
 18516                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset
 18517                              <1> 	;call	set_working_path 
 18518 000124FD E8DE0A0000          <1> 	call	set_working_path_x
 18519 00012502 731D                <1> 	jnc	short sysrmdir_1
 18520                              <1> 
 18521 00012504 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 18522 00012506 7505                <1> 	jnz	short sysrmdir_err
 18523                              <1> 	; eax = 0
 18524                              <1> sysrmdir_not_found:
 18525 00012508 B80C000000          <1> 	mov	eax, ERR_DIR_NOT_FOUND ; Directory not found !
 18526                              <1> sysrmdir_err:
 18527 0001250D A3[64030300]        <1> 	mov	[u.r0], eax
 18528 00012512 A3[C8030300]        <1> 	mov	[u.error], eax
 18529 00012517 E8990B0000          <1> 	call 	reset_working_path
 18530 0001251C E9CBB3FFFF          <1> 	jmp	error
 18531                              <1> sysrmdir_1:
 18532                              <1> 	;mov	esi, FindFile_Name
 18533 00012521 66B81008            <1> 	mov	ax, 0810h ; Only directories
 18534 00012525 E8676FFFFF          <1> 	call	find_first_file
 18535 0001252A 7306                <1> 	jnc	short sysrmdir_2
 18536                              <1> 
 18537                              <1> 	; eax = 2 (File not found !)
 18538 0001252C 3C02                <1> 	cmp	al, 2 ; ERR_NOT_FOUND
 18539 0001252E 74D8                <1> 	je	short sysrmdir_not_found
 18540 00012530 EBDB                <1> 	jmp	short sysrmdir_err
 18541                              <1> sysrmdir_2:
 18542                              <1> 	; check directory attributes
 18543                              <1> 
 18544 00012532 F6C307              <1>         test	bl, 7 ; system, hidden, readonly 
 18545 00012535 7407                <1>         jz	short sysrmdir_3
 18546                              <1> 
 18547 00012537 B80B000000          <1>         mov	eax, ERR_DIR_ACCESS ; 11 = 'permission denied !'
 18548 0001253C EBCF                <1>         jmp	short sysrmdir_err
 18549                              <1> sysrmdir_3:
 18550 0001253E 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
 18551 00012541 7407                <1> 	jz	short sysrmdir_4
 18552                              <1> 	;mov	eax, ERR_NOT_DIR ; 'not a valid directory !'
 18553 00012543 B813000000          <1> 	mov	eax, ERR_INV_PATH_NAME ; 'bad path name !'
 18554 00012548 EBC3                <1>         jmp	short sysrmdir_err
 18555                              <1> sysrmdir_4:
 18556                              <1> 	;mov	bh, [LongName_EntryLength]
 18557 0001254A 883D[5E940100]      <1> 	mov	[DelFile_LNEL], bh ; Long name entry length (if > 0)
 18558                              <1> 	; edi = Directory Entry Offset (DirBuff)
 18559                              <1> 	; esi = Directory Entry (FFF Structure)
 18560 00012550 E81176FFFF          <1> 	call	delete_sub_directory
 18561 00012555 0F8372FFFFFF        <1> 	jnc	sysrmdir_5
 18562                              <1> ;	jc	short sysrmdir_6
 18563                              <1> ;
 18564                              <1> ;	xor	eax, eax ; 0
 18565                              <1> ;sysrmdir_5:
 18566                              <1> ;	mov	[u.r0], eax
 18567                              <1> ;	;mov	[u.error], eax
 18568                              <1> ;	call 	reset_working_path
 18569                              <1> ;	jmp	sysret
 18570                              <1> sysrmdir_6:
 18571 0001255B A3[64030300]        <1> 	mov	[u.r0], eax
 18572 00012560 A3[C8030300]        <1> 	mov	[u.error], eax
 18573                              <1> 
 18574 00012565 09C0                <1> 	or	eax, eax ; EAX = 0 -> Directory not empty!
 18575 00012567 741C                <1> 	jz	short sysrmdir_9
 18576                              <1> 
 18577                              <1> 	; EAX > 0 -> Error code in AL (or AX or EAX)
 18578                              <1> 
 18579 00012569 833D[12920100]01    <1> 	cmp	dword [FAT_ClusterCounter], 1
 18580 00012570 7209                <1> 	jb	short sysrmdir_8
 18581                              <1> sysrmdir_7:
 18582                              <1> 	; ESI = Logical DOS Drive Description Table address	
 18583 00012572 66BB00FF            <1> 	mov	bx, 0FF00h ; BH = FFh -> use ESI for Drive parameters
 18584                              <1> 	           ; BL = 0 -> Recalculate free cluster count
 18585 00012576 E877AEFFFF          <1> 	call	calculate_fat_freespace	
 18586                              <1> sysrmdir_8:
 18587 0001257B E8350B0000          <1> 	call 	reset_working_path
 18588 00012580 E967B3FFFF          <1> 	jmp	error
 18589                              <1> 
 18590                              <1> sysrmdir_9:
 18591 00012585 A1[12920100]        <1> 	mov	eax, [FAT_ClusterCounter]
 18592 0001258A 09C0                <1> 	or	eax, eax ; 0 ?
 18593 0001258C 0F847BFFFFFF        <1> 	jz	sysrmdir_err
 18594                              <1> 	; ESI = Logical DOS Drive Description Table address	
 18595 00012592 66BB01FF            <1> 	mov	bx, 0FF01h ; BH = FFh -> use ESI for Drive parameters
 18596                              <1> 	           ; BL = 1 -> add free clusters
 18597 00012596 E857AEFFFF          <1> 	call	calculate_fat_freespace
 18598 0001259B 09C9                <1> 	or	ecx, ecx
 18599 0001259D 74DC                <1>         jz	short sysrmdir_8 ; ecx = 0 -> OK
 18600                              <1> 	; ecx > 0 -> Error (Recalculation is needed)
 18601 0001259F EBD1                <1> 	jmp	short sysrmdir_7
 18602                              <1> 
 18603                              <1> 
 18604                              <1> syschdir: ; Change Current (Working) Drive & Directory (for user)
 18605                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 18606                              <1> 	;	
 18607                              <1>         ; INPUT ->
 18608                              <1>         ;          EBX = Directory name (ASCIIZ string) address
 18609                              <1> 	; OUTPUT ->
 18610                              <1> 	;          cf = 0 -> eax = 0
 18611                              <1> 	;          cf = 1 -> Error code in AL
 18612                              <1> 	;
 18613                              <1> 	; Modified Registers: EAX (at the return of system call)
 18614                              <1> 	;
 18615                              <1> 	; NOTE: If drive name is not included, only the working
 18616                              <1> 	; directory (for user, not for drive/OS) will be chanded.
 18617                              <1> 	; If there is a drive name (as A:, B:, C:, D: etc.)
 18618                              <1> 	; at the beginning of the ASCIIZ (directory) string,
 18619                              <1> 	; working drive and working directory (for user) 
 18620                              <1> 	; will be changed together.
 18621                              <1> 	; (When the program is terminated, MainProg -internal 
 18622                              <1> 	; shell- will reset working directory to the previous
 18623                              <1> 	; -current- logical drive's current directory again.) 	
 18624                              <1>   
 18625 000125A1 89DE                <1> 	mov	esi, ebx
 18626                              <1> 	; file name is not forced, change directory as temporary
 18627 000125A3 31C0                <1> 	xor	eax, eax
 18628                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset
 18629                              <1> 	;call	set_working_path 
 18630 000125A5 E83A0A0000          <1> 	call	set_working_path_xx
 18631 000125AA 731D                <1> 	jnc	short syschdir_ok
 18632 000125AC 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 18633 000125AE 7505                <1> 	jnz	short syschdir_err
 18634                              <1> 	; eax = 0
 18635                              <1> syschdir_not_found:
 18636 000125B0 B80C000000          <1> 	mov	eax, ERR_DIR_NOT_FOUND ; Directory not found !
 18637                              <1> syschdir_err:
 18638 000125B5 A3[64030300]        <1> 	mov	[u.r0], eax
 18639 000125BA A3[C8030300]        <1> 	mov	[u.error], eax
 18640 000125BF E8F10A0000          <1> 	call 	reset_working_path
 18641 000125C4 E923B3FFFF          <1> 	jmp	error
 18642                              <1> syschdir_ok:
 18643 000125C9 31C0                <1> 	xor	eax, eax ; 0
 18644 000125CB A3[64030300]        <1> 	mov	[u.r0], eax
 18645                              <1> 	;mov	[u.error], eax
 18646 000125D0 E937B3FFFF          <1> 	jmp	sysret
 18647                              <1> 
 18648                              <1> 
 18649                              <1> syschmod: ; Get & Change File (or Directory) Attributes
 18650                              <1> 	; 19/01/2021
 18651                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 18652                              <1> 	;	
 18653                              <1>         ; INPUT ->
 18654                              <1>         ;          EBX = File/Directory (ASCIIZ) name address
 18655                              <1> 	;	    CL = New attributes (if CL < 40h)
 18656                              <1> 	;	    CL >= 40h -> Get File Attributes		
 18657                              <1> 	; OUTPUT ->
 18658                              <1> 	;          cf = 0 -> EAX = File attributes (in AL)
 18659                              <1> 	;          cf = 1 -> Error code in AL
 18660                              <1> 	;
 18661                              <1> 	; Modified Registers: EAX (at the return of system call)
 18662                              <1> 	;  
 18663                              <1> 	; MSDOS File Attributes:    (bit value of attrib byte)
 18664                              <1> 	;	ATTR_READ_ONLY	=	01h  (bit 0, 'R')
 18665                              <1> 	;	ATTR_HIDDEN	=	02h  (bit 1, 'H')
 18666                              <1> 	;	ATTR_SYSTEM	=	04h  (bit 2, 'S')
 18667                              <1> 	;	ATTR_VOLUME_ID	=	08h  (bit 3)
 18668                              <1> 	;	ATTR_DIRECTORY	=	10h  (bit 4)
 18669                              <1> 	;	ATTR_ARCHIVE	=	20h  (bit 5, 'A')
 18670                              <1> 	;	ATTR_LONG_NAME	=	ATTR_READONLY |
 18671                              <1> 	;				ATTR_HIDDEN |
 18672                              <1> 	;				ATTR_SYSTEM |
 18673                              <1> 	;				ATTR_VOLUME_ID				
 18674                              <1> 	;	The upper two bits of attributes must be 0.
 18675                              <1> 
 18676                              <1> 	; Note:	* If ATTR_DIRECTORY is set, only directory names
 18677                              <1> 	;	  will be searched (and S,H,R,A attributeds of 
 18678                              <1> 	;	  the directory will be changed.)
 18679                              <1> 	;	* If ATTR_VOLUME_ID is set, 'syschmod' system call
 18680                              <1> 	;	  will return with 'permission denied' error.
 18681                              <1> 	;	* If ATTR_DIRECTORY is not set, only file names
 18682                              <1> 	;	  will be searched (and S,H,R,A attributes of the
 18683                              <1> 	;	  file will be changed.)
 18684                              <1> 	;
 18685                              <1> 	; (Ony Super User can change S,H,R attributes.) 
 18686                              <1> 
 18687 000125D5 80F940              <1> 	cmp	cl, 40h	
 18688 000125D8 7327                <1> 	jnb	short syschmod_0
 18689                              <1> 
 18690 000125DA F6C108              <1> 	test	cl, 08h ; ATTR_VOLUME_ID
 18691 000125DD 750E                <1> 	jnz	short syschmod_perm_err
 18692                              <1> 
 18693                              <1> 	; 19/01/2021
 18694 000125DF 803D[B0030300]00    <1> 	cmp	byte [u.uid], 0  ; root (super user) ?
 18695 000125E6 7619                <1> 	jna	short syschmod_0
 18696                              <1> 
 18697                              <1> 	; Not super user..
 18698 000125E8 F6C107              <1> 	test	cl, 07h	; S,H,R attributes
 18699 000125EB 7414                <1> 	jz	short syschmod_0
 18700                              <1> 
 18701                              <1> syschmod_perm_err:
 18702                              <1> 	;mov	dword [u.r0], ERR_PERM_DENIED
 18703 000125ED B80B000000          <1> 	mov	eax, ERR_PERM_DENIED ; 'permission denied !'
 18704 000125F2 A3[64030300]        <1> 	mov	[u.r0], eax
 18705 000125F7 A3[C8030300]        <1> 	mov	[u.error], eax
 18706 000125FC E9EBB2FFFF          <1> 	jmp	error
 18707                              <1> 
 18708                              <1> syschmod_0:
 18709 00012601 880D[AC940100]      <1> 	mov	[Attributes], cl
 18710 00012607 89DE                <1> 	mov	esi, ebx
 18711                              <1> 	; file name is forced, change directory as temporary
 18712                              <1> 	;mov	ax, 1
 18713                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset
 18714                              <1> 	;call	set_working_path 
 18715 00012609 E8D2090000          <1> 	call	set_working_path_x
 18716 0001260E 731D                <1> 	jnc	short syschmod_1
 18717 00012610 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 18718 00012612 7505                <1> 	jnz	short syschmod_err
 18719                              <1> 	; eax = 0
 18720                              <1> syschmod_path_not_found:
 18721 00012614 B813000000          <1> 	mov	eax, ERR_INV_PATH_NAME ; 'Bad path name !'
 18722                              <1> syschmod_err:
 18723 00012619 A3[64030300]        <1> 	mov	[u.r0], eax
 18724 0001261E A3[C8030300]        <1> 	mov	[u.error], eax
 18725 00012623 E88D0A0000          <1> 	call 	reset_working_path
 18726 00012628 E9BFB2FFFF          <1> 	jmp	error
 18727                              <1> syschmod_1:
 18728 0001262D B008                <1> 	mov	al, 08h ; Except volume labels (& long names)
 18729 0001262F A0[AC940100]        <1> 	mov	al, [Attributes]
 18730 00012634 2410                <1> 	and	al, 10h ;
 18731                              <1> 	;mov	esi, FindFile_Name
 18732                              <1> 	;mov	ax, 1800h ; Only files
 18733                              <1> 	;mov	ax, 0810h ; Only directories
 18734 00012636 E8566EFFFF          <1> 	call	find_first_file
 18735                              <1> 	;jnc	short syschmod_2
 18736 0001263B 72DC                <1> 	jc	short syschmod_err
 18737                              <1> 
 18738                              <1> 	;; eax = 2 (File not found !)
 18739                              <1> 	;cmp	al, 2 ; ERR_NOT_FOUND
 18740                              <1> 	;jne	short syschmod_err
 18741                              <1> 
 18742                              <1> 	;and	byte [Attributes], 10h
 18743                              <1> 	;jz	short syschmod_err
 18744                              <1> 
 18745                              <1> 	;; Directory not found !
 18746                              <1> 	;mov	al, 3 ; ERR_PATH_NOT_FOUND
 18747                              <1> 	;jmp	short syschmod_err
 18748                              <1> 
 18749                              <1> syschmod_2:
 18750 0001263D 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
 18751 00012640 7407                <1> 	jz	short syschmod_3
 18752 00012642 B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME ; 'invalid file name !'
 18753 00012647 EBD0                <1>         jmp	short syschmod_err
 18754                              <1> syschmod_3:
 18755                              <1> 	; EDI = Directory buffer entry offset/address
 18756                              <1> 	; BL = File (or Directory) Attributes 
 18757                              <1> 	; mov	bl, [EDI+0Bh]
 18758                              <1> 
 18759                              <1> 	; check directory attributes
 18760 00012649 8A3D[AC940100]      <1> 	mov	bh, [Attributes] ; new attributes
 18761 0001264F 80FF40              <1> 	cmp	bh, 40h  ;>=40 -> get file/directory attributes
 18762 00012652 732D                <1> 	jnb	short syschmod_6
 18763                              <1> 
 18764                              <1> 	; set file/directory attributes
 18765 00012654 F6C307              <1> 	test	bl, 7 ; system, hidden, readonly 
 18766 00012657 7409                <1>         jz	short syschmod_4
 18767                              <1> 
 18768                              <1> 	; 19/01/2021
 18769 00012659 803D[B0030300]00    <1> 	cmp	byte [u.uid], 0  ; root (super user) ?
 18770 00012660 778B                <1> 	ja	short syschmod_perm_err
 18771                              <1> syschmod_4:
 18772 00012662 66817F0CA101        <1> 	cmp	word [edi+DirEntry_NTRes], 01A1h ; Singlix FS
 18773 00012668 7424                <1> 	je	short syschmod_7
 18774                              <1> 
 18775 0001266A 887F0B              <1> 	mov	[edi+0Bh], bh    ; Attributes (New!)
 18776                              <1> 
 18777 0001266D C605[1C920100]02    <1> 	mov	byte [DirBuff_ValidData], 2 ; modified sign
 18778                              <1> 					    ; to force write	
 18779 00012674 E84D94FFFF          <1> 	call 	save_directory_buffer
 18780 00012679 729E                <1> 	jc	short syschmod_err
 18781                              <1> 
 18782                              <1> syschmod_5:
 18783 0001267B 8A1D[AC940100]      <1> 	mov	bl, [Attributes]
 18784                              <1> syschmod_6:
 18785 00012681 0FB6C3              <1> 	movzx	eax, bl
 18786 00012684 A3[64030300]        <1> 	mov	[u.r0], eax
 18787                              <1> 	;mov	dword [u.error], 0
 18788 00012689 E97EB2FFFF          <1> 	jmp	sysret
 18789                              <1> 
 18790                              <1> syschmod_7:
 18791 0001268E 29C0                <1> 	sub	eax, eax
 18792 00012690 8A25[1A920100]      <1>         mov     ah, [DirBuff_DRV]
 18793 00012696 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 18794 0001269B 01C6                <1>         add     esi, eax
 18795 0001269D 807E04A1            <1>         cmp     byte [esi+LD_FSType], 0A1h
 18796 000126A1 7307                <1> 	jnc	short syschmod_8
 18797 000126A3 B01D                <1> 	mov	al, ERR_INV_DATA ; 29 = Invalid Data
 18798 000126A5 E96FFFFFFF          <1> 	jmp	syschmod_err
 18799                              <1> 
 18800                              <1> syschmod_8:
 18801                              <1> 	; BH = New MS-DOS File Attributes
 18802 000126AA 88F8                <1> 	mov	al, bh ; File/Directory Attributes
 18803 000126AC 30E4                <1> 	xor	ah, ah ; Attributes in MS-DOS format sign	  
 18804 000126AE E83C7FFFFF          <1> 	call	change_fs_file_attributes
 18805 000126B3 0F8260FFFFFF        <1> 	jc	syschmod_err
 18806 000126B9 EBC0                <1> 	jmp	short syschmod_5
 18807                              <1> 
 18808                              <1> 
 18809                              <1> sysdrive: ; Get/Set Current (Working) Drive (for user)
 18810                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 18811                              <1> 	;	
 18812                              <1>         ; INPUT ->
 18813                              <1>         ;          BL = Logical DOS Drive number (0=A: ... 2=C:)
 18814                              <1> 	;	   If BL = 0FFh -> Get Current Drive 	
 18815                              <1> 	; OUTPUT ->
 18816                              <1> 	;          cf = 0 -> 
 18817                              <1> 	;		   AL = Current Drive number	
 18818                              <1> 	;		   AH = The Last Logical DOS Drive no.
 18819                              <1> 	;          cf = 1 -> Error code in AL
 18820                              <1> 	;
 18821                              <1> 	; Modified Registers: EAX (at the return of system call)
 18822                              <1> 	;
 18823                              <1> 	; NOTE: If the requested logical dos drive is ready, 
 18824                              <1> 	;	it's current current directory will be the user's
 18825                              <1> 	;	(program's) current directory.
 18826                              <1> 	;	(When the program is terminated, MainProg -internal 
 18827                              <1> 	;	shell- will reset the previous -current- logical drive
 18828                              <1> 	;       as current drive again).	
 18829                              <1>   
 18830 000126BB 80FBFF              <1> 	cmp	bl, 0FFh
 18831 000126BE 7435                <1> 	je	short sysdrive_ok
 18832 000126C0 3A1D[C2400100]      <1> 	cmp	bl, [Last_DOS_DiskNo]
 18833 000126C6 771E                <1> 	ja	short sysdrive_err	
 18834                              <1> 
 18835                              <1> 	; Save current drive and reset mode
 18836                              <1> 	; for 'reset_working_path' procedure (for MainProg)
 18837 000126C8 30C0                <1> 	xor	al, al
 18838 000126CA 66A3[E8960100]      <1> 	mov	[SWP_Mode], ax ; ah = 0
 18839 000126D0 A0[F68A0100]        <1> 	mov	al, [Current_Drv]
 18840 000126D5 FEC4                <1> 	inc	ah ; mov ah, 1
 18841 000126D7 66A3[EA960100]      <1> 	mov	[SWP_DRV], ax 
 18842                              <1> 
 18843 000126DD 88DA                <1> 	mov	dl, bl
 18844 000126DF E80A5AFFFF          <1> 	call	change_current_drive
 18845 000126E4 730F                <1> 	jnc	short sysdrive_ok
 18846                              <1> sysdrive_err:
 18847 000126E6 C705[64030300]0F00- <1> 	mov	dword [u.r0], ERR_DRV_NOT_RDY ; 'drive not ready !'
 18847 000126EE 0000                <1>
 18848 000126F0 E9F7B1FFFF          <1> 	jmp	error
 18849                              <1> sysdrive_ok:
 18850 000126F5 A0[F68A0100]        <1> 	mov	al, [Current_Drv]
 18851 000126FA 8A25[C2400100]      <1> 	mov	ah, [Last_DOS_DiskNo]
 18852 00012700 A3[64030300]        <1> 	mov	[u.r0], eax
 18853 00012705 E902B2FFFF          <1> 	jmp	sysret
 18854                              <1> 
 18855                              <1> 
 18856                              <1> sysdir: ; Get Current (Working) Drive & Directory (for user)
 18857                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 18858                              <1> 	;	
 18859                              <1>         ; INPUT ->
 18860                              <1>         ;          EBX = Current directory name buffer address
 18861                              <1> 	;		(Buffer length = 92 bytes)
 18862                              <1> 	; OUTPUT ->
 18863                              <1> 	;          AL = Current drive (0=A: .. 2=C:)
 18864                              <1> 	;	   If CF = 1 -> AL = error code
 18865                              <1> 	;
 18866                              <1> 	; Modified Registers: EAX (at the return of system call)
 18867                              <1> 	;
 18868                              <1> 	; Note: Required directory name buffer length may be 
 18869                              <1> 	;	<= 92 bytes for current TRDOS 386 version.
 18870                              <1> 	;	(7*12 name chars + 7 slash + 0)
 18871                              <1> 
 18872 0001270A 89E5                <1> 	mov	ebp, esp
 18873 0001270C 83EC60              <1> 	sub	esp, 96
 18874 0001270F 53                  <1> 	push	ebx ; User's buffer address
 18875 00012710 30D2                <1> 	xor	dl, dl ; 0 = current drive
 18876 00012712 E8D388FFFF          <1>   	call	get_current_directory
 18877 00012717 72CD                <1> 	jc	short sysdrive_err ; 'drive not ready !' error
 18878 00012719 89E6                <1> 	mov	esi, esp ; System's buffer address
 18879 0001271B 5F                  <1> 	pop	edi  ; User's buffer address
 18880                              <1> 	; ecx = transfer (byte) count (<=92)
 18881 0001271C E843F4FFFF          <1> 	call	transfer_to_user_buffer
 18882 00012721 89EC                <1> 	mov	esp, ebp
 18883 00012723 730F                <1> 	jnc	short sysdir_ok
 18884                              <1> sysdir_err:
 18885 00012725 C705[64030300]2E00- <1> 	mov	dword [u.r0], ERR_BUFFER  ; 'buffer error !'
 18885 0001272D 0000                <1>
 18886 0001272F E9B8B1FFFF          <1> 	jmp	error
 18887                              <1> sysdir_ok:	
 18888 00012734 8A0D[F68A0100]      <1> 	mov	cl, [Current_Drv]
 18889 0001273A 890D[64030300]      <1> 	mov	[u.r0], ecx
 18890 00012740 E9C7B1FFFF          <1> 	jmp	sysret
 18891                              <1> 
 18892                              <1> 
 18893                              <1> sysldrvt: ; Get copy of Logical DOS Drive Description Table
 18894                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 18895                              <1> 	;	
 18896                              <1>         ; INPUT ->
 18897                              <1> 	;	    BL = Logical DOS drive number (zero based)	
 18898                              <1>         ;          ECX = Logical DOS drv desc table buffer addr
 18899                              <1> 	;		(Buffer length = 256 bytes)
 18900                              <1> 	; OUTPUT ->
 18901                              <1> 	;          cf = 0 -> 
 18902                              <1> 	;		   AL = Current Drive number	
 18903                              <1> 	;		   AH = The Last Logical DOS Drive no.
 18904                              <1> 	;          cf = 1 -> Error code in AL
 18905                              <1> 	;		   AH = The Last Logical DOS Drive no.
 18906                              <1> 	;
 18907                              <1> 	; Modified Registers: EAX (at the return of system call)
 18908                              <1> 	;
 18909                              <1> 	; Note: Required description table buffer length is
 18910                              <1> 	;	256 bytes for current TRDOS 386 version.
 18911                              <1> 	
 18912 00012745 89CF                <1> 	mov	edi, ecx ; Destination address (user space)
 18913 00012747 88DC                <1> 	mov	ah, bl
 18914 00012749 30C0                <1> 	xor	al, al
 18915 0001274B BE00010900          <1> 	mov	esi, Logical_DOSDisks
 18916 00012750 01C6                <1> 	add	esi, eax ; Source address (system space)	 
 18917 00012752 B900010000          <1> 	mov	ecx, 256 ; Byte count 
 18918                              <1> 			 ; Logical Dos Drv Desc Table size
 18919 00012757 E808F4FFFF          <1> 	call	transfer_to_user_buffer
 18920 0001275C 72C7                <1> 	jc	short sysdir_err
 18921 0001275E 8A2D[C2400100]      <1> 	mov	ch, [Last_DOS_DiskNo]
 18922 00012764 EBCE                <1> 	jmp	short sysdir_ok
 18923                              <1> 
 18924                              <1> 
 18925                              <1> systime: ; Get System Date&Time
 18926                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 18927                              <1> 	;	
 18928                              <1>         ; INPUT -> BL =
 18929                              <1> 	;	    0 = Get Date&Time in Unix/Epoch format
 18930                              <1> 	;	    1 = Get Time in MSDOS format
 18931                              <1> 	;	    2 = Get Date in MSDOS format
 18932                              <1> 	;	    3 = Get Date&Time in MSDOS format
 18933                              <1> 	;	    4 & other values =
 18934                              <1> 	;		System timer ticks will be returned
 18935                              <1> 	;		in EAX and Carry Flag will be set.
 18936                              <1> 	;		(CF will not be set if BL = 4)	 	
 18937                              <1> 	; OUTPUT ->
 18938                              <1> 	;	For BL input = 3
 18939                              <1> 	;          EAX = Current Time (RTC)
 18940                              <1> 	;		AL = Second (DL in MSDOS)
 18941                              <1> 	;		AH = Minute (CL in MSDOS)
 18942                              <1> 	;	   	HW of EAX = Hour (CH in MSDOS)	
 18943                              <1> 	;	   EDX = Current System Date (RTC)
 18944                              <1> 	;		DL = Day (DL in MSDOS)
 18945                              <1> 	;		DH = Month (DH in MSDOS)
 18946                              <1> 	;		HW of EDX = Year (CX in MSDOS)	
 18947                              <1> 	;
 18948                              <1> 	;	For BL input = 2
 18949                              <1> 	;	   EAX = Current System Date (RTC)
 18950                              <1> 	;		DL = Day (DL in MSDOS)
 18951                              <1> 	;		DH = Month (DH in MSDOS)
 18952                              <1> 	;		HW of EDX = Year (CX in MSDOS)
 18953                              <1> 	;
 18954                              <1> 	;	For BL input = 1
 18955                              <1> 	;          EAX = Current Time (RTC)
 18956                              <1> 	;		AL = Second (DL in MSDOS)
 18957                              <1> 	;		AH = Minute (CL in MSDOS)
 18958                              <1> 	;	   	HW of EAX = Hour (CH in MSDOS)	
 18959                              <1> 	;
 18960                              <1> 	;	For BL input = 0
 18961                              <1> 	;          EAX = Unix (Epoch) Time Ticks/Seconds
 18962                              <1> 	;
 18963                              <1> 	;	For BL input  = 4
 18964                              <1> 	;	   EAX = System timer ticks
 18965                              <1> 	;
 18966                              <1> 	;	If CF = 1 (for other values of BL input)
 18967                              <1> 	;	   EAX = System timer ticks (no error code!)	
 18968                              <1> 	;		
 18969                              <1> 	; Modified Registers: EAX, (EDX)
 18970                              <1> 	;		 (at the return of system call)
 18971                              <1> 	;
 18972                              <1> 
 18973 00012766 20DB                <1> 	and	bl, bl
 18974 00012768 750F                <1> 	jnz	short systime_1
 18975 0001276A E86F4FFFFF          <1> 	call	epoch
 18976                              <1> systime_0:
 18977 0001276F A3[64030300]        <1> 	mov	[u.r0], eax
 18978 00012774 E993B1FFFF          <1> 	jmp	sysret
 18979                              <1> systime_1:
 18980 00012779 80FB04              <1> 	cmp	bl, 4
 18981 0001277C 7211                <1> 	jb	short systime_2
 18982 0001277E A1[B08A0100]        <1> 	mov	eax, [TIMER_LH] ; 18.2 Hz timer ticks
 18983                              <1> 				; Note: [TIMER_LH] may be set
 18984                              <1> 				; to wrong timer value due to
 18985                              <1> 				; program functions.
 18986                              <1> 				; (This value must not be
 18987                              <1> 				; accepted as [TIMER_LH]/18.2
 18988                              <1> 				; seconds since the midnight.)
 18989 00012783 76EA                <1> 	jna	short systime_0
 18990 00012785 A3[64030300]        <1> 	mov	[u.r0], eax	
 18991 0001278A E95DB1FFFF          <1> 	jmp	error ; cf = 1 & [u.r0] = eax = timer ticks 
 18992                              <1> 
 18993                              <1> systime_2:
 18994                              <1> 	;push	ebx
 18995 0001278F E8AC4EFFFF          <1> 	call	get_rtc_date_time
 18996                              <1> 	;pop	ebx
 18997 00012794 F6C301              <1> 	test	bl, 1
 18998 00012797 7429                <1> 	jz	short systime_4
 18999 00012799 30E4                <1> 	xor	ah, ah
 19000 0001279B A0[FE860100]        <1> 	mov	al, [hour]
 19001 000127A0 88C2                <1> 	mov	dl, al
 19002 000127A2 C1E010              <1> 	shl	eax, 16
 19003 000127A5 A0[02870100]        <1> 	mov	al, [second]
 19004 000127AA 8A25[00870100]      <1> 	mov	ah, [minute]
 19005 000127B0 F6C302              <1> 	test	bl, 2
 19006 000127B3 74BA                <1> 	jz	short systime_0
 19007                              <1> 	; Check time & date match risk 
 19008                              <1> 	; (23:59:59 may cause to wrong
 19009                              <1> 	; date -new day with previous date-...)
 19010 000127B5 80FA17              <1> 	cmp	dl, 23
 19011 000127B8 7206                <1> 	jb	short systime_3
 19012 000127BA 663D3B3B            <1> 	cmp	ax, (59*256)+59 ; if hour is 23:59:59
 19013 000127BE 73CF                <1> 	jnb	short systime_2 ; wait for 1 second
 19014                              <1> systime_3:
 19015                              <1> 	; eax = time
 19016 000127C0 89C6                <1> 	mov	esi, eax
 19017                              <1> systime_4:	
 19018 000127C2 66A1[F8860100]      <1> 	mov	ax, [year]
 19019 000127C8 C1E010              <1> 	shl	eax, 16
 19020 000127CB A0[FC860100]        <1> 	mov	al, [day]
 19021 000127D0 8A25[FA860100]      <1> 	mov	ah, [month]
 19022                              <1> 	; eax = date
 19023 000127D6 80E301              <1> 	and	bl, 1
 19024 000127D9 7494                <1> 	jz	short systime_0
 19025 000127DB 96                  <1> 	xchg	esi, eax
 19026                              <1> 	; eax = time, esi = date
 19027 000127DC 8B2D[60030300]      <1> 	mov	ebp, [u.usp]  ; EBP points to user's registers
 19028                              <1> 	; (user) edx <-- (system) esi
 19029 000127E2 897514              <1> 	mov	[ebp+20], esi ; return to user with EDX value 
 19030 000127E5 EB88                <1> 	jmp	short systime_0
 19031                              <1> 
 19032                              <1> 
 19033                              <1> sysstime: ; Set System Date&Time
 19034                              <1> 	; 31/12/2017
 19035                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 19036                              <1> 	;	
 19037                              <1>         ; INPUT -> BL =
 19038                              <1> 	;	    0 = Set Date&Time in Unix/Epoch format
 19039                              <1> 	;	    1 = Set Time in MSDOS format
 19040                              <1> 	;	    2 = Set Date in MSDOS format
 19041                              <1> 	;	    3 = Set Date&Time in MSDOS format
 19042                              <1> 	;	    4 = Set System Timer (Ticks)
 19043                              <1> 	;	    5 = Convert/Save current time to/as
 19044                              <1> 	;		18.2 Hz system timer ticks
 19045                              <1> 	;	    6 = Convert MSDOS Date&Time to UNIX format
 19046                              <1> 	;		without setting system date&time ; (test)
 19047                              <1> 	;	    7 = Convert UNIX Date&Time to MSDOS format
 19048                              <1> 	;		without setting system date&time ; (test)
 19049                              <1> 	;	   8-0FFh = invalid !
 19050                              <1> 	;	  ECX = Time (or Timer) value in selected format  	
 19051                              <1> 	;	  EDX = Date value in MSDOS format if BL=2,3,6	
 19052                              <1> 	; 	
 19053                              <1> 	; OUTPUT ->
 19054                              <1> 	;	If CF = 0 ->
 19055                              <1> 	;          EAX = Set value
 19056                              <1> 	;	If CF = 1 -> (invalid BL input)
 19057                              <1> 	;	   EAX = Ticks count [TIMER_LH]	
 19058                              <1> 	;
 19059                              <1> 
 19060 000127E7 20DB                <1> 	and	bl, bl ; 0
 19061 000127E9 7511                <1> 	jnz	short sysstime_0
 19062 000127EB 89C8                <1> 	mov	eax, ecx
 19063 000127ED E8764FFFFF          <1> 	call	convert_from_epoch
 19064 000127F2 E82250FFFF          <1> 	call	set_rtc_date_time
 19065 000127F7 E910B1FFFF          <1> 	jmp	sysret
 19066                              <1> sysstime_0:
 19067 000127FC 80FB08              <1> 	cmp	bl, 8
 19068 000127FF 722D                <1> 	jb	short sysstime_1
 19069                              <1> 	; invalid input (>7)
 19070 00012801 A1[B08A0100]        <1> 	mov	eax, [TIMER_LH] ; 18.2 Hz timer ticks
 19071                              <1> 				; Note: [TIMER_LH] may be set
 19072                              <1> 				; to wrong timer value due to
 19073                              <1> 				; program functions.
 19074                              <1> 				; (This value must not be
 19075                              <1> 				; accepted as [TIMER_LH]/18.2
 19076                              <1> 				; seconds since the midnight.)
 19077 00012806 A3[64030300]        <1> 	mov	[u.r0], eax	
 19078 0001280B E9DCB0FFFF          <1> 	jmp	error ; cf = 1 & [u.r0] = eax = timer ticks 
 19079                              <1> 
 19080                              <1> sysstime_8:	
 19081                              <1> 	; BL = 7
 19082 00012810 89C8                <1> 	mov	eax, ecx ; seconds since 1/1/1970 00:00:00
 19083 00012812 E8514FFFFF          <1> 	call	convert_from_epoch
 19084 00012817 30E4                <1> 	xor	ah, ah
 19085 00012819 A0[FE860100]        <1> 	mov	al, [hour]
 19086 0001281E C1E010              <1> 	shl	eax, 16
 19087 00012821 A0[02870100]        <1> 	mov	al, [second]
 19088 00012826 8A25[00870100]      <1> 	mov	ah, [minute]
 19089 0001282C EB92                <1> 	jmp	short systime_3
 19090                              <1> 
 19091                              <1> sysstime_1:
 19092 0001282E 80FB04              <1> 	cmp	bl, 4
 19093 00012831 743F                <1> 	je	short sysstime_2 ; set system timer ticks	
 19094 00012833 80FB05              <1> 	cmp	bl, 5
 19095 00012836 754B                <1> 	jne	short sysstime_4
 19096                              <1> 	; convert current time to system timer ticks (18.2Hz)
 19097 00012838 E8034EFFFF          <1> 	call	get_rtc_date_time
 19098 0001283D 0FB60D[FE860100]    <1> 	movzx	ecx, byte [hour]
 19099 00012844 B8100E0000          <1> 	mov	eax, 60*60 ; 1 hour = 3600 seconds
 19100 00012849 F7E1                <1> 	mul	ecx
 19101 0001284B 89C3                <1> 	mov	ebx, eax	
 19102 0001284D B13C                <1> 	mov	cl, 60  ; 1 minute = 60 seconds
 19103 0001284F 0FB605[00870100]    <1> 	movzx	eax, byte [minute]
 19104 00012856 F7E1                <1> 	mul	ecx
 19105 00012858 01D8                <1> 	add	eax, ebx  
 19106 0001285A 8A0D[02870100]      <1> 	mov	cl, [second]
 19107 00012860 01C8                <1> 	add	eax, ecx
 19108 00012862 B1B6                <1> 	mov	cl, 182
 19109 00012864 F7E1                <1> 	mul	ecx
 19110 00012866 83C009              <1> 	add	eax, 9
 19111 00012869 83D200              <1> 	adc	edx, 0
 19112 0001286C B10A                <1> 	mov	cl, 10
 19113 0001286E F7F1                <1> 	div	ecx
 19114                              <1> 	; eax = ((182*seconds)+9)/10
 19115 00012870 89C1                <1> 	mov	ecx, eax
 19116                              <1> sysstime_2:
 19117 00012872 890D[B08A0100]      <1> 	mov	[TIMER_LH], ecx ; 18.2 * seconds
 19118                              <1> sysstime_3:
 19119 00012878 890D[64030300]      <1> 	mov	[u.r0], ecx
 19120 0001287E E989B0FFFF          <1> 	jmp	sysret
 19121                              <1> sysstime_4:
 19122 00012883 80FB06              <1> 	cmp	bl, 6
 19123 00012886 7788                <1> 	ja	short sysstime_8
 19124                              <1> 
 19125 00012888 890D[64030300]      <1> 	mov	[u.r0], ecx
 19126                              <1> 
 19127 0001288E 880D[02870100]      <1> 	mov	[second], cl
 19128 00012894 882D[00870100]      <1> 	mov	[minute], ch
 19129 0001289A C1E910              <1> 	shr	ecx, 16
 19130 0001289D 880D[FE860100]      <1> 	mov	[hour], cl
 19131                              <1> 	; BL = 1,2,3,6
 19132 000128A3 80FB01              <1> 	cmp	bl, 1
 19133 000128A6 762A                <1> 	jna	short sysstime_5
 19134                              <1> 	; BL = 2,3,6
 19135 000128A8 8815[FC860100]      <1> 	mov	[day], dl
 19136 000128AE 8835[FA860100]      <1> 	mov	[month], dh
 19137 000128B4 C1EA10              <1> 	shr	edx, 16
 19138 000128B7 668915[F8860100]    <1> 	mov	[year], dx
 19139 000128BE 80E303              <1> 	and	bl, 3
 19140 000128C1 742D                <1> 	jz	short sysstime_7 ; 6
 19141                              <1> 	; BL = 2,3
 19142 000128C3 F6C301              <1> 	test	bl, 1
 19143 000128C6 7419                <1> 	jz	short sysstime_6 ; 2
 19144                              <1> 	; BL = 3
 19145 000128C8 E84C4FFFFF          <1> 	call	set_rtc_date_time
 19146 000128CD E93AB0FFFF          <1> 	jmp	sysret
 19147                              <1> sysstime_5:
 19148                              <1> 	; BL = 1
 19149 000128D2 E8834FFFFF          <1> 	call	set_time_bcd
 19150 000128D7 E80542FFFF          <1> 	call	set_rtc_time
 19151 000128DC E92BB0FFFF          <1> 	jmp	sysret	
 19152                              <1> sysstime_6:
 19153                              <1> 	; BL = 2
 19154 000128E1 E8474FFFFF          <1> 	call	set_date_bcd
 19155 000128E6 E86542FFFF          <1> 	call	set_rtc_date
 19156 000128EB E91CB0FFFF          <1> 	jmp	sysret
 19157                              <1> sysstime_7:
 19158                              <1> 	; BL = 6
 19159                              <1> 	; [year], [month], [day], 
 19160                              <1> 	; [hour], [minute], [second]
 19161 000128F0 E8EE4DFFFF          <1> 	call	convert_to_epoch
 19162 000128F5 89C1                <1> 	mov	ecx, eax ; seconds since 1/1/1970 00:00:00
 19163 000128F7 E97CFFFFFF          <1> 	jmp	sysstime_3
 19164                              <1> 
 19165                              <1> sysrename: ; Rename File (or Directory)
 19166                              <1> 	; 19/01/2021
 19167                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0) 
 19168                              <1> 	;	
 19169                              <1>         ; INPUT ->
 19170                              <1>         ;          EBX = File/Directory (ASCIIZ) name address
 19171                              <1> 	;	   ECX = New name (in same dir, no path name)			
 19172                              <1> 	; OUTPUT ->
 19173                              <1> 	;          cf = 0 -> EAX = 0
 19174                              <1> 	;          cf = 1 -> Error code in AL
 19175                              <1> 
 19176                              <1> 	; 19/01/2021
 19177 000128FC 803D[B0030300]00    <1> 	cmp	byte [u.uid], 0  ; root (super user) ?
 19178 00012903 7614                <1> 	jna	short sysrename_0
 19179                              <1> 
 19180                              <1> sysrename_perm_err:
 19181                              <1> 	;mov	dword [u.r0], ERR_PERM_DENIED
 19182 00012905 B80B000000          <1> 	mov	eax, ERR_PERM_DENIED ; 'permission denied !'
 19183 0001290A A3[64030300]        <1> 	mov	[u.r0], eax
 19184 0001290F A3[C8030300]        <1> 	mov	[u.error], eax
 19185 00012914 E9D3AFFFFF          <1> 	jmp	error
 19186                              <1> 
 19187                              <1> sysrename_0:
 19188 00012919 51                  <1> 	push	ecx ; new file name address (in user space)
 19189 0001291A 89DE                <1> 	mov	esi, ebx
 19190                              <1> 	; file name is forced, change directory as temporary
 19191                              <1> 	;mov	ax, 1
 19192                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset
 19193                              <1> 	;call	set_working_path 
 19194 0001291C E8BF060000          <1> 	call	set_working_path_x
 19195 00012921 731E                <1> 	jnc	short sysrename_1
 19196 00012923 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 19197 00012925 7505                <1> 	jnz	short sysrename_err
 19198                              <1> 	; eax = 0
 19199                              <1> sysrename_path_not_found:
 19200 00012927 B813000000          <1> 	mov	eax, ERR_INV_PATH_NAME ; 'Bad path name !'
 19201                              <1> sysrename_err:
 19202 0001292C 59                  <1> 	pop	ecx ; new file name address (in user space)
 19203                              <1> sysrename_error:
 19204 0001292D A3[64030300]        <1> 	mov	[u.r0], eax
 19205 00012932 A3[C8030300]        <1> 	mov	[u.error], eax
 19206 00012937 E879070000          <1> 	call 	reset_working_path
 19207 0001293C E9ABAFFFFF          <1> 	jmp	error
 19208                              <1> sysrename_1:
 19209 00012941 B008                <1> 	mov	al, 08h ; Except volume labels (& long names)
 19210 00012943 A0[AC940100]        <1> 	mov	al, [Attributes]
 19211 00012948 2410                <1> 	and	al, 10h ;
 19212                              <1> 	;mov	esi, FindFile_Name
 19213                              <1> 	;mov	ax, 1800h ; Only files
 19214                              <1> 	;mov	ax, 0810h ; Only directories
 19215 0001294A 66B80008            <1> 	mov	ax, 0800h ; Find File or Directory
 19216 0001294E E83E6BFFFF          <1> 	call	find_first_file
 19217                              <1> 	;jnc	short sysrename_2
 19218 00012953 72D7                <1> 	jc	short sysrename_err
 19219                              <1> sysrename_2:
 19220                              <1> 	; ESI = Directory Entry (FindFile_DirEntry) Location
 19221                              <1> 	; EDI = Directory Buffer Directory Entry Location
 19222                              <1> 	; EAX = File Size
 19223                              <1> 	;  BL = Attributes of The File/Directory
 19224                              <1> 	;  BH = Long Name Yes/No Status (>0 is YES)
 19225                              <1> 	;  DX > 0 : Ambiguous filename chars are used
 19226                              <1> 
 19227 00012955 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
 19228 00012958 7407                <1> 	jz	short sysrename_3
 19229 0001295A B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME ; 'invalid file name !'
 19230 0001295F EBCB                <1>         jmp	short sysrename_err
 19231                              <1> sysrename_3:
 19232                              <1> 	; EDI = Directory buffer entry offset/address
 19233                              <1> 	; BL = File (or Directory) Attributes 
 19234                              <1> 	; mov	bl, [EDI+0Bh]
 19235                              <1> 
 19236 00012961 5A                  <1> 	pop	edx ; new file name address (in user space)
 19237                              <1> 
 19238                              <1> 	; check file/directory attributes
 19239 00012962 F6C307              <1> 	test	bl, 7 ; system, hidden, readonly 
 19240 00012965 759E                <1>         jnz	short sysrename_perm_err
 19241                              <1> sysrename_4:
 19242 00012967 66817F0CA101        <1> 	cmp	word [edi+DirEntry_NTRes], 01A1h ; Singlix FS
 19243 0001296D 7496                <1> 	je	short sysrename_perm_err ; -temporary!-
 19244                              <1> 
 19245                              <1> 	; save old file name & file info (FFF structure)
 19246 0001296F BE[96930100]        <1> 	mov	esi, FindFile_Drv
 19247 00012974 BF[DC940100]        <1> 	mov	edi, SourceFile_Drv
 19248 00012979 B920000000          <1> 	mov	ecx, 128/4
 19249 0001297E F3A5                <1> 	rep	movsd
 19250                              <1> 
 19251 00012980 89D6                <1> 	mov	esi, edx ; new file name address (in user space)
 19252 00012982 BF[5C950100]        <1> 	mov	edi, DestinationFile_Drv
 19253 00012987 E8D68CFFFF          <1> 	call	parse_path_name
 19254 0001298C 729F                <1> 	jc	short sysrename_error ; eax = 1 (Bad file name)
 19255                              <1> 
 19256                              <1> 	; same drive ? 
 19257 0001298E A0[96930100]        <1> 	mov	al, [FindFile_Drv]
 19258 00012993 3A05[5C950100]      <1> 	cmp	al, [DestinationFile_Drv]
 19259                              <1> 	;jne	short sysrename_perm_err ; Permission denied
 19260 00012999 7509                <1> 	jne	short sysrename_5 ; Bad file name
 19261                              <1>  
 19262                              <1> 	; no path name !? (rename file in same directory)
 19263 0001299B 803D[5D950100]20    <1> 	cmp	byte [DestinationFile_Directory], 20h
 19264 000129A2 7607                <1> 	jna	short sysrename_6
 19265                              <1> sysrename_5:
 19266 000129A4 B801000000          <1> 	mov	eax, ERR_BAD_CMD_ARG ; 1 = Bad file name 
 19267                              <1> 				     ; (Bad argument)
 19268 000129A9 EB82                <1> 	jmp	short sysrename_error
 19269                              <1> sysrename_6:
 19270 000129AB 803D[9E950100]20    <1> 	cmp	byte [DestinationFile_Name], 20h
 19271 000129B2 76F0                <1> 	jna	short sysrename_5
 19272                              <1> 
 19273 000129B4 BE[9E950100]        <1> 	mov	esi, DestinationFile_Name
 19274 000129B9 E8916EFFFF          <1> 	call	check_filename ; is it a valid msdos file name?
 19275 000129BE 0F8269FFFFFF        <1> 	jc	sysrename_error ; 26 = ERR_INV_FILE_NAME 
 19276                              <1> 	
 19277                              <1> 	;mov	esi, DestinationFile_Name
 19278 000129C4 66B80008            <1> 	mov	ax, 0800h ; Find File or Directory
 19279 000129C8 E8C46AFFFF          <1> 	call	find_first_file
 19280 000129CD 720A                <1> 	jc	short sysrename_7
 19281                              <1> 	
 19282 000129CF B80E000000          <1> 	mov	eax, ERR_FILE_EXISTS  ; file already exists !
 19283 000129D4 E954FFFFFF          <1> 	jmp	sysrename_error	
 19284                              <1> sysrename_7:
 19285                              <1> 	; eax = 2 (File not found !)
 19286 000129D9 3C02                <1> 	cmp	al, 2 ; ERR_NOT_FOUND
 19287 000129DB 0F854CFFFFFF        <1> 	jne	sysrename_error
 19288                              <1> 
 19289                              <1> 	; 31/12/2017
 19290                              <1> 	; Following code is also part of 'rename_file' in
 19291                              <1> 	; 'trdosk3.s' (MainProg's 'rename' command) ; 13/11/2017
 19292 000129E1 BE[9E950100]        <1> 	mov	esi, DestinationFile_Name ; (Rename_NewName)
 19293 000129E6 668B0D[56950100]    <1> 	mov	cx, [SourceFile_DirEntryNumber] 
 19294 000129ED 66A1[42950100]      <1> 	mov	ax, [SourceFile_DirEntry+20] ; First Cluster, HW 
 19295 000129F3 C1E010              <1> 	shl	eax, 16
 19296 000129F6 66A1[48950100]      <1> 	mov	ax, [SourceFile_DirEntry+26] ; First Cluster, LW 
 19297 000129FC 0FB61D[2B950100]    <1>   	movzx	ebx, byte [SourceFile_LongNameEntryLength]  
 19298 00012A03 E8A294FFFF          <1>    	call	rename_directory_entry
 19299 00012A08 0F821FFFFFFF        <1> 	jc	sysrename_error
 19300                              <1> 	;xor	eax, eax
 19301 00012A0E A3[64030300]        <1> 	mov	[u.r0], eax ; 0
 19302                              <1> 	;mov	[u.error], eax
 19303 00012A13 E89D060000          <1> 	call 	reset_working_path
 19304 00012A18 E9EFAEFFFF          <1> 	jmp	sysret
 19305                              <1> 
 19306                              <1> sysmem: ; Get Total&Free Memory amount 
 19307                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0) 
 19308                              <1> 	;	
 19309                              <1>         ; INPUT -> 
 19310                              <1> 	;	none	
 19311                              <1> 	; OUTPUT ->
 19312                              <1> 	;	EAX = Total memory count (in bytes)
 19313                              <1> 	;	EBX = Virtually available memory amount (in bytes)
 19314                              <1> 	;	      = 4GB - CORE (4MB)	
 19315                              <1> 	;	ECX = Free memory count (in bytes)
 19316                              <1> 	;	EDX = Calculated free memory count (in bytes)
 19317                              <1> 	
 19318 00012A1D A1[348A0100]        <1> 	mov	eax, [memory_size] ; in pages
 19319 00012A22 C1E00C              <1> 	shl	eax, 12		   ; in bytes
 19320 00012A25 A3[64030300]        <1> 	mov	[u.r0], eax
 19321 00012A2A E82619FFFF          <1> 	call	calc_free_mem
 19322                              <1> 	; edx = calculated free pages
 19323                              <1> 	; ecx = 0
 19324 00012A2F 8B2D[60030300]      <1> 	mov	ebp, [u.usp]  ; EBP points to user's registers
 19325 00012A35 C745100000C0FF      <1> 	mov	dword [ebp+16], ECORE ; EBX (for user)
 19326                              <1> 				; 0FFC00000h ; 4GB - 4MB
 19327 00012A3C C1E20C              <1> 	shl	edx, 12
 19328 00012A3F 895514              <1> 	mov	[ebp+20], edx ; EDX (for user)
 19329 00012A42 8B0D[388A0100]      <1> 	mov 	ecx, [free_pages]
 19330 00012A48 C1E10C              <1> 	shl	ecx, 12	; free bytes
 19331 00012A4B 894D18              <1> 	mov	[ebp+24], ecx ; ECX (for user)
 19332                              <1> 	;mov	[free_pages], edx	
 19333 00012A4E E9B9AEFFFF          <1> 	jmp	sysret
 19334                              <1> 
 19335                              <1> sysprompt:
 19336                              <1> 	; Set TRDOS 386 Command Interpreter (MainProg) prompt 
 19337                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0) 
 19338                              <1> 	;	
 19339                              <1>         ; INPUT -> 
 19340                              <1> 	;	EBX = 0 -> use default prompt
 19341                              <1> 	;	EBX > 0 -> prompt string (ASCIIZ) address
 19342                              <1> 	;		  (Max. 11 characters except ZERO tail)	
 19343                              <1> 	; OUTPUT ->
 19344                              <1> 	;	(EAX = 0)
 19345                              <1> 	;	CF = 0 -> Successful
 19346                              <1> 	;	CF = 1 -> Failed
 19347                              <1> 
 19348 00012A53 21DB                <1> 	and	ebx, ebx
 19349 00012A55 750A                <1> 	jnz	short sysprompt_0
 19350                              <1> 
 19351 00012A57 E83964FFFF          <1> 	call	default_command_prompt ; '['+'TRDOS'+']'
 19352 00012A5C E9ABAEFFFF          <1> 	jmp	sysret
 19353                              <1> 
 19354                              <1> sysprompt_0:
 19355 00012A61 31C0                <1> 	xor	eax, eax
 19356 00012A63 A3[64030300]        <1> 	mov	[u.r0], eax 
 19357 00012A68 89DE                <1> 	mov	esi, ebx
 19358 00012A6A B90C000000          <1> 	mov	ecx, 12
 19359 00012A6F 89E5                <1> 	mov	ebp, esp
 19360 00012A71 29CC                <1> 	sub	esp, ecx
 19361 00012A73 49                  <1> 	dec	ecx ; 11
 19362 00012A74 89E7                <1> 	mov	edi, esp
 19363 00012A76 E833F1FFFF          <1> 	call	transfer_from_user_buffer
 19364 00012A7B 7211                <1> 	jc	short sysprompt_err
 19365 00012A7D 803E20              <1> 	cmp	byte [esi], 20h
 19366 00012A80 760C                <1> 	jna	short sysprompt_err
 19367 00012A82 E82064FFFF          <1> 	call	set_command_prompt
 19368 00012A87 89EC                <1> 	mov	esp, ebp
 19369 00012A89 E97EAEFFFF          <1> 	jmp	sysret
 19370                              <1> sysprompt_err:
 19371                              <1> syspath_err:
 19372 00012A8E 89EC                <1> 	mov	esp, ebp
 19373 00012A90 E957AEFFFF          <1> 	jmp	error
 19374                              <1> 
 19375                              <1> syspath:
 19376                              <1> 	; Get/Set Run Path
 19377                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0) 
 19378                              <1> 	;	
 19379                              <1>         ; INPUT -> 
 19380                              <1> 	;	EBX = 0 -> get path (to buffer address in ECX)
 19381                              <1> 	;	EBX > 0 -> set path
 19382                              <1> 	;	    EBX = Path string buffer address (ASCIIZ)
 19383                              <1> 	;	    	  (Path description except 'PATH=')
 19384                              <1> 	;	ECX = Buffer address (if EBX = 0)
 19385                              <1> 	;	      (ECX will not be used if EBX > 0)	
 19386                              <1> 	;	DL = Buffer size (0 = 256 byte)	
 19387                              <1> 	;
 19388                              <1> 	; OUTPUT ->
 19389                              <1> 	;	CF = 0 -> Successful (EAX = String length)
 19390                              <1> 	;	CF = 1 -> Failed (EAX = 0)
 19391                              <1> 	;
 19392                              <1> 	; NOTE: 'PATH=' or 'PATH' must be excluded
 19393                              <1> 	;  (It must not be at the beginning of the string.)
 19394                              <1> 
 19395 00012A95 89E5                <1> 	mov	ebp, esp
 19396 00012A97 81EC00010000        <1> 	sub	esp, 256
 19397 00012A9D 89E7                <1> 	mov	edi, esp
 19398                              <1> 
 19399 00012A9F 31C0                <1> 	xor	eax, eax
 19400 00012AA1 A3[64030300]        <1> 	mov	[u.r0], eax 
 19401                              <1> 	
 19402 00012AA6 21DB                <1> 	and	ebx, ebx
 19403 00012AA8 752E                <1> 	jnz	short syspath_0
 19404                              <1> 
 19405                              <1> 	; EBX = 0 -> get run path
 19406 00012AAA 89CB                <1> 	mov	ebx, ecx ; buffer addr (in user's mem space)
 19407 00012AAC BE[8F410100]        <1> 	mov	esi, Cmd_Path  ; 'PATH' address
 19408 00012AB1 0FB6CA              <1> 	movzx	ecx, dl
 19409 00012AB4 80E901              <1> 	sub	cl, 1 ; 0 -> 255, 1 -> 0
 19410 00012AB7 6683D101            <1> 	adc	cx, 1 ; 255 -> 256, 0 -> 1
 19411                              <1> 	; EDI = Output buffer 
 19412                              <1> 	; CX = Buffer length
 19413                              <1> 	; AL = 0 -> use ASCIIZ word in [ESI]
 19414                              <1> 	; ESI = 'PATH' address (with zero tail)
 19415 00012ABB E81B7CFFFF          <1> 	call	get_environment_string
 19416 00012AC0 72CC                <1> 	jc	short syspath_err
 19417 00012AC2 89DF                <1> 	mov	edi, ebx ; User's buffer address
 19418 00012AC4 89E6                <1> 	mov	esi, esp 
 19419                              <1> 	; EDI = User's buffer address
 19420                              <1> 	; ECX = transfer (byte) count
 19421 00012AC6 E899F0FFFF          <1> 	call	transfer_to_user_buffer
 19422 00012ACB 72C1                <1> 	jc	short syspath_err
 19423 00012ACD 890D[64030300]      <1> 	mov	[u.r0], ecx 
 19424 00012AD3 E934AEFFFF          <1> 	jmp	sysret
 19425                              <1> 
 19426                              <1> syspath_0:
 19427 00012AD8 89DE                <1> 	mov	esi, ebx
 19428 00012ADA 0FB6CA              <1> 	movzx	ecx, dl
 19429 00012ADD 80E901              <1> 	sub	cl, 1 ; 0 -> 255, 1 -> 0
 19430 00012AE0 6683D101            <1> 	adc	cx, 1 ; 255 -> 256, 0 -> 1
 19431 00012AE4 E8C5F0FFFF          <1> 	call	transfer_from_user_buffer
 19432 00012AE9 72A3                <1> 	jc	short syspath_err
 19433                              <1> 	;(*) 'PATH=' will be added to 
 19434                              <1> 	;         the head of the string
 19435 00012AEB 83EC08              <1> 	sub	esp, 8 ;(*)
 19436 00012AEE 89FE                <1> 	mov	esi, edi ;(*)
 19437 00012AF0 E8CA7BFFFF          <1> 	call	set_path_x ;(*)
 19438 00012AF5 7297                <1> 	jc	short syspath_err
 19439 00012AF7 8915[64030300]      <1> 	mov	[u.r0], edx ; run path string length
 19440 00012AFD E90AAEFFFF          <1> 	jmp	sysret	
 19441                              <1> 
 19442                              <1> sysenv:
 19443                              <1> 	; Get/Set Environment Variables
 19444                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0) 
 19445                              <1> 	;	
 19446                              <1>         ; INPUT -> 
 19447                              <1> 	;	EBX = 0 -> get (all) environment variables
 19448                              <1> 	;	      (Required Buffer length = 512 bytes)
 19449                              <1> 	;	EBX > 0 -> set (one) environment variable
 19450                              <1> 	;	      (If there is not a '=' after
 19451                              <1> 	;	      the environment variable name, it will
 19452                              <1> 	;	      accepted as 'get environment variable'.) 
 19453                              <1> 	;	       EBX = Buffer address
 19454                              <1> 	;	ECX = Buffer address (if EBX = 0)
 19455                              <1> 	;	      (ECX will not be used if EBX > 0)	
 19456                              <1> 	;	      (Note: Buffer size is 512 bytes.)	
 19457                              <1> 	;	DL = Buffer size (0 = 256 byte)
 19458                              <1> 	;	     (For one envrionment variable)		
 19459                              <1> 	;
 19460                              <1> 	; OUTPUT ->
 19461                              <1> 	;	(EAX = 0)
 19462                              <1> 	;	CF = 0 -> Successful (EAX = String length)
 19463                              <1> 	;	CF = 1 -> Failed (EAX = 0)
 19464                              <1> 	;
 19465                              <1> 	; Note: Environment variable name, for example,
 19466                              <1> 	;	'PATH=' must be included at the beginning
 19467                              <1> 	;	of the environment string. If the variable
 19468                              <1> 	;	name is as 'PATH' but it is not as 'PATH='
 19469                              <1> 	;	the variable string (row) will be returned.
 19470                              <1> 	;	If variable name is as 'PATH=' but there is
 19471                              <1> 	;	not a following text after the variable name,
 19472                              <1> 	;	the environment variable will be reset/deleted.
 19473                              <1> 
 19474 00012B02 89E5                <1> 	mov	ebp, esp
 19475 00012B04 81EC00020000        <1> 	sub	esp, 512
 19476 00012B0A 89E7                <1> 	mov	edi, esp
 19477                              <1> 
 19478 00012B0C 31C0                <1> 	xor	eax, eax
 19479 00012B0E A3[64030300]        <1> 	mov	[u.r0], eax 
 19480                              <1> 	
 19481 00012B13 21DB                <1> 	and	ebx, ebx
 19482 00012B15 7524                <1> 	jnz	short sysenv_0
 19483                              <1> 
 19484                              <1> 	; EBX = 0 -> get (all) environment variables
 19485 00012B17 89EC                <1> 	mov	esp, ebp
 19486 00012B19 BE00300900          <1> 	mov	esi, Env_Page  ; Environment page
 19487 00012B1E 89CF                <1> 	mov	edi, ecx ; buffer addr (in user's mem space)
 19488 00012B20 B900020000          <1> 	mov	ecx, 512
 19489 00012B25 E83AF0FFFF          <1> 	call	transfer_to_user_buffer
 19490 00012B2A 0F82BCADFFFF        <1> 	jc	error
 19491 00012B30 890D[64030300]      <1> 	mov	[u.r0], ecx 
 19492 00012B36 E9D1ADFFFF          <1> 	jmp	sysret
 19493                              <1> 
 19494                              <1> sysenv_0:
 19495 00012B3B 89DE                <1> 	mov	esi, ebx ; * ; user's buffer address
 19496 00012B3D 0FB6CA              <1> 	movzx	ecx, dl
 19497 00012B40 80E901              <1> 	sub	cl, 1 ; 0 -> 255, 1 -> 0
 19498 00012B43 6683D101            <1> 	adc	cx, 1 ; 255 -> 256, 0 -> 1
 19499 00012B47 E862F0FFFF          <1> 	call	transfer_from_user_buffer
 19500 00012B4C 723F                <1> 	jc	short sysenv_err
 19501 00012B4E 89FE                <1> 	mov	esi, edi
 19502 00012B50 8A06                <1> 	mov	al, [esi]
 19503 00012B52 3C20                <1> 	cmp	al, 20h
 19504 00012B54 7637                <1> 	jna	short sysenv_err
 19505 00012B56 3C3D                <1> 	cmp	al, '='
 19506 00012B58 7433                <1> 	je	short sysenv_err
 19507 00012B5A 56                  <1> 	push	esi
 19508                              <1> sysenv_1:
 19509 00012B5B 46                  <1> 	inc	esi
 19510 00012B5C 803E3D              <1> 	cmp	byte [esi], '='
 19511 00012B5F 7433                <1> 	je	short sysenv_3
 19512 00012B61 803E20              <1> 	cmp	byte [esi], 20h
 19513 00012B64 73F5                <1> 	jnb	short sysenv_1
 19514 00012B66 C60600              <1> 	mov	byte [esi], 0 
 19515 00012B69 5E                  <1> 	pop	esi
 19516                              <1> 	; EDI = Output buffer 
 19517                              <1> 	; CX = Buffer length
 19518 00012B6A 30C0                <1> 	xor	al, al
 19519                              <1> 	; AL = 0 -> use ASCIIZ word in [ESI]
 19520                              <1> 	; ESI = Environment variable name address
 19521 00012B6C E86A7BFFFF          <1> 	call	get_environment_string
 19522 00012B71 721A                <1> 	jc	short sysenv_err
 19523 00012B73 89DF                <1> 	mov	edi, ebx ; * ; user's buffer address
 19524 00012B75 89C1                <1> 	mov	ecx, eax ; String length
 19525 00012B77 89E6                <1> 	mov	esi, esp 
 19526                              <1> 	; ESI = system buffer address
 19527                              <1> 	; EDI = User's buffer address
 19528                              <1> 	; ECX = transfer (byte) count
 19529 00012B79 E8E6EFFFFF          <1> 	call	transfer_to_user_buffer
 19530 00012B7E 720D                <1> 	jc	short sysenv_err
 19531 00012B80 890D[64030300]      <1> 	mov	[u.r0], ecx ; transfer (byte) count
 19532                              <1> sysenv_2:
 19533 00012B86 89EC                <1> 	mov	esp, ebp
 19534 00012B88 E97FADFFFF          <1> 	jmp	sysret
 19535                              <1> sysenv_err:
 19536 00012B8D 89EC                <1> 	mov	esp, ebp
 19537 00012B8F E958ADFFFF          <1> 	jmp	error
 19538                              <1> sysenv_3:
 19539 00012B94 46                  <1> 	inc	esi
 19540 00012B95 803E20              <1> 	cmp	byte [esi], 20h
 19541 00012B98 73FA                <1> 	jnb	short sysenv_3
 19542 00012B9A C60600              <1> 	mov	byte [esi], 0	
 19543 00012B9D 5E                  <1> 	pop	esi
 19544 00012B9E E8FB7BFFFF          <1> 	call	set_environment_string
 19545 00012BA3 72E8                <1> 	jc	short sysenv_err
 19546 00012BA5 8915[64030300]      <1> 	mov	[u.r0], edx
 19547 00012BAB EBD9                <1> 	jmp	short sysenv_2
 19548                              <1> 
 19549                              <1> 
 19550                              <1> ; 22/01/2021
 19551                              <1> ; temporary - 24/01/2016
 19552                              <1> 
 19553                              <1> iget:
 19554                              <1> 	;retn
 19555                              <1> isintr:
 19556                              <1> 	;retn
 19557                              <1> iopen:
 19558                              <1> 	;retn
 19559                              <1> iclose:
 19560                              <1> 	;retn
 19561                              <1> sndc:
 19562                              <1> 	;retn
 19563                              <1> access:
 19564                              <1> 	;retn
 19565                              <1> sleep:
 19566 00012BAD C3                  <1> 	retn
  3093                                  %include 'trdosk7.s' ; 24/01/2016
  3094                              <1> ; ****************************************************************************
  3095                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - DISK READ&WRITE : trdosk7.s
  3096                              <1> ; ----------------------------------------------------------------------------
  3097                              <1> ; Last Update: 25/02/2016
  3098                              <1> ; ----------------------------------------------------------------------------
  3099                              <1> ; Beginning: 24/01/2016
  3100                              <1> ; ----------------------------------------------------------------------------
  3101                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
  3102                              <1> ; ----------------------------------------------------------------------------
  3103                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
  3104                              <1> ; DISK_IO.ASM (20/07/2011)
  3105                              <1> ; ****************************************************************************
  3106                              <1> ; DISK_IO.ASM (c) 2009-2011 Erdogan TAN [ 04/07/2009 ] Last Update: 20/07/2011
  3107                              <1> 
  3108                              <1> disk_write:
  3109                              <1> 	; 25/02/2016
  3110                              <1> 	; 24/02/2016
  3111                              <1> 	; 23/02/2016
  3112 00012BAE 807E0500            <1> 	cmp	byte [esi+LD_LBAYes], 0
  3113 00012BB2 777B                <1>         ja      short lba_write
  3114                              <1> 
  3115                              <1> chs_write:
  3116                              <1> 	; 25/02/2016
  3117                              <1> 	; 23/02/2016
  3118 00012BB4 C605[E5920100]03    <1> 	mov	byte [disk_rw_op], 3 ; CHS write
  3119 00012BBB EB0D                <1> 	jmp	short chs_rw
  3120                              <1> 
  3121                              <1> disk_read:
  3122                              <1> 	; 25/02/2016
  3123                              <1> 	; 24/02/2016
  3124                              <1> 	; 23/02/2016
  3125                              <1> 	; 17/02/2016
  3126                              <1> 	; 14/02/2016
  3127                              <1> 	; 31/01/2016 (TRDOS 386 =  TRDOS v2.0)
  3128                              <1> 	; 17/10/2010
  3129                              <1> 	; 18/04/2010
  3130                              <1> 	;
  3131                              <1> 	; INPUT -> EAX = Logical Block Address
  3132                              <1> 	;	   ESI = Logical Dos Disk Table Offset (DRV)	
  3133                              <1> 	;	   ECX = Sector Count	
  3134                              <1> 	; 	   EBX = Destination Buffer
  3135                              <1> 	; OUTPUT -> 
  3136                              <1> 	;	   cf = 0 or cf = 1
  3137                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX)
  3138                              <1> 
  3139 00012BBD 807E0500            <1> 	cmp	byte [esi+LD_LBAYes], 0
  3140 00012BC1 7775                <1>         ja      short lba_read
  3141                              <1> 
  3142                              <1> chs_read:
  3143                              <1> 	; 25/02/2016
  3144                              <1> 	; 24/02/2016
  3145                              <1> 	; 23/02/2016
  3146                              <1> 	; 31/01/2016 (TRDOS 386 =  TRDOS v2.0)
  3147                              <1> 	; 20/07/2011
  3148                              <1> 	; 04/07/2009
  3149                              <1> 	;
  3150                              <1> 	; INPUT -> EAX = Logical Block Address
  3151                              <1> 	;	   ECX = Number of sectors to read
  3152                              <1> 	; 	   ESI = Logical Dos Disk Table Offset (DRV)
  3153                              <1> 	; 	   EBX = Destination Buffer
  3154                              <1> 	; OUTPUT -> 
  3155                              <1> 	;	   cf = 0 or cf = 1
  3156                              <1> 	; (Modified registers: EAX; EBX, ECX, EDX)
  3157                              <1> 
  3158                              <1> 	; 23/02/2016
  3159 00012BC3 C605[E5920100]02    <1> 	mov	byte [disk_rw_op], 2 ; CHS read
  3160                              <1> 
  3161                              <1> chs_rw:
  3162                              <1> 	;;movzx	edx, word [esi+LD_BPB+SecPerTrack]
  3163                              <1> 	;movzx	edx, byte [esi+LD_BPB+SecPerTrack] ; <= 63
  3164                              <1> 	;mov	[disk_rw_spt], dl
  3165                              <1> 
  3166                              <1> chs_read_next_sector:
  3167 00012BCA C605[E6920100]04    <1> 	mov	byte [retry_count], 4
  3168                              <1>      
  3169                              <1> chs_read_retry:
  3170                              <1> 	;mov	[sector_count], ecx ; 23/02/2016
  3171                              <1> 
  3172 00012BD1 50                  <1> 	push	eax			; Linear sector #
  3173 00012BD2 51                  <1> 	push	ecx			; # of FAT/FILE/DIR sectors
  3174                              <1>                 
  3175 00012BD3 0FB74E1E            <1> 	movzx	ecx, word [esi+LD_BPB+SecPerTrack]
  3176                              <1> 	;movzx	ecx, byte [disk_rw_spt] ; 23/02/2016
  3177 00012BD7 29D2                <1> 	sub	edx, edx
  3178 00012BD9 F7F1                <1> 	div	ecx
  3179                              <1> 	; eax = track, dx (dl ) = sector (on track)
  3180                              <1> 	;sub	cl, dl ; 24/02/2016 (spt - sec)
  3181                              <1> 	;push	ecx ; *
  3182 00012BDB 6689D1              <1> 	mov	cx, dx			; Sector (zero based)
  3183 00012BDE 6641                <1> 	inc	cx			; To make it 1 based
  3184 00012BE0 6651                <1> 	push	cx
  3185 00012BE2 668B4E20            <1> 	mov	cx, [esi+LD_BPB+Heads]
  3186 00012BE6 6629D2              <1> 	sub	dx, dx
  3187 00012BE9 F7F1                <1> 	div	ecx			; Convert track to head & cyl
  3188                              <1> 	; eax (ax) = cylinder, dx (dl) = head (max. FFh)
  3189 00012BEB 88D6                <1> 	mov	dh, dl
  3190 00012BED 6659                <1> 	pop	cx			; AX=Cyl, DH=Head, CX=Sector
  3191 00012BEF 8A5602              <1> 	mov	dl, [esi+LD_PhyDrvNo]
  3192                              <1> 
  3193 00012BF2 88C5                <1> 	mov	ch, al			; NOTE: max. 1023 cylinders !                   
  3194 00012BF4 C0CC02              <1> 	ror	ah, 2			; Rotate 2 bits right
  3195 00012BF7 08E1                <1> 	or	cl, ah
  3196                              <1> 
  3197                              <1> 	; 24/02/2016
  3198                              <1> 	;pop	eax ; * (spt - sec) (example: 63 - 0 = 63)
  3199                              <1> 	;cmp	eax, [sector_count]
  3200                              <1> 	;jb	short chs_write_sectors
  3201                              <1> 	;je	short chs_read_sectors
  3202                              <1> 	;; (# of sectors to read is more than remaining sectors on the track)
  3203                              <1> 	;mov	al, [sector_count]
  3204                              <1> ;chs_read_sectors: ; read or write !
  3205 00012BF9 B001                <1> 	mov	al, 1 ; 25/02/2016
  3206 00012BFB 8A25[E5920100]      <1> 	mov	ah, [disk_rw_op]  ; 02h = chs read, 03h = chs write 
  3207                              <1> 	;
  3208 00012C01 E82B26FFFF          <1> 	call	int13h			; BIOS Service func ( ah ) = 2
  3209                              <1>                                         ; Read disk sectors
  3210                              <1>                                         ; AL-sec num CH-track CL-sec
  3211                              <1>                                         ; DH-head DL-drive ES:BX-buffer
  3212                              <1>                                         ; CF-flag AH-stat AL-sec read
  3213                              <1> 	                                ; If CF = 1 then (If AH > 0)
  3214 00012C06 8825[E7920100]      <1> 	mov	[disk_rw_err], ah
  3215                              <1> 	
  3216 00012C0C 59                  <1> 	pop	ecx
  3217 00012C0D 58                  <1> 	pop	eax
  3218 00012C0E 7314                <1> 	jnc	short chs_read_ok
  3219                              <1> 
  3220 00012C10 803D[E7920100]09    <1> 	cmp	byte [disk_rw_err], 09h ; DMA crossed 64K segment boundary
  3221 00012C17 7408                <1> 	je	short chs_read_error_retn
  3222                              <1>              
  3223 00012C19 FE0D[E6920100]      <1> 	dec	byte [retry_count]
  3224 00012C1F 75B0                <1> 	jnz	short chs_read_retry
  3225                              <1> 
  3226                              <1> chs_read_error_retn:
  3227 00012C21 F9                  <1> 	stc
  3228                              <1> 	;retn
  3229 00012C22 EB69                <1> 	jmp	short update_drv_error_byte
  3230                              <1> 
  3231                              <1> ;chs_write_sectors: ; read or write 
  3232                              <1> 	;; (# of sectors to read is less than remaining sectors on the track)
  3233                              <1> 	;mov	[sector_count], al
  3234                              <1> 	;jmp	short chs_read_sectors
  3235                              <1> 
  3236                              <1> chs_read_ok:
  3237                              <1> 	;; 23/02/2016
  3238                              <1> 	;movzx	edx, byte [sector_count] ; sector count (<= spt)	
  3239                              <1>         ;sub    ecx, edx  ; remaining sector count
  3240                              <1> 	;jna	short update_drv_error_byte	
  3241                              <1> 	;add	eax, edx ; next disk sector
  3242                              <1> 	;shl	edx, 9 ; 512 * sector count
  3243                              <1> 	;add	ebx, edx ; next buffer byte address 
  3244                              <1>         ;jmp     chs_read_next_sector        
  3245                              <1> 	; 25/02/2016
  3246 00012C24 40                  <1> 	inc	eax ; next sector
  3247 00012C25 81C300020000        <1> 	add	ebx, 512
  3248 00012C2B E29D                <1> 	loop	chs_read_next_sector
  3249 00012C2D EB5E                <1> 	jmp	short update_drv_error_byte
  3250                              <1> 
  3251                              <1> lba_write:
  3252                              <1> 	; 23/02/2016
  3253 00012C2F C605[E5920100]1C    <1> 	mov	byte [disk_rw_op], 1Ch ; LBA write
  3254 00012C36 EB07                <1> 	jmp	short lba_rw
  3255                              <1> 
  3256                              <1> lba_read:
  3257                              <1> 	; 23/02/2016
  3258                              <1> 	; 17/02/2016
  3259                              <1> 	; 14/02/2016
  3260                              <1> 	; 13/02/2016
  3261                              <1> 	; 31/01/2016 (TRDOS 386 =  TRDOS v2.0)
  3262                              <1> 	; 10/07/2015 (Retro UNIX 386 v1)
  3263                              <1> 	;
  3264                              <1> 	; INPUT -> EAX = Logical Block Address
  3265                              <1> 	;	   ESI = Logical Dos Disk Table Offset (DRV)	
  3266                              <1> 	;	   ECX = Sector Count	
  3267                              <1> 	; 	   EBX = Destination Buffer
  3268                              <1> 	; OUTPUT -> 
  3269                              <1> 	;	   cf = 0 or cf = 1
  3270                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX)
  3271                              <1> 
  3272                              <1> 	; LBA read/write (with private LBA function) 
  3273                              <1> 	;((Retro UNIX 386 v1 - DISK I/O code by Erdogan Tan))
  3274                              <1> 
  3275                              <1> 
  3276                              <1> 	; 23/02/2016
  3277 00012C38 C605[E5920100]1B    <1> 	mov	byte [disk_rw_op], 1Bh ; LBA read
  3278                              <1> 
  3279                              <1> lba_rw:
  3280                              <1> 	; 17/02/2016
  3281 00012C3F 57                  <1> 	push	edi
  3282                              <1> 
  3283 00012C40 890D[E8920100]      <1> 	mov	[sector_count], ecx ; total sector (read) count
  3284                              <1> 
  3285 00012C46 8A5602              <1> 	mov	dl, [esi+LD_PhyDrvNo]
  3286                              <1> 	; dl = physical drive number (0,1, 80h, 81h, 82h, 83h)
  3287                              <1> 
  3288                              <1> lba_read_next:
  3289 00012C49 81F900010000        <1> 	cmp	ecx, 256
  3290 00012C4F 7605                <1> 	jna	short lba_read_rsc
  3291 00012C51 B900010000          <1> 	mov	ecx, 256 ; 17/02/2016
  3292                              <1> lba_read_rsc:
  3293 00012C56 290D[E8920100]      <1> 	sub	[sector_count], ecx ; remain sectors
  3294                              <1> 
  3295 00012C5C 89CF                <1> 	mov	edi, ecx 
  3296 00012C5E 89C1                <1> 	mov	ecx, eax ; sector number/address
  3297                              <1> 
  3298 00012C60 C605[E6920100]04    <1> 	mov	byte [retry_count], 4
  3299                              <1> lba_read_retry:
  3300 00012C67 89F8                <1> 	mov	eax, edi
  3301                              <1> 	;
  3302                              <1> 	; ecx = sector number
  3303                              <1> 	; al = sector count (0 - 255) /// (0 = 256)
  3304                              <1> 	; dl = drive number
  3305                              <1> 	; ebx = buffer offset
  3306                              <1> 	;
  3307                              <1> 	; Function 1Bh = LBA read, 1Ch = LBA write
  3308                              <1> 	; 23/02/2016
  3309 00012C69 8A25[E5920100]      <1> 	mov	ah, [disk_rw_op] ; 1Bh = LBA read, 1Ch = LBA write
  3310 00012C6F E8BD25FFFF          <1> 	call	int13h
  3311                              <1> 	; al = ? (changed)
  3312                              <1> 	; ah = error code
  3313 00012C74 8825[E7920100]      <1> 	mov	[disk_rw_err], ah
  3314 00012C7A 7334                <1> 	jnc	short lba_read_ok
  3315 00012C7C 80FC80              <1> 	cmp	ah, 80h ; time out?
  3316 00012C7F 740A                <1>         je      short lba_read_stc_retn
  3317 00012C81 FE0D[E6920100]      <1> 	dec	byte [retry_count]
  3318 00012C87 7FDE                <1> 	jg	short lba_read_retry
  3319 00012C89 743A                <1> 	jz	short lba_read_reset
  3320                              <1> 	; sf =  1
  3321                              <1> 
  3322                              <1> lba_read_stc_retn:
  3323 00012C8B F9                  <1> 	stc
  3324                              <1> lba_read_retn:
  3325 00012C8C 5F                  <1> 	pop	edi
  3326                              <1> 
  3327                              <1> update_drv_error_byte:
  3328 00012C8D 9C                  <1> 	pushf
  3329 00012C8E 53                  <1> 	push	ebx
  3330 00012C8F 6651                <1> 	push	cx
  3331                              <1> 	;or	ecx, ecx
  3332                              <1> 	;jz	short udrv_errb0
  3333 00012C91 8A0D[E7920100]      <1> 	mov	cl, [disk_rw_err]
  3334                              <1> udrv_errb0:
  3335 00012C97 0FB65E02            <1> 	movzx	ebx, byte [esi+LD_PhyDrvNo]
  3336 00012C9B 80FB02              <1> 	cmp	bl, 2
  3337 00012C9E 7203                <1>         jb      short udrv_errb1
  3338 00012CA0 80EB7E              <1> 	sub	bl, 7Eh
  3339                              <1> 	;cmp	bl, 5
  3340                              <1> 	;ja	short udrv_errb2	
  3341                              <1> udrv_errb1:
  3342 00012CA3 81C3[616E0000]      <1>         add     ebx, drv.error ; 13/02/2016
  3343 00012CA9 880B                <1> 	mov	[ebx], cl ; error code
  3344                              <1> udrv_errb2:
  3345 00012CAB 6659                <1> 	pop	cx
  3346 00012CAD 5B                  <1> 	pop	ebx
  3347 00012CAE 9D                  <1> 	popf
  3348 00012CAF C3                  <1> 	retn
  3349                              <1> 
  3350                              <1> lba_read_ok:
  3351 00012CB0 89C8                <1> 	mov	eax, ecx ; sector number
  3352 00012CB2 01F8                <1> 	add	eax, edi ; sector number (next)
  3353 00012CB4 C1E709              <1> 	shl	edi, 9 ; sector count * 512
  3354 00012CB7 01FB                <1> 	add	ebx, edi ; next buffer offset
  3355                              <1> 
  3356 00012CB9 8B0D[E8920100]      <1> 	mov	ecx, [sector_count] ; remaining sectors
  3357 00012CBF 09C9                <1> 	or	ecx, ecx
  3358 00012CC1 7586                <1> 	jnz	short lba_read_next
  3359 00012CC3 EBC7                <1> 	jmp	short lba_read_retn
  3360                              <1> 
  3361                              <1> lba_read_reset:
  3362 00012CC5 B40D                <1> 	mov	ah, 0Dh ; Alternate reset
  3363 00012CC7 E86525FFFF          <1>         call	int13h
  3364                              <1> 	; al = ? (changed)
  3365                              <1> 	; ah = error code
  3366 00012CCC 7399                <1> 	jnc	short lba_read_retry
  3367 00012CCE EBBC                <1> 	jmp	short lba_read_retn
  3094                                  %include 'trdosk8.s' ; 24/01/2016
  3095                              <1> ; ****************************************************************************
  3096                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.2) - MAIN PROGRAM : trdosk8.s
  3097                              <1> ; ----------------------------------------------------------------------------
  3098                              <1> ; Last Update: 12/02/2021
  3099                              <1> ; ----------------------------------------------------------------------------
  3100                              <1> ; Beginning: 24/01/2016
  3101                              <1> ; ----------------------------------------------------------------------------
  3102                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
  3103                              <1> ; ----------------------------------------------------------------------------
  3104                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
  3105                              <1> ; u0.s (20/11/2015), u4.s (14/10/2015)
  3106                              <1> ; ****************************************************************************
  3107                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
  3108                              <1> ; TRDOS2.ASM (09/11/2011)
  3109                              <1> ; ----------------------------------------------------------------------------
  3110                              <1> ; DIR.ASM (c) 2004-2011 Erdogan TAN  [07/01/2004] Last Update: 09/10/2011
  3111                              <1> 
  3112                              <1> set_run_sequence:
  3113                              <1> 	; 23/12/2016
  3114                              <1> 	; 10/06/2016
  3115                              <1> 	; 22/05/2016
  3116                              <1> 	; 20/05/2016
  3117                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
  3118                              <1> 	; TRDOS 386 feature only !
  3119                              <1> 	;
  3120                              <1> 	; INPUT ->
  3121                              <1> 	;	AL = process number (next process)
  3122                              <1> 	;
  3123                              <1> 	;	this process must be added to run sequence
  3124                              <1> 	;
  3125                              <1> 	;	[u.pri] = priority of present process
  3126                              <1> 	;
  3127                              <1> 	;	DL = priority (queue)
  3128                              <1> 	;	     0 = background (low) ; run on background 
  3129                              <1> 	;	     1 = regular (normal) ; run as regular
  3130                              <1> 	;	     2 = event (high)     ; run for event
  3131                              <1> 	;
  3132                              <1> 	;	1) If the requested process is already running:
  3133                              <1> 	;	   a) If present priority is high ([u.pri]=2) 
  3134                              <1> 	;	      and requested priority is also high, 
  3135                              <1> 	;	      there is nothing to do! Because it has been
  3136                              <1> 	;	      done already (before this attempt).		 	
  3137                              <1> 	;	   b) If present priority is high ([u.pri]=2)
  3138                              <1> 	;	      and requested priority is not high, there is
  3139                              <1> 	;	      nothing to do! Because, it's current
  3140                              <1> 	;	      run queue is unspecified, here. (It may be in
  3141                              <1> 	;	      a waiting list or in a run queue; if the new
  3142                              <1> 	;	      priority would be used to add it to relavant
  3143                              <1>         ;             run queue, this would be wrong, unnecessary
  3144                              <1> 	;	      and destabilizing duplication!)
  3145                              <1> 	;	   c) If present priority is not high ([u.pri]<2)
  3146                              <1>         ;             and requested priority is high (event),
  3147                              <1> 	;	      process will be added to present priority's
  3148                              <1> 	;	      run queue and then, priority will be changed
  3149                              <1> 	;	      to high ([u.pri]=2).
  3150                              <1> 	;	   d) If present priority is not high ([u.pri]<2)
  3151                              <1> 	;	      and requested priority is not high, [u.pri]
  3152                              <1> 	;	      value will be changed. There is nothing to do
  3153                              <1> 	;	      in addition. (The new priority value will be
  3154                              <1> 	;	      used by 'tswap/tswitch' procedure at 'sysret'
  3155                              <1> 	;	      or 'sysrele' stage.)
  3156                              <1> 	;
  3157                              <1> 	;	2) If the requested process is not running:
  3158                              <1> 	;	   a) If requested priority of the requested
  3159                              <1> 	;	      (next) process is high (event) and priority
  3160                              <1> 	;	      of present process is not high, the requested
  3161                              <1> 	;	      process will be added to ('runq_event') high
  3162                              <1> 	;	      priority run queue and then present (running)
  3163                              <1> 	;	      process will be stopped (swapped/switched out)
  3164                              <1> 	;	      immediately if it is in user mode, or it's 
  3165                              <1> 	;	      [u.quant] value will be reset to 0 and (then) 
  3166                              <1> 	;	      it will be stopped at 'sysret' stage.			
  3167                              <1> 	;	   b) If requested priority of the requested
  3168                              <1> 	;	      (next) process is high (event) and priority
  3169                              <1> 	;	      of present process is also high, the requested
  3170                              <1> 	;	      process will be added to ('runq_event') high
  3171                              <1> 	;	      priority run queue and present (running) 
  3172                              <1> 	;	      process will be allowed to run until it's 
  3173                              <1> 	;	      time quantum will be elapsed ([u.quant]=0).	
  3174                              <1> 	;	   c) If requested priority of the requested
  3175                              <1> 	;	      (next) process is not high ('run for event'), 
  3176                              <1> 	;	      there is nothing to do. Because, it's current
  3177                              <1> 	;	      run queue is unspecified, here. (It may be in
  3178                              <1> 	;	      a waiting list or in a run queue; if the new
  3179                              <1> 	;	      priority would be used to add it to relavant
  3180                              <1>         ;             run queue, this would be wrong, unnecessary
  3181                              <1> 	;	      and destabilizing duplication!) 
  3182                              <1> 	;
  3183                              <1> 	; OUTPUT ->
  3184                              <1> 	;	none
  3185                              <1> 	;
  3186                              <1> 	;	[u.pri] = priority of present process
  3187                              <1> 	;
  3188                              <1> 	;	cf = 1, if the request could not be fulfilled.
  3189                              <1> 	;			 	     	  
  3190                              <1> 	;	NOTE: 
  3191                              <1>         ;          * Processes in 'run as regular' queue can run
  3192                              <1> 	;	     if there is no process in 'run for event' queue
  3193                              <1> 	;	     ('run for event' processes have higher priority)	 		 
  3194                              <1> 	;	   * When [u.quant] time quantum of a process is
  3195                              <1> 	;	     elapsed, it's high priority ('run for event')
  3196                              <1> 	;	     status will be disabled, it can be run in sequence
  3197                              <1> 	;	     of it's actual run queue.
  3198                              <1> 	;	   * A 'run on background' process will always be 
  3199                              <1> 	;	     sequenced in 'run on background' (low priority)
  3200                              <1> 	;	     queue, it can run only when other priority queues
  3201                              <1> 	;	     are empty. (idle time processes, e.g. printing)  	 	
  3202                              <1> 	;
  3203                              <1> 	; Modified registers: eax, ebx, edx
  3204                              <1> 	;
  3205                              <1> 
  3206                              <1> srunseq_0:
  3207 00012CD0 3A05[B3030300]      <1>         cmp     al, [u.uno]     ; same process ?
  3208 00012CD6 750C                <1> 	jne	short srunseq_2 ; no
  3209                              <1> 
  3210 00012CD8 8A25[A9030300]      <1> 	mov	ah, [u.pri] 	; present/current priority
  3211 00012CDE 80FC02              <1> 	cmp	ah, 2       	; 'run for event' priority level
  3212 00012CE1 7221                <1> 	jb	short srunseq_6 ; no
  3213                              <1> 
  3214                              <1> srunseq_1:
  3215                              <1> 	; there is nothing to do!
  3216 00012CE3 C3                  <1> 	retn
  3217                              <1> 
  3218                              <1> srunseq_2:
  3219                              <1> 	;;this not necessary ! 23/12/2016
  3220                              <1>         ;;cmp	al, nproc	; number of processes = 16 
  3221                              <1> 	;;jnb	short srunseq_5	; error ! invalid process number 
  3222                              <1> 
  3223                              <1> 	; dl = priority
  3224 00012CE4 80FA02              <1> 	cmp	dl, 2 		; event queue
  3225 00012CE7 72FA                <1> 	jb	short srunseq_1 ; requested process is not present
  3226                              <1> 				; process and priority of requested
  3227                              <1> 				; process is not high (event), 
  3228                              <1> 				; there is nothing to do!
  3229                              <1> 	
  3230                              <1> 	; requested process is not present process
  3231                              <1> 	; & priority of requested process is high
  3232 00012CE9 3A15[A9030300]      <1> 	cmp	dl, [u.pri] 	; priority of present process
  3233 00012CEF 7606                <1> 	jna	short srunseq_3 ; is high, also
  3234                              <1> 	;
  3235                              <1> 	; present process will be swapped/switched out
  3236 00012CF1 FE05[C1960100]      <1> 	inc	byte [p_change] ; 1
  3237                              <1> 
  3238                              <1> srunseq_3:
  3239                              <1> 	; add process to 'runq_event' queue for new event
  3240 00012CF7 BB[52030300]        <1> 	mov	ebx, runq_event ; high priority run queue
  3241                              <1> 
  3242                              <1> srunseq_4:
  3243                              <1> 	; al = process number
  3244                              <1> 	; ebx = run queue
  3245 00012CFC E887EDFFFF          <1> 	call	putlu
  3246 00012D01 C3                  <1> 	retn
  3247                              <1> 
  3248                              <1> srunseq_5:
  3249 00012D02 F5                  <1> 	cmc
  3250 00012D03 C3                  <1> 	retn
  3251                              <1> 
  3252                              <1> srunseq_6:
  3253                              <1> 	; present priority of the process is not high
  3254                              <1> 	
  3255 00012D04 8815[A9030300]      <1> 	mov	[u.pri], dl ; new priority 
  3256                              <1> 			    ; (will be used by 'tswap')
  3257                              <1> 
  3258 00012D0A 80FA02              <1> 	cmp	dl, 2 		; high priority ?
  3259 00012D0D 72F3                <1> 	jb	short srunseq_5 ; no, there is nothing to do
  3260                              <1> 				; in addition
  3261                              <1> 
  3262                              <1> 	; process must be added to relevant run queue, here!
  3263                              <1> 	; (new priority is high/event priority and process
  3264                              <1> 	; will not be added to a run queue by 'tswap')
  3265                              <1> 
  3266 00012D0F BB[54030300]        <1> 	mov	ebx, runq_normal ; 'run as regular' queue
  3267                              <1> 
  3268 00012D14 20E4                <1> 	and	ah, ah  ;  previous value of [u.pri]
  3269 00012D16 75E4                <1> 	jnz	short srunseq_4
  3270                              <1> 
  3271 00012D18 43                  <1> 	inc	ebx
  3272 00012D19 43                  <1> 	inc	ebx
  3273                              <1> 	; ebx = runq_background ; 'run on backgroud' queue 
  3274                              <1> 
  3275 00012D1A EBE0                <1> 	jmp	short srunseq_4
  3276                              <1> clock:
  3277                              <1> 	; 23/05/2016
  3278                              <1> 	; 22/05/2016
  3279                              <1> 	; 20/05/2016
  3280                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
  3281                              <1> 	; 14/05/2015 - 14/10/2015 (Retro UNIX 386 v1)
  3282                              <1> 	; 07/12/2013 - 10/04/2014 (Retro UNIX 8086 v1)
  3283                              <1> 
  3284 00012D1C 803D[A8030300]00    <1> 	cmp	byte [u.quant], 0
  3285 00012D23 772C                <1> 	ja	short clk_1
  3286                              <1> 	;
  3287 00012D25 803D[B3030300]01    <1> 	cmp     byte [u.uno], 1 ; /etc/init ? (for Retro UNIX 8086 & 386 v1)
  3288                              <1> 				; MainProg (Kernel's Command Interpreter)
  3289                              <1> 				; for TRDOS 386.
  3290 00012D2C 7623                <1> 	jna	short clk_1 ; yes, do not swap out
  3291                              <1> 	;
  3292 00012D2E 803D[5B030300]FF    <1> 	cmp     byte [sysflg], 0FFh ; user or system space ?
  3293 00012D35 7520                <1> 	jne	short clk_2 	    ; system space (sysflg <> 0FFh)
  3294                              <1> 	;
  3295 00012D37 66833D[AA030300]00  <1> 	cmp	word [u.intr], 0
  3296 00012D3F 7616                <1> 	jna	short clk_2
  3297                              <1> 	;
  3298                              <1> 	; 23/05/2016
  3299 00012D41 803D[C2960100]00    <1> 	cmp	byte [multi_tasking], 0
  3300 00012D48 760D                <1> 	jna	short clk_2
  3301                              <1> 	;
  3302 00012D4A FE05[C1960100]      <1> 	inc	byte [p_change] ; it is time to change running process	
  3303 00012D50 C3                  <1> 	retn
  3304                              <1> clk_1:
  3305 00012D51 FE0D[A8030300]      <1> 	dec	byte [u.quant]
  3306                              <1> clk_2:
  3307 00012D57 C3                  <1> 	retn   ; return to (hardware) timer interrupt routine
  3308                              <1> 
  3309                              <1> ; 12/10/2017
  3310                              <1> ; 15/01/2017
  3311                              <1> ; 14/01/2017
  3312                              <1> ; 07/01/2017
  3313                              <1> ; 02/01/2017
  3314                              <1> ; 17/08/2016
  3315                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  3316                              <1> int34h:  ; #IOCTL# (I/O port access support for ring 3)
  3317                              <1> ; 23/05/2016
  3318                              <1> 	; 20/06/2016
  3319                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  3320                              <1> 	;
  3321                              <1> 	; INPUT ->
  3322                              <1> 	;	AH = 0 -> read port  (physical IO port) -byte-
  3323                              <1> 	;	AH = 1 -> write port (physical IO port) -byte-
  3324                              <1> 	;		AL = data byte
  3325                              <1> 	;	AH = 2 -> read port  (physical IO port) -word-
  3326                              <1> 	;	AH = 3 -> write port (physical IO port) -word-
  3327                              <1> 	;		BX = data word
  3328                              <1> 	;	AH = 4 -> read port  (physical IO port) -dword-
  3329                              <1> 	;	AH = 5 -> write port (physical IO port) -dword-
  3330                              <1> 	;		EBX = data dword
  3331                              <1> 	;	; 12/10/2017
  3332                              <1> 	;	AH = 6 -> read port (physical IO port) twice -byte-
  3333                              <1> 	;	AH = 7 -> write port (physical IO port) twice -byte-
  3334                              <1> 	;		BX = data word	
  3335                              <1> 	;
  3336                              <1> 	;	DX = Port number (<= 0FFFFh)
  3337                              <1> 	;
  3338                              <1> 	; OUTPUT ->
  3339                              <1> 	;	AL = data byte (in al, dx)
  3340                              <1> 	;	AX = data word (in ax, dx)
  3341                              <1> 	;	EAX = data dword (in eax, dx)
  3342                              <1> 	;
  3343                              <1> 	;	(ECX = actual TRANSFER COUNT for string functions)
  3344                              <1> 	;
  3345                              <1> 	;
  3346                              <1> 	; Modified registers: EAX
  3347                              <1> 	;
  3348                              <1> 
  3349                              <1> 	;cmp	ah, 5
  3350                              <1> 	;ja	short int34h_5 ; invalid function !
  3351                              <1> 
  3352                              <1> 	; 12/10/2017
  3353 00012D58 80FC07              <1> 	cmp	ah, 7
  3354 00012D5B 7743                <1> 	ja	short int34h_5 ; invalid function !
  3355                              <1> 
  3356                              <1> 	;; 15/01/2017
  3357                              <1> 	; 14/01/2017
  3358                              <1> 	; 02/01/2017
  3359                              <1> 	;;mov	byte [ss:intflg], 34h	; IOCTL interrupt 
  3360 00012D5D FB                  <1> 	sti
  3361                              <1> 	
  3362                              <1> 	;sti	; enable interrupts
  3363 00012D5E 80642408FE          <1> 	and	byte [esp+8], 11111110b	; clear carry bit of eflags register
  3364                              <1> 
  3365 00012D63 80FC01              <1> 	cmp	ah, 1
  3366 00012D66 7205                <1> 	jb	short int34h_0
  3367 00012D68 7705                <1> 	ja	short int34h_1
  3368                              <1> 
  3369 00012D6A EE                  <1> 	out	dx, al
  3370                              <1> 	;iretd
  3371 00012D6B EB01                <1> 	jmp short int34h_iret
  3372                              <1> 
  3373                              <1> int34h_0:
  3374 00012D6D EC                  <1> 	in	al, dx
  3375                              <1> 	;iretd
  3376                              <1> int34h_iret:
  3377                              <1> 	;cli	; 07/01/2017
  3378                              <1> 	;; 15/01/2017
  3379                              <1> 	;;mov	byte [ss:intflg], 0 ; reset
  3380 00012D6E CF                  <1> 	iretd 
  3381                              <1> 
  3382                              <1> int34h_1:
  3383 00012D6F F6C401              <1> 	test	ah, 1
  3384 00012D72 7516                <1> 	jnz	short int34h_3 ; out
  3385                              <1> 
  3386                              <1> 	; in
  3387 00012D74 80FC02              <1> 	cmp	ah, 2
  3388 00012D77 7707                <1> 	ja	short int34h_2
  3389                              <1> 
  3390 00012D79 6689D8              <1> 	mov	ax, bx
  3391 00012D7C 66ED                <1> 	in	ax, dx
  3392                              <1> 	;iretd
  3393 00012D7E EBEE                <1> 	jmp	short int34h_iret
  3394                              <1> 
  3395                              <1> int34h_2:
  3396 00012D80 80FC04              <1> 	cmp	ah, 4
  3397 00012D83 772C                <1> 	ja	short int34h_7	; 12/10/2017
  3398                              <1> 	; ah = 4
  3399 00012D85 89D8                <1> 	mov	eax, ebx
  3400 00012D87 ED                  <1> 	in	eax, dx
  3401                              <1> 	;iretd
  3402 00012D88 EBE4                <1> 	jmp	short int34h_iret
  3403                              <1> 
  3404                              <1> int34h_3:
  3405 00012D8A 80FC03              <1> 	cmp	ah, 3
  3406 00012D8D 7707                <1> 	ja	short int34h_4
  3407                              <1> 
  3408 00012D8F 6689D8              <1> 	mov	ax, bx
  3409 00012D92 66EF                <1> 	out	dx, ax
  3410                              <1> 	;iretd
  3411 00012D94 EBD8                <1> 	jmp	short int34h_iret
  3412                              <1> 
  3413                              <1> int34h_4:
  3414 00012D96 80FC05              <1> 	cmp	ah, 5
  3415 00012D99 770B                <1> 	ja	short int34h_6	; 12/10/2017
  3416                              <1> 	; ah = 5
  3417 00012D9B 89D8                <1> 	mov	eax, ebx
  3418 00012D9D EF                  <1> 	out	dx, eax
  3419                              <1> 	;iretd
  3420 00012D9E EBCE                <1> 	jmp	short int34h_iret
  3421                              <1> 
  3422                              <1> int34h_5:
  3423 00012DA0 804C240801          <1> 	or	byte [esp+8], 1	; set carry bit of eflags register
  3424 00012DA5 CF                  <1> 	iretd
  3425                              <1> 
  3426                              <1> 	; 12/10/2017
  3427                              <1> int34h_6:
  3428 00012DA6 6689D8              <1> 	mov	ax, bx
  3429 00012DA9 EE                  <1> 	out	dx, al
  3430 00012DAA EB00                <1> 	jmp	short $+2
  3431 00012DAC 86E0                <1> 	xchg	ah, al
  3432 00012DAE EE                  <1> 	out	dx, al
  3433                              <1> 	;xchg	al, ah
  3434                              <1> 	;iretd
  3435 00012DAF EB06                <1> 	jmp	short int34h_8
  3436                              <1> int34h_7:
  3437 00012DB1 EC                  <1> 	in	al, dx
  3438 00012DB2 EB00                <1> 	jmp	short $+2
  3439 00012DB4 88C4                <1> 	mov	ah, al
  3440 00012DB6 EC                  <1> 	in	al, dx
  3441                              <1> int34h_8:
  3442 00012DB7 86C4                <1> 	xchg	al, ah
  3443 00012DB9 CF                  <1> 	iretd
  3444                              <1> 			
  3445                              <1> 
  3446                              <1> INT4Ah:
  3447                              <1> 	; 24/01/2016
  3448                              <1> 	; this procedure will be called by 'RTC_INT' (in 'timer.s')
  3449 00012DBA C3                  <1> 	retn
  3450                              <1> 
  3451                              <1> ; u0.s
  3452                              <1> ; Retro UNIX 386 v1 Kernel (v0.2) - SYS0.INC
  3453                              <1> ; Last Modification: 20/11/2015
  3454                              <1> 
  3455                              <1> com2_int:
  3456                              <1> 	; 07/11/2015 
  3457                              <1> 	; 24/10/2015
  3458                              <1> 	; 23/10/2015
  3459                              <1> 	; 14/03/2015 (Retro UNIX 386 v1 - Beginning)
  3460                              <1> 	; 28/07/2014 (Retro UNIX 8086 v1)
  3461                              <1> 	; < serial port 2 interrupt handler >
  3462                              <1> 	;
  3463 00012DBB 890424              <1> 	mov 	[esp], eax ; overwrite call return address
  3464                              <1> 	;push	eax
  3465 00012DBE 66B80900            <1> 	mov	ax, 9
  3466 00012DC2 EB07                <1> 	jmp	short comm_int
  3467                              <1> com1_int:
  3468                              <1> 	; 07/11/2015
  3469                              <1> 	; 24/10/2015
  3470 00012DC4 890424              <1> 	mov 	[esp], eax ; overwrite call return address
  3471                              <1> 	; 23/10/2015
  3472                              <1> 	;push	eax
  3473 00012DC7 66B80800            <1> 	mov	ax, 8
  3474                              <1> comm_int:
  3475                              <1> 	; 20/11/2015
  3476                              <1> 	; 18/11/2015
  3477                              <1> 	; 17/11/2015
  3478                              <1> 	; 16/11/2015
  3479                              <1> 	; 09/11/2015
  3480                              <1> 	; 08/11/2015
  3481                              <1> 	; 07/11/2015
  3482                              <1> 	; 06/11/2015 (serial4.asm, 'serial')	
  3483                              <1> 	; 01/11/2015
  3484                              <1> 	; 26/10/2015
  3485                              <1> 	; 23/10/2015
  3486 00012DCB 53                  <1> 	push	ebx
  3487 00012DCC 56                  <1> 	push	esi
  3488 00012DCD 57                  <1> 	push	edi
  3489 00012DCE 1E                  <1> 	push 	ds
  3490 00012DCF 06                  <1> 	push 	es
  3491                              <1> 	; 18/11/2015
  3492 00012DD0 0F20DB              <1> 	mov	ebx, cr3
  3493 00012DD3 53                  <1> 	push	ebx ; ****
  3494                              <1> 	;
  3495 00012DD4 51                  <1> 	push	ecx ; ***
  3496 00012DD5 52                  <1> 	push	edx ; **
  3497                              <1> 	;
  3498 00012DD6 BB10000000          <1> 	mov	ebx, KDATA
  3499 00012DDB 8EDB                <1> 	mov	ds, bx
  3500 00012DDD 8EC3                <1> 	mov	es, bx
  3501                              <1> 	;
  3502 00012DDF 8B0D[308A0100]      <1> 	mov	ecx, [k_page_dir]
  3503 00012DE5 0F22D9              <1> 	mov	cr3, ecx
  3504                              <1> 	; 20/11/2015
  3505                              <1> 	; Interrupt identification register
  3506 00012DE8 66BAFA02            <1> 	mov	dx, 2FAh ; COM2
  3507                              <1> 	;
  3508 00012DEC 3C08                <1> 	cmp 	al, 8 
  3509 00012DEE 7702                <1> 	ja 	short com_i0
  3510                              <1> 	;
  3511                              <1> 	; 20/11/2015
  3512                              <1> 	; 17/11/2015
  3513                              <1> 	; 16/11/2015
  3514                              <1> 	; 15/11/2015
  3515                              <1> 	; 24/10/2015
  3516                              <1> 	; 14/03/2015 (Retro UNIX 386 v1 - Beginning)
  3517                              <1> 	; 28/07/2014 (Retro UNIX 8086 v1)
  3518                              <1> 	; < serial port 1 interrupt handler >
  3519                              <1> 	;
  3520 00012DF0 FEC6                <1> 	inc	dh ; 3FAh ; COM1 Interrupt id. register
  3521                              <1> com_i0:
  3522                              <1> 	;push	eax ; *
  3523                              <1> 	; 07/11/2015
  3524 00012DF2 A2[9A8A0100]        <1> 	mov 	byte [ccomport], al
  3525                              <1> 	; 09/11/2015
  3526 00012DF7 0FB7D8              <1> 	movzx	ebx, ax ; 8 or 9
  3527                              <1> 	; 17/11/2015
  3528                              <1>  	; reset request for response status
  3529 00012DFA 88A3[908A0100]      <1> 	mov	[ebx+req_resp-8], ah ; 0
  3530                              <1> 	;
  3531                              <1> 	; 20/11/2015
  3532 00012E00 EC                  <1> 	in	al, dx		; read interrupt id. register
  3533 00012E01 EB00                <1> 	JMP	$+2	   	; I/O DELAY
  3534 00012E03 2404                <1> 	and	al, 4		; received data available?	
  3535 00012E05 7470                <1> 	jz	short com_eoi	; (transmit. holding reg. empty)
  3536                              <1> 	;
  3537                              <1> 	; 20/11/2015
  3538 00012E07 80EA02              <1> 	sub	dl, 3FAh-3F8h	; data register (3F8h, 2F8h)
  3539 00012E0A EC                  <1> 	in	al, dx     	; read character
  3540                              <1> 	;JMP	$+2	   	; I/O DELAY
  3541                              <1> 	; 08/11/2015
  3542                              <1> 	; 07/11/2015
  3543 00012E0B 89DE                <1> 	mov	esi, ebx 
  3544 00012E0D 89DF                <1> 	mov	edi, ebx
  3545 00012E0F 81C6[948A0100]      <1> 	add 	esi, rchar - 8 ; points to last received char
  3546 00012E15 81C7[968A0100]      <1> 	add	edi, schar - 8 ; points to last sent char
  3547 00012E1B 8806                <1> 	mov	[esi], al ; received char (current char)
  3548                              <1> 	; query
  3549 00012E1D 20C0                <1> 	and	al, al
  3550 00012E1F 7527                <1> 	jnz	short com_i2
  3551                              <1>    	; response
  3552                              <1> 	; 17/11/2015
  3553                              <1> 	; set request for response status
  3554 00012E21 FE83[908A0100]      <1>         inc     byte [ebx+req_resp-8] ; 1 
  3555                              <1> 	;
  3556 00012E27 6683C205            <1> 	add	dx, 3FDh-3F8h	; (3FDh, 2FDh)
  3557 00012E2B EC                  <1> 	in	al, dx	   	; read line status register 
  3558 00012E2C EB00                <1> 	JMP	$+2	   	; I/O DELAY
  3559 00012E2E 2420                <1> 	and	al, 20h	   	; transmitter holding reg. empty?
  3560 00012E30 7445                <1> 	jz	short com_eoi 	; no
  3561 00012E32 B0FF                <1> 	mov 	al, 0FFh   	; response			
  3562 00012E34 6683EA05            <1> 	sub	dx, 3FDh-3F8h 	; data port (3F8h, 2F8h)
  3563 00012E38 EE                  <1> 	out	dx, al	   	; send on serial port
  3564                              <1> 	; 17/11/2015
  3565 00012E39 803F00              <1> 	cmp 	byte [edi], 0   ; query ? (schar)
  3566 00012E3C 7502                <1> 	jne 	short com_i1    ; no
  3567 00012E3E 8807                <1> 	mov	[edi], al 	; 0FFh (responded)
  3568                              <1> com_i1:
  3569                              <1> 	; 17/11/2015
  3570                              <1> 	; reset request for response status (again)
  3571 00012E40 FE8B[908A0100]      <1>         dec     byte [ebx+req_resp-8] ; 0 
  3572 00012E46 EB2F                <1> 	jmp	short com_eoi
  3573                              <1> com_i2:	
  3574                              <1> 	; 08/11/2015
  3575 00012E48 3CFF                <1> 	cmp 	al, 0FFh	; (response ?)
  3576 00012E4A 7417                <1> 	je	short com_i3	; (check for response signal)
  3577                              <1> 	; 07/11/2015
  3578 00012E4C 3C04                <1> 	cmp	al, 04h	; EOT
  3579 00012E4E 751C                <1> 	jne	short com_i4	
  3580                              <1> 	; EOT = 04h (End of Transmit) - 'CTRL + D'
  3581                              <1> 	;(an EOT char is supposed as a ctrl+brk from the terminal)
  3582                              <1> 	; 08/11/2015
  3583                              <1> 		; ptty -> tty 0 to 7 (pseudo screens)
  3584 00012E50 861D[5E8A0100]      <1> 	xchg	bl, [ptty]  ; tty number (8 or 9)
  3585 00012E56 E89547FFFF          <1> 	call 	ctrlbrk
  3586 00012E5B 861D[5E8A0100]      <1> 	xchg	[ptty], bl ; (restore ptty value and BL value)
  3587                              <1> 	;mov	al, 04h ; EOT
  3588                              <1> 	; 08/11/2015
  3589 00012E61 EB09                <1> 	jmp	short com_i4	
  3590                              <1> com_i3:
  3591                              <1> 	; 08/11/2015
  3592                              <1> 	; If 0FFh has been received just after a query
  3593                              <1> 	; (schar, ZERO), it is a response signal.
  3594                              <1> 	; 17/11/2015
  3595 00012E63 803F00              <1>         cmp     byte [edi], 0 ; query ? (schar)
  3596 00012E66 7704                <1> 	ja	short com_i4 ; no
  3597                              <1> 	; reset query status (schar)
  3598 00012E68 8807                <1> 	mov	[edi], al ; 0FFh
  3599 00012E6A FEC0                <1> 	inc	al ; 0
  3600                              <1> com_i4:
  3601                              <1> 	; 27/07/2014
  3602                              <1> 	; 09/07/2014
  3603 00012E6C D0E3                <1> 	shl	bl, 1	
  3604 00012E6E 81C3[608A0100]      <1> 	add	ebx, ttychr
  3605                              <1> 	; 23/07/2014 (always overwrite)
  3606                              <1> 	;;cmp	word [ebx], 0
  3607                              <1> 	;;ja	short com_eoi
  3608                              <1> 	;
  3609 00012E74 668903              <1> 	mov	[ebx], ax   ; Save ascii code
  3610                              <1> 			    ; scan code = 0
  3611                              <1> com_eoi:
  3612                              <1> 	;mov	al, 20h
  3613                              <1> 	;out	20h, al	   ; end of interrupt
  3614                              <1> 	;
  3615                              <1> 	; 07/11/2015
  3616                              <1>       	;pop	eax ; *
  3617 00012E77 A0[9A8A0100]        <1> 	mov	al, byte [ccomport] ; current COM port
  3618                              <1> 	 ; al = tty number (8 or 9)
  3619 00012E7C E85E010000          <1>         call	wakeup
  3620                              <1> com_iret:
  3621                              <1> 	; 23/10/2015
  3622 00012E81 5A                  <1> 	pop	edx ; **
  3623 00012E82 59                  <1> 	pop	ecx ; ***
  3624                              <1> 	; 18/11/2015
  3625                              <1> 	;pop	eax ; ****
  3626                              <1> 	;mov	cr3, eax
  3627                              <1> 	;jmp	iiret
  3628 00012E83 E92BDFFEFF          <1> 	jmp	iiretp
  3629                              <1> 
  3630                              <1> ;iiretp: ; 01/09/2015
  3631                              <1> ;	; 28/08/2015
  3632                              <1> ;	pop	eax ; (*) page directory
  3633                              <1> ;	mov	cr3, eax
  3634                              <1> ;iiret:
  3635                              <1> ;	; 22/08/2014
  3636                              <1> ;	mov	al, 20h ; END OF INTERRUPT COMMAND TO 8259
  3637                              <1> ;	out	20h, al	; 8259 PORT
  3638                              <1> ;	;
  3639                              <1> ;	pop	es
  3640                              <1> ;	pop	ds
  3641                              <1> ;	pop	edi
  3642                              <1> ;	pop	esi
  3643                              <1> ;	pop	ebx ; 29/08/2014
  3644                              <1> ;	pop 	eax
  3645                              <1> ;	iretd
  3646                              <1> 
  3647                              <1> sp_init:
  3648                              <1> 	; 07/11/2015
  3649                              <1> 	; 29/10/2015
  3650                              <1> 	; 26/10/2015
  3651                              <1> 	; 23/10/2015
  3652                              <1> 	; 29/06/2015
  3653                              <1> 	; 14/03/2015 (Retro UNIX 386 v1 - 115200 baud)
  3654                              <1> 	; 28/07/2014 (Retro UNIX 8086 v1 - 9600 baud)
  3655                              <1> 	; Initialization of Serial Port Communication Parameters
  3656                              <1> 	; (COM1 base port address = 3F8h, COM1 Interrupt = IRQ 4)
  3657                              <1> 	; (COM2 base port address = 2F8h, COM1 Interrupt = IRQ 3)
  3658                              <1> 	;
  3659                              <1> 	; ((Modified registers: EAX, ECX, EDX, EBX))
  3660                              <1> 	;
  3661                              <1> 	; INPUT:  (29/06/2015)
  3662                              <1> 	;	AL = 0 for COM1
  3663                              <1> 	;	     1 for COM2
  3664                              <1> 	;	AH = Communication parameters	
  3665                              <1> 	;
  3666                              <1> 	;  (*) Communication parameters (except BAUD RATE):
  3667                              <1> 	;	Bit	4	3	2	1	0
  3668                              <1> 	;		-PARITY--   STOP BIT  -WORD LENGTH-	 		 
  3669                              <1> 	;  this one -->	00 = none    0 = 1 bit  11 = 8 bits
  3670                              <1> 	;		01 = odd     1 = 2 bits	10 = 7 bits
  3671                              <1> 	;		11 = even
  3672                              <1> 	;  Baud rate setting bits: (29/06/2015)
  3673                              <1> 	;		Retro UNIX 386 v1 feature only !
  3674                              <1> 	;	Bit	7    6    5  | Baud rate
  3675                              <1> 	;		------------------------
  3676                              <1> 	;	value	0    0    0  | Default (Divisor = 1)
  3677                              <1> 	;		0    0    1  | 9600 (12)
  3678                              <1> 	;		0    1    0  | 19200 (6) 
  3679                              <1> 	;		0    1	  1  | 38400 (3) 
  3680                              <1> 	;		1    0	  0  | 14400 (8)
  3681                              <1> 	;		1    0	  1  | 28800 (4)
  3682                              <1> 	;		1    1    0  | 57600 (2)
  3683                              <1> 	;		1    1    1  | 115200 (1) 	
  3684                              <1> 	
  3685                              <1> 	; References:	
  3686                              <1> 	; (1) IBM PC-XT Model 286 BIOS Source Code
  3687                              <1> 	;     RS232.ASM --- 10/06/1985 COMMUNICATIONS BIOS (RS232)
  3688                              <1> 	; (2) Award BIOS 1999 - ATORGS.ASM
  3689                              <1> 	; (3) http://wiki.osdev.org/Serial_Ports
  3690                              <1> 	;
  3691                              <1> 	; Set communication parameters for COM1 (= 03h)	
  3692                              <1> 	;
  3693 00012E88 BB[968A0100]        <1> 	mov	ebx, com1p		; COM1 parameters  
  3694 00012E8D 66BAF803            <1> 	mov	dx, 3F8h		; COM1
  3695                              <1> 	 ; 29/10/2015
  3696 00012E91 66B90103            <1> 	mov	cx, 301h  ; divisor = 1 (115200 baud)
  3697 00012E95 E86F000000          <1> 	call	sp_i3	; call A4	
  3698 00012E9A A880                <1> 	test	al, 80h
  3699 00012E9C 7410                <1> 	jz	short sp_i0 ; OK..
  3700                              <1> 		; Error !
  3701                              <1> 	;mov	dx, 3F8h
  3702 00012E9E 80EA05              <1> 	sub	dl, 5 ; 3FDh -> 3F8h
  3703 00012EA1 66B90E03            <1> 	mov	cx, 30Eh  ; divisor = 12 (9600 baud)
  3704 00012EA5 E85F000000          <1> 	call	sp_i3	; call A4	
  3705 00012EAA A880                <1> 	test	al, 80h
  3706 00012EAC 7508                <1> 	jnz	short sp_i1
  3707                              <1> sp_i0:
  3708                              <1>         ; (Note: Serial port interrupts will be disabled here...)	
  3709                              <1>         ; (INT 14h initialization code disables interrupts.)
  3710                              <1> 	;
  3711 00012EAE C603E3              <1> 	mov	byte [ebx], 0E3h ; 11100011b
  3712 00012EB1 E8DC000000          <1> 	call	sp_i5 ; 29/06/2015
  3713                              <1> sp_i1:
  3714 00012EB6 43                  <1> 	inc	ebx
  3715 00012EB7 66BAF802            <1> 	mov	dx, 2F8h		; COM2
  3716                              <1> 	 ; 29/10/2015
  3717 00012EBB 66B90103            <1> 	mov	cx, 301h  ; divisor = 1 (115200 baud)
  3718 00012EBF E845000000          <1> 	call	sp_i3	; call A4	
  3719 00012EC4 A880                <1> 	test	al, 80h
  3720 00012EC6 7410                <1> 	jz	short sp_i2 ; OK..
  3721                              <1> 		; Error !
  3722                              <1> 	;mov	dx, 2F8h
  3723 00012EC8 80EA05              <1> 	sub	dl, 5 ; 2FDh -> 2F8h
  3724 00012ECB 66B90E03            <1> 	mov	cx, 30Eh  ; divisor = 12 (9600 baud)
  3725 00012ECF E835000000          <1> 	call	sp_i3	; call A4	
  3726 00012ED4 A880                <1> 	test	al, 80h
  3727 00012ED6 7530                <1> 	jnz	short sp_i7
  3728                              <1> sp_i2:
  3729 00012ED8 C603E3              <1> 	mov	byte [ebx], 0E3h ; 11100011b
  3730                              <1> sp_i6:
  3731                              <1> 	;; COM2 - enabling IRQ 3
  3732                              <1> 	; 07/11/2015
  3733                              <1> 	; 26/10/2015
  3734 00012EDB 9C                  <1> 	pushf
  3735 00012EDC FA                  <1> 	cli
  3736                              <1> 	;
  3737 00012EDD 66BAFC02            <1> 	mov	dx, 2FCh   		; modem control register
  3738 00012EE1 EC                  <1> 	in	al, dx 	   		; read register
  3739 00012EE2 EB00                <1> 	JMP	$+2	   		; I/O DELAY
  3740 00012EE4 0C08                <1> 	or	al, 8      		; enable bit 3 (OUT2)
  3741 00012EE6 EE                  <1> 	out	dx, al     		; write back to register
  3742 00012EE7 EB00                <1> 	JMP	$+2	   		; I/O DELAY
  3743 00012EE9 66BAF902            <1> 	mov	dx, 2F9h   		; interrupt enable register
  3744 00012EED EC                  <1> 	in	al, dx     		; read register
  3745 00012EEE EB00                <1> 	JMP	$+2	   		; I/O DELAY
  3746                              <1> 	;or	al, 1      		; receiver data interrupt enable and
  3747 00012EF0 0C03                <1> 	or	al, 3	   		; transmitter empty interrupt enable
  3748 00012EF2 EE                  <1> 	out	dx, al 	   		; write back to register
  3749 00012EF3 EB00                <1> 	JMP	$+2        		; I/O DELAY
  3750 00012EF5 E421                <1> 	in	al, 21h    		; read interrupt mask register
  3751 00012EF7 EB00                <1> 	JMP	$+2	   		; I/O DELAY
  3752 00012EF9 24F7                <1> 	and	al, 0F7h   		; enable IRQ 3 (COM2)
  3753 00012EFB E621                <1> 	out	21h, al    		; write back to register
  3754                              <1> 	;
  3755                              <1> 	; 23/10/2015
  3756 00012EFD B8[BB2D0100]        <1> 	mov 	eax, com2_int
  3757 00012F02 A3[DA2F0100]        <1> 	mov	[com2_irq3], eax
  3758                              <1> 	; 26/10/2015
  3759 00012F07 9D                  <1> 	popf	
  3760                              <1> sp_i7:
  3761 00012F08 C3                  <1> 	retn
  3762                              <1> 
  3763                              <1> sp_i3:
  3764                              <1> ;A4:  	;-----	INITIALIZE THE COMMUNICATIONS PORT
  3765                              <1> 	; 28/10/2015
  3766 00012F09 FEC2                <1> 	inc	dl	; 3F9h (2F9h)	; 3F9h, COM1 Interrupt enable register 
  3767 00012F0B B000                <1> 	mov	al, 0
  3768 00012F0D EE                  <1> 	out	dx, al			; disable serial port interrupt
  3769 00012F0E EB00                <1> 	JMP	$+2			; I/O DELAY
  3770 00012F10 80C202              <1> 	add	dl, 2 	; 3FBh (2FBh)	; COM1 Line control register (3FBh)
  3771 00012F13 B080                <1> 	mov	al, 80h			
  3772 00012F15 EE                  <1> 	out	dx, al			; SET DLAB=1 ; divisor latch access bit
  3773                              <1> 	;-----	SET BAUD RATE DIVISOR
  3774                              <1> 	; 26/10/2015
  3775 00012F16 80EA03              <1> 	sub 	dl, 3   ; 3F8h (2F8h)	; register for least significant byte
  3776                              <1> 					; of the divisor value
  3777 00012F19 88C8                <1> 	mov	al, cl	; 1
  3778 00012F1B EE                  <1> 	out	dx, al			; 1 = 115200 baud (Retro UNIX 386 v1)
  3779                              <1> 					; 2 = 57600 baud
  3780                              <1> 					; 3 = 38400 baud
  3781                              <1> 					; 6 = 19200 baud
  3782                              <1> 					; 12 = 9600 baud (Retro UNIX 8086 v1)
  3783 00012F1C EB00                <1> 	JMP	$+2			; I/O DELAY
  3784 00012F1E 28C0                <1> 	sub	al, al
  3785 00012F20 FEC2                <1> 	inc	dl      ; 3F9h (2F9h)	; register for most significant byte
  3786                              <1> 					; of the divisor value
  3787 00012F22 EE                  <1> 	out	dx, al ; 0
  3788 00012F23 EB00                <1> 	JMP	$+2			; I/O DELAY
  3789                              <1> 	;	
  3790 00012F25 88E8                <1> 	mov	al, ch ; 3		; 8 data bits, 1 stop bit, no parity
  3791                              <1> 	;and	al, 1Fh ; Bits 0,1,2,3,4	
  3792 00012F27 80C202              <1> 	add	dl, 2	; 3FBh (2FBh)	; Line control register
  3793 00012F2A EE                  <1> 	out	dx, al			
  3794 00012F2B EB00                <1> 	JMP	$+2			; I/O DELAY
  3795                              <1> 	; 29/10/2015
  3796 00012F2D FECA                <1> 	dec 	dl 	; 3FAh (2FAh)	; FIFO Control register (16550/16750)
  3797 00012F2F 30C0                <1> 	xor	al, al			; 0
  3798 00012F31 EE                  <1> 	out	dx, al			; Disable FIFOs (reset to 8250 mode)
  3799 00012F32 EB00                <1> 	JMP	$+2	
  3800                              <1> sp_i4:
  3801                              <1> ;A18:	;-----	COMM PORT STATUS ROUTINE
  3802                              <1> 	; 29/06/2015 (line status after modem status)
  3803 00012F34 80C204              <1> 	add	dl, 4	; 3FEh (2FEh)	; Modem status register
  3804                              <1> sp_i4s:
  3805 00012F37 EC                  <1> 	in	al, dx			; GET MODEM CONTROL STATUS
  3806 00012F38 EB00                <1> 	JMP	$+2			; I/O DELAY
  3807 00012F3A 88C4                <1> 	mov	ah, al			; PUT IN (AH) FOR RETURN
  3808 00012F3C FECA                <1> 	dec	dl	; 3FDh (2FDh)	; POINT TO LINE STATUS REGISTER
  3809                              <1> 					; dx = 3FDh for COM1, 2FDh for COM2
  3810 00012F3E EC                  <1> 	in	al, dx			; GET LINE CONTROL STATUS
  3811                              <1> 	; AL = Line status, AH = Modem status
  3812 00012F3F C3                  <1> 	retn
  3813                              <1> 
  3814                              <1> sp_status:
  3815                              <1> 	; 29/06/2015
  3816                              <1> 	; 27/06/2015 (Retro UNIX 386 v1)
  3817                              <1> 	; Get serial port status
  3818 00012F40 66BAFE03            <1> 	mov	dx, 3FEh		; Modem status register (COM1)
  3819 00012F44 28C6                <1> 	sub	dh, al			; dh = 2 for COM2 (al = 1)
  3820                              <1> 					; dx = 2FEh for COM2
  3821 00012F46 EBEF                <1> 	jmp	short sp_i4s
  3822                              <1> 
  3823                              <1> sp_setp: ; Set serial port communication parameters
  3824                              <1> 	; 07/11/2015
  3825                              <1> 	; 29/10/2015
  3826                              <1> 	; 29/06/2015
  3827                              <1> 	; Retro UNIX 386 v1 feature only !	
  3828                              <1> 	;
  3829                              <1> 	; INPUT:
  3830                              <1> 	;	AL = 0 for COM1
  3831                              <1> 	;	     1 for COM2
  3832                              <1> 	;	AH = Communication parameters (*)
  3833                              <1> 	; OUTPUT:
  3834                              <1> 	;	CL = Line status
  3835                              <1> 	;	CH = Modem status
  3836                              <1> 	;   If cf = 1 -> Error code in [u.error]
  3837                              <1> 	;		 'invalid parameter !' 
  3838                              <1> 	;		 	 or
  3839                              <1> 	;		 'device not ready !' error
  3840                              <1> 	;	
  3841                              <1> 	;  (*) Communication parameters (except BAUD RATE):
  3842                              <1> 	;	Bit	4	3	2	1	0
  3843                              <1> 	;		-PARITY--   STOP BIT  -WORD LENGTH-	 		 
  3844                              <1> 	;  this one -->	00 = none    0 = 1 bit  11 = 8 bits
  3845                              <1> 	;		01 = odd     1 = 2 bits	10 = 7 bits
  3846                              <1> 	;		11 = even
  3847                              <1> 	;  Baud rate setting bits: (29/06/2015)
  3848                              <1> 	;		Retro UNIX 386 v1 feature only !
  3849                              <1> 	;	Bit	7    6    5  | Baud rate
  3850                              <1> 	;		------------------------
  3851                              <1> 	;	value	0    0    0  | Default (Divisor = 1)
  3852                              <1> 	;		0    0    1  | 9600 (12)
  3853                              <1> 	;		0    1    0  | 19200 (6) 
  3854                              <1> 	;		0    1	  1  | 38400 (3) 
  3855                              <1> 	;		1    0	  0  | 14400 (8)
  3856                              <1> 	;		1    0	  1  | 28800 (4)
  3857                              <1> 	;		1    1    0  | 57600 (2)
  3858                              <1> 	;		1    1    1  | 115200 (1) 
  3859                              <1> 	;
  3860                              <1> 	; (COM1 base port address = 3F8h, COM1 Interrupt = IRQ 4)
  3861                              <1> 	; (COM2 base port address = 2F8h, COM1 Interrupt = IRQ 3)
  3862                              <1> 	;
  3863                              <1> 	; ((Modified registers: EAX, ECX, EDX, EBX))
  3864                              <1> 	;
  3865 00012F48 66BAF803            <1> 	mov	dx, 3F8h
  3866 00012F4C BB[968A0100]        <1> 	mov	ebx, com1p ; COM1 control byte offset
  3867 00012F51 3C01                <1> 	cmp	al, 1
  3868 00012F53 776B                <1> 	ja 	short sp_invp_err
  3869 00012F55 7203                <1> 	jb	short sp_setp1 ;  COM1 (AL = 0)
  3870 00012F57 FECE                <1> 	dec	dh ; 2F8h
  3871 00012F59 43                  <1> 	inc	ebx ; COM2 control byte offset
  3872                              <1> sp_setp1:
  3873                              <1> 	; 29/10/2015
  3874 00012F5A 8823                <1> 	mov	[ebx], ah
  3875 00012F5C 0FB6CC              <1> 	movzx 	ecx, ah
  3876 00012F5F C0E905              <1> 	shr	cl, 5 ; -> baud rate index
  3877 00012F62 80E41F              <1> 	and	ah, 1Fh ; communication parameters except baud rate
  3878 00012F65 8A81[CF2F0100]      <1> 	mov	al, [ecx+b_div_tbl]
  3879 00012F6B 6689C1              <1> 	mov	cx, ax
  3880 00012F6E E896FFFFFF          <1> 	call	sp_i3
  3881 00012F73 6689C1              <1> 	mov	cx, ax ; CL = Line status, CH = Modem status
  3882 00012F76 A880                <1> 	test	al, 80h
  3883 00012F78 740F                <1> 	jz	short sp_setp2
  3884 00012F7A C603E3              <1>         mov     byte [ebx], 0E3h ; Reset to initial value (11100011b)
  3885                              <1> stp_dnr_err:
  3886 00012F7D C705[C8030300]0F00- <1> 	mov	dword [u.error], ERR_DEV_NOT_RDY ; 'device not ready !'
  3886 00012F85 0000                <1>
  3887                              <1> 	; CL = Line status, CH = Modem status
  3888 00012F87 F9                  <1> 	stc
  3889 00012F88 C3                  <1> 	retn
  3890                              <1> sp_setp2:
  3891 00012F89 80FE02              <1> 	cmp	dh, 2 ; COM2 (2F?h)
  3892 00012F8C 0F8649FFFFFF        <1>         jna     sp_i6 
  3893                              <1> 		      ; COM1 (3F?h)
  3894                              <1> sp_i5: 
  3895                              <1> 	; 07/11/2015
  3896                              <1> 	; 26/10/2015
  3897                              <1> 	; 29/06/2015
  3898                              <1> 	;
  3899                              <1> 	;; COM1 - enabling IRQ 4
  3900 00012F92 9C                  <1> 	pushf
  3901 00012F93 FA                  <1> 	cli
  3902 00012F94 66BAFC03            <1> 	mov	dx, 3FCh   		; modem control register
  3903 00012F98 EC                  <1> 	in	al, dx 	   		; read register
  3904 00012F99 EB00                <1> 	JMP	$+2			; I/O DELAY
  3905 00012F9B 0C08                <1> 	or	al, 8      		; enable bit 3 (OUT2)
  3906 00012F9D EE                  <1> 	out	dx, al     		; write back to register
  3907 00012F9E EB00                <1> 	JMP	$+2			; I/O DELAY
  3908 00012FA0 66BAF903            <1> 	mov	dx, 3F9h   		; interrupt enable register
  3909 00012FA4 EC                  <1> 	in	al, dx     		; read register
  3910 00012FA5 EB00                <1> 	JMP	$+2			; I/O DELAY
  3911                              <1> 	;or	al, 1      		; receiver data interrupt enable and
  3912 00012FA7 0C03                <1> 	or	al, 3	   		; transmitter empty interrupt enable
  3913 00012FA9 EE                  <1> 	out	dx, al 	   		; write back to register
  3914 00012FAA EB00                <1> 	JMP	$+2        		; I/O DELAY
  3915 00012FAC E421                <1> 	in	al, 21h    		; read interrupt mask register
  3916 00012FAE EB00                <1> 	JMP	$+2			; I/O DELAY
  3917 00012FB0 24EF                <1> 	and	al, 0EFh   		; enable IRQ 4 (COM1)
  3918 00012FB2 E621                <1> 	out	21h, al    		; write back to register
  3919                              <1> 	;
  3920                              <1> 	; 23/10/2015
  3921 00012FB4 B8[C42D0100]        <1> 	mov 	eax, com1_int
  3922 00012FB9 A3[D62F0100]        <1> 	mov	[com1_irq4], eax
  3923                              <1> 	; 26/10/2015
  3924 00012FBE 9D                  <1> 	popf
  3925 00012FBF C3                  <1> 	retn
  3926                              <1> 
  3927                              <1> sp_invp_err:
  3928 00012FC0 C705[C8030300]1700- <1> 	mov	dword [u.error], ERR_INV_PARAMETER ; 'invalid parameter !' 
  3928 00012FC8 0000                <1>
  3929 00012FCA 31C9                <1> 	xor	ecx, ecx
  3930 00012FCC 49                  <1> 	dec	ecx ; 0FFFFh
  3931 00012FCD F9                  <1> 	stc
  3932 00012FCE C3                  <1> 	retn
  3933                              <1> 
  3934                              <1> ; 29/10/2015
  3935                              <1> b_div_tbl: ; Baud rate divisor table (115200/divisor)
  3936 00012FCF 010C0603080401      <1> 	db 1, 12, 6, 3, 8, 4, 1
  3937                              <1> 
  3938                              <1> 
  3939                              <1> ; 23/10/2015
  3940                              <1> com1_irq4:
  3941 00012FD6 [DE2F0100]          <1> 	dd dummy_retn
  3942                              <1> com2_irq3:
  3943 00012FDA [DE2F0100]          <1> 	dd dummy_retn
  3944                              <1> 
  3945                              <1> dummy_retn:
  3946 00012FDE C3                  <1> 	retn
  3947                              <1> 
  3948                              <1> wakeup:
  3949                              <1> 	; 24/01/2016
  3950 00012FDF C3                  <1> 	retn
  3951                              <1> 
  3952                              <1> set_working_path_x:
  3953                              <1> 		; 17/10/2016 (TRDOS 386 - FFF & FNF)
  3954 00012FE0 66B80100            <1> 		mov	ax, 1 
  3955                              <1> 			; File name is needed/forced (AL=1)
  3956                              <1> 			; Change directory as temporary (AH=0)	
  3957                              <1> 
  3958                              <1> set_working_path_xx: ; 30/12/2017 (syschdir)
  3959                              <1> 		; This is needed for preventing wrong Find Next File
  3960                              <1> 		; system call after sysopen, syscreate, sysmkdir etc. 
  3961                              <1> 		; Find Next File must immediate follow Find First File)
  3962                              <1> 
  3963 00012FE4 8825[E4960100]      <1> 		mov	[FFF_Valid], ah ; 0 ; reset ; 17/10/2016
  3964                              <1> 
  3965                              <1> set_working_path:
  3966                              <1> 		; 16/10/2016
  3967                              <1> 		; 12/10/2016
  3968                              <1> 		; 10/10/2016
  3969                              <1> 		; 05/10/2016 - TRDOS 386 (TRDOS v2.0)
  3970                              <1> 		;
  3971                              <1> 		; TRDOS v1.0 (DIR.ASM, "proc_set_working_path")
  3972                              <1>                 ; 27/01/2011 - 08/02/2011 
  3973                              <1> 		; Set/Changes current drive, directory and file
  3974                              <1> 		; depending on command tail
  3975                              <1> 		; (procedure is derivated from CMD_INTR.ASM 
  3976                              <1> 		; file or dir locating code of internal commands)
  3977                              <1> 		; (This procedure is prepared for INT 21H file/dir 
  3978                              <1> 		; functions and also to get compact code for 
  3979                              <1> 		; internal mainprog -command interpreter- commands)
  3980                              <1> 		; 
  3981                              <1> 		; INPUT: DS:SI -> Command tail (ASCIIZ string)
  3982                              <1> 		; AL = 0 -> any, AL > 0 -> file name is forced
  3983                              <1> 		; AH = CD -> Change directory permanently 
  3984                              <1> 		; AH <> CD -> Change directory as temporary    
  3985                              <1> 		; 
  3986                              <1> 		; OUTPUT: ES=DS, FindFile structure has been set
  3987                              <1> 		;        RUN_CDRV points previous current drive  
  3988                              <1> 		;        DS:SI = FindFile structure address
  3989                              <1> 		;        (DS=CS)       
  3990                              <1> 		;        AX, BX, CX, DX, DI will be changed
  3991                              <1> 		;   cf = 1 -> Error code in AX (AL)
  3992                              <1> 		;        stc & AX = 0 -> Bad command or path name 
  3993                              <1> 		; -----------------------------------------------
  3994                              <1> 		;
  3995                              <1> 		; TRDOS 386 (05/10/2016)
  3996                              <1> 		; INPUT:
  3997                              <1> 		;	ESI = File/Directory Path (ASCIIZ string)
  3998                              <1> 		;             address in user's memory space
  3999                              <1> 		;       AL = 0 -> any
  4000                              <1> 		;       AL > 0 -> file name is forced
  4001                              <1> 		;       AH = CD -> change directory as permanent
  4002                              <1> 		;       AH <> CD -> change directory as temporary
  4003                              <1> 		; 
  4004                              <1> 		; OUTPUT:
  4005                              <1> 		;	FindFile structure has been set
  4006                              <1> 		;       RUN_CDRV points previous current drive  
  4007                              <1> 		;       ESI = FindFile_Name address ; 12/10/2016
  4008                              <1> 		;
  4009                              <1> 		;       cf = 1 -> Error code in EAX (AL)
  4010                              <1> 		;       stc & EAX = 0 -> Bad command or path name
  4011                              <1> 		;  
  4012                              <1> 		; Modified registers: EAX, EBX, ECX, EDX, ESI, EDI
  4013                              <1> 
  4014 00012FEA 66A3[E8960100]      <1> 		mov	[SWP_Mode], ax
  4015 00012FF0 A0[F68A0100]        <1> 		mov	al, [Current_Drv]
  4016 00012FF5 30E4                <1> 		xor	ah, ah
  4017 00012FF7 66A3[EA960100]      <1> 		mov	[SWP_DRV], ax
  4018                              <1> 
  4019                              <1> 		; TRDOS 386 ring 3 (user's page directory)
  4020                              <1> 		; to ring 0 (kernel's page directory) 
  4021                              <1> 		; transfer modifications (05/10/2016).
  4022                              <1> 
  4023 00012FFD 55                  <1> 		push	ebp
  4024 00012FFE 89E5                <1> 		mov	ebp, esp
  4025                              <1> 		
  4026 00013000 B980000000          <1> 		mov	ecx, 128 ; maximum path length = 128 bytes
  4027 00013005 29CC                <1> 		sub	esp, ecx ; reserve 128 bytes (buffer) on stack
  4028 00013007 89E7                <1> 		mov	edi, esp ; destination address (kernel space)
  4029                              <1> 		; esi = source address (virtual, in user's memory space)
  4030 00013009 E8A0EBFFFF          <1> 		call	transfer_from_user_buffer
  4031 0001300E 720A                <1> 		jc	short loc_swp_xor_retn 
  4032                              <1> 		
  4033 00013010 89E6                <1> 		mov	esi, esp ; temporary buffer (the path) on stack
  4034                              <1> loc_swp_fchar:
  4035 00013012 8A06                <1> 		mov	al, [esi]
  4036 00013014 3C20                <1> 		cmp	al, 20h
  4037 00013016 7711                <1> 		ja	short loc_swp_parse_path_name
  4038 00013018 740C                <1> 		je	short loc_swp_fchar_next
  4039                              <1> 
  4040                              <1> loc_swp_xor_retn:
  4041 0001301A 31C0                <1> 		xor	eax, eax
  4042 0001301C F9                  <1> 		stc
  4043                              <1> loc_swp_retn:
  4044 0001301D 89EC                <1> 		mov	esp, ebp
  4045 0001301F 5D                  <1> 		pop	ebp
  4046                              <1> 
  4047                              <1> 		;mov	esi, FindFile_Drv
  4048 00013020 BE[D8930100]        <1> 		mov	esi, FindFile_Name ; 12/10/2016
  4049 00013025 C3                  <1> 		retn 
  4050                              <1> 
  4051                              <1> loc_swp_fchar_next:
  4052 00013026 46                  <1> 		inc	esi
  4053 00013027 EBE9                <1> 		jmp	short loc_swp_fchar  
  4054                              <1> 
  4055                              <1> loc_swp_parse_path_name:
  4056 00013029 BF[96930100]        <1> 		mov	edi, FindFile_Drv
  4057 0001302E E82F86FFFF          <1> 		call	parse_path_name
  4058 00013033 72E8                <1> 		jc	short loc_swp_retn
  4059                              <1> 
  4060                              <1> loc_swp_checkfile_name:
  4061 00013035 803D[E8960100]00    <1> 		cmp	byte [SWP_Mode], 0
  4062 0001303C 761E                <1> 		jna	short loc_swp_drv
  4063                              <1> 
  4064                              <1> 		; 10/10/2016 (valid file name checking)
  4065 0001303E BE[D8930100]        <1> 		mov	esi, FindFile_Name
  4066 00013043 803E20              <1> 		cmp	byte [esi], 20h
  4067 00013046 76D2                <1> 		jna	short loc_swp_xor_retn
  4068                              <1> 
  4069                              <1> 		; 16/10/2016
  4070 00013048 C605[E7960100]00    <1> 		mov	byte [SWP_inv_fname], 0 ; reset 
  4071                              <1> 		; esi = file name address (ASCIIZ)
  4072 0001304F E8FB67FFFF          <1> 		call	check_filename
  4073 00013054 7306                <1> 		jnc	short loc_swp_drv
  4074                              <1> 
  4075 00013056 FE05[E7960100]      <1> 		inc	byte [SWP_inv_fname] ; set 	
  4076                              <1> loc_swp_drv:
  4077 0001305C 8A35[F68A0100]      <1> 		mov	dh, [Current_Drv]
  4078                              <1>                ;mov	[RUN_CDRV], dh
  4079                              <1> 
  4080 00013062 8A15[96930100]      <1> 		mov	dl, [FindFile_Drv]
  4081                              <1>                ;cmp	dl, dh
  4082 00013068 3A15[F68A0100]      <1> 		cmp	dl, [Current_Drv]
  4083 0001306E 740D                <1> 		je	short loc_swp_change_directory
  4084                              <1> 
  4085 00013070 FE05[EB960100]      <1> 		inc	byte [SWP_DRV_chg]
  4086 00013076 E87350FFFF          <1> 		call	change_current_drive
  4087 0001307B 72A0                <1> 		jc	short loc_swp_retn ; eax = error code
  4088                              <1> 		; eax = 0
  4089                              <1> 
  4090                              <1> loc_swp_change_directory:
  4091 0001307D 803D[97930100]21    <1> 		cmp	byte [FindFile_Directory], 21h
  4092 00013084 F5                  <1> 		cmc
  4093 00013085 7396                <1> 		jnc	short loc_swp_retn
  4094                              <1> 
  4095 00013087 FE05[EB960100]      <1> 		inc	byte [SWP_DRV_chg]
  4096 0001308D FE05[C3400100]      <1> 		inc	byte [Restore_CDIR]
  4097 00013093 BE[97930100]        <1> 		mov	esi, FindFile_Directory
  4098 00013098 8A25[E9960100]      <1> 		mov	ah, [SWP_Mode+1] 
  4099 0001309E E8A97FFFFF          <1> 		call	change_current_directory
  4100 000130A3 0F8274FFFFFF        <1> 		jc	loc_swp_retn ; eax = error code
  4101                              <1> 
  4102                              <1> loc_swp_change_prompt_dir_string:
  4103                              <1> 		; esi = PATH_Array
  4104                              <1> 		; eax = Current Directory First Cluster
  4105                              <1> 		; edi = Logical DOS Drive Description Table	
  4106 000130A9 E8C37EFFFF          <1> 		call	change_prompt_dir_str 
  4107 000130AE 29C0                <1> 		sub	eax, eax ; 0
  4108 000130B0 E968FFFFFF          <1> 		jmp	loc_swp_retn 
  4109                              <1> 
  4110                              <1> reset_working_path:
  4111                              <1> 		; 06/10/2016 - TRDOS 386 (TRDOS v2.0)
  4112                              <1> 		;
  4113                              <1> 		; TRDOS v1.0 (DIR.ASM, "proc_reset_working_path")
  4114                              <1> 		; 05/02/2011 - 08/02/2011 
  4115                              <1> 		;
  4116                              <1> 		; Restores current drive and directory 
  4117                              <1> 		; 
  4118                              <1> 		; INPUT: none
  4119                              <1> 		; OUTPUT: DL = SWP_DRV, EAX = 0 -> OK
  4120                              <1> 		;
  4121                              <1> 		;    AX = 0 -> ESI = Logical Dos Drv Desc. Table
  4122                              <1> 		;
  4123                              <1> 		;    EAX, EBX, ECX, EDX, ESI, EDI will be changed
  4124                              <1> 		;
  4125                              <1> 
  4126                              <1>   
  4127 000130B5 31C0                <1> 		xor	eax, eax
  4128 000130B7 48                  <1> 		dec	eax 
  4129                              <1> 
  4130 000130B8 668B15[EA960100]    <1> 		mov	dx, [SWP_DRV]
  4131 000130BF 08F6                <1> 		or	dh, dh
  4132 000130C1 742E                <1> 		jz	short loc_rwp_return
  4133                              <1> 
  4134 000130C3 3A15[F68A0100]      <1> 		cmp	dl, [Current_Drv]
  4135 000130C9 7407                <1> 		je	short loc_rwp_restore_cdir
  4136                              <1> loc_rwp_restore_cdrv:
  4137 000130CB E81E50FFFF          <1> 		call	change_current_drive 
  4138 000130D0 EB10                <1> 		jmp	short loc_rwp_restore_ok
  4139                              <1> loc_rwp_restore_cdir:
  4140 000130D2 31DB                <1> 		xor	ebx, ebx
  4141 000130D4 88D7                <1> 		mov	bh, dl
  4142 000130D6 BE00010900          <1> 		mov	esi, Logical_DOSDisks
  4143 000130DB 01DE                <1> 		add	esi, ebx
  4144                              <1> 
  4145 000130DD E8C350FFFF          <1> 		call	restore_current_directory
  4146                              <1> 
  4147                              <1> loc_rwp_restore_ok:
  4148 000130E2 668B15[EA960100]    <1> 		mov	dx, [SWP_DRV]
  4149 000130E9 31C0                <1> 		xor	eax, eax  
  4150 000130EB 66A3[EB960100]      <1> 		mov	[SWP_DRV_chg], ax
  4151                              <1> loc_rwp_return:
  4152 000130F1 C3                  <1> 		retn
  4153                              <1> 
  4154                              <1> get_file_name:
  4155                              <1> 		; 15/10/2016 - TRDOS 386 (TRDOS v2.0)
  4156                              <1> 		; Convert file name 
  4157                              <1> 		;	from directory entry format
  4158                              <1>                 ; 	to (8.3) dot file name format 
  4159                              <1> 		;
  4160                              <1> 		; TRDOS v1.0 (DIR.ASM, "get_file_name")
  4161                              <1>                 ; 2005 - 09/10/2011 	
  4162                              <1> 		; INPUT: 
  4163                              <1> 		;	DS:SI -> Directory Entry Format File Name
  4164                              <1> 		;       ES:DI -> DOS Dot File Name Address
  4165                              <1> 		; OUTPUT:
  4166                              <1> 		;	DS:SI -> DOS Dot File Name Address
  4167                              <1>                 ;	ES:DI -> Directory Entry Format File Name
  4168                              <1> 		;	
  4169                              <1> 		; TRDOS 386 (15/10/2016)
  4170                              <1> 		; INPUT:
  4171                              <1> 		;	ESI = File name addr in dir entry format
  4172                              <1> 		;	EDI = Dot file name address (destination)
  4173                              <1> 		; OUTPUT: 
  4174                              <1> 		;	File name is converted and moved
  4175                              <1> 		;	to destination (as 8.3 dot filename)
  4176                              <1> 		;  
  4177                              <1> 		; Modified registers: EAX, ECX
  4178                              <1> 
  4179                              <1>                 ; 2005 (TRDOS 8086) - 2016 (TRDOS 386)
  4180                              <1>                             
  4181 000130F2 57                  <1> 		push	edi
  4182 000130F3 56                  <1> 		push	esi
  4183 000130F4 AC                  <1> 		lodsb
  4184 000130F5 3C20                <1> 		cmp	al, 20h
  4185 000130F7 762A                <1> 		jna	short pass_gfn_ext
  4186 000130F9 56                  <1> 		push	esi
  4187 000130FA AA                  <1> 		stosb
  4188 000130FB B907000000          <1> 		mov	ecx, 7
  4189                              <1> loc_gfn_next_char:
  4190 00013100 AC                  <1> 		lodsb
  4191 00013101 3C20                <1> 		cmp	al, 20h
  4192 00013103 7603                <1> 		jna	short pass_gfn_fn
  4193 00013105 AA                  <1> 		stosb
  4194 00013106 E2F8                <1> 		loop	loc_gfn_next_char
  4195                              <1> pass_gfn_fn:
  4196 00013108 5E                  <1> 		pop	esi
  4197 00013109 83C607              <1> 		add	esi, 7
  4198 0001310C AC                  <1> 		lodsb
  4199 0001310D 3C20                <1> 		cmp	al, 20h
  4200 0001310F 7612                <1> 		jna	short pass_gfn_ext
  4201 00013111 B42E                <1> 		mov	ah, '.'
  4202 00013113 86E0                <1> 		xchg	ah, al
  4203 00013115 66AB                <1> 		stosw
  4204 00013117 AC                  <1> 		lodsb
  4205 00013118 3C20                <1> 		cmp	al, 20h
  4206 0001311A 7607                <1> 		jna	short pass_gfn_ext
  4207 0001311C AA                  <1> 		stosb
  4208 0001311D AC                  <1> 		lodsb
  4209 0001311E 3C20                <1> 		cmp	al, 20h
  4210 00013120 7601                <1> 		jna	short pass_gfn_ext
  4211 00013122 AA                  <1> 		stosb
  4212                              <1> pass_gfn_ext:		
  4213 00013123 30C0                <1> 		xor	al, al
  4214 00013125 AA                  <1> 		stosb
  4215 00013126 5E                  <1> 		pop	esi
  4216 00013127 5F                  <1> 		pop	edi
  4217 00013128 C3                  <1> 		retn
  4218                              <1> 
  4219                              <1> set_hardware_int_vector:
  4220                              <1> 		; 18/03/2017
  4221                              <1> 		; 03/03/2017
  4222                              <1> 		; 28/02/2017 - TRDOS 386 (TRDOS v2.0)
  4223                              <1> 		;
  4224                              <1> 		; SET/RESET HARDWARE INTERRUPT GATE
  4225                              <1> 		;
  4226                              <1> 		; Changes interrupt gate descriptor table
  4227                              <1> 		; (without changing default interrupt list)
  4228                              <1> 		;
  4229                              <1> 		; INPUT:
  4230                              <1> 		;	AL = IRQ number (0 to 15)
  4231                              <1> 		;	AH > 0 -> set
  4232                              <1> 		;	AH = 0 -> reset
  4233                              <1> 		;	
  4234                              <1> 		; Modified registers: eax, ebx, edx, edi 
  4235                              <1> 		;
  4236                              <1> 		
  4237 00013129 C0E002              <1> 		shl	al, 2 ; IRQ number * 4
  4238 0001312C 0FB6D8              <1> 		movzx	ebx, al
  4239                              <1> 
  4240 0001312F 08E4                <1> 		or	ah, ah
  4241 00013131 7508                <1> 		jnz	short shintv_1 ; set (for user call service)
  4242                              <1> 		
  4243                              <1> 		; 18/03/2017
  4244 00013133 81C3[C04A0100]      <1> 		add	ebx, IRQ_list ; reset to default interrupt list
  4245 00013139 EB06                <1> 		jmp	short shintv_2
  4246                              <1> shintv_1:
  4247 0001313B 81C3[62310100]      <1> 		add	ebx, IRQ_u_list
  4248                              <1> shintv_2:	
  4249 00013141 8B13                <1> 		mov	edx, [ebx] ; IRQ handler address
  4250                              <1> 		
  4251                              <1> 		; 03/03/2017
  4252 00013143 D0E0                <1> 		shl	al, 1 ; IRQ number * 8 
  4253                              <1> 		; 18/03/2017
  4254 00013145 0FB6F8              <1> 		movzx	edi, al 
  4255 00013148 81C7[48880100]      <1> 		add	edi, idt + (8*32) ; IRQ 0 offset = idt + 256
  4256                              <1> 		
  4257 0001314E 89D0                <1> 		mov	eax, edx ; IRQ handler address
  4258 00013150 BB00000800          <1> 		mov	ebx, 80000h
  4259                              <1> 
  4260                              <1> 		;mov	edx, eax
  4261 00013155 66BA008E            <1> 		mov	dx, 8E00h
  4262 00013159 6689C3              <1> 		mov	bx, ax
  4263 0001315C 89D8                <1> 		mov	eax, ebx ; /* selector = 0x0008 = cs */
  4264                              <1>        			         ; /* interrupt gate - dpl=0, present */
  4265 0001315E AB                  <1> 		stosd	; selector & offset bits 0-15 	
  4266 0001315F 8917                <1> 		mov	[edi], edx ; attributes & offset bits 16-23
  4267                              <1> 
  4268 00013161 C3                  <1> 		retn
  4269                              <1> IRQ_u_list:
  4270                              <1> 		; 28/02/2017
  4271 00013162 [5E090000]          <1> 		dd	timer_int
  4272 00013166 [D6100000]          <1> 		dd	kb_int
  4273 0001316A [400B0000]          <1> 		dd	irq2
  4274 0001316E [A2310100]          <1> 		dd	IRQ_service3
  4275 00013172 [AC310100]          <1> 		dd	IRQ_service4
  4276 00013176 [B6310100]          <1> 		dd	IRQ_service5
  4277 0001317A [DB510000]          <1> 		dd	fdc_int	
  4278 0001317E [C0310100]          <1> 		dd	IRQ_service7
  4279 00013182 [C90A0000]          <1> 		dd	rtc_int
  4280 00013186 [CA310100]          <1> 		dd	IRQ_service9
  4281 0001318A [D4310100]          <1> 		dd	IRQ_service10
  4282 0001318E [DE310100]          <1> 		dd	IRQ_service11
  4283 00013192 [E8310100]          <1> 		dd	IRQ_service12
  4284 00013196 [F2310100]          <1> 		dd	IRQ_service13
  4285 0001319A [8E5B0000]          <1> 		dd	hdc1_int
  4286 0001319E [B55B0000]          <1> 		dd	hdc2_int
  4287                              <1> 
  4288                              <1> 		; 03/03/2017
  4289                              <1> 		; 27/02/2017
  4290                              <1> IRQ_service3:
  4291 000131A2 36C605[AE9C0100]03  <1> 		mov	byte [ss:IRQnum], 3
  4292 000131AA EB4E                <1> 		jmp	short IRQ_service
  4293                              <1> IRQ_service4:
  4294 000131AC 36C605[AE9C0100]04  <1> 		mov	byte [ss:IRQnum], 4
  4295 000131B4 EB44                <1> 		jmp	short IRQ_service
  4296                              <1> IRQ_service5:
  4297 000131B6 36C605[AE9C0100]05  <1> 		mov	byte [ss:IRQnum], 5
  4298 000131BE EB3A                <1> 		jmp	short IRQ_service
  4299                              <1> IRQ_service7:
  4300 000131C0 36C605[AE9C0100]07  <1> 		mov	byte [ss:IRQnum], 7
  4301 000131C8 EB30                <1> 		jmp	short IRQ_service
  4302                              <1> IRQ_service9:
  4303 000131CA 36C605[AE9C0100]09  <1> 		mov	byte [ss:IRQnum], 9
  4304 000131D2 EB26                <1> 		jmp	short IRQ_service
  4305                              <1> IRQ_service10:
  4306 000131D4 36C605[AE9C0100]0A  <1> 		mov	byte [ss:IRQnum], 10
  4307 000131DC EB1C                <1> 		jmp	short IRQ_service
  4308                              <1> IRQ_service11:
  4309 000131DE 36C605[AE9C0100]0B  <1> 		mov	byte [ss:IRQnum], 11
  4310 000131E6 EB12                <1> 		jmp	short IRQ_service
  4311                              <1> IRQ_service12:
  4312 000131E8 36C605[AE9C0100]0C  <1> 		mov	byte [ss:IRQnum], 12
  4313 000131F0 EB08                <1> 		jmp	short IRQ_service
  4314                              <1> IRQ_service13:
  4315 000131F2 36C605[AE9C0100]0D  <1> 		mov	byte [ss:IRQnum], 13
  4316                              <1> 		;jmp	short IRQ_service
  4317                              <1> IRQ_service:
  4318                              <1> 		; 13/06/2017
  4319                              <1> 		; 11/06/2017
  4320                              <1> 		; 10/06/2017
  4321                              <1> 		; 01/03/2017, 04/03/2017
  4322                              <1> 		; 27/02/2017, 28/02/2017
  4323 000131FA 1E                  <1> 		push	ds
  4324 000131FB 06                  <1> 		push	es
  4325 000131FC 0FA0                <1> 		push	fs
  4326 000131FE 0FA8                <1> 		push	gs
  4327                              <1> 
  4328 00013200 60                  <1> 		pushad	; eax,ecx,edx,ebx,esp,ebp,esi,edi
  4329 00013201 66B91000            <1> 		mov     cx, KDATA
  4330 00013205 8ED9                <1>         	mov     ds, cx
  4331 00013207 8EC1                <1>         	mov     es, cx
  4332 00013209 8EE1                <1>         	mov     fs, cx
  4333 0001320B 8EE9                <1>         	mov     gs, cx
  4334                              <1> 
  4335 0001320D 0F20D8              <1> 		mov	eax, cr3
  4336 00013210 A3[AA9C0100]        <1> 		mov	[IRQ_cr3], eax
  4337                              <1> 
  4338 00013215 A1[308A0100]        <1> 		mov	eax, [k_page_dir]
  4339 0001321A 0F22D8              <1> 		mov	cr3, eax 
  4340                              <1> 
  4341 0001321D A0[AE9C0100]        <1> 		mov	al, [IRQnum]
  4342                              <1> 
  4343                              <1> 		;mov	cl, [sysflg]
  4344                              <1> 		;mov	[u.r_mode], cl  ; system (0) or user mode (FFh) 
  4345                              <1> IRQsrv_0:
  4346 00013222 0FB6D8              <1> 		movzx	ebx, al
  4347 00013225 8A9B[F8490100]      <1> 		mov	bl, [ebx+IRQenum] ; IRQ (available) index number + 1
  4348                              <1> 		; 01/03/2017
  4349 0001322B FECB                <1> 		dec	bl  ; IRQ index number, 0 to 8
  4350 0001322D 0F8807010000        <1> 		js	IRQsrv_5 ; not available to use here!?
  4351                              <1> 		;		 
  4352 00013233 80BB[749C0100]80    <1> 		cmp	byte [ebx+IRQ.method], 80h ; using by a dev or kernel? 
  4353 0001323A 7205                <1> 		jb	short IRQsrv_1 ; no
  4354                              <1> 
  4355                              <1> 		; If the IRQ service is already owned by TRDOS 386 kernel
  4356                              <1> 		;	 or a Device driver
  4357                              <1> 		; we need to call 'dev_IRQ_service'
  4358                              <1> 
  4359                              <1> 		; IRQ number in AL
  4360 0001323C E866020000          <1> 		call	dev_IRQ_service	 ; IRQ service for device drivers	
  4361                              <1> 		; IRQ number in AL
  4362                              <1> IRQsrv_1:		
  4363                              <1> 		; check user callback service status
  4364                              <1> 		; AL = IRQ number
  4365                              <1> 		; EBX = IRQ (Available) Index number
  4366                              <1> 
  4367 00013241 A2[D7030300]        <1> 		mov	[u.irqwait], al ; set waiting IRQ flag
  4368                              <1> 
  4369 00013246 8A83[629C0100]      <1> 		mov	al, [ebx+IRQ.owner]
  4370 0001324C 20C0                <1> 		and	al, al
  4371 0001324E 0F84E6000000        <1> 		jz	IRQsrv_5 ; it is not owned by a user/proc
  4372                              <1> 
  4373                              <1> 		; 03/03/2017
  4374 00013254 89DA                <1> 		mov	edx, ebx
  4375 00013256 C0E202              <1> 		shl	dl, 2
  4376 00013259 8B92[869C0100]      <1> 		mov	edx, [edx+IRQ.addr] ; S.R.B. or Callback service addr
  4377                              <1> 		
  4378 0001325F 8AA3[749C0100]      <1> 		mov	ah, [ebx+IRQ.method]
  4379 00013265 F6C401              <1> 		test	ah, 1
  4380 00013268 7534                <1> 		jnz	short IRQsrv_4 ; Callback service method
  4381                              <1> 
  4382                              <1> 		; Signal Response Byte method
  4383                              <1> 		;mov	edx, [edx+IRQ.addr] ; Signal Response Byte address
  4384                              <1> 		;			    ; (Physical address, non-swappable) 	
  4385 0001326A 80E402              <1> 		and	ah, 2 ; bit 1, (S.R.B.) counter (auto increment) method
  4386 0001326D 8AA3[7D9C0100]      <1> 		mov	ah, [ebx+IRQ.srb] ; Signal Response Byte value
  4387 00013273 7408                <1> 		jz	short IRQsrv_2 ; fixed S.R.B. value
  4388                              <1> 		; counter method (auto increment)
  4389 00013275 FEC4                <1> 		inc	ah
  4390 00013277 88A3[7D9C0100]      <1> 		mov	[ebx+IRQ.srb], ah ; next (count) number
  4391                              <1> IRQsrv_2:
  4392 0001327D 8822                <1> 		mov	[edx], ah ; put S.R.B. val to the user's S.R.B. addr
  4393 0001327F C605[D7030300]00    <1> 		mov	byte [u.irqwait], 0 ; clear waiting IRQ flag
  4394                              <1> 
  4395 00013286 3A05[B3030300]      <1> 		cmp	al, [u.uno]
  4396 0001328C 0F84A8000000        <1> 		je	IRQsrv_5 ; the owner is current user/process
  4397                              <1> IRQsrv_3:
  4398                              <1> 		; the owner is not current user/process
  4399                              <1> 		; AL = process number
  4400 00013292 B202                <1> 		mov	dl, 2 ; priority, 2 = event (high)	
  4401 00013294 E837FAFFFF          <1> 		call	set_run_sequence
  4402                              <1> 
  4403                              <1> 		; [u.irqwait] = waiting IRQ number for callback service
  4404                              <1> 
  4405 00013299 E99C000000          <1> 		jmp	IRQsrv_5
  4406                              <1> IRQsrv_4:
  4407 0001329E 3A05[B3030300]      <1> 		cmp	al, [u.uno]  ; is the owner is current user/process?
  4408 000132A4 75EC                <1> 		jne	short IRQsrv_3 ; no !
  4409                              <1> 
  4410                              <1> 		; Check if an IRQ callback service already in progress
  4411 000132A6 803D[D8030300]00    <1> 		cmp	byte [u.r_lock], 0
  4412 000132AD 0F8787000000        <1> 		ja	IRQsrv_5 ; nothing to do !  
  4413                              <1> 				     ; (we need to complete prev callback)
  4414 000132B3 803D[D4030300]00    <1> 		cmp	byte [u.t_lock], 0
  4415 000132BA 777E                <1> 		ja	short IRQsrv_5 ; nothing to do !  
  4416                              <1> 				     ; (we need to complete timer callback)
  4417                              <1> 
  4418                              <1> 		; 04/03/2017
  4419 000132BC C605[D7030300]00    <1> 		mov	byte [u.irqwait], 0 ; reset/clear waiting IRQ flag
  4420                              <1> 
  4421 000132C3 FE05[D8030300]      <1> 		inc	byte [u.r_lock] ; 'IRQ callback service in progress' flag
  4422                              <1> 
  4423 000132C9 8A0D[5B030300]      <1> 		mov	cl, [sysflg]   ; (system call) mode flag (kernel/user)
  4424 000132CF 880D[D9030300]      <1> 		mov	[u.r_mode], cl ; system mode (0) or user mode (FFh)
  4425                              <1> 
  4426                              <1> 		; 
  4427 000132D5 8B2D[CC890100]      <1> 		mov	ebp, [tss.esp0] ; kernel stack address (for ring 0)
  4428 000132DB 83ED14              <1> 		sub	ebp, 20		; eip, cs, eflags, esp, ss
  4429 000132DE 892D[5C030300]      <1> 	 	mov	[u.sp], ebp
  4430 000132E4 8925[60030300]      <1> 		mov	[u.usp], esp
  4431                              <1> 
  4432                              <1> 		;or	word [ebp+8], 200h ; 22/01/2017, force enabling interrupts
  4433                              <1> 
  4434 000132EA 8B44241C            <1> 		mov	eax, [esp+28] ; pushed eax
  4435 000132EE A3[64030300]        <1> 		mov	[u.r0], eax
  4436                              <1> 
  4437 000132F3 E820E7FFFF          <1> 		call	wswap ; save user's registers & status
  4438                              <1> 
  4439                              <1> 		; software int is in ring 0 but IRQ handler must return to ring 3
  4440                              <1> 		; so, ring 3 return address and stack registers
  4441                              <1> 		; (eip, cs, eflags, esp, ss) 
  4442                              <1> 		; must be copied to IRQ handler return
  4443                              <1> 		; eip will be replaced by callback service routine address
  4444                              <1> 
  4445 000132F8 C605[5B030300]FF    <1> 		mov	byte [sysflg], 0FFh ; user mode
  4446                              <1> 
  4447                              <1> 		; system mode (system call)
  4448                              <1> 		;mov	ebp, [u.sp] ; EIP (u), CS (UCODE), EFLAGS (u),
  4449                              <1> 				    ; ESP (u), SS (UDATA)
  4450                              <1> 
  4451 000132FF 8B4510              <1> 		mov	eax, [ebp+16]	; SS (UDATA)
  4452 00013302 89E6                <1> 		mov	esi, esp
  4453 00013304 50                  <1> 		push	eax
  4454 00013305 50                  <1> 		push	eax
  4455 00013306 89E7                <1> 		mov	edi, esp
  4456 00013308 893D[60030300]      <1> 		mov	[u.usp], edi
  4457 0001330E B908000000          <1> 		mov	ecx, ((ESPACE/4) - 4) ; except DS, ES, FS, GS
  4458 00013313 F3A5                <1> 		rep	movsd
  4459 00013315 B104                <1> 		mov	cl, 4	
  4460 00013317 F3AB                <1> 		rep	stosd
  4461 00013319 893D[5C030300]      <1> 		mov	[u.sp], edi
  4462 0001331F 89EE                <1> 		mov	esi, ebp
  4463 00013321 B105                <1> 		mov	cl, 5 ; EIP (u), CS (UCODE), EFLAGS (u), ESP (u), SS (UDATA)
  4464 00013323 F3A5                <1> 		rep	movsd
  4465                              <1> 		;
  4466                              <1> 
  4467 00013325 8B0D[B8030300]      <1> 		mov	ecx, [u.pgdir]
  4468 0001332B 890D[AA9C0100]      <1> 		mov	[IRQ_cr3], ecx
  4469                              <1> 
  4470                              <1> set_IRQ_callback_addr:
  4471                              <1> 		;
  4472                              <1> 		; This routine sets return address
  4473                              <1> 		; to start of user's interrupt
  4474                              <1> 		; service (callback) address
  4475                              <1> 		;
  4476                              <1> 		; INPUT:
  4477                              <1> 		;	EDX = callback routine/service address
  4478                              <1> 		;	      (virtual, not physical address!)	
  4479                              <1> 		;	[u.sp] = kernel stack, points to
  4480                              <1> 		;		 user's EIP,CS,EFLAGS,ESP,SS
  4481                              <1> 		;		 registers.
  4482                              <1> 		; OUTPUT:
  4483                              <1> 		;	EIP (user) = callback (service) address
  4484                              <1> 		;	CS (user) = UCODE
  4485                              <1> 		;	EFLAGS (user) = flags before callback 	 
  4486                              <1> 		;       ESP (user) = ESP-4 (user, before callback) 
  4487                              <1> 		;	[ESP](user) = EIP (user) before callback
  4488                              <1> 		;
  4489                              <1> 		; Note: If CPU was in user mode while entering 
  4490                              <1> 		;	the timer interrupt service routine,
  4491                              <1> 		;	'IRET' will get return to callback routine
  4492                              <1> 		;	immediately. If CPU was in system/kernel mode  
  4493                              <1> 		;	'iret' will get return to system call and
  4494                              <1> 		;	then, callback routine will be return address
  4495                              <1> 		;	from system call. (User's callback/service code
  4496                              <1> 		;	will be able to return to normal return address
  4497                              <1> 		;	via a 'sysrele' system call at the end.) 
  4498                              <1> 		;
  4499                              <1> 		; Note: User's IRQ callback service code must be ended
  4500                              <1> 		;	with a 'sysrele' system call !
  4501                              <1> 		;
  4502                              <1> 		;	For example:
  4503                              <1> 		;
  4504                              <1> 		;	audio_IRQ_callback:
  4505                              <1> 		;	    ...	 
  4506                              <1> 		;	    <load DMA buffer with audio data>
  4507                              <1> 		;	    ...
  4508                              <1> 		;	    mov eax, 39 ; 'sysrele'
  4509                              <1> 		;	    int 40h ; TRDOS 386 system call (interrupt)		
  4510                              <1> 		;
  4511                              <1> 		
  4512                              <1> 		;mov	edx, [edx+IRQ.addr] ; Callback service address
  4513                              <1> 		;			    ; (Virtual address)
  4514                              <1> 		
  4515 00013331 8B2D[5C030300]      <1> 		mov	ebp, [u.sp]; kernel's stack, points to EIP (user)
  4516 00013337 895500              <1> 		mov	[ebp], edx
  4517                              <1> IRQsrv_5:
  4518                              <1> 		; EOI & return
  4519                              <1> 		; 01/08/2020
  4520                              <1> 		; 11/06/2017
  4521                              <1> 		; 10/06/2017 
  4522                              <1> 		;mov	al, [IRQnum]
  4523 0001333A B020                <1> 		mov	al, 20h ; 01/08/2020
  4524 0001333C FA                  <1> 		cli
  4525                              <1> 		;cmp	al, 7
  4526 0001333D 803D[AE9C0100]07    <1> 		cmp	byte [IRQnum], 7 ; 01/08/2020	
  4527 00013344 7602                <1> 		jna	short IRQsrv_6
  4528                              <1> 		;
  4529                              <1> 		;;mov	al, EOI	; end of interrupt
  4530                              <1> 		;mov	al, 20h ; 01/08/2020
  4531                              <1> 		;cli		; disable interrupts till stack cleared
  4532                              <1> 		;out	INTB00, al ; For controll2 #2
  4533 00013346 E6A0                <1> 		out	0A0h, al
  4534                              <1> IRQsrv_6:
  4535                              <1> 		;mov	byte [IRQnum], 0 ; reset
  4536                              <1> 		;;mov	al, EOI	; end of interrupt
  4537                              <1> 		;mov	al, 20h ; 01/08/2020
  4538                              <1> 		;cli		; disable interrupts till stack cleared
  4539                              <1> 		;out	INTA00, al ; end of interrupt to 8259 - 1
  4540 00013348 E620                <1> 		out	20h, al	
  4541                              <1> IRQsrv_7:	
  4542                              <1> 		;; 13/06/2017
  4543                              <1> 		;or	word [ebp+8], 200h ; force enabling interrupts
  4544                              <1> 		;
  4545 0001334A 8B0D[AA9C0100]      <1> 		mov 	ecx, [IRQ_cr3]	; previous content of cr3 register
  4546 00013350 0F22D9              <1>  		mov	cr3, ecx	; restore cr3 register content
  4547                              <1> 		;
  4548 00013353 61                  <1> 		popad ; edi,esi,ebp,(icrement esp by 4),ebx,edx,ecx,eax
  4549                              <1> 		;
  4550 00013354 0FA9                <1> 		pop	gs
  4551 00013356 0FA1                <1> 		pop	fs
  4552 00013358 07                  <1> 		pop	es
  4553 00013359 1F                  <1> 		pop	ds
  4554                              <1> 		;
  4555 0001335A CF                  <1> 		iretd	; return from interrupt
  4556                              <1> 
  4557                              <1> get_device_number:
  4558                              <1> 		; 08/10/2016
  4559                              <1> 		; 07/10/2016 - TRDOS 386 (TRDOS v2.0)
  4560                              <1> 		;
  4561                              <1> 		; This procedure compares name of requested
  4562                              <1> 		; device with kernel device names and
  4563                              <1> 		; installable device names. If names match, 
  4564                              <1> 		; the relevant device index (entry) number 
  4565                              <1> 		; will be returned the caller (sysopen) 
  4566                              <1> 		; for the requested device.
  4567                              <1> 		;
  4568                              <1> 		; NOTE: Installable device drivers must
  4569                              <1> 		; be loaded before using 'sysopen'
  4570                              <1> 		; (opendev) system call.
  4571                              <1> 		;
  4572                              <1> 		; INPUT:
  4573                              <1> 		;    ESI = device name address (ASCIIZ)
  4574                              <1> 		;         (in kernel's memory space)  
  4575                              <1>    		;    max name length = 8 without '/dev/')
  4576                              <1> 		;    Device name will be capitalized 
  4577                              <1> 		;    and if there is, '/dev/' will be
  4578                              <1> 		;    removed from name before comparising)
  4579                              <1> 		;
  4580                              <1> 		; OUTPUT:
  4581                              <1> 		;    cf = 0 -> 
  4582                              <1> 		;      EAX (AL) = device entry/index number 	 	
  4583                              <1> 		;    cf = 1 -> device not found (installed)
  4584                              <1> 		;	       or invalid device name
  4585                              <1> 		;	       (AL=0)
  4586                              <1> 		;    device_name = device name address (asciiz)
  4587                              <1> 			;
  4588                              <1> 		; Modified registers: EAX, EBX, ESI, EDI
  4589                              <1> 
  4590 0001335B BF[ED960100]        <1> 		mov	edi, device_name
  4591 00013360 E805010000          <1> 		call 	lodsb_capitalize
  4592 00013365 88C4                <1> 		mov	ah, al
  4593 00013367 3C2F                <1> 		cmp	al, '/'
  4594 00013369 750E                <1> 		jne	short gdn_1
  4595 0001336B BF[ED960100]        <1> 		mov	edi, device_name
  4596 00013370 E8F5000000          <1> 		call 	lodsb_capitalize
  4597                              <1> gdn_0:
  4598 00013375 20C0                <1> 		and	al, al ; 0 ?
  4599 00013377 7420                <1> 		jz	short gdn_err ; null name after '/'
  4600                              <1> gdn_1:
  4601 00013379 3C44                <1> 		cmp	al, 'D'
  4602 0001337B 7517                <1> 		jne	short gdn_2
  4603 0001337D E8E8000000          <1> 		call 	lodsb_capitalize
  4604 00013382 3C45                <1> 		cmp	al, 'E'
  4605 00013384 750E                <1> 		jne	short gdn_2
  4606 00013386 E8DF000000          <1> 		call 	lodsb_capitalize
  4607 0001338B 3C56                <1> 		cmp	al, 'V'
  4608 0001338D 7505                <1> 		jne	short gdn_2			
  4609 0001338F AC                  <1> 		lodsb
  4610 00013390 3C2F                <1> 		cmp	al, '/'
  4611 00013392 740D                <1> 		je	short gdn_4
  4612                              <1> gdn_2:
  4613 00013394 80FC2F              <1> 		cmp	ah, '/'
  4614 00013397 750F                <1> 		jne	short gdn_5
  4615                              <1> gdn_err:		
  4616                              <1> 		; invalid device name or device not found
  4617 00013399 31C0                <1> 		xor	eax, eax ; 0
  4618 0001339B F9                  <1> 		stc
  4619 0001339C C3                  <1> 		retn
  4620                              <1> gdn_3:
  4621 0001339D 3C2F                <1> 		cmp	al, '/'
  4622 0001339F 7507                <1> 		jne	short gdn_5
  4623                              <1> gdn_4:
  4624 000133A1 BF[ED960100]        <1> 		mov	edi, device_name
  4625 000133A6 EB04                <1> 		jmp	short gdn_6
  4626                              <1> gdn_5:
  4627 000133A8 3C00                <1> 		cmp	al, 0
  4628 000133AA 7419                <1> 		je	short gdn_7
  4629                              <1> gdn_6:
  4630 000133AC E8B9000000          <1> 		call lodsb_capitalize
  4631 000133B1 81FF[F5960100]      <1> 		cmp	edi, device_name + 8
  4632 000133B7 72E4                <1> 		jb	short gdn_3
  4633 000133B9 3C00                <1> 		cmp	al, 0
  4634 000133BB 75DC                <1> 		jne	short gdn_err
  4635 000133BD 81FF[EE960100]      <1> 		cmp	edi, device_name + 1
  4636 000133C3 76D4                <1> 		jna	short gdn_err ; null name after '/'
  4637                              <1> gdn_7:
  4638 000133C5 AA                  <1> 		stosb
  4639                              <1> 		; zero padding ("NAME",0,0,0,0)
  4640 000133C6 81FF[F5960100]      <1> 		cmp	edi, device_name + 8
  4641 000133CC 72F7                <1> 		jb	short gdn_7
  4642                              <1> gdn_8:
  4643                              <1> 		; search for kernel device names
  4644 000133CE BE[ED960100]        <1> 		mov	esi, device_name 
  4645 000133D3 BF[DE470100]        <1> 		mov	edi, KDEV_NAME
  4646 000133D8 31C0                <1> 		xor	eax, eax
  4647                              <1> gdn_9:
  4648 000133DA A7                  <1> 		cmpsd	
  4649 000133DB 7505                <1> 		jne	short gdn_10
  4650 000133DD A7                  <1> 		cmpsd
  4651 000133DE 7503                <1> 		jne	short gdn_11
  4652 000133E0 EB2B                <1> 		jmp	short gdn_17 ; match
  4653                              <1> gdn_10:
  4654 000133E2 A7                  <1> 		cmpsd  ; add esi, 4 & add edi, 4
  4655                              <1> gdn_11:
  4656 000133E3 BE[ED960100]        <1> 		mov	esi, device_name
  4657 000133E8 FEC0                <1> 		inc	al
  4658 000133EA 3C16                <1> 		cmp	al, NumOfKernelDevNames
  4659 000133EC 72EC                <1> 		jb	short gdn_9
  4660                              <1> gdn_12:
  4661                              <1> 		; search for installable device names
  4662                              <1> 		; esi = offset device_name 
  4663 000133EE BF[18970100]        <1> 		mov	edi, IDEV_NAME
  4664 000133F3 28C0                <1> 		sub	al, al ; 0
  4665                              <1> gdn_13:
  4666 000133F5 A7                  <1> 		cmpsd	
  4667 000133F6 7505                <1> 		jne	short gdn_14
  4668 000133F8 A7                  <1> 		cmpsd
  4669 000133F9 7503                <1> 		jne	short gdn_15
  4670 000133FB EB3F                <1> 		jmp	short gdn_19 ; match
  4671                              <1> gdn_14:
  4672 000133FD A7                  <1> 		cmpsd  ; add esi, 4 & add edi, 4
  4673                              <1> gdn_15:
  4674 000133FE BE[ED960100]        <1> 		mov	esi, device_name
  4675 00013403 FEC0                <1> 		inc	al
  4676 00013405 3C08                <1> 		cmp	al, NumOfInstallableDevices
  4677 00013407 72EC                <1> 		jb	short gdn_13
  4678                              <1> 
  4679                              <1> gdn_16: 	; error: invalid device name (not found) !
  4680 00013409 30C0                <1> 		xor	al, al
  4681 0001340B F9                  <1> 		stc
  4682 0001340C C3                  <1> 		retn
  4683                              <1> 
  4684                              <1> gdn_17:		; name match (with one of kernel device names)
  4685                              <1> 		;
  4686                              <1> 		; convert KDEV_NAME index to 
  4687                              <1> 		; KDEV_NUMBER index
  4688                              <1> 		; (different names are used for same devices)
  4689                              <1> 		; (example: "COM1" & "TTY8" = device number 18) 
  4690 0001340D 89C3                <1> 		mov	ebx, eax ; < 256
  4691 0001340F 8A83[8E480100]      <1> 		mov	al, [KDEV_NUMBER+ebx]
  4692                              <1> 
  4693                              <1> 		; check if empty dev entry in the list
  4694 00013415 80B8[9C980100]00    <1> 		cmp	byte [DEV_OPENMODE+eax], 0
  4695 0001341C 771B                <1> 		ja	short gdn_18 ; it must be already set
  4696                              <1> 
  4697                              <1> 		; (re)set device name and access flags
  4698                              <1> 		; (remain open work will be easy after that)
  4699                              <1> 		; (NOTE: here, data will be copied to bss section)
  4700 0001341E 88C3                <1> 		mov	bl, al
  4701 00013420 83EF08              <1> 		sub	edi, 8 ; kernel device name address (data)
  4702 00013423 66C1E302            <1> 		shl	bx, 2 
  4703 00013427 89BB[BA980100]      <1> 		mov	[DEV_NAME_PTR+ebx], edi ; (all) device names
  4704 0001342D 8A98[E4490100]      <1> 		mov	bl, [KDEV_ACCESS+eax] ; kernel dev list (data)
  4705 00013433 8898[E8970100]      <1> 		mov	[DEV_ACCESS+eax], bl ; (all) device list (bss)
  4706                              <1> gdn_18:
  4707 00013439 FEC0                <1> 		inc	al ; 1 to NumOfKernelDevNames (<=7Fh)
  4708                              <1> 		; eax = device index/entry number
  4709 0001343B C3                  <1> 		retn		
  4710                              <1> 
  4711                              <1> gdn_19:		; name match (with one of installable device names)
  4712                              <1> 		;
  4713                              <1> 		; al = 0 to NumOfInstallableDevices - 1 (<=7Fh)
  4714                              <1> 
  4715 0001343C 89C3                <1> 		mov	ebx, eax
  4716 0001343E 80C316              <1> 		add	bl, NumOfKernelDevices 	; < NUMOFDEVICES	
  4717                              <1> 
  4718                              <1> 		; check if empty dev entry in the list
  4719 00013441 80BB[9C980100]00    <1> 		cmp	byte [DEV_OPENMODE+ebx], 0
  4720 00013448 771D                <1> 		ja	short gdn_20 ; it must be already set
  4721                              <1> 
  4722                              <1> 		; (re)set device name and access flags
  4723                              <1> 		; (remain open work will be easy after that)
  4724 0001344A 83EF08              <1> 		sub	edi, 8 ; installable device name address
  4725 0001344D 66C1E302            <1> 		shl	bx, 2 ;*4
  4726 00013451 89BB[BA980100]      <1> 		mov	[DEV_NAME_PTR+ebx], edi ; (all) device names
  4727 00013457 66C1EB02            <1> 		shr	bx, 2
  4728 0001345B 8A80[60970100]      <1> 		mov	al, [IDEV_FLAGS+eax] ; installable dev list
  4729 00013461 8883[E8970100]      <1> 		mov	[DEV_ACCESS+ebx], al ; (all) device list
  4730                              <1> gdn_20:	
  4731 00013467 88D8                <1> 		mov	al, bl
  4732                              <1> 		; eax = device index/entry number ; < NUMOFDEVICES  
  4733 00013469 C3                  <1> 		retn
  4734                              <1> 
  4735                              <1> lodsb_capitalize:
  4736                              <1> 	; 07/10/2016 - TRDOS 386 (TRDOS v2.0)
  4737                              <1> 	; INPUT -> [esi] = character
  4738                              <1> 	;          edi = destination
  4739                              <1> 	; OUTPUT -> AL contains capitalized character
  4740                              <1> 	;	   esi = esi+1
  4741                              <1> 	;	   edi = edi+1	
  4742                              <1> 	; 
  4743 0001346A AC                  <1> 	lodsb	
  4744 0001346B 3C61                <1> 	cmp al, 61h
  4745 0001346D 7206                <1>      	jb  short lodsb_cap_retn
  4746 0001346F 3C7A                <1>      	cmp al, 7Ah
  4747 00013471 7702                <1>      	ja  short lodsb_cap_retn
  4748 00013473 24DF                <1>      	and al, 0DFh
  4749                              <1> lodsb_cap_retn:
  4750 00013475 AA                  <1> 	stosb
  4751 00013476 C3                  <1> 	retn
  4752                              <1> 
  4753                              <1> device_open:
  4754                              <1> 	; 08/10/2016 - TRDOS 386 (TRDOS v2.0)
  4755                              <1> 	; Complete device opening work for sysopen (device)
  4756                              <1> 	;
  4757                              <1> 	; INPUT -> 
  4758                              <1> 	;	EAX = Device Number (AL)
  4759                              <1> 	;        CL = Open mode (1 = read, 2 = write)
  4760                              <1> 	;	 CH = Device access byte (bit 0 = 0)		
  4761                              <1> 	; OUTPUT ->
  4762                              <1> 	;	EAX = Device Number	
  4763                              <1> 	;	CF = 0 -> device has been opened
  4764                              <1> 	;	CF = 1 -> device could not be opened
  4765                              <1> 	;
  4766                              <1> 	;  Modified registers: ebx, (edx, ecx, esi, edi, ebp)
  4767                              <1> 	;
  4768                              <1> 
  4769 00013477 89C3                <1> 	mov	ebx, eax
  4770 00013479 66C1E302            <1> 	shl	bx, 2 ; *4
  4771                              <1> 
  4772 0001347D F6C580              <1> 	test	ch, 80h ; bit 7, installable device driver flag
  4773 00013480 7406                <1> 	jz	short d_open_2 ; Kernel device
  4774                              <1> 	; installable device
  4775                              <1> d_open_1:
  4776 00013482 FFA3[64970100]      <1>         jmp	dword [ebx+IDEV_OADDR-4]
  4777                              <1> d_open_2:
  4778 00013488 FFA3[A0480100]      <1> 	jmp	dword [ebx+KDEV_OADDR-4]
  4779                              <1> 
  4780                              <1> device_close:
  4781                              <1> 	; 08/10/2016 - TRDOS 386 (TRDOS v2.0)
  4782                              <1> 	; Complete device closing work for sysclose (device)
  4783                              <1> 	;
  4784                              <1> 	; INPUT -> 
  4785                              <1> 	;	EAX = Device Number (AL)
  4786                              <1> 	;        CL = Open mode (1 = read, 2 = write)
  4787                              <1> 	;	 CH = Device access byte (bit 0 = 0)		
  4788                              <1> 	; OUTPUT ->
  4789                              <1> 	;	EAX = Device Number	
  4790                              <1> 	;	CF = 0 -> device has been closed
  4791                              <1> 	;	CF = 1 -> device could not be closed
  4792                              <1> 	;
  4793                              <1> 	; Modified registers: ebx, (edx, ecx, esi, edi, ebp)
  4794                              <1> 	;
  4795                              <1> 
  4796 0001348E 89C3                <1> 	mov	ebx, eax
  4797 00013490 66C1E302            <1> 	shl	bx, 2 ; *4
  4798                              <1> 
  4799 00013494 F6C580              <1> 	test	ch, 80h ; bit 7, installable device driver flag
  4800 00013497 7406                <1> 	jz	short d_close_2 ; Kernel device
  4801                              <1> 	; installable device
  4802                              <1> d_close_1:
  4803 00013499 FFA3[84970100]      <1>         jmp	dword [ebx+IDEV_CADDR-4]
  4804                              <1> d_close_2:
  4805 0001349F FFA3[F0480100]      <1> 	jmp	dword [ebx+KDEV_CADDR-4]	
  4806                              <1> 
  4807                              <1> rnull:
  4808                              <1> 	; 07/10/2016 - TRDOS 386 (TRDOS v2.0)
  4809                              <1> 	; read null (read from null device)
  4810 000134A5 C3                  <1> 	retn
  4811                              <1> 
  4812                              <1> wnull:
  4813                              <1> 	; 07/10/2016 - TRDOS 386 (TRDOS v2.0)
  4814                              <1> 	; write null (write to null device)
  4815 000134A6 C3                  <1> 	retn
  4816                              <1> 
  4817                              <1> dev_IRQ_service:
  4818                              <1> 	; 12/05/2017
  4819                              <1> 	; 13/04/2017
  4820                              <1> 	; 27/02/2017 - TRDOS 386 (TRDOS v2.0)
  4821                              <1> 	; INPUT ->
  4822                              <1> 	;	AL = IRQ Number (0 to 15)
  4823                              <1> 	;	
  4824 000134A7 53                  <1> 	push	ebx
  4825 000134A8 0FB6D8              <1> 	movzx	ebx, al
  4826 000134AB C0E302              <1> 	shl	bl, 2 ; * 4	
  4827 000134AE 8B9B[229C0100]      <1> 	mov	ebx, [ebx+DEV_INT_HNDLR]
  4828 000134B4 21DB                <1> 	and 	ebx, ebx
  4829 000134B6 7404                <1>         jz	short dIRQ_s_retn
  4830 000134B8 50                  <1> 	push	eax
  4831                              <1> 
  4832 000134B9 FFD3                <1> 	call	ebx
  4833                              <1> 
  4834 000134BB 58                  <1> 	pop	eax
  4835                              <1> dIRQ_s_retn:
  4836 000134BC 5B                  <1> 	pop	ebx
  4837 000134BD C3                  <1> 	retn		
  4838                              <1> 
  4839                              <1> 
  4840                              <1> set_dev_IRQ_service:
  4841                              <1> 	; 13/04/2017 - TRDOS 386 (TRDOS v2.0)
  4842                              <1> 	;
  4843                              <1> 	; Set Device Interrupt Service
  4844                              <1> 	;
  4845                              <1> 	; INPUT ->
  4846                              <1> 	;	AL = IRQ Number
  4847                              <1> 	;	EBX = Hardware Interrupt Service Address
  4848                              <1> 	;
  4849                              <1> 	; Note: There is not a validation check here
  4850                              <1> 	;	because this procedure is called by
  4851                              <1> 	;	TRDOS 386 kernel !
  4852                              <1> 	;       (Even if a device driver does not exist
  4853                              <1> 	;	this setting may be used by sysaudio
  4854                              <1> 	;	and other system calls for hardware
  4855                              <1> 	;	components which use IRQ method for I/O.)
  4856                              <1> 	;
  4857                              <1> 	;push	esi
  4858 000134BE 0FB6F0              <1> 	movzx	esi, al
  4859 000134C1 66C1E602            <1> 	shl	si, 2 ; * 4	
  4860 000134C5 899E[229C0100]      <1> 	mov	[esi+DEV_INT_HNDLR], ebx
  4861                              <1> 	;pop	esi
  4862 000134CB C3                  <1> 	retn		
  4863                              <1> 	
  4864                              <1> 
  4865                              <1> sysaudio: ; AUDIO FUNCTIONS
  4866                              <1> 	; 12/02/2021 (TRDOS 386 v2.0.3) 
  4867                              <1> 	; 28/07/2020
  4868                              <1> 	; 27/07/2020
  4869                              <1> 	; 10/10/2017
  4870                              <1> 	; 22/06/2017
  4871                              <1> 	; 28/05/2017, 04/06/2017, 05/06/2017, 10/06/2017
  4872                              <1> 	; 01/05/2017, 12/05/2017, 15/05/2017, 20/05/2017
  4873                              <1> 	; 21/04/2017, 22/04/2017, 23/04/2017, 24/04/2017
  4874                              <1> 	; 10/04/2017, 13/04/2017, 14/04/2017, 16/04/2017
  4875                              <1> 	; 03/04/2017 (VIA VT8237R)
  4876                              <1> 	; 01/04/2016 (trdosk6.s -> tdosk8.s)
  4877                              <1> 	; 16/05/2016 - TRDOS 386 (TRDOS v2.0)
  4878                              <1> 	;
  4879                              <1> 	; Inputs:
  4880                              <1> 	;
  4881                              <1> 	;	BH = 0 -> Beep (PC Speaker)
  4882                              <1> 	;	     BL = Duration Counter (1 for 1/64 second)
  4883                              <1> 	;	     CX = Frequency Divisor (1193180/Frequency)
  4884                              <1> 	;		 (1331 for 886 Hz)
  4885                              <1> 	;
  4886                              <1> 	;	01/04/2017	
  4887                              <1> 	;
  4888                              <1> 	; 	BH = 1 -> DETECT (& ENABLE) AUDIO DEVICE
  4889                              <1> 	;	     BL = 0 : PC SPEAKER
  4890                              <1> 	;		  1 : SOUND BLASTER 16
  4891                              <1> 	;		  2 : INTEL AC'97
  4892                              <1> 	;		  3 : VIA VT8237R (VT8233)			 				
  4893                              <1> 	;		  4 : INTEL HDA
  4894                              <1> 	;	      5-FEh : unknown/invalid
  4895                              <1> 	;	        ; 04/06/2017
  4896                              <1> 	;		FFh : Get current audio device id
  4897                              <1> 	;
  4898                              <1> 	; 	BH = 2 -> ALLOCATE AUDIO BUFFER (for user)
  4899                              <1> 	;		ECX = Audio Buffer Size (must be equal to
  4900                              <1> 	;		      the half of DMA buffer size) 
  4901                              <1> 	;		EDX = Virtual Address of the buffer
  4902                              <1> 	;		      (This is not DMA buffer!)
  4903                              <1> 	;
  4904                              <1> 	;	BH = 3 -> INITIALIZE AUDIO DEVICE
  4905                              <1> 	;	     BL = 0,2 -> for Signal Response Byte	 	
  4906                              <1> 	;	     	CL = Signal Response Byte Value (fixed)
  4907                              <1> 	;				if BL = 0
  4908                              <1> 	;	             auto increment of S.R.B. value
  4909                              <1> 	;			 	if BL = 2
  4910                              <1> 	;	        EDX = Signal Response (Return) Byte Address
  4911                              <1> 	;	     	   			
  4912                              <1> 	;	     BL = 1 for CallBack Method	 	
  4913                              <1> 	;	    	EDX = CallBack Service Address (Virtual)
  4914                              <1> 	;
  4915                              <1> 	;	     BL > 2 -> invalid function	
  4916                              <1> 	;
  4917                              <1> 	;	    (Audio buffer must be allocated before
  4918                              <1> 	;	     initialization.) 		
  4919                              <1> 	;
  4920                              <1> 	;	BH = 4 -> START TO PLAY
  4921                              <1> 	;	     BL = Mode
  4922                              <1> 	;		  Bit 0 = mono/stereo (1 = stereo)		
  4923                              <1> 	;		  Bit 1 = 8 bit / 16 bit (1 = 16 bit)
  4924                              <1> 	;	     CX = Sampling Rate (Hz)
  4925                              <1> 	;
  4926                              <1> 	;	BH = 5 -> PAUSE
  4927                              <1> 	;	     BL = Any
  4928                              <1> 	;
  4929                              <1> 	;	BH = 6 -> CONTINUE TO PLAY
  4930                              <1> 	;	     BL = Any
  4931                              <1> 	;
  4932                              <1> 	;	BH = 7 -> STOP
  4933                              <1> 	;	     BL = Any
  4934                              <1> 	;
  4935                              <1> 	;	BH = 8 -> RESET 
  4936                              <1> 	;	     BL = Any
  4937                              <1> 	;
  4938                              <1> 	;	BH = 9 -> CANCEL (CALLBACK or S.R.B. SERVICE)
  4939                              <1> 	;	     BL = Any	
  4940                              <1> 	;	
  4941                              <1> 	;	BH = 10 -> DEALLOCATE AUDIO BUFFER (for user)
  4942                              <1> 	;	     BL = Any
  4943                              <1> 	;
  4944                              <1> 	;	BH = 11 -> SET VOLUME LEVEL
  4945                              <1> 	;	     BL: (Bit 0 to 6)
  4946                              <1> 	;		  0 = Master (Playback, Lineout) volume
  4947                              <1> 	;	     CL = Left Channel Volume
  4948                              <1> 	;	     CH = Right Channel Volume
  4949                              <1> 	;	
  4950                              <1> 	;	     Note: If BL >= 80h (Bit 7 of BL is set),
  4951                              <1> 	;	     volume level will be set for next playing
  4952                              <1> 	;	     (actual volume level will not be changed
  4953                              <1> 	;	     immediately)	
  4954                              <1> 	;
  4955                              <1> 	;	BH = 12 -> DISABLE AUDIO DEVICE
  4956                              <1> 	;	     (reset audio device and unlink dma buffer)	
  4957                              <1> 	;	     BL = Any	  		  	  	
  4958                              <1> 	;
  4959                              <1> 	;    	12/05/2017
  4960                              <1> 	;	BH = 13 -> MAP DMA BUFFER TO USER
  4961                              <1> 	;	    (for direct access to system's dma buffer)
  4962                              <1> 	;
  4963                              <1> 	;	     ECX = map size in bytes 
  4964                              <1> 	;		  (will be rounded up to page borders)
  4965                              <1> 	;	     EDX = Virtual Address of the buffer
  4966                              <1> 	;		  (Will be rounded up to page borders)
  4967                              <1> 	;
  4968                              <1> 	;	05/06/2017	
  4969                              <1> 	;    	04/06/2017
  4970                              <1> 	;	BH = 14 -> GET AUDIO DEVICE INFO
  4971                              <1> 	;	     BL: 0 = Audio Controller Info
  4972                              <1> 	;	       > 0 = Invalid for now! 
  4973                              <1> 	;
  4974                              <1> 	;	22/06/2017	
  4975                              <1> 	;	BH = 15 -> GET CURRENT SOUND DATA (for graphics)
  4976                              <1> 	;	     BL: 0 -> PCM OUT data
  4977                              <1> 	;	       > 0 -> Invalid for now! 
  4978                              <1> 	;	     ECX = 0 -> Get DMA Buffer Pointer
  4979                              <1> 	;		 EDX = Not Used
  4980                              <1> 	;	     ECX > 0 -> Byte count for buffer (EDX)	 	
  4981                              <1> 	;	         EDX = Buffer Address (Virtual)	
  4982                              <1> 	;
  4983                              <1> 	;	10/10/2017	
  4984                              <1> 	;	BH = 16 -> UPDATE DMA BUFFER DATA
  4985                              <1> 	;		   (by using the Audio Buffer content)
  4986                              <1> 	;	     BL = 0 : Update dma half buffer in sequence
  4987                              <1> 	;		      (automatic destination)	
  4988                              <1> 	;		  1 : Update 1st half of the dma buffer
  4989                              <1> 	;		  2 : Update 2nd half of the dma buffer
  4990                              <1> 	;		  3-FEh: Invalid!
  4991                              <1> 	;		  FFh = Get current flag value
  4992                              <1> 	;			(Half buffer number -1)
  4993                              <1> 	;
  4994                              <1> 	;
  4995                              <1> 	; Outputs:
  4996                              <1> 	;
  4997                              <1> 	;	For BH = 0 -> Beep
  4998                              <1> 	;	    None
  4999                              <1> 	;
  5000                              <1> 	;	01/04/2017
  5001                              <1> 	;
  5002                              <1> 	; 	For BH = 1 -> DETECT (& ENABLE) AUDIO DEVICE
  5003                              <1> 	;	    AH = 0 : PC SPEAKER
  5004                              <1> 	;		 1 : SOUND BLASTER 16
  5005                              <1> 	;		 2 : INTEL AC'97
  5006                              <1> 	;		 3 : VIA VT8237R (VT8233)			 				
  5007                              <1> 	;		 4 : INTEL HDA
  5008                              <1> 	;	      5-FFh : unknown/invalid
  5009                              <1> 	;	    AL = mode status
  5010                              <1> 	;		 bit 0 = mono /stereo (1 = stereo)
  5011                              <1> 	;		 bit 1 = 8 bit / 16 bit ( 1 = 16 bit)
  5012                              <1> 	;	    04/06/2017
  5013                              <1> 	;	    EBX = PCI DEVICE/VENDOR ID (if >0)
  5014                              <1> 	;		 (BX = VENDOR ID) 
  5015                              <1> 	;	    (if CF = 1 -> Error code in EAX)
  5016                              <1> 	;
  5017                              <1> 	; 	For BH = 2 -> ALLOCATE AUDIO BUFFER (for user)
  5018                              <1> 	;	    EAX = Physical Address of the buffer
  5019                              <1> 	;	    (if CF = 1 -> Error code in EAX)
  5020                              <1> 	;
  5021                              <1> 	;	For BH = 3 -> INITIALIZE AUDIO DEVICE
  5022                              <1> 	;	    (if CF = 1 -> Error code in EAX)
  5023                              <1> 	;
  5024                              <1> 	;	For BH = 4 -> START TO PLAY
  5025                              <1> 	;	    none (if CF = 1 -> Error code in EAX)	
  5026                              <1> 	;
  5027                              <1> 	;	For BH = 5 -> PAUSE
  5028                              <1> 	;	    none (if CF = 1 -> Error code in EAX)	
  5029                              <1> 	;
  5030                              <1> 	;	For BH = 6 -> CONTINUE TO PLAY
  5031                              <1> 	;	    none (if CF = 1 -> Error code in EAX)	
  5032                              <1> 	;
  5033                              <1> 	;	For BH = 7 -> STOP
  5034                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
  5035                              <1> 	;
  5036                              <1> 	;	For BH = 8 -> RESET 
  5037                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
  5038                              <1> 	;
  5039                              <1> 	;	For BH = 9 -> CANCEL (CALLBACK or S.R.B. SERVICE)
  5040                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
  5041                              <1> 	;	
  5042                              <1> 	;	For BH = 10 -> DEALLOCATE AUDIO BUFFER (for user)
  5043                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
  5044                              <1> 	;
  5045                              <1> 	;	For BH = 11 -> SET VOLUME LEVEL
  5046                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
  5047                              <1> 	;
  5048                              <1> 	;	For BH = 12 -> DISABLE AUDIO DEVICE
  5049                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
  5050                              <1> 	; 
  5051                              <1> 	;    	12/05/2017
  5052                              <1> 	;	For BH = 13 -> MAP DMA BUFFER TO USER
  5053                              <1> 	;	    EAX = Physical Address of the buffer
  5054                              <1> 	;	    (if CF = 1 -> Error code in EAX)	
  5055                              <1> 	;
  5056                              <1> 	;    	04/06/2017
  5057                              <1> 	;	For BH = 14 -> GET AUDIO DEVICE INFO
  5058                              <1> 	;	(for BL = 0) ; 05/06/2017	
  5059                              <1> 	;	    EAX = IRQ Number in AL
  5060                              <1> 	;		  Audio Device Number in AH 
  5061                              <1> 	;	    EBX = DEV/VENDOR ID
  5062                              <1> 	;		 (DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV)
  5063                              <1> 	;	    ECX = BUS/DEV/FN 
  5064                              <1> 	;		 (00000000BBBBBBBBDDDDDFFF00000000)
  5065                              <1> 	;	    EDX = NABMBAR/NAMBAR (for AC97)
  5066                              <1> 	;		  (Low word, DX = NAMBAR address)
  5067                              <1> 	;	    EDX = Base IO Addr (DX) for SB16 & VT8233	  			  		
  5068                              <1> 	;	    (if CF = 1 -> Error code in EAX)	
  5069                              <1> 	;	                 (ERR_DEV_NOT_RDY = 15)  
  5070                              <1> 	;
  5071                              <1> 	;	22/06/2017	
  5072                              <1> 	;	For BH = 15 -> GET CURRENT SOUND DATA
  5073                              <1> 	;			 (for graphics)
  5074                              <1> 	;	(for BL = 0)
  5075                              <1> 	;	 If ECX input is 0 
  5076                              <1> 	;	    EAX = DMA Buffer Current Position (Offset)
  5077                              <1> 	;	 If ECX input >  0
  5078                              <1> 	;	    EAX = Actual transfer count 		 	
  5079                              <1> 	;	    (Sound samples will be copied from 
  5080                              <1> 	;	     Current DMA Buffer Position to EDX
  5081                              <1> 	;	     virtual address as EAX bytes.)
  5082                              <1> 	;	 ((If CF = 1 ->  Error code in EAX))
  5083                              <1> 	;
  5084                              <1> 	;
  5085                              <1> 	;	10/10/2017	
  5086                              <1> 	;	For BH = 16 -> UPDATE DMA BUFFER DATA
  5087                              <1> 	;	    EAX = 0, if the updated (or current)
  5088                              <1> 	;		     half buffer is DMA half buffer 1
  5089                              <1> 	;	    EAX = 1, if the updated (or current)
  5090                              <1> 	; 		     half buffer is DMA half buffer 2 	  	
  5091                              <1> 	;	    (If CF = 1 -> Error code in EAX)	
  5092                              <1> 	;	
  5093                              <1> 
  5094 000134CC 80FF11              <1> 	cmp	bh, AUDIO1L/4
  5095 000134CF 0F8337A4FFFF        <1> 	jnb	sysret
  5096                              <1> 
  5097 000134D5 C0E702              <1> 	shl	bh, 2 ; *4	
  5098 000134D8 0FB6F7              <1> 	movzx	esi, bh
  5099                              <1> 
  5100                              <1> 	; 22/04/2017
  5101 000134DB 31C0                <1> 	xor	eax, eax
  5102 000134DD A3[64030300]        <1> 	mov	[u.r0], eax  ; 0
  5103                              <1> 		
  5104 000134E2 FF96[ED340100]      <1> 	call	dword [esi+AUDIO1]
  5105                              <1> 	;jc	error
  5106 000134E8 E91FA4FFFF          <1> 	jmp	sysret	
  5107                              <1> 
  5108 000134ED [E9230000]          <1> AUDIO1:	dd	_beep ; 12/02/2021	
  5109                              <1> 	;dd	beep ; FUNCTION = 0 (bl = Duration Counter
  5110                              <1> 		     ; 		     cx = Frequency Divisor
  5111 000134F1 [31350100]          <1> 	dd	soundc_detect
  5112 000134F5 [CD350100]          <1> 	dd	sound_alloc
  5113 000134F9 [8B360100]          <1> 	dd	soundc_init
  5114 000134FD [43380100]          <1> 	dd	sound_play
  5115 00013501 [DF380100]          <1> 	dd	sound_pause
  5116 00013505 [09390100]          <1> 	dd	sound_continue
  5117 00013509 [33390100]          <1> 	dd	sound_stop
  5118 0001350D [5C390100]          <1> 	dd	soundc_reset
  5119 00013511 [8D390100]          <1> 	dd	soundc_cancel
  5120 00013515 [B3390100]          <1> 	dd	sound_dalloc
  5121 00013519 [DE390100]          <1> 	dd	sound_volume
  5122 0001351D [303A0100]          <1> 	dd	soundc_disable
  5123 00013521 [A23A0100]          <1> 	dd	sound_dma_map
  5124 00013525 [113B0100]          <1> 	dd	soundc_info
  5125 00013529 [703B0100]          <1> 	dd	sound_data
  5126 0001352D [1D3C0100]          <1> 	dd	sound_update
  5127                              <1> 	
  5128                              <1> AUDIO1L	EQU	$ - AUDIO1
  5129                              <1> 
  5130                              <1> soundc_detect:
  5131                              <1> 	; FUNCTION = 1
  5132                              <1> 	; bl = Audio device type number 
  5133                              <1> 	; (0= pc speaker, 1 = sound blaster 16, 2 = intel ac97
  5134                              <1> 	;  3= via vt823x, 4 = intel HDA, 0FFh= any)
  5135                              <1> 	
  5136                              <1> 	; 04/06/2017
  5137 00013531 8A25[B19C0100]      <1> 	mov	ah, [audio_device]
  5138 00013537 80FBFF              <1> 	cmp	bl, 0FFh ; get current audio device id
  5139 0001353A 7408                <1> 	je	short sysaudio0
  5140                              <1> 
  5141 0001353C 20E4                <1> 	and	ah, ah
  5142 0001353E 741E                <1> 	jz	short soundc_get_dev
  5143                              <1> 
  5144 00013540 38DC                <1> 	cmp	ah, bl
  5145 00013542 7567                <1> 	jne	short soundc_dev_err
  5146                              <1> 
  5147                              <1> sysaudio0:	
  5148 00013544 A0[B29C0100]        <1> 	mov	al, [audio_mode]
  5149                              <1> sysaudio1:
  5150 00013549 A3[64030300]        <1> 	mov	[u.r0], eax
  5151 0001354E 8B1D[BC9C0100]      <1> 	mov	ebx, [audio_vendor] ; (DEVICE/VENDOR ID)
  5152 00013554 8B2D[60030300]      <1> 	mov	ebp, [u.usp]
  5153 0001355A 895D10              <1> 	mov	[ebp+16], ebx  ; ebx
  5154 0001355D C3                  <1> 	retn
  5155                              <1> 
  5156                              <1> soundc_get_dev:
  5157                              <1> 	; 28/05/2017
  5158                              <1> 	; 03/04/2017, 24/04/2017
  5159 0001355E C605[B09C0100]00    <1> 	mov	byte [audio_pci], 0
  5160 00013565 80FB03              <1> 	cmp	bl, 3 ; VIA VT8233 (VT8237R) Audio Controller & AC97 Codec
  5161                              <1> 	;jne	short soundc_get_dev_sb
  5162                              <1> 	; 28/05/2017
  5163 00013568 7220                <1> 	jb	short soundc_get_dev_sb
  5164 0001356A 773F                <1> 	ja	short soundc_dev_err  ; temporary (28/05/2017)
  5165                              <1> 	;  		
  5166 0001356C E86C180000          <1> 	call	DetectVT8233
  5167 00013571 7238                <1> 	jc	short soundc_dev_err
  5168                              <1> 	; eax = 0
  5169                              <1> 
  5170                              <1> 	;mov	ebx, [audio_vendor]
  5171                              <1> 	; ebx = DEVICE/VENDOR ID
  5172                              <1> 	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
  5173                              <1> 
  5174 00013573 B003                <1> 	mov	al, 3  ; VIA VT8237R (VT3233) Audio Controller
  5175 00013575 88C4                <1> 	mov	ah, al
  5176                              <1> 
  5177                              <1> soundc_get_pci_dev_ok: ; 28/05/2017
  5178 00013577 FE05[B09C0100]      <1> 	inc	byte [audio_pci] ; = 1
  5179                              <1> soundc_get_dev_ok:
  5180                              <1> 	
  5181                              <1> soundc_get_dev_sb16_ok:
  5182 0001357D A2[B19C0100]        <1> 	mov	[audio_device], al
  5183 00013582 8825[B29C0100]      <1> 	mov	[audio_mode], ah ; stereo (bit0), 16 bit (bit1) capability	
  5184 00013588 EBBF                <1> 	jmp	short sysaudio1
  5185                              <1> 
  5186                              <1> soundc_get_dev_sb:
  5187                              <1> 	; 24/04/2017
  5188 0001358A 80FB01              <1> 	cmp	bl, 1 ; Sound Blaster 16
  5189 0001358D 750E                <1> 	jne	short soundc_get_dev_ich ; 28/05/2017
  5190                              <1> 	;
  5191 0001358F E86D1D0000          <1> 	call	DetectSB
  5192 00013594 7215                <1> 	jc	short soundc_dev_err
  5193 00013596 B801030000          <1> 	mov	eax, 0301h ; Sound Blaster 16
  5194 0001359B EBE0                <1> 	jmp	short soundc_get_dev_sb16_ok
  5195                              <1> 
  5196                              <1> soundc_get_dev_ich:
  5197                              <1> 	; 28/05/2017
  5198                              <1> 	;cmp	bl, 2 ; Intel AC'97 Audio Controller (ICH)
  5199                              <1> 	;jne	short soundc_dev_err ; Temporary  (28/05/2017)
  5200                              <1> 	;			     ; (Here will be modified just after
  5201                              <1> 	;			     ; new sound card code will be ready!)  	
  5202 0001359D E82E180000          <1> 	call	DetectICH
  5203 000135A2 7207                <1> 	jc	short soundc_dev_err
  5204                              <1> 	;
  5205 000135A4 B802030000          <1> 	mov	eax, 0302h ; AC'97 (ICH)
  5206 000135A9 EBCC                <1> 	jmp	short soundc_get_pci_dev_ok
  5207                              <1> 
  5208                              <1> soundc_dev_err:
  5209 000135AB B80F000000          <1> 	mov	eax, ERR_DEV_NOT_RDY ; Device not ready !
  5210 000135B0 EB0C                <1> 	jmp	short sysaudio_err
  5211                              <1> 
  5212                              <1> sound_buff_error:
  5213 000135B2 B82E000000          <1> 	mov	eax, ERR_BUFFER ; Buffer error !
  5214 000135B7 EB05                <1> 	jmp	short sysaudio_err
  5215                              <1> 
  5216                              <1> soundc_respond_err:
  5217                              <1> 	; ERR_TIME_OUT ; 'time out !' error	
  5218 000135B9 B819000000          <1> 	mov	eax, ERR_DEV_NOT_RESP ; 'device not responding !' error
  5219                              <1> sysaudio_err:
  5220 000135BE A3[64030300]        <1> 	mov	[u.r0], eax
  5221 000135C3 A3[C8030300]        <1> 	mov	[u.error], eax
  5222 000135C8 E91FA3FFFF          <1> 	jmp	error
  5223                              <1> 
  5224                              <1> sound_alloc:
  5225                              <1> 	; FUNCTION =  2
  5226                              <1> 	; ecx = audio buffer size (in bytes)
  5227                              <1> 	; edx = audio buffer address (virtual)
  5228                              <1> 	; 27/07/2020
  5229                              <1> 	; 28/05/2017
  5230                              <1> 	; 01/05/2017, 15/05/2017
  5231                              <1> 	; 21/04/2017, 24/04/2017
  5232 000135CD 803D[B09C0100]00    <1> 	cmp	byte [audio_pci], 0
  5233 000135D4 7708                <1> 	ja	short snd_alloc_0
  5234                              <1> 	; Max. 64KB DMA buffer !!!
  5235 000135D6 81F900800000        <1> 	cmp	ecx, 32768
  5236 000135DC 77D4                <1> 	ja	short sound_buff_error
  5237                              <1> snd_alloc_0:
  5238                              <1> 	; 15/05/2017
  5239 000135DE 81F900100000        <1> 	cmp	ecx, 4096 ; PAGE_SIZE
  5240 000135E4 72CC                <1> 	jb	short sound_buff_error
  5241                              <1> 	;
  5242 000135E6 A1[C49C0100]        <1> 	mov	eax, [audio_buffer] ; audio buffer address (current)
  5243 000135EB 09C0                <1> 	or	eax, eax
  5244 000135ED 7445                <1> 	jz	short snd_alloc_2
  5245                              <1> 	; audio buffer exists !
  5246 000135EF 8A1D[B3030300]      <1> 	mov	bl, [u.uno]
  5247 000135F5 3A1D[D99C0100]      <1> 	cmp	bl, [audio_user]
  5248 000135FB 0F85FC000000        <1> 	jne	sndc_owner_error ; not owner !
  5249 00013601 39D0                <1> 	cmp	eax, edx ; same virtual buffer address ?
  5250 00013603 7508                <1> 	jne	short snd_alloc_1
  5251 00013605 3B0D[CC9C0100]      <1> 	cmp	ecx, [audio_buff_size]
  5252 0001360B 746C                <1> 	je	short snd_alloc_3 ; Nothing to do !
  5253                              <1> 				  ; Buffer has been set already!
  5254                              <1> snd_alloc_1:
  5255 0001360D 51                  <1> 	push	ecx
  5256 0001360E 52                  <1> 	push	edx
  5257 0001360F 89C3                <1> 	mov	ebx, eax ; audio buffer address (current)
  5258 00013611 8B0D[CC9C0100]      <1> 	mov	ecx, [audio_buff_size]
  5259 00013617 E8C431FFFF          <1> 	call	deallocate_user_pages
  5260 0001361C 5A                  <1> 	pop	edx
  5261 0001361D 59                  <1> 	pop	ecx
  5262 0001361E 31C0                <1> 	xor	eax, eax ; 0
  5263 00013620 A3[C49C0100]        <1> 	mov	[audio_buffer], eax  ; 0
  5264 00013625 A3[C89C0100]        <1>  	mov	[audio_p_buffer], eax  ; 0
  5265 0001362A A3[CC9C0100]        <1>  	mov	[audio_buff_size], eax
  5266 0001362F A2[D99C0100]        <1> 	mov	[audio_user], al ; 0
  5267                              <1> snd_alloc_2:
  5268 00013634 89D3                <1> 	mov	ebx, edx
  5269                              <1> 	; 01/05/2017
  5270 00013636 BA00F0FFFF          <1> 	mov	edx, ~PAGE_OFF ; truncating page offsets
  5271                              <1> 			       ; for aligning to page borders	
  5272                              <1> 	;and	eax, edx
  5273 0001363B 21D3                <1> 	and	ebx, edx
  5274 0001363D 21D1                <1> 	and	ecx, edx
  5275                              <1> 	; 15/05/2017
  5276                              <1> 	; EAX = Beginning address (physical)
  5277                              <1> 	; EAX = 0 -> Allocate mem block from the 1st proper aperture	
  5278                              <1> 	; ECX = Number of bytes to be allocated		
  5279 0001363F E8412EFFFF          <1> 	call	allocate_memory_block
  5280 00013644 0F8268FFFFFF        <1> 	jc	sound_buff_error
  5281                              <1> 	; EAX = Physical address of the allocated memory block
  5282                              <1> 	; ECX = Allocated bytes (as truncated to page border)
  5283                              <1> 	; EBX = Virtual address (as truncated to page border)
  5284 0001364A 50                  <1> 	push	eax
  5285 0001364B 53                  <1> 	push	ebx
  5286 0001364C 51                  <1> 	push	ecx
  5287 0001364D E88332FFFF          <1> 	call	allocate_user_pages
  5288 00013652 59                  <1> 	pop	ecx
  5289 00013653 5B                  <1> 	pop	ebx
  5290 00013654 58                  <1> 	pop	eax
  5291 00013655 722A                <1> 	jc	short snd_alloc_4  ; insufficient memory, buff error
  5292                              <1> 	; eax = physical address of the user's audio buffer
  5293                              <1> 	; ebx = virtual address of the user's audio buffer
  5294                              <1> 	; ecx = buffer size (in bytes)
  5295 00013657 A3[C89C0100]        <1> 	mov	[audio_p_buffer], eax
  5296 0001365C 891D[C49C0100]      <1> 	mov	[audio_buffer], ebx
  5297 00013662 890D[CC9C0100]      <1>  	mov	[audio_buff_size], ecx
  5298 00013668 8A15[B3030300]      <1> 	mov	dl, [u.uno]
  5299 0001366E 8815[D99C0100]      <1> 	mov	[audio_user], dl
  5300 00013674 A3[64030300]        <1> 	mov	[u.r0], eax
  5301                              <1> snd_alloc_3:
  5302                              <1> 	; 27/07/2020
  5303 00013679 C605[D89C0100]00    <1> 	mov	byte [audio_flag], 0 ; clear dma half buffer flag
  5304                              <1> 	;	
  5305 00013680 C3                  <1> 	retn
  5306                              <1> snd_alloc_4:
  5307                              <1> 	; 15/05/2017
  5308                              <1> 	; EAX = Beginning address (physical)
  5309                              <1> 	; ECX = Number of bytes to be deallocated
  5310 00013681 E80C30FFFF          <1> 	call	deallocate_memory_block
  5311 00013686 E927FFFFFF          <1> 	jmp	sound_buff_error  ; insufficient memory, buff error
  5312                              <1> 
  5313                              <1> soundc_init:
  5314                              <1> 	; FUNCTION = 3 
  5315                              <1> 	; bl = method (0= s.r.b., 1= callback, 2= auto incr s.r.b.)
  5316                              <1> 	; cl = signal response byte (initial or fixed) value
  5317                              <1> 	; edx = signal response byte or callback address
  5318                              <1> 	; 27/07/2020
  5319                              <1> 	; 28/05/2017
  5320                              <1> 	; 12/05/2017, 20/05/2017
  5321                              <1> 	; 22/04/2017, 23/04/2017, 24/04/2017
  5322                              <1> 	; 13/04/2017, 14/04/2017, 16/04/2017, 21/04/2017
  5323                              <1> 	; 03/04/2017, 10/04/2017
  5324                              <1> 
  5325 0001368B A0[B19C0100]        <1> 	mov	al, [audio_device]
  5326 00013690 20C0                <1> 	and	al, al
  5327 00013692 7549                <1> 	jnz	short sndc_init_6
  5328                              <1> 	;
  5329 00013694 C605[B09C0100]00    <1> 	mov	byte [audio_pci], 0
  5330 0001369B 52                  <1> 	push	edx
  5331 0001369C 53                  <1> 	push	ebx
  5332 0001369D 51                  <1> 	push	ecx
  5333 0001369E E85E1C0000          <1> 	call	DetectSB
  5334 000136A3 7213                <1> 	jc	short sndc_init_8
  5335 000136A5 66B80103            <1> 	mov	ax, 0301h ; Sound Blaster 16
  5336 000136A9 EB1E                <1> 	jmp	short sndc_init_7
  5337                              <1> 
  5338                              <1> sndc_init_11:
  5339                              <1> 	; 28/05/2017
  5340 000136AB E820170000          <1> 	call	DetectICH ; Detect AC'97 (ICH) Audio Controller
  5341 000136B0 7217                <1> 	jc	short sndc_init_7
  5342 000136B2 66B80203            <1> 	mov	ax, 0302h ; Intel AC'97 Audio Device
  5343 000136B6 EB0B                <1> 	jmp	short sndc_init_12 ; (PCI device)
  5344                              <1> 
  5345                              <1> sndc_init_8:
  5346 000136B8 E820170000          <1> 	call	DetectVT8233
  5347                              <1> 	;jc	short sndc_init_7
  5348 000136BD 72EC                <1> 	jc	sndc_init_11 ; 28/05/2017
  5349                              <1> 	; eax = 0
  5350 000136BF B003                <1> 	mov	al, 3	; VIA VT8237R (VT3233) Audio Controller
  5351 000136C1 88C4                <1> 	mov	ah, al
  5352                              <1> 
  5353                              <1> sndc_init_12:
  5354 000136C3 FE05[B09C0100]      <1> 	inc	byte [audio_pci] ; = 1
  5355                              <1> sndc_init_7:
  5356 000136C9 59                  <1> 	pop	ecx
  5357 000136CA 5B                  <1> 	pop	ebx
  5358 000136CB 5A                  <1> 	pop	edx
  5359 000136CC 0F82D9FEFFFF        <1> 	jc	soundc_dev_err
  5360                              <1> 	;
  5361 000136D2 A2[B19C0100]        <1> 	mov	[audio_device], al
  5362 000136D7 8825[B29C0100]      <1> 	mov	[audio_mode], ah ; stereo (bit0), 16 bit (bit1) capability
  5363                              <1> 
  5364                              <1> sndc_init_6:
  5365 000136DD 833D[C49C0100]00    <1> 	cmp	dword [audio_buffer], 0
  5366 000136E4 0F86C8FEFFFF        <1> 	jna	sound_buff_error
  5367                              <1> 
  5368 000136EA A0[B3030300]        <1> 	mov	al, [u.uno]
  5369 000136EF 8A25[D99C0100]      <1> 	mov	ah, [audio_user]
  5370 000136F5 08E4                <1> 	or	ah, ah
  5371 000136F7 7418                <1> 	jz	short sndc_init0
  5372 000136F9 38E0                <1> 	cmp	al, ah
  5373 000136FB 7419                <1> 	je	short sndc_init1
  5374                              <1> 
  5375                              <1> sndc_owner_error:
  5376 000136FD B80B000000          <1> 	mov	eax, ERR_NOT_OWNER ; 'permission denied !' error
  5377                              <1> sndc_perm_error:
  5378 00013702 A3[64030300]        <1> 	mov	[u.r0], eax
  5379 00013707 A3[C8030300]        <1> 	mov	[u.error], eax
  5380 0001370C E9DBA1FFFF          <1> 	jmp	error
  5381                              <1> sndc_init0:
  5382 00013711 A2[D99C0100]        <1> 	mov	[audio_user], al
  5383                              <1> sndc_init1:
  5384 00013716 8915[DC9C0100]      <1> 	mov	[audio_cb_addr], edx
  5385 0001371C 881D[DA9C0100]      <1> 	mov	[audio_cb_mode], bl
  5386 00013722 880D[DB9C0100]      <1> 	mov	[audio_srb], cl
  5387                              <1> 
  5388                              <1> 	; 27/07/2020
  5389                              <1> 	;mov	byte [audio_flag], 0  ; clear dma half buffer flag
  5390                              <1> 
  5391                              <1> 	; 24/04/2017
  5392 00013728 803D[B19C0100]03    <1> 	cmp	byte [audio_device], 3 ; VT8233 (VT8237R)
  5393 0001372F 7438                <1> 	je	short sndc_init_9
  5394                              <1> 	;ja	short soundc_respond_err ; temporary (28/05/2017)
  5395 00013731 803D[B19C0100]01    <1> 	cmp	byte [audio_device], 1 ; SB 16
  5396 00013738 7510                <1> 	jne	short sndc_init_13
  5397 0001373A BB[26550100]        <1> 	mov	ebx, sb16_int_handler
  5398                              <1> 	; Note: 'SbInit' is at 'Start to Play' stage
  5399                              <1> 	; 20/05/2017
  5400 0001373F 66C705[E69C0100]08- <1> 	mov	word [audio_master_volume], 0808h ; 2/8
  5400 00013747 08                  <1>
  5401 00013748 EB3F                <1> 	jmp	short sndc_init_10
  5402                              <1> sndc_init_13:
  5403                              <1> 	; 28/05/2017
  5404 0001374A 803D[B19C0100]02    <1> 	cmp	byte [audio_device], 2 ; AC 97 (ICH)	
  5405 00013751 0F8562FEFFFF        <1> 	jne	soundc_respond_err ; temporary (28/05/2017)
  5406                              <1> 
  5407 00013757 E81F1F0000          <1> 	call	ac97_codec_config
  5408 0001375C 0F8257FEFFFF        <1> 	jc	soundc_respond_err ; codec error !
  5409                              <1> 
  5410 00013762 BB[62580100]        <1> 	mov	ebx, ac97_int_handler
  5411 00013767 EB20                <1> 	jmp	short sndc_init_10	
  5412                              <1> 
  5413                              <1> sndc_init_9:
  5414                              <1> 	;call	reset_codec
  5415                              <1> 	;; eax = 1
  5416                              <1> 	;call	codec_io_w16 ; w32
  5417 00013769 E8E6170000          <1> 	call	init_codec ; 28/05/2017
  5418 0001376E 0F8245FEFFFF        <1> 	jc	soundc_respond_err ; codec error !
  5419                              <1> 
  5420 00013774 E80D1A0000          <1> 	call	channel_reset
  5421                              <1> 
  5422                              <1> 	; setup the Codec (actually mixer registers) 
  5423 00013779 E82D190000          <1>         call    codec_config  ; unmute codec, set rates.
  5424 0001377E 0F8235FEFFFF        <1> 	jc	soundc_respond_err ; codec error !
  5425                              <1> 
  5426 00013784 BB[18510100]        <1> 	mov	ebx, vt8233_int_handler
  5427                              <1> sndc_init_10:
  5428                              <1> 	; 13/04/2017
  5429 00013789 A0[B39C0100]        <1> 	mov	al, [audio_intr] ; IRQ number	
  5430 0001378E E82BFDFFFF          <1> 	call	set_dev_IRQ_service
  5431                              <1> 
  5432                              <1> 	; SETUP (audio) INTERRUPT CALLBACK SERVICE
  5433 00013793 8A1D[B39C0100]      <1> 	mov	bl, [audio_intr] ; IRQ number
  5434 00013799 8A3D[DA9C0100]      <1> 	mov	bh, [audio_cb_mode]
  5435 0001379F FEC7                <1> 	inc	bh  ; 1 = Signal Response Byte method (fixed value)
  5436                              <1> 		    ; 2 = Callback service method
  5437                              <1> 		    ; 3 = Auto Increment S.R.B. method 	
  5438 000137A1 8A0D[DB9C0100]      <1> 	mov	cl, [audio_srb]
  5439 000137A7 8B15[DC9C0100]      <1> 	mov	edx, [audio_cb_addr]
  5440 000137AD A0[D99C0100]        <1> 	mov	al, [audio_user]
  5441                              <1> 	; 14/04/2017
  5442 000137B2 E8E1040000          <1>  	call	set_irq_callback_service
  5443                              <1> 	; 16/04/2017
  5444 000137B7 A3[64030300]        <1> 	mov	[u.r0], eax
  5445                              <1> 	;jnc	sysret
  5446 000137BC 7316                <1> 	jnc	short sndc_init2 ; 21/04/2017
  5447                              <1> 	;
  5448 000137BE A3[C8030300]        <1> 	mov	dword [u.error], eax
  5449                              <1> 
  5450 000137C3 A0[B39C0100]        <1> 	mov	al, [audio_intr] ; IRQ number	
  5451 000137C8 31DB                <1> 	xor	ebx, ebx ; reset IRQ handler address
  5452 000137CA E8EFFCFFFF          <1> 	call	set_dev_IRQ_service
  5453                              <1> 
  5454 000137CF E918A1FFFF          <1> 	jmp	error
  5455                              <1> 
  5456                              <1> sndc_init2:
  5457                              <1> 	; 21/04/2017
  5458 000137D4 8B0D[CC9C0100]      <1> 	mov	ecx, [audio_buff_size] ; audio buffer size
  5459 000137DA D1E1                <1> 	shl	ecx, 1 ; *2
  5460 000137DC A1[D09C0100]        <1> 	mov	eax, [audio_dma_buff]
  5461 000137E1 21C0                <1> 	and	eax, eax
  5462 000137E3 7415                <1> 	jz	short sndc_init3
  5463                              <1> 
  5464 000137E5 8B15[D49C0100]      <1> 	mov	edx, [audio_dmabuff_size] ; dma buffer size
  5465 000137EB 39D1                <1> 	cmp	ecx, edx
  5466 000137ED 744D                <1> 	je	short sndc_init5
  5467                              <1> 
  5468 000137EF 87CA                <1> 	xchg	ecx, edx
  5469 000137F1 E89C2EFFFF          <1> 	call	deallocate_memory_block
  5470 000137F6 87D1                <1> 	xchg	edx, ecx
  5471 000137F8 31C0                <1> 	xor	eax, eax
  5472                              <1> sndc_init3:
  5473                              <1> 	; 12/05/2017
  5474 000137FA 803D[B19C0100]01    <1> 	cmp	byte [audio_device], 1 ; SB 16
  5475 00013801 7515                <1> 	jne	short sndc_init4
  5476 00013803 C705[D09C0100]-     <1> 	mov	dword [audio_dma_buff], sb16_dma_buffer
  5476 00013809 [00000200]          <1>
  5477 0001380D C705[D49C0100]0000- <1> 	mov	dword [audio_dmabuff_size], 65536
  5477 00013815 0100                <1>
  5478                              <1> 	;xor	eax, eax
  5479                              <1> 	;mov	[u.r0], eax ; 0 = no error, successful
  5480 00013817 C3                  <1> 	retn 
  5481                              <1> 
  5482                              <1> sndc_init4:
  5483                              <1> 	; EAX = Beginning address (physical)
  5484                              <1> 	; EAX = 0 -> Allocate mem block from the 1st proper aperture	
  5485                              <1> 	; ECX = Number of bytes to be allocated	(>0)	
  5486 00013818 E8682CFFFF          <1> 	call	allocate_memory_block
  5487 0001381D 0F828FFDFFFF        <1> 	jc	sound_buff_error
  5488                              <1> 
  5489                              <1> 	; set dma buffer address and size parameters
  5490 00013823 A3[D09C0100]        <1> 	mov	[audio_dma_buff], eax ; dma buffer address
  5491 00013828 890D[D49C0100]      <1> 	mov	[audio_dmabuff_size], ecx ; dma buffer size
  5492                              <1> ;	; EAX = Beginning (physical) addr of the allocated mem block
  5493                              <1> ;	; ECX = Num of allocated bytes (rounded up to page borders)
  5494                              <1> ;	cmp	byte [audio_pci], 0 ; AC97 audio controller ?
  5495                              <1> ;	ja	short sndc_init4
  5496                              <1> ;
  5497                              <1> ;	; Sound Blaster 16 uses classic DMA
  5498                              <1> ;	mov	edx, eax
  5499                              <1> ;	add	edx, ecx
  5500                              <1> ;	cmp	edx, 1000000h ; 1st 16 MB
  5501                              <1> ;	jna	short sndc_init4
  5502                              <1> ;
  5503                              <1> ;	; error !
  5504                              <1> ;	; restore Memory Allocation Table Content
  5505                              <1> ;	; EAX = Beginning address (physical)
  5506                              <1> ;	; ECX = Number of bytes to be deallocated
  5507                              <1> ;	call	deallocate_memory_block
  5508                              <1> ;	; reset dma buffer address and size parameters
  5509                              <1> ;	xor	eax, eax ; 0
  5510                              <1> ;	mov	[audio_dma_buff], eax ; 0
  5511                              <1> ;	mov	[audio_dmabuff_size], ecx ; 0
  5512                              <1> ;	jmp	sound_buff_error				
  5513                              <1> ;
  5514                              <1> ;sndc_init4:
  5515 0001382E 803D[B19C0100]03    <1> 	cmp	byte [audio_device], 3
  5516                              <1> 	;jne	short sndc_init5
  5517 00013835 7506                <1> 	jne	short sndc_init14 ; 28/05/2017
  5518 00013837 E88B190000          <1> 	call	set_vt8233_bdl	
  5519                              <1> sndc_init5:
  5520                              <1> 	;sub	eax, eax ; 0
  5521                              <1> 	;mov	[u.r0], eax ; 0 = no error, successful
  5522 0001383C C3                  <1> 	retn
  5523                              <1> sndc_init14:
  5524 0001383D E8521F0000          <1> 	call	set_ac97_bdl
  5525                              <1> 	;jmp	short sndc_init5
  5526 00013842 C3                  <1> 	retn
  5527                              <1> 
  5528                              <1> sound_play:
  5529                              <1> 	; FUNCTION = 4 
  5530                              <1> 	; bl = Mode 
  5531                              <1> 	;      bit 0 = mono/stereo (1 = stereo)		
  5532                              <1> 	;      bit 1 = 8 bit / 16 bit (1 = 16 bit)
  5533                              <1> 	; cx = Sampling Rate (Hz)
  5534                              <1> 
  5535                              <1> 	; 13/06/2017
  5536                              <1> 	; Note: Even if Mode bits are not 11b,
  5537                              <1> 	; 	AC'97 Audio Controller (&Codec)
  5538                              <1> 	;	will play audio samples as 16 bit, stereo
  5539                              <1> 	;	samples.
  5540                              <1> 	;	(Program must fill the audio buffer
  5541                              <1> 	;	as required; 8 bit samples must be converted
  5542                              <1> 	;	to 16 bit samples and mono samples must be
  5543                              <1> 	;	converted to stereo samples...)
  5544                              <1> 	; 
  5545                              <1> 	; 28/07/2020
  5546                              <1> 	; 27/07/2020	 	
  5547                              <1> 	; 28/05/2017
  5548                              <1> 	; 15/05/2017, 20/05/2017
  5549                              <1> 	; 21/04/2017, 24/04/2017
  5550                              <1> 	; ... device check at first
  5551 00013843 A0[B19C0100]        <1> 	mov	al, [audio_device]
  5552 00013848 08C0                <1> 	or	al, al ; 0 ; pc speaker or invalid 
  5553 0001384A 0F84AAEBFEFF        <1> 	jz	beeper_gfx ; 'video.s' ; temporary !
  5554                              <1> ;	cmp	al, 3 ; VIA VT 8237R (vt8233)
  5555                              <1> ;	je	short snd_play_1
  5556                              <1> ;	cmp	al, 1 ; SB 16
  5557                              <1> ;	jne	soundc_dev_err ; temporary !
  5558                              <1> ;snd_play_0:
  5559                              <1> 	; ... buffer & (buffer) owner check at second
  5560 00013850 833D[C49C0100]00    <1> 	cmp	dword [audio_buffer], 0
  5561 00013857 0F8655FDFFFF        <1> 	jna	sound_buff_error
  5562 0001385D A0[B3030300]        <1> 	mov	al, [u.uno]
  5563 00013862 3A05[D99C0100]      <1> 	cmp	al, [audio_user]
  5564 00013868 0F858FFEFFFF        <1> 	jne	sndc_owner_error
  5565                              <1> 
  5566 0001386E 66890D[E29C0100]    <1> 	mov	[audio_freq], cx ; sample frequency (Hertz)
  5567 00013875 88D8                <1> 	mov	al, bl
  5568 00013877 2401                <1> 	and	al, 1 ; mono/stereo (1= stereo)
  5569 00013879 FEC0                <1> 	inc	al ; channels
  5570 0001387B A2[E19C0100]        <1> 	mov	[audio_stmo], al ; sound channels (1 or 2)
  5571 00013880 B008                <1> 	mov	al, 8
  5572 00013882 F6C302              <1> 	test	bl, 2 ; bits per sample (1= 16 bit)
  5573 00013885 7402                <1> 	jz	short snd_play_bps
  5574 00013887 D0E0                <1> 	shl	al, 1  
  5575                              <1> snd_play_bps:	
  5576 00013889 A2[E09C0100]        <1> 	mov	[audio_bps], al
  5577                              <1> 
  5578                              <1> 	; Transfer ring 3 (user's) audio buffer content to dma buffer
  5579 0001388E 8B3D[D09C0100]      <1> 	mov	edi, [audio_dma_buff] ; dma buffer (ring 0)
  5580 00013894 09FF                <1> 	or	edi, edi
  5581 00013896 0F8416FDFFFF        <1> 	jz	sound_buff_error
  5582                              <1> 
  5583                              <1> 	; 27/07/2020
  5584                              <1> 
  5585 0001389C 8B35[C89C0100]      <1> 	mov	esi, [audio_p_buffer] ; physical address (ring 3)
  5586                              <1> 	;mov	ecx, [audio_buff_size] ; 15/05/2017
  5587 000138A2 8B0D[D49C0100]      <1> 	mov	ecx, [audio_dmabuff_size] ; 27/07/2020
  5588                              <1> 	;or	ecx, ecx 
  5589                              <1> 	;jz	sound_buff_error
  5590                              <1> 	; 28/07/2020
  5591 000138A8 D1E9                <1> 	shr	ecx, 1  ; dma half buffer size
  5592                              <1> 
  5593 000138AA 8035[D89C0100]01    <1> 	xor	byte [audio_flag], 1 ;  0 -> 1, 1 -> 0
  5594 000138B1 7502                <1> 	jnz	short snd_play_0 ; [audio_flag] = 1
  5595                              <1> 				 ; fill dma half buffer 1
  5596                              <1> 	; [audio_flag] = 0
  5597                              <1> 	
  5598                              <1> 	; fill dma half buffer 2
  5599 000138B3 01CF                <1> 	add	edi, ecx
  5600                              <1> 
  5601                              <1> snd_play_0:
  5602                              <1> 	;rep	movsb
  5603 000138B5 C1E902              <1> 	shr	ecx, 2  ; convert byte count to dword count
  5604 000138B8 F3A5                <1> 	rep	movsd
  5605                              <1> 
  5606                              <1> 	; here, if [audio_flag] = 0, interrupt handler will update
  5607                              <1> 				; dma half buffer 2 
  5608                              <1> 				; (user's audio buffer data will be 
  5609                              <1> 				; copied into dma half buffer 2) 
  5610                              <1> 	;; 20/05/2017
  5611                              <1> 	;mov	byte [audio_flag], 1 ; next half (on next time)
  5612                              <1> 
  5613                              <1> 	; 24/04/2017
  5614 000138BA A0[B19C0100]        <1> 	mov	al, [audio_device]
  5615 000138BF 3C03                <1> 	cmp	al, 3 ; VT8233 (VT8237R) 
  5616 000138C1 7410                <1> 	je	short snd_play_1
  5617 000138C3 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
  5618 000138C5 7512                <1> 	jne	short snd_play_2  ; 28/05/2017
  5619 000138C7 E8031B0000          <1> 	call	SbInit_play
  5620 000138CC 0F82E7FCFFFF        <1> 	jc	soundc_respond_err
  5621 000138D2 C3                  <1> 	retn
  5622                              <1> 
  5623                              <1> snd_play_1:	
  5624 000138D3 E826190000          <1> 	call	vt8233_start_play
  5625 000138D8 C3                  <1> 	retn
  5626                              <1> 
  5627                              <1> snd_play_2:
  5628                              <1> 	; 28/05/2017
  5629                              <1> 	;cmp	al, 2 ; AC'97
  5630                              <1> 	;jne	short snd_play_3
  5631                              <1> 
  5632 000138D9 E8EA1E0000          <1> 	call	ac97_start_play
  5633 000138DE C3                  <1> 	retn
  5634                              <1> 
  5635                              <1> ;snd_play_3:
  5636                              <1> ;	;call	hda_start_play
  5637                              <1> ;	retn
  5638                              <1> 
  5639                              <1> sound_pause:
  5640                              <1> 	; FUNCTION = 5
  5641                              <1> 	; Pause
  5642                              <1> 	; 28/05/2017
  5643                              <1> 	; 24/04/2017
  5644                              <1> 	; 22/04/2017
  5645 000138DF E814030000          <1> 	call	snd_dev_check
  5646 000138E4 7275                <1> 	jc	short snd_nothing ; temporary.
  5647 000138E6 E81A030000          <1> 	call	snd_buf_check
  5648 000138EB 726E                <1> 	jc	short snd_nothing ; temporary.
  5649 000138ED A0[B19C0100]        <1> 	mov	al, [audio_device]
  5650 000138F2 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
  5651 000138F4 7409                <1> 	je	short snd_pause_1
  5652 000138F6 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
  5653 000138F8 750A                <1> 	jne	short snd_pause_2 ; 28/05/2017
  5654 000138FA E9AE1C0000          <1> 	jmp	sb16_pause
  5655                              <1> snd_pause_1:
  5656 000138FF E9B3190000          <1> 	jmp	vt8233_pause
  5657                              <1> snd_pause_2:
  5658                              <1> 	; 28/05/2017
  5659                              <1> 	;cmp	al, 2 ; AC'97
  5660                              <1> 	;jne	short snd_nothing ; temporary.
  5661 00013904 E94D200000          <1> 	jmp	ac97_pause
  5662                              <1> 
  5663                              <1> sound_continue:
  5664                              <1> 	; FUNCTION = 6
  5665                              <1> 	; Continue to play
  5666                              <1> 	; 28/05/2017
  5667                              <1> 	; 22/04/2017
  5668 00013909 E8EA020000          <1> 	call	snd_dev_check
  5669 0001390E 724B                <1> 	jc	short snd_nothing ; temporary.
  5670 00013910 E8F0020000          <1> 	call	snd_buf_check
  5671 00013915 7244                <1> 	jc	short snd_nothing ; temporary.
  5672 00013917 A0[B19C0100]        <1> 	mov	al, [audio_device]
  5673 0001391C 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
  5674 0001391E 7409                <1> 	je	short snd_cont_1
  5675 00013920 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
  5676 00013922 750A                <1> 	jne	short snd_cont_2 ; 28/05/2017
  5677 00013924 E9A71C0000          <1> 	jmp	sb16_continue
  5678                              <1> snd_cont_1:
  5679 00013929 E93A190000          <1> 	jmp	vt8233_play
  5680                              <1> snd_cont_2:
  5681                              <1> 	; 28/05/2017
  5682                              <1> 	;cmp	al, 2 ; AC'97
  5683                              <1> 	;jne	short snd_nothing ; temporary.
  5684 0001392E E9EB1E0000          <1> 	jmp	ac97_play
  5685                              <1> 
  5686                              <1> sound_stop:
  5687                              <1> 	; FUNCTION = 7
  5688                              <1> 	; Stop playing
  5689                              <1> 	; 28/05/2017
  5690                              <1> 	; 24/05/2017
  5691                              <1> 	; 21/04/2017, 22/04/2017, 24/04/2017
  5692 00013933 E8C0020000          <1> 	call	snd_dev_check
  5693 00013938 7221                <1> 	jc	short snd_nothing ; temporary.
  5694                              <1> 	;call	snd_buf_check
  5695 0001393A E8CF020000          <1> 	call	snd_user_check ; 24/05/2017
  5696 0001393F 721A                <1> 	jc	short snd_nothing ; temporary.	
  5697                              <1> 	
  5698 00013941 A0[B19C0100]        <1> 	mov	al, [audio_device]
  5699 00013946 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
  5700 00013948 0F8470180000        <1> 	je	vt8233_stop
  5701                              <1> 	; 28/05/2017
  5702                              <1> 	;ja	short snd_nothing
  5703 0001394E 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
  5704 00013950 0F849D1C0000        <1> 	je	sb16_stop
  5705                              <1> 	;cmp	al, 2 
  5706                              <1> 	;je	short ac97_stop
  5707 00013956 E9CD1F0000          <1> 	jmp	ac97_stop ; temporary.
  5708                              <1> 	;jmp	hda_stop
  5709                              <1> 
  5710                              <1> snd_nothing:
  5711                              <1> 	; 21/04/2017
  5712 0001395B C3                  <1> 	retn
  5713                              <1> 
  5714                              <1> soundc_reset:
  5715                              <1> 	; FUNCTION = 8
  5716                              <1> 	; Reset Audio Controller
  5717                              <1> 	; 28/05/2017
  5718                              <1> 	; 22/04/2017
  5719 0001395C E897020000          <1> 	call	snd_dev_check
  5720 00013961 72F8                <1> 	jc	snd_nothing ; temporary.
  5721 00013963 E89D020000          <1> 	call	snd_buf_check
  5722 00013968 72F1                <1> 	jc	snd_nothing ; temporary.	
  5723                              <1> 	
  5724 0001396A A0[B19C0100]        <1> 	mov	al, [audio_device]
  5725 0001396F 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
  5726 00013971 0F844C190000        <1> 	je	vt8233_reset
  5727 00013977 77E2                <1> 	ja	short snd_nothing ; temporary.
  5728                              <1> 	;ja	hda_reset	
  5729 00013979 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
  5730 0001397B 0F8526200000        <1> 	jne	ac97_reset	
  5731 00013981 E8BF1C0000          <1> 	call	sb16_reset
  5732 00013986 0F822DFCFFFF        <1> 	jc	soundc_respond_err
  5733 0001398C C3                  <1> 	retn
  5734                              <1> 
  5735                              <1> soundc_cancel:
  5736                              <1> 	; FUNCTION = 9
  5737                              <1> 	; Cancel audio callback service
  5738                              <1> 	; 22/04/2017
  5739 0001398D A0[D99C0100]        <1> 	mov	al, [audio_user]	
  5740 00013992 3A05[B3030300]      <1> 	cmp	al, [u.uno]
  5741 00013998 75C1                <1> 	jne	short snd_nothing
  5742                              <1> 	; RESET (audio) INTERRUPT CALLBACK SERVICE
  5743 0001399A 8A1D[B39C0100]      <1> 	mov	bl, [audio_intr] ; IRQ number
  5744 000139A0 A0[B3030300]        <1> 	mov	al, [u.uno]
  5745 000139A5 28FF                <1> 	sub	bh, bh ; 0 ; unlink IRQ from user service
  5746 000139A7 E8EC020000          <1>  	call	set_irq_callback_service
  5747 000139AC 0F8250FDFFFF        <1> 	jc	sndc_perm_error ; 'permission denied' error
  5748 000139B2 C3                  <1> 	retn
  5749                              <1> 
  5750                              <1> sound_dalloc:
  5751                              <1> 	; FUNCTION = 10
  5752                              <1> 	; Deallocate (ring 3) audio buffer
  5753                              <1> 	; 22/04/2017
  5754 000139B3 A0[D99C0100]        <1> 	mov	al, [audio_user]	
  5755 000139B8 3A05[B3030300]      <1> 	cmp	al, [u.uno]
  5756 000139BE 759B                <1> 	jne	short snd_nothing
  5757 000139C0 8B1D[C49C0100]      <1> 	mov	ebx, [audio_buffer]
  5758                              <1> 	;or	ebx, ebx
  5759                              <1> 	;jz	short snd_nothing
  5760 000139C6 8B0D[CC9C0100]      <1> 	mov	ecx, [audio_buff_size]
  5761 000139CC E80F2EFFFF          <1> 	call	deallocate_user_pages
  5762 000139D1 31C0                <1> 	xor	eax, eax
  5763 000139D3 A3[C49C0100]        <1> 	mov	[audio_buffer], eax ; 0
  5764 000139D8 A2[D99C0100]        <1> 	mov	[audio_user], al ; 0
  5765 000139DD C3                  <1> 	retn
  5766                              <1> 
  5767                              <1> sound_volume:
  5768                              <1> 	; FUNCTION = 11
  5769                              <1> 	; Set sound volume level
  5770                              <1> 	; 28/05/2017
  5771                              <1> 	; 20/05/2017
  5772                              <1> 	; 22/04/2017, 24/04/2017
  5773                              <1> 	; bl = component (0 = master/playback/lineout volume)
  5774                              <1> 	; cl = left channel volume level (0 to 31)
  5775                              <1> 	; ch = right channel volume level (0 to 31)
  5776                              <1> 
  5777 000139DE 80FB80              <1> 	cmp	bl, 80h
  5778 000139E1 720E                <1> 	jb	short snd_vol_1
  5779 000139E3 0F8772FFFFFF        <1> 	ja	snd_nothing ; temporary.
  5780                              <1> 	; Set volume level for next play (BL>= 80h)
  5781 000139E9 66890D[E69C0100]    <1> 	mov	[audio_master_volume], cx
  5782 000139F0 C3                  <1> 	retn
  5783                              <1> snd_vol_1:
  5784                              <1> 	; set volume level immediate (BL< 80h)
  5785 000139F1 80FB00              <1> 	cmp	bl, 0
  5786 000139F4 0F8761FFFFFF        <1> 	ja	snd_nothing ; temporary.
  5787                              <1> 
  5788 000139FA E8F9010000          <1> 	call	snd_dev_check
  5789 000139FF 0F8256FFFFFF        <1> 	jc	snd_nothing ; temporary.
  5790 00013A05 E8FB010000          <1> 	call	snd_buf_check
  5791 00013A0A 0F824BFFFFFF        <1> 	jc	snd_nothing ; temporary.	
  5792                              <1> 
  5793 00013A10 A0[B19C0100]        <1> 	mov	al, [audio_device]
  5794 00013A15 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
  5795 00013A17 0F84BF180000        <1> 	je	vt8233_volume
  5796                              <1> 	; 28/05/2017
  5797 00013A1D 0F8738FFFFFF        <1> 	ja	snd_nothing ; temporary.
  5798                              <1> 	;ja	hda_volume	
  5799                              <1> 	; Sound Blaster 16
  5800 00013A23 3C01                <1> 	cmp	al, 1 ; SB 16
  5801 00013A25 0F844D1B0000        <1> 	je	sb16_volume
  5802 00013A2B E90A1E0000          <1> 	jmp	ac97_volume
  5803                              <1> 
  5804                              <1> soundc_disable:
  5805                              <1> 	; FUNCTION = 12 
  5806                              <1> 	; Disable audio device (and unlink DMA memory)
  5807                              <1> 	; 28/05/2017
  5808                              <1> 	; 24/05/2017
  5809                              <1> 	; 22/04/2017
  5810 00013A30 E8C3010000          <1> 	call	snd_dev_check
  5811 00013A35 0F8270FBFFFF        <1> 	jc	soundc_dev_err ; temporary.
  5812                              <1> 	;call	snd_buf_check
  5813                              <1> 	;jc	sndc_owner_error ; temporary.
  5814                              <1> 
  5815 00013A3B A0[B19C0100]        <1> 	mov	al, [audio_device]
  5816 00013A40 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
  5817 00013A42 7418                <1> 	je	short snd_disable_1
  5818 00013A44 0F8711FFFFFF        <1> 	ja	snd_nothing ; temporary.
  5819 00013A4A 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
  5820 00013A4C 7507                <1> 	jne	short snd_disable_0
  5821 00013A4E E8A01B0000          <1> 	call	sb16_stop
  5822 00013A53 EB0C                <1> 	jmp	short snd_disable_2
  5823                              <1> snd_disable_0:
  5824 00013A55 E8CE1E0000          <1> 	call	ac97_stop
  5825 00013A5A EB05                <1> 	jmp	short snd_disable_2
  5826                              <1> snd_disable_1:
  5827 00013A5C E85D170000          <1> 	call	vt8233_stop
  5828                              <1> snd_disable_2:
  5829 00013A61 A0[B39C0100]        <1> 	mov	al, [audio_intr]
  5830 00013A66 29DB                <1> 	sub	ebx, ebx ; 0 = reset
  5831 00013A68 E851FAFFFF          <1> 	call	set_dev_IRQ_service
  5832                              <1> 
  5833                              <1> 	;mov	al, [audio_intr]
  5834 00013A6D 28E4                <1> 	sub	ah, ah ; 0 = reset
  5835 00013A6F E8B5F6FFFF          <1> 	call	set_hardware_int_vector
  5836                              <1> 
  5837 00013A74 31C0                <1> 	xor	eax, eax
  5838 00013A76 A2[B19C0100]        <1> 	mov	byte [audio_device], al
  5839 00013A7B A2[B39C0100]        <1> 	mov	byte [audio_intr], al
  5840 00013A80 8705[D09C0100]      <1> 	xchg	eax, [audio_dma_buff]
  5841                              <1> 	; 24/05/2017
  5842                              <1> 	;or	eax, eax
  5843                              <1> 	;jz	short snd_disable_3
  5844                              <1> 	;cmp	eax, sb16_dma_buffer ; default DMA buffer
  5845                              <1> 	;je	short snd_disable_3
  5846 00013A86 803D[B09C0100]00    <1> 	cmp	byte [audio_pci], 0 ; AC97 audio controller ?
  5847 00013A8D 7612                <1> 	jna	short snd_disable_3
  5848 00013A8F C605[B09C0100]00    <1> 	mov	byte [audio_pci], 0
  5849                              <1> 	;sub	ecx, ecx
  5850                              <1> 	;xchg	ecx, [audio_dmabuff_size]
  5851 00013A96 8B0D[D49C0100]      <1> 	mov	ecx, [audio_dmabuff_size]
  5852 00013A9C E8F12BFFFF          <1> 	call	deallocate_memory_block
  5853                              <1> snd_disable_3:
  5854 00013AA1 C3                  <1> 	retn
  5855                              <1> 
  5856                              <1> sound_dma_map:
  5857                              <1> 	; FUNCTION = 13 
  5858                              <1> 	; Map audio dma buff addr to user's buffer addr
  5859                              <1> 	; 12/05/2017
  5860 00013AA2 21C9                <1> 	and	ecx, ecx
  5861 00013AA4 0F8408FBFFFF        <1> 	jz	sound_buff_error
  5862 00013AAA 803D[B19C0100]01    <1> 	cmp	byte [audio_device], 1
  5863 00013AB1 7229                <1> 	jb	short snd_dma_map_1
  5864                              <1> snd_dma_map_0:
  5865 00013AB3 A1[D09C0100]        <1> 	mov	eax, [audio_dma_buff]
  5866 00013AB8 21C0                <1> 	and	eax, eax
  5867 00013ABA 7420                <1> 	jz	short snd_dma_map_1
  5868                              <1> 	;
  5869 00013ABC 8A1D[D99C0100]      <1> 	mov	bl, [audio_user]
  5870 00013AC2 08DB                <1> 	or	bl, bl
  5871 00013AC4 7416                <1> 	jz	short snd_dma_map_1
  5872 00013AC6 3A1D[B3030300]      <1> 	cmp	bl, [u.uno]
  5873 00013ACC 0F852BFCFFFF        <1> 	jne	sndc_owner_error
  5874                              <1> 	;
  5875 00013AD2 8B1D[D49C0100]      <1> 	mov	ebx, [audio_dmabuff_size]
  5876 00013AD8 21DB                <1> 	and	ebx, ebx
  5877 00013ADA 750A                <1> 	jnz	short snd_dma_map_2
  5878                              <1> snd_dma_map_1:
  5879 00013ADC B8[00000200]        <1> 	mov	eax, sb16_dma_buffer
  5880 00013AE1 BB00000100          <1> 	mov	ebx, 65536
  5881                              <1> snd_dma_map_2:	
  5882 00013AE6 81C1FF0F0000        <1> 	add	ecx, PAGE_SIZE-1 ; 4095
  5883 00013AEC 6681E100F0          <1> 	and	cx, ~PAGE_OFF ; not 4095
  5884 00013AF1 39D9                <1> 	cmp	ecx, ebx
  5885 00013AF3 0F87B9FAFFFF        <1> 	ja	sound_buff_error
  5886 00013AF9 50                  <1> 	push	eax
  5887 00013AFA 89D3                <1> 	mov	ebx, edx
  5888 00013AFC C1E90C              <1> 	shr	ecx, 12 ; byte count to page count
  5889                              <1> 	; eax = physical address of (audio) dma buffer
  5890                              <1> 	; ebx = virtual address of (audio) dma buffer (user's pgdir) 
  5891                              <1> 	; ecx = page count (>0)
  5892 00013AFF E8FE2BFFFF          <1> 	call	direct_memory_access
  5893 00013B04 58                  <1> 	pop	eax
  5894 00013B05 0F82A7FAFFFF        <1> 	jc	sound_buff_error
  5895 00013B0B A3[64030300]        <1> 	mov	[u.r0], eax
  5896 00013B10 C3                  <1> 	retn
  5897                              <1> 
  5898                              <1> soundc_info:
  5899                              <1> 	; FUNCTION = 14 
  5900                              <1> 	; Get Audio Controller Info
  5901                              <1> 	; 10/06/2017
  5902                              <1> 	; 05/06/2017
  5903 00013B11 20DB                <1> 	and	bl, bl ; 0
  5904 00013B13 740A                <1> 	jz	short sndc_info_0
  5905                              <1> 	; invalid parameter !
  5906 00013B15 B817000000          <1> 	mov	eax, ERR_INV_PARAMETER ; 23
  5907                              <1> ;sndc_inf_error:
  5908                              <1> ;	mov	[u.r0], eax
  5909                              <1> ;	mov	[u.error], eax
  5910                              <1> ;	jmp	error
  5911 00013B1A E99FFAFFFF          <1> 	jmp	sysaudio_err
  5912                              <1> 
  5913                              <1> sndc_info_0:
  5914 00013B1F E8D4000000          <1> 	call	snd_dev_check
  5915 00013B24 0F8281FAFFFF        <1> 	jc	soundc_dev_err
  5916                              <1> 
  5917 00013B2A 8B1D[BC9C0100]      <1> 	mov	ebx, [audio_vendor]
  5918 00013B30 8B0D[B89C0100]      <1> 	mov	ecx, [audio_dev_id]
  5919                              <1> 	;mov	al,  [audio_device]
  5920 00013B36 3C02                <1> 	cmp	al, 2 ; AC'97 (ICH)
  5921 00013B38 7513                <1> 	jne	short sndc_info_1
  5922                              <1> 	; Intel AC97 (ICH) Audio Controller (=2)	
  5923 00013B3A 668B15[EA9C0100]    <1> 	mov	dx, [NABMBAR]
  5924 00013B41 C1E210              <1> 	shl	edx, 16
  5925 00013B44 668B15[E89C0100]    <1> 	mov	dx, [NAMBAR]
  5926 00013B4B EB07                <1> 	jmp	short sndc_info_2
  5927                              <1> sndc_info_1:
  5928                              <1> 	; 05/06/2017
  5929                              <1> 	; Note: Intel HDA code (here) is not ready yet!
  5930                              <1> 	; !!! SB16 or VT8233 (VT8237R) !!!
  5931 00013B4D 0FB715[B69C0100]    <1> 	movzx	edx, word [audio_io_base]	
  5932                              <1> sndc_info_2:
  5933 00013B54 88C4                <1> 	mov	ah, al ;  [audio_device]
  5934 00013B56 A0[B39C0100]        <1> 	mov	al, [audio_intr] 
  5935                              <1> 
  5936                              <1> 	; EAX = IRQ Number in AL
  5937                              <1> 	;	Audio Device Number in AH 
  5938                              <1> 	; EBX = DEV/VENDOR ID
  5939                              <1> 	;	(DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV)
  5940                              <1> 	; ECX = BUS/DEV/FN 
  5941                              <1> 	;	(00000000BBBBBBBBDDDDDFFF00000000)
  5942                              <1> 	; EDX = NABMBAR/NAMBAR (for AC97)
  5943                              <1> 	;	(Low word, DX = NAMBAR address)
  5944                              <1> 	; EDX = Base IO Addr (DX) for SB16 & VT8233
  5945                              <1> 
  5946                              <1> 	; 10/06/2017
  5947 00013B5B A3[64030300]        <1> 	mov	[u.r0], eax
  5948 00013B60 8B2D[60030300]      <1> 	mov	ebp, [u.usp]
  5949 00013B66 895D10              <1> 	mov	[ebp+16], ebx  ; ebx
  5950 00013B69 895514              <1> 	mov	[ebp+20], edx  ; edx
  5951 00013B6C 894D18              <1> 	mov	[ebp+24], ecx  ; ecx
  5952                              <1>   			  		
  5953 00013B6F C3                  <1>  	retn
  5954                              <1> 
  5955                              <1> sound_data:
  5956                              <1> 	; FUNCTION = 15 
  5957                              <1> 	; Get Current Sound data for graphics
  5958                              <1> 	; 22/06/2017
  5959                              <1> 	;
  5960 00013B70 E883000000          <1> 	call	snd_dev_check
  5961 00013B75 0F8230FAFFFF        <1> 	jc	soundc_dev_err ; Device not ready !
  5962                              <1> 
  5963 00013B7B 80FB00              <1> 	cmp	bl, 0
  5964 00013B7E 760A                <1> 	jna	short sound_data_0
  5965                              <1> 
  5966                              <1> 	; Only PCM OUT buffer data is valid for now!
  5967 00013B80 B817000000          <1> 	mov	eax, ERR_INV_PARAMETER  ; 23
  5968 00013B85 E934FAFFFF          <1> 	jmp	sysaudio_err
  5969                              <1> 
  5970                              <1> sound_data_0:
  5971 00013B8A A1[D09C0100]        <1> 	mov	eax, [audio_dma_buff]
  5972 00013B8F 09C0                <1> 	or	eax, eax
  5973 00013B91 0F841BFAFFFF        <1> 	jz	sound_buff_error
  5974                              <1> 
  5975 00013B97 803D[B19C0100]04    <1> 	cmp	byte [audio_device], 4 ; Intel HDA
  5976 00013B9E 744F                <1> 	je	short sound_data_4 ; temporary ! (22/06/2017)
  5977                              <1> 
  5978 00013BA0 21C9                <1> 	and	ecx, ecx
  5979                              <1> 	;jnz	short sound_data_1 ; sample tranfer
  5980                              <1> 	
  5981                              <1> 	; Return only DMA Buffer pointer/offset... 
  5982                              <1> 	; (If DMA Buffer has been mapped to user's
  5983                              <1> 	;  memory space; program can get graphics
  5984                              <1> 	;  data by using only this pointer value.)
  5985                              <1> 	   	
  5986                              <1> 	;call	get_dma_buffer_offset
  5987                              <1> 	;; eax = DMA buffer offset
  5988                              <1> 	;;	(!not half buffer offset!)
  5989                              <1> 	;mov	[u.r0], eax
  5990                              <1> 	;retn
  5991                              <1> 
  5992 00013BA2 0F84771F0000        <1> 	jz	get_dma_buffer_offset	
  5993                              <1> 	
  5994                              <1> sound_data_1:
  5995                              <1> 	;mov	eax, [audio_dmabuff_size]
  5996                              <1> 	;shr	eax, 1 ; half buffer size
  5997                              <1> 	;cmp	ecx, eax
  5998                              <1> 	;ja	short sound_buff_error	
  5999                              <1> 
  6000 00013BA8 3B0D[D49C0100]      <1> 	cmp	ecx, [audio_dmabuff_size]
  6001 00013BAE 0F87FEF9FFFF        <1> 	ja	sound_buff_error
  6002                              <1> 
  6003 00013BB4 89D0                <1> 	mov	eax, edx
  6004 00013BB6 25FF0F0000          <1> 	and	eax, PAGE_OFF ; 4095 (0FFFh)
  6005 00013BBB 81F900100000        <1> 	cmp	ecx, 4096
  6006 00013BC1 7605                <1> 	jna	short sound_data_2
  6007 00013BC3 B900100000          <1> 	mov	ecx, 4096 ; max. 1 page
  6008                              <1> sound_data_2:
  6009 00013BC8 01C8                <1> 	add	eax, ecx
  6010 00013BCA 3D00100000          <1> 	cmp	eax, 4096
  6011 00013BCF 7606                <1> 	jna	short sound_data_3
  6012 00013BD1 6625FF0F            <1> 	and	ax, PAGE_OFF ; 4095 (0FFFh)
  6013 00013BD5 29C1                <1> 	sub	ecx, eax
  6014                              <1> 	; here, ECX has been adjusted to fit 
  6015                              <1> 	;	in page border..  (<= 4096, >0)
  6016                              <1> sound_data_3:
  6017 00013BD7 51                  <1> 	push	ecx
  6018 00013BD8 52                  <1> 	push	edx
  6019 00013BD9 89D3                <1> 	mov	ebx, edx 
  6020 00013BDB E81027FFFF          <1> 	call	get_physical_addr
  6021 00013BE0 5A                  <1> 	pop	edx
  6022 00013BE1 59                  <1> 	pop	ecx
  6023 00013BE2 0F82CAF9FFFF        <1> 	jc	sound_buff_error	
  6024                              <1> 	
  6025                              <1> 	; eax = physical address of user's buffer
  6026 00013BE8 89C3                <1> 	mov	ebx, eax  
  6027                              <1> 	; ecx = byte (transfer) count
  6028                              <1> 	;call	get_current_sound_data
  6029                              <1> 	;retn
  6030 00013BEA E98D1E0000          <1> 	jmp	get_current_sound_data
  6031                              <1> 
  6032                              <1> sound_data_4:
  6033                              <1> 	; Intel HDA code is not ready yet !
  6034                              <1> 	; 22/06/2017
  6035 00013BEF 31C0                <1> 	xor	eax, eax
  6036 00013BF1 48                  <1> 	dec	eax
  6037 00013BF2 A3[64030300]        <1> 	mov	[u.r0], eax ; 0FFFFFFFFh
  6038 00013BF7 C3                  <1> 	retn 
  6039                              <1> 
  6040                              <1> snd_dev_check:
  6041                              <1> 	; 10/06/2017
  6042                              <1> 	; 05/06/2017
  6043                              <1> 	; 24/05/2017
  6044                              <1> 	; 22/04/2017
  6045                              <1> 	; 21/04/2017
  6046                              <1> 	; ... device check at first
  6047 00013BF8 A0[B19C0100]        <1> 	mov	al, [audio_device]
  6048 00013BFD 3C01                <1> 	cmp	al, 1 ; SB 16
  6049 00013BFF 7203                <1> 	jb	short snd_dev_chk_retn ; error !
  6050                              <1> 	;cmp	al, 4 ; Intel HDA
  6051                              <1> 	;ja	short snd_dbchk_stc ; invalid !
  6052                              <1> 	; 10/06/2017
  6053 00013C01 3C05                <1> 	cmp	al, 5
  6054 00013C03 F5                  <1> 	cmc
  6055                              <1> snd_dev_chk_retn:
  6056 00013C04 C3                  <1> 	retn
  6057                              <1> 
  6058                              <1> snd_buf_check:
  6059                              <1> 	; 10/06/2017
  6060                              <1> 	; 22/04/2017
  6061                              <1> 	; 21/04/2017
  6062                              <1> 	; ... buffer & (buffer) owner check at second
  6063 00013C05 833D[C49C0100]00    <1> 	cmp	dword [audio_buffer], 0
  6064 00013C0C 760D                <1> 	jna	short snd_dbchk_stc
  6065                              <1> snd_user_check:
  6066 00013C0E A0[B3030300]        <1> 	mov	al, [u.uno]
  6067 00013C13 3A05[D99C0100]      <1> 	cmp	al, [audio_user]
  6068                              <1> 	;jne	short snd_dbchk_stc
  6069                              <1> 	;retn
  6070 00013C19 74E9                <1> 	je	short snd_dev_chk_retn
  6071                              <1> 
  6072                              <1> snd_dbchk_stc:
  6073 00013C1B F9                  <1> 	stc
  6074 00013C1C C3                  <1> 	retn
  6075                              <1> 
  6076                              <1> sound_update:
  6077                              <1> 	; FUNCTION = 16 
  6078                              <1> 	; bl = 
  6079                              <1> 	;    0 = automatic (sequental) update (with flag switch!)
  6080                              <1> 	;    1 = update dma half buffer 1 (without flag switch!)		
  6081                              <1> 	;    2 = update dma half buffer 2 (without flag switch!)
  6082                              <1> 	;  FFh = get current flag value	
  6083                              <1> 	;      0 = dma half buffer 1 (will be played next)
  6084                              <1> 	;      1 = dma half buffer 2 (will be played next)
  6085                              <1> 	
  6086                              <1> 	; 10/10/2017
  6087                              <1> 	
  6088                              <1> 	; ... device check at first
  6089 00013C1D A0[B19C0100]        <1> 	mov	al, [audio_device]
  6090 00013C22 08C0                <1> 	or	al, al ; 0 ; pc speaker or invalid 
  6091 00013C24 0F8481F9FFFF        <1> 	jz	soundc_dev_err
  6092                              <1> 
  6093                              <1> 	; ... buffer & (buffer) owner check at second
  6094 00013C2A 833D[C49C0100]00    <1> 	cmp	dword [audio_buffer], 0
  6095 00013C31 0F867BF9FFFF        <1> 	jna	sound_buff_error
  6096 00013C37 A0[B3030300]        <1> 	mov	al, [u.uno]
  6097 00013C3C 3A05[D99C0100]      <1> 	cmp	al, [audio_user]
  6098 00013C42 0F85B5FAFFFF        <1> 	jne	sndc_owner_error
  6099                              <1> 
  6100                              <1> 	; Transfer ring 3 (user's) audio buffer content to dma buffer
  6101 00013C48 8B3D[D09C0100]      <1> 	mov	edi, [audio_dma_buff] ; dma buffer (ring 0)
  6102 00013C4E 09FF                <1> 	or	edi, edi
  6103 00013C50 0F845CF9FFFF        <1> 	jz	sound_buff_error
  6104 00013C56 8B35[C89C0100]      <1> 	mov	esi, [audio_p_buffer] ; physical address (ring 3)
  6105 00013C5C 8B0D[CC9C0100]      <1> 	mov	ecx, [audio_buff_size]
  6106                              <1> 	
  6107                              <1> 	;movzx	eax, byte [audio_flag]
  6108 00013C62 A0[D89C0100]        <1> 	mov	al, [audio_flag]
  6109                              <1> 
  6110 00013C67 FEC3                <1> 	inc	bl
  6111 00013C69 7427                <1> 	jz	short snd_update_3 ; bl = 0FFh
  6112 00013C6B FECB                <1> 	dec	bl 
  6113 00013C6D 7411                <1> 	jz	short snd_update_0 ; bl = 0
  6114                              <1> 
  6115 00013C6F 80FB02              <1> 	cmp	bl, 2
  6116 00013C72 7417                <1> 	je	short snd_update_1 ; dma half buffer 2
  6117 00013C74 7217                <1> 	jb	short snd_update_2 ; dma half buffer 1
  6118                              <1>  
  6119                              <1> 	; invalid parameter !
  6120 00013C76 B817000000          <1> 	mov	eax, ERR_INV_PARAMETER ; 23
  6121                              <1> ;	mov	[u.r0], eax
  6122                              <1> ;	mov	[u.error], eax
  6123                              <1> ;	jmp	error
  6124 00013C7B E93EF9FFFF          <1> 	jmp	sysaudio_err
  6125                              <1> 	
  6126                              <1> snd_update_0:
  6127 00013C80 8035[D89C0100]01    <1> 	xor	byte [audio_flag], 1 ; update flag !!!
  6128 00013C87 3C01                <1> 	cmp	al, 1
  6129 00013C89 7202                <1> 	jb	short snd_update_2 ; dma half buffer 1
  6130                              <1> snd_update_1:
  6131                              <1> 	; dma half buffer 2
  6132 00013C8B 01CF                <1> 	add	edi, ecx
  6133                              <1> snd_update_2:
  6134                              <1> 	;rep	movsb
  6135 00013C8D C1E902              <1> 	shr	ecx, 2
  6136 00013C90 F3A5                <1> 	rep	movsd
  6137                              <1> snd_update_3:
  6138 00013C92 A3[64030300]        <1> 	mov	[u.r0], eax
  6139                              <1> 
  6140 00013C97 C3                  <1> 	retn
  6141                              <1> 	
  6142                              <1> set_irq_callback_service:
  6143                              <1> 	; 03/08/2020
  6144                              <1> 	; 10/06/2017
  6145                              <1> 	; 12/05/2017
  6146                              <1> 	; 24/04/2017
  6147                              <1> 	; 22/04/2017
  6148                              <1> 	; caller: 'syscalbac' or 'sysaudio' or ...
  6149                              <1> 	; 13/04/2017, 14/04/2017, 17/04/2017
  6150                              <1> 	; 24/02/2017, 26/02/2017, 28/02/2017
  6151                              <1> 	; 21/02/2017 - TRDOS 386 (TRDOS v2.0)
  6152                              <1> 	;
  6153                              <1> 	; Link or unlink IRQ callback service to/from user (ring 3)	
  6154                              <1> 	;
  6155                              <1> 	; INPUT ->
  6156                              <1> 	;	If AL = 0, the caller is 'syscalbac';
  6157                              <1> 	;	   otherwise, the caller is 'sysaudio' or ...
  6158                              <1> 	;	   (AL = user number) 
  6159                              <1> 	; 	 
  6160                              <1> 	;	BL = IRQ number (Hardware interrupt request number)
  6161                              <1> 	;	     (0 t0 15 but IRQ 0,1,2,6,8,14,15 are prohibited)
  6162                              <1> 	;	     IRQ numbers 3,4,5,7,9,10,11,12,13 are valid
  6163                              <1> 	;	     (numbers >15 are invalid)
  6164                              <1> 	;
  6165                              <1> 	;	BH = 0 = Unlink IRQ (in BL) from user (ring 3) service
  6166                              <1> 	;	     1 = Link IRQ by using Signal Response Byte method
  6167                              <1> 	;	     2 = Link IRQ by using Callback service method 		
  6168                              <1> 	;	     3 = Link IRQ by using Auto Increment S.R.B. method 	
  6169                              <1> 	;	    >3 = invalid 
  6170                              <1> 	;		 (syscallback version will return to user) 	
  6171                              <1> 	;	
  6172                              <1> 	;	CL = Signal Return/Response Byte value 
  6173                              <1> 	;
  6174                              <1> 	;	If BH = 3, kernel will put a counter value ; 03/08/2020
  6175                              <1> 	;	          (into the S.R.B. addr)
  6176                              <1> 	;		  between 0 to 255. (start value = CL+1)
  6177                              <1> 	;	
  6178                              <1> 	;	NOTE: counter value, for example: even and odd numbers
  6179                              <1> 	;	      may be used for -audio- DMA buffer switch 
  6180                              <1> 	;	      within double buffer method, etc. 		
  6181                              <1> 	;
  6182                              <1> 	;	EDX = Signal return (Response) byte address
  6183                              <1> 	;	       		  - or -
  6184                              <1> 	;	      Interrupt/Callback service/routine address
  6185                              <1> 	; 	
  6186                              <1> 	;	      (virtual address in user's memory space)
  6187                              <1> 	;
  6188                              <1> 	; OUTPUT ->
  6189                              <1> 	;	CF = 0 & EAX = 0 -> Successful setting
  6190                              <1> 	;	CF = 1 & EAX > 0 -> IRQ is prohibited or locked 
  6191                              <1> 	;			by another process
  6192                              <1> 	;		 eax = ERR_PERM_DENIED -> prohibited or locked
  6193                              <1> 	;		 eax = ERR_INV_PARAMETER -> 
  6194                              <1> 	;		       invalid parameter/option or bad address
  6195                              <1> 	;
  6196                              <1> 	; TRDOS 386 - IRQ CALLBACK structures (parameters):
  6197                              <1> 	;	
  6198                              <1> 	;	   [u.irqlock] = 1 word, IRQ flags (0-15) that indicates
  6199                              <1> 	;			which IRQs are locked by (that) user.
  6200                              <1> 	;		        Lock and unlock (by user) will change
  6201                              <1> 	;			these flags or 'terminate process' (sysexit)
  6202                              <1> 	;			will clear these flags and unlock those IRQs.
  6203                              <1> 	;			               
  6204                              <1> 	;		   	Bit 0 is for IRQ 0 and Bit 15 is for IRQ 15
  6205                              <1> 	;
  6206                              <1> 	;	   IRQ(x).owner	 : 1 byte, user, [u.uno], 0 = free (unlocked)	
  6207                              <1> 	;
  6208                              <1> 	;	   IRQ(x).method : 1 byte for callback method & status
  6209                              <1> 	;			   0 = Signal Response Byte method
  6210                              <1> 	;			   1 = Callback service method
  6211                              <1> 	;			   >1 = invalid for current 'syscalback'.
  6212                              <1> 	;			or(+) 80h = IRQ is in use by system (ring 0)
  6213                              <1> 	;			            function (audio etc.) or
  6214                              <1> 	;			   	    a device driver.	   	
  6215                              <1> 	;			(system function will ignore the lock/owner)
  6216                              <1> 	;
  6217                              <1> 	;	   IRQ(x).srb	: 1 byte, Signal Return/Response byte value
  6218                              <1> 	;			  (a fixed value by user or a counter value
  6219                              <1> 	;			 from 0 to 255, which is increased by every
  6220                              <1> 	;			 interrupt just before putting it into 
  6221                              <1> 	;			 the Signal Response byte address
  6222                              <1> 	;			 (This is not used in callback serv method)
  6223                              <1> 	;	    	  
  6224                              <1> 	;	   IRQ(x).addr	: 1 dword
  6225                              <1> 	;			  Signal Response Byte address (physical)
  6226                              <1> 	;			  		-or-
  6227                              <1> 	;			  Callback service address (virtual)
  6228                              <1> 	;
  6229                              <1> 	;	   IRQ(x).dev	: 1 byte
  6230                              <1> 	;			  0 = Default device or kernel function
  6231                              <1> 	;			  		-or-
  6232                              <1> 	;			  1-255 = Assigned device driver number
  6233                              <1> 	;
  6234                              <1> 	;	   (x) = 3,4,5,7,9,10,11,12,13
  6235                              <1> 	;
  6236                              <1> 	
  6237 00013C98 80FB0F              <1> 	cmp	bl, 15
  6238 00013C9B 7729                <1> 	ja	short scbs_2
  6239                              <1> 	
  6240 00013C9D 80FF03              <1> 	cmp	bh, 3
  6241 00013CA0 7724                <1> 	ja	short scbs_2  ; invalid parameter
  6242                              <1> 
  6243 00013CA2 0FB6FB              <1> 	movzx	edi, bl ; save IRQ number
  6244                              <1> 
  6245                              <1> 		;  IRQ 0,1,2,6,8,14,15 are prohibited
  6246                              <1> 	;IRQenum: ; 'trdosk9.s'
  6247                              <1> 	;	db  0,0,0,1,2,3,0,4,0,5,6,7,8,9,0,0
  6248                              <1> 
  6249 00013CA5 0FB6B7[F8490100]    <1> 	movzx	esi, byte [edi+IRQenum] ; IRQ availability 
  6250                              <1> 					; enumeration/index
  6251                              <1> 	;dec	esi
  6252 00013CAC 664E                <1> 	dec	si
  6253 00013CAE 780F                <1> 	js	short scbs_1 ;  0 -> 0FFFFh  
  6254                              <1> 
  6255                              <1> 	; ESI = IRQ callback parameters index number (0 to 8)
  6256                              <1> 
  6257 00013CB0 08FF                <1> 	or	bh, bh
  6258 00013CB2 7419                <1> 	jz	short scbs_4 ; unlink the IRQ (in BL)
  6259                              <1> 
  6260 00013CB4 FECF                <1> 	dec	bh
  6261                              <1> 	; bh = method (0 = signal response byte, 1 = callback)
  6262                              <1> 	;	      (2 = auto increment of signal response byte) 
  6263                              <1> 
  6264 00013CB6 80BE[629C0100]00    <1> 	cmp	byte [esi+IRQ.owner], 0 ; locked ?
  6265 00013CBD 7637                <1> 	jna	short scbs_6	; no... OK...	
  6266                              <1> 
  6267                              <1> scbs_1:
  6268                              <1> 	; permission denied (prohibited IRQ)
  6269 00013CBF B80B000000          <1> 	mov	eax, ERR_PERM_DENIED
  6270 00013CC4 F9                  <1> 	stc
  6271 00013CC5 C3                  <1> 	retn
  6272                              <1> scbs_2:
  6273 00013CC6 F9                  <1> 	stc
  6274                              <1> scbs_3:
  6275 00013CC7 B817000000          <1> 	mov	eax, ERR_INV_PARAMETER
  6276 00013CCC C3                  <1> 	retn
  6277                              <1> 
  6278                              <1> scbs_4: ; unlink the requested IRQ (if it belongs to current user)
  6279                              <1> 	; 10/06/2017
  6280                              <1> 	; 22/04/2017
  6281                              <1> 	; 14/04/2017
  6282                              <1> 	; If AL = 0 -> The caller is 'syscalbac'
  6283 00013CCD 8AA6[629C0100]      <1> 	mov	ah, [esi+IRQ.owner]
  6284 00013CD3 3A25[B3030300]      <1> 	cmp	ah, [u.uno]
  6285 00013CD9 75E4                <1> 	jne	short scbs_1
  6286                              <1> 
  6287 00013CDB FE0D[D6030300]      <1> 	dec	byte [u.irqc] ; decrease IRQ count (in use)
  6288                              <1> 
  6289                              <1> 	;sub	ah, ah
  6290                              <1> 	;mov	[esi+IRQ.owner], ah ; 0 ; free !!!
  6291                              <1> 	;and	byte [esi+IRQ.method], 80h
  6292                              <1> 	;mov	[esi+IRQ.srb], ah ; 0
  6293                              <1> 	;mov	[esi+IRQ.dev], ah ; 0
  6294                              <1> 	;mov	dword [esi+IRQ.addr], 0
  6295                              <1> 	;mov	dword [u.r0], 0
  6296                              <1> 
  6297                              <1> 	;mov	byte [esi+IRQ.owner], 0
  6298                              <1> 
  6299                              <1> 	; 22/04/2017
  6300 00013CE1 29C0                <1> 	sub	eax, eax
  6301 00013CE3 8886[629C0100]      <1> 	mov	[esi+IRQ.owner], al ; 0
  6302                              <1> 	; 10/06/2017
  6303 00013CE9 8686[749C0100]      <1> 	xchg	al, [esi+IRQ.method]
  6304 00013CEF 2480                <1> 	and	al, 80h
  6305 00013CF1 745E                <1> 	jz	short scbs_12 
  6306                              <1> 	; Audio device must be disabled -later- ! ([IRQ.medhod] = 80h)
  6307                              <1> 
  6308                              <1> ;	cmp	byte [esi+IRQ.method], 80h ; device drv or kernel extension ?
  6309                              <1> ;	jb	short scbs_12 ; bh = 0 reset to default IRQ handler
  6310                              <1> ;
  6311                              <1> ;	and	al, al
  6312                              <1> ;	jz	short  scbs_5  ; the caller is 'syscalbac'
  6313                              <1> ;	; The caller is 'sysaudio' or ...
  6314 00013CF3 30C0                <1> 	xor	al, al
  6315                              <1> ;	mov	[esi+IRQ.method], al ; 0 ; reset kernel extension flag
  6316                              <1> ;scbs_5:
  6317                              <1> ;	sub	ah, ah
  6318                              <1> 	;mov	[u.r0], eax ; 0
  6319 00013CF5 C3                  <1> 	retn	
  6320                              <1> 
  6321                              <1> scbs_6:
  6322                              <1> 	; 14/04/2017
  6323 00013CF6 20C0                <1> 	and	al, al
  6324 00013CF8 7405                <1> 	jz	short scbs_7  ; the caller is 'syscalbac'
  6325                              <1> 	; AL = user number ([u.uno] or [audio.user] or ...)
  6326                              <1> 	; The caller is 'sysaudio' or ...
  6327                              <1> 	;	
  6328                              <1> 	; bh = method (0 = signal response byte, 1 = callback)
  6329                              <1> 	;	      (2 = auto increment of signal response byte) 
  6330                              <1> 
  6331 00013CFA 80CF80              <1> 	or	bh, 80h		; Kernel extension flag !
  6332 00013CFD EB0A                <1> 	jmp	short scbs_8
  6333                              <1> scbs_7:	
  6334 00013CFF 8A86[749C0100]      <1> 	mov	al, [esi+IRQ.method] ; >= 80h = kernel is using this IRQ
  6335 00013D05 2480                <1> 	and	al, 80h ; use only bit 7 (kernel function flag)
  6336 00013D07 08C7                <1> 	or	bh, al		 ; method 
  6337                              <1> 				 ; 0 = signal response byte, 1 = callback
  6338                              <1> 				 ; 2 = auto increment of s.r.b.
  6339                              <1> scbs_8:
  6340 00013D09 A0[B3030300]        <1> 	mov	al, [u.uno] ; user (process) number (1 to 16)
  6341 00013D0E 8886[629C0100]      <1> 	mov	[esi+IRQ.owner], al ; lock the IRQ for user
  6342 00013D14 88BE[749C0100]      <1> 	mov	[esi+IRQ.method], bh
  6343                              <1> 
  6344                              <1> ;	test	bh, 1
  6345                              <1> ;	jnz	short scbs_9 	 ; Callback method, CX will not be used 
  6346                              <1> ;			
  6347                              <1> ;	test	bh, 2		 ; use auto increment (counter) method
  6348                              <1> ;	jz	short scbs_10	 ; (count can be used for buffer switch)
  6349                              <1> ;scbs_9:
  6350                              <1> ;	xor	ecx, ecx ; 0
  6351                              <1> scbs_10:			      	
  6352                              <1> 	;mov	[esi+IRQ.method], bh
  6353 00013D1A 888E[7D9C0100]      <1> 	mov	[esi+IRQ.srb], cl
  6354 00013D20 C686[6B9C0100]00    <1> 	mov	byte [esi+IRQ.dev], 0 ; device number is always 0 
  6355                              <1> 				 ; for this system call
  6356                              <1> 	;test	bh, 1
  6357 00013D27 80E701              <1> 	and	bh, 1 ; 17/04/2017
  6358 00013D2A 7513                <1> 	jnz	short scbs_11	 ; callback method, use virtual address 
  6359                              <1> 
  6360 00013D2C 53                  <1> 	push	ebx ; IRQ number (in BL)
  6361 00013D2D 89D3                <1> 	mov	ebx, edx
  6362                              <1> 	; ebx = virtual address
  6363                              <1> 	; [u.pgdir] = page directory's physical address
  6364 00013D2F FE05[029C0100]      <1> 	inc	 byte [no_page_swap] ; 1 
  6365                              <1> 			; Do not add this page to swap queue
  6366                              <1> 			; and remove it from swap queue if it is
  6367                              <1> 			; on the queue.
  6368 00013D35 E8B625FFFF          <1> 	call	get_physical_addr
  6369 00013D3A 5B                  <1> 	pop	ebx
  6370 00013D3B 728A                <1> 	jc	scbs_3 ; invalid address !
  6371                              <1> 	; eax = physical address of the virtual address in user's space
  6372 00013D3D 89C2                <1> 	mov	edx, eax
  6373                              <1> scbs_11:
  6374 00013D3F 66C1E602            <1> 	shl	si, 2		; byte (index) to dword (offset)
  6375 00013D43 8996[869C0100]      <1> 	mov	[esi+IRQ.addr], edx
  6376                              <1> 
  6377 00013D49 FE05[D6030300]      <1> 	inc	byte [u.irqc]	; increase IRQ (in use) count
  6378                              <1> 
  6379 00013D4F FEC7                <1> 	inc	 bh ; 17/04/2017
  6380                              <1> 	; bh > 0 -> set to requested IRQ handler (IRQ_u_list)
  6381                              <1> scbs_12:
  6382 00013D51 88D8                <1> 	mov	al, bl ; IRQ number
  6383 00013D53 88FC                <1> 	mov	ah, bh ; 0 = reset, >0 = set
  6384 00013D55 E8CFF3FFFF          <1> 	call	set_hardware_int_vector
  6385                              <1> 
  6386 00013D5A 31C0                <1> 	xor	eax, eax
  6387                              <1> 	;mov 	[u.r0], eax ; 0	
  6388                              <1> 
  6389 00013D5C C3                  <1> 	retn	; return with success (cf=0, eax=0)
  6390                              <1> 
  6391                              <1> 
  6392                              <1> sysdma: ; DMA FUNCTIONS
  6393                              <1> 	; 02/09/2017
  6394                              <1> 	; 28/08/2017
  6395                              <1> 	; 20/08/2017 - TRDOS 386 (TRDOS v2.0)
  6396                              <1> 	;
  6397                              <1> 	; Inputs:
  6398                              <1> 	;	BH = 0 -> Allocate DMA buffer
  6399                              <1> 	;	   BL = 0 -> Use the system's default DMA
  6400                              <1> 	;		     (SB16) Buffer
  6401                              <1> 	;	        Buffer Size (max.) = 65536 bytes
  6402                              <1> 	;	   BL > 0 -> Allocate (a new) DMA buffer
  6403                              <1>  	;	   ECX = DMA Buffer Size in bytes (<=128KB)
  6404                              <1> 	;	   EDX = Virtual Address of DMA buffer 	
  6405                              <1> 	;		
  6406                              <1> 	;	BH = 1 -> Initialize (Start) DMA service
  6407                              <1> 	;	     BL, bit 0 to 3 = Channel Number (0 to 7)	
  6408                              <1> 	;	     BL, bit 7 = Auto Initialized Mode 
  6409                              <1> 	;			(If bit 7 is set)
  6410                              <1> 	;		 bit 6 = Record (read) mode (0= playback)
  6411                              <1> 	;	     ECX = byte count (0 = use dma buffer size)
  6412                              <1> 	;	     EDX = physical buffer address
  6413                              <1> 	;	     	   (0 = use dma buffer -start- address)		
  6414                              <1> 	;
  6415                              <1> 	;	BH = 2 -> Get Current DMA Buffer Offset
  6416                              <1> 	;	     BL = DMA channel number	
  6417                              <1> 	;		
  6418                              <1> 	;	BH = 3 -> Get Current DMA count down value
  6419                              <1> 	;	     BL = DMA channel number (0 tO 7)	
  6420                              <1> 	;
  6421                              <1> 	;	BH = 4 -> Get Current DMA channel (in progress)
  6422                              <1> 	;
  6423                              <1> 	;	BH = 5 -> Get System's Default DMA Buffer Address
  6424                              <1> 	;
  6425                              <1> 	;	BH = 6 -> Get Current DMA Buffer Address	
  6426                              <1> 	;
  6427                              <1> 	;	BH = 7 -> Stop DMA service
  6428                              <1> 	;
  6429                              <1> 	;
  6430                              <1> 	; Outputs:
  6431                              <1> 	;
  6432                              <1> 	;	For BH = 0 ; Allocate DMA buffer
  6433                              <1> 	;	    EAX = Physical address of DMA buffer
  6434                              <1> 	;	    ECX = Allocated buffer size in bytes
  6435                              <1> 	;		  - page count * 4096 -
  6436                              <1> 	;		  (may be bigger than requested)	
  6437                              <1> 	;	    If BL input > 0,
  6438                              <1> 	;	       'sysalloc:' system call will be used with
  6439                              <1>   	;	       EBX (for 'sysalloc') = EDX (for 'sysdma')
  6440                              <1> 	;	       ECX is same, byte count (buffer size)
  6441                              <1> 	;	       EDX = 1024*1024*16 ; 16 MB upper limit	 		        	 
  6442                              <1> 	;	    If BL input = 0,
  6443                              <1> 	;	       Default DMA buffer (SB16 buffer) will be
  6444                              <1> 	;	       checked and if it is free, it's address
  6445                              <1> 	;	       will be returned in EAX and it's size
  6446                              <1> 	;	       will be returned in ECX (as 65536)
  6447                              <1> 	;
  6448                              <1> 	;	    If CF = 1, error code is in EAX
  6449                              <1> 	;	       EAX = -1 ; DMA buffer allocation error! 		
  6450                              <1> 	;	       EAX = 11 ; 'Permission Denied' error !
  6451                              <1> 	;
  6452                              <1> 	;	       Note: 'sysalloc' error return method
  6453                              <1> 	;		      will be applied if BL input > 0 !		
  6454                              <1> 	;
  6455                              <1> 	; 	 For BH = 1 ; Initialize (Start) DMA
  6456                              <1> 	;	     EAX = 0 (Successful)	
  6457                              <1> 	;	     If CF = 1, error code is in EAX
  6458                              <1> 	;
  6459                              <1> 	; 	 For BH = 2 ; Get Current DMA Buffer Offset
  6460                              <1> 	;	     EAX = DMA Buffer Offset (in bytes)
  6461                              <1> 	;	     ;
  6462                              <1> 	;	      AX = DMA buffer offset
  6463                              <1> 	;	     EAX bits 16 to 23 = Page register value
  6464                              <1> 	;		   	
  6465                              <1> 	; 	 For BH = 3 ; Get Current DMA count down value
  6466                              <1> 	;	     EAX = Count down value (remain bytes)
  6467                              <1> 	;	
  6468                              <1> 	;	 For BH = 4 ; Get Current DMA channel (in progress)
  6469                              <1> 	;	     EAX = DMA channel number (0 to 7)
  6470                              <1> 	;		AH = 0 if the owner is the caller process
  6471                              <1> 	;		AH > 0 if the dma channel is in use by
  6472                              <1> 	;		       another user/process
  6473                              <1> 	;	     EAX = -1 (0FFFFFFFFh) 
  6474                              <1> 	;		    if DMA service is not in use	    		
  6475                              <1> 	;	 	    (stopped or not initialized/started)	
  6476                              <1> 	;
  6477                              <1> 	;	 For BH = 5 ; Get System's Default DMA Buff Addr
  6478                              <1> 	;	     EAX = Default DMA Buffer Address (Physical)
  6479                              <1> 	;		 = offset 'sb16_dma_buffer:'	
  6480                              <1> 	;	     ECX = Buffer size
  6481                              <1> 	;		 = 65536 
  6482                              <1> 	;
  6483                              <1> 	;	 For BH = 6 ; Get Current DMA Buffer Address
  6484                              <1> 	;	     EAX = Current DMA buffer address (Physical)
  6485                              <1> 	;	     ECX = Current DMA buffer size (setting value)	   		  	 		
  6486                              <1> 	;	     Note: These values are for current dma channel
  6487                              <1> 	;		   settings for the user/process
  6488                              <1> 	;	     ** For now (for current TRDOS 386 version)
  6489                              <1> 	;		only one user/process can use only one
  6490                              <1> 	;		dma channel & one dma buffer at same time
  6491                              <1> 	;		(no multi tasking on DMA service) !!! **
  6492                              <1> 	;	     (Once, current DMA user must stop it's own DMA
  6493                              <1> 	;	      DMA service, than another user/program 
  6494                              <1> 	;	      can use DMA service with same dma channel 
  6495                              <1> 	;	      or with another DMA channel.)	 			      		
  6496                              <1> 	;
  6497                              <1> 	;	 For BH = 7 ; Stop DMA service (for current user
  6498                              <1> 	;	     and current DMA channel)	
  6499                              <1> 	;	     EAX = 0 ; successful
  6500                              <1> 	;	     CF = 1 & EAX > 0 (= -1) -> Error		
  6501                              <1> 
  6502 00013D5D 80FF07              <1> 	cmp	bh, 7
  6503 00013D60 7612                <1> 	jna	short sysdma_0
  6504                              <1> 
  6505                              <1> sysdma_err:
  6506 00013D62 31C0                <1> 	xor	eax, eax
  6507 00013D64 48                  <1> 	dec	eax ; -1
  6508                              <1> sysdma_perm_err:
  6509 00013D65 A3[64030300]        <1> 	mov	[u.r0], eax
  6510 00013D6A A3[C8030300]        <1> 	mov	[u.error], eax ; DMA service error !
  6511 00013D6F E9789BFFFF          <1> 	jmp	error
  6512                              <1> 
  6513                              <1> sysdma_0:
  6514 00013D74 08FF                <1> 	or	bh, bh
  6515 00013D76 0F85BA000000        <1> 	jnz	sysdma_1
  6516                              <1> 	
  6517 00013D7C 20DB                <1> 	and	bl, bl
  6518 00013D7E 7416                <1> 	jz	short sysdma_01
  6519                              <1> 
  6520                              <1> 	; redirect system call to 'sysalloc'
  6521 00013D80 89D3                <1> 	mov	ebx, edx ; virtual address of DMA buffer
  6522                              <1> 	;ecx = Buffer size in bytes
  6523                              <1> 	; DMA buffer address <= 16MB upper limit
  6524 00013D82 BA00000001          <1> 	mov	edx, 1024*1024*16 ; 16MB limit for DMA buff
  6525                              <1> 
  6526 00013D87 C705[F4A00100]FFFF- <1> 	mov	dword [dma_addr], 0FFFFFFFFh ; -1
  6526 00013D8F FFFF                <1>
  6527                              <1> 
  6528 00013D91 E9A3E5FFFF          <1> 	jmp	sysalloc
  6529                              <1> 
  6530                              <1> sysdma_01:
  6531 00013D96 B8[00000200]        <1> 	mov	eax, sb16_dma_buffer
  6532                              <1> 
  6533 00013D9B 803D[B19C0100]01    <1> 	cmp	byte [audio_device], 1
  6534 00013DA2 722A                <1> 	jb	short sysdma_03
  6535                              <1> 
  6536 00013DA4 3B05[D09C0100]      <1> 	cmp	eax, [audio_dma_buff]
  6537 00013DAA 7507                <1> 	jne	short sysdma_02
  6538                              <1> 
  6539                              <1> sysdma_0_err:
  6540 00013DAC B80B000000          <1> 	mov	eax, ERR_PERM_DENIED
  6541 00013DB1 EBB2                <1> 	jmp	short sysdma_perm_err
  6542                              <1> 
  6543                              <1> sysdma_02:
  6544                              <1> 	; Only one user is permitted for audio/dma functions
  6545                              <1> 
  6546 00013DB3 833D[D09C0100]00    <1> 	cmp	dword [audio_dma_buff], 0
  6547 00013DBA 7612                <1> 	jna	short sysdma_03
  6548                              <1> 
  6549 00013DBC 8A1D[D99C0100]      <1> 	mov	bl, [audio_user]
  6550 00013DC2 08DB                <1> 	or	bl, bl
  6551 00013DC4 7408                <1> 	jz	short sysdma_03
  6552                              <1> 
  6553 00013DC6 3A1D[B3030300]      <1> 	cmp	bl, [u.uno]
  6554 00013DCC 75DE                <1> 	jne	short sysdma_0_err
  6555                              <1> 
  6556                              <1> sysdma_03: 
  6557 00013DCE 8A1D[F1A00100]      <1> 	mov	bl, [dma_user]
  6558 00013DD4 20DB                <1> 	and	bl, bl
  6559 00013DD6 750E                <1> 	jnz	short sysdma_04
  6560                              <1> 	
  6561 00013DD8 8A1D[B3030300]      <1> 	mov	bl, [u.uno]
  6562 00013DDE 881D[F1A00100]      <1> 	mov	[dma_user], bl
  6563                              <1> 
  6564 00013DE4 EB15                <1> 	jmp	short sysdma_05
  6565                              <1> 
  6566                              <1> sysdma_04:
  6567 00013DE6 8B35[F4A00100]      <1> 	mov	esi, [dma_addr]
  6568 00013DEC 21F6                <1> 	and	esi, esi
  6569 00013DEE 740B                <1> 	jz	short sysdma_05
  6570                              <1> 
  6571 00013DF0 46                  <1> 	inc	esi ; -1 -> 0
  6572 00013DF1 7408                <1> 	jz	short sysdma_05
  6573                              <1> 
  6574 00013DF3 3A1D[B3030300]      <1> 	cmp	bl, [u.uno]
  6575 00013DF9 75B1                <1> 	jne	short sysdma_0_err
  6576                              <1> 	
  6577                              <1> sysdma_05:
  6578                              <1> 	; edx = virtual address (user's buffer address)
  6579                              <1> 	; 
  6580 00013DFB 81F900000100        <1> 	cmp	ecx, 65536   ; byte count (buffer size)
  6581 00013E01 0F875BFFFFFF        <1> 	ja	sysdma_err	
  6582                              <1> 	;
  6583 00013E07 81C1FF0F0000        <1> 	add	ecx, PAGE_SIZE-1 ; 4095
  6584 00013E0D 6681E100F0          <1> 	and	cx, ~PAGE_OFF ; not 4095
  6585                              <1> 	;cmp	ecx, 65536
  6586                              <1> 	;ja	sysdma_err ;
  6587 00013E12 51                  <1> 	push	ecx	; buffer size (allocated pages * 4096) 
  6588 00013E13 50                  <1> 	push	eax	; offset sb16_dma_buffer
  6589 00013E14 89D3                <1> 	mov	ebx, edx
  6590 00013E16 C1E90C              <1> 	shr	ecx, 12 ; byte count to page count
  6591                              <1> 	; eax = physical address of (audio) dma buffer
  6592                              <1> 	; ebx = virtual address of (audio) dma buffer (user's pgdir) 
  6593                              <1> 	; ecx = page count (>0)
  6594 00013E19 E8E428FFFF          <1> 	call	direct_memory_access
  6595 00013E1E 58                  <1> 	pop	eax
  6596 00013E1F 59                  <1> 	pop	ecx
  6597 00013E20 0F823CFFFFFF        <1> 	jc	sysdma_err
  6598                              <1> 
  6599 00013E26 A3[F4A00100]        <1> 	mov	[dma_addr], eax
  6600 00013E2B 890D[F8A00100]      <1> 	mov	[dma_size], ecx ; dma buffer size (in bytes)
  6601                              <1> 
  6602                              <1> 	;mov	[u.r0], eax ; DMA Buffer Address (Physical)
  6603                              <1> 
  6604                              <1> 	;mov	ebp, [u.usp]  ; ebp points to user's registers
  6605                              <1> 	;mov	[ebp+24], ecx ; return to user with ecx value
  6606                              <1> 
  6607                              <1> 	;jmp	sysret
  6608                              <1> 
  6609                              <1> 	; 28/08/2017
  6610 00013E31 E9C4000000          <1> 	jmp	sysdma_51
  6611                              <1> 
  6612                              <1> sysdma_1:
  6613 00013E36 80FF01              <1> 	cmp	bh, 1
  6614 00013E39 0F87A6000000        <1> 	ja	sysdma_5
  6615                              <1> 
  6616 00013E3F F6C340              <1> 	test	bl, 40h	; record (read) mode -BL, bit 6-
  6617 00013E42 0F851AFFFFFF        <1> 	jnz	sysdma_err ; not ready yet!
  6618                              <1> 
  6619 00013E48 A1[F4A00100]        <1> 	mov	eax, [dma_addr] ; physical address of dma buffer
  6620 00013E4D 21C0                <1> 	and	eax, eax
  6621 00013E4F 0F840DFFFFFF        <1> 	jz	sysdma_err
  6622                              <1> 
  6623 00013E55 09D2                <1> 	or	edx, edx
  6624 00013E57 7504                <1> 	jnz	short sysdma_11
  6625                              <1> 
  6626 00013E59 89C2                <1> 	mov	edx, eax
  6627 00013E5B EB08                <1> 	jmp	short sysdma_12	
  6628                              <1> sysdma_11:
  6629 00013E5D 39C2                <1> 	cmp	edx, eax
  6630 00013E5F 0F82FDFEFFFF        <1> 	jb	sysdma_err
  6631                              <1> sysdma_12:
  6632 00013E65 21C9                <1> 	and	ecx, ecx
  6633 00013E67 7508                <1> 	jnz	short sysdma_13
  6634                              <1> 
  6635 00013E69 8B0D[F8A00100]      <1> 	mov	ecx, [dma_size]
  6636 00013E6F EB0C                <1> 	jmp	short sysdma_14
  6637                              <1> sysdma_13:
  6638 00013E71 3B0D[F8A00100]      <1> 	cmp	ecx, [dma_size]
  6639 00013E77 0F87E5FEFFFF        <1> 	ja	sysdma_err
  6640                              <1> sysdma_14:
  6641 00013E7D 89C6                <1> 	mov	esi, eax
  6642 00013E7F 0335[F8A00100]      <1> 	add	esi, [dma_size]
  6643                              <1> 
  6644 00013E85 89D0                <1> 	mov	eax, edx
  6645 00013E87 01C8                <1> 	add	eax, ecx
  6646 00013E89 0F82D3FEFFFF        <1> 	jc	sysdma_err ; 02/09/2017	
  6647                              <1> 		
  6648 00013E8F 39F0                <1> 	cmp	eax, esi
  6649 00013E91 0F87CBFEFFFF        <1> 	ja	sysdma_err
  6650                              <1> 
  6651 00013E97 8B3D[D09C0100]      <1> 	mov	edi, [audio_dma_buff]
  6652 00013E9D 8B35[F4A00100]      <1> 	mov	esi, [dma_addr]
  6653                              <1> 
  6654 00013EA3 09FF                <1> 	or	edi, edi
  6655 00013EA5 7424                <1> 	jz	short sysdma_16
  6656                              <1> 	
  6657 00013EA7 803D[B19C0100]01    <1> 	cmp	byte [audio_device], 1
  6658 00013EAE 7208                <1> 	jb	short sysdma_15
  6659                              <1> 
  6660                              <1> 	; Sound Blaster 16
  6661 00013EB0 39FE                <1> 	cmp	esi, edi
  6662 00013EB2 0F84F4FEFFFF        <1> 	je	sysdma_0_err ; permmission denied !
  6663                              <1> 
  6664                              <1> sysdma_15:
  6665 00013EB8 C605[F3A00100]48    <1> 	mov	byte [dma_mode], 48h ; single mode playback	
  6666                              <1> 
  6667 00013EBF F6C380              <1> 	test	bl, 80h ; DMA mode - BL, bit 7, auto init -
  6668 00013EC2 7407                <1> 	jz	short sysdma_16	
  6669                              <1> 	; Auto initialized playback (write) mode
  6670 00013EC4 8005[F3A00100]10    <1> 	add	byte [dma_mode], 10h ; = 58h
  6671                              <1> sysdma_16:
  6672 00013ECB 80E307              <1> 	and	bl, 07h
  6673 00013ECE 881D[F2A00100]      <1> 	mov	[dma_channel], bl
  6674 00013ED4 8915[FCA00100]      <1> 	mov	[dma_start], edx
  6675 00013EDA 890D[00A10100]      <1> 	mov	[dma_count], ecx
  6676                              <1> 	 
  6677                              <1> 	; 28/08/2017
  6678                              <1> 	;call	dma_init
  6679                              <1> 	;jmp	sysret
  6680 00013EE0 E94B010000          <1> 	jmp	dma_init
  6681                              <1> 
  6682                              <1> sysdma_5:
  6683 00013EE5 80FF05              <1> 	cmp	bh, 5
  6684 00013EE8 7223                <1> 	jb	short sysdma_3
  6685 00013EEA 0F87CE000000        <1> 	ja	sysdma_6	
  6686                              <1> 
  6687                              <1> 	; Get the system's default dma buffer addr and size
  6688 00013EF0 B8[00000200]        <1> 	mov	eax, sb16_dma_buffer
  6689 00013EF5 B900000100          <1> 	mov	ecx, 65536 ; Buffer size in bytes
  6690                              <1> 
  6691                              <1> sysdma_51:
  6692                              <1> 	; 0 = there is not a dma buffer (in use or available)
  6693 00013EFA A3[64030300]        <1> 	mov	[u.r0], eax
  6694                              <1> 
  6695 00013EFF 8B2D[60030300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
  6696 00013F05 894D18              <1> 	mov	[ebp+24], ecx ; return to user with ecx value
  6697                              <1> 
  6698 00013F08 E9FF99FFFF          <1> 	jmp	sysret
  6699                              <1> 
  6700                              <1> sysdma_3:
  6701 00013F0D 80FF03              <1> 	cmp	bh, 3
  6702 00013F10 7231                <1> 	jb	short sysdma_2
  6703 00013F12 776B                <1> 	ja	short sysdma_4
  6704                              <1> 
  6705                              <1> 	; Get current dma count down value (remain bytes)
  6706                              <1> 	; 28/08/2017
  6707 00013F14 0FB635[F2A00100]    <1> 	movzx	esi, byte [dma_channel]
  6708 00013F1B 0FB696[304A0100]    <1> 	movzx	edx, byte [dma_flip+esi]
  6709 00013F22 EE                  <1> 	out	dx, al			; flip-flop clear
  6710 00013F23 8A96[104A0100]      <1> 	mov	dl, [dma_cnt+esi] ; dma count register addr
  6711 00013F29 EC                  <1> 	in	al, dx
  6712 00013F2A 0FB6D8              <1> 	movzx	ebx, al	
  6713 00013F2D EC                  <1> 	in	al, dx
  6714 00013F2E 88C7                <1> 	mov     bh, al
  6715                              <1> 	
  6716 00013F30 6683FE04            <1> 	cmp	si, 4 ; channel number ?
  6717 00013F34 7202                <1> 	jb	short sysdma_31 ; 8 bit dma channel
  6718                              <1> 
  6719 00013F36 D1E3                <1> 	shl	ebx, 1	; word count to byte count
  6720                              <1> 
  6721                              <1> sysdma_31:
  6722 00013F38 891D[64030300]      <1> 	mov	[u.r0], ebx
  6723                              <1> 
  6724 00013F3E E9C999FFFF          <1> 	jmp	sysret	
  6725                              <1> 
  6726                              <1> sysdma_2:
  6727                              <1> 	; Get current dma buffer offset (& page)
  6728                              <1> 	; 28/08/2017
  6729 00013F43 0FB635[F2A00100]    <1> 	movzx	esi, byte [dma_channel]
  6730 00013F4A 0FB696[304A0100]    <1> 	movzx	edx, byte [dma_flip+esi]
  6731 00013F51 EE                  <1> 	out	dx, al			; flip-flop clear
  6732 00013F52 8A96[084A0100]      <1> 	mov	dl, [dma_adr+esi]
  6733 00013F58 EC                  <1> 	in	al, dx			; get dma position
  6734 00013F59 0FB6D8              <1> 	movzx	ebx, al
  6735 00013F5C EC                  <1> 	in	al, dx			
  6736 00013F5D 88C7                <1> 	mov	bh, al
  6737                              <1> 
  6738 00013F5F 6683FE04            <1> 	cmp	si, 4 ; channel number ?
  6739 00013F63 7202                <1> 	jb	short sysdma_21 ; 8 bit dma channel
  6740                              <1> 
  6741 00013F65 D1E3                <1> 	shl	ebx, 1	; word offset to byte offset
  6742                              <1> 
  6743                              <1> sysdma_21:
  6744 00013F67 891D[64030300]      <1> 	mov	[u.r0], ebx
  6745                              <1> 
  6746 00013F6D 8A96[184A0100]      <1> 	mov	dl, [dma_page+esi]
  6747 00013F73 EC                  <1> 	in	al, dx			; get dma page
  6748                              <1> 
  6749                              <1> 	;add	[u.ro+2], al
  6750 00013F74 0805[66030300]      <1> 	or	[u.r0+2], al
  6751                              <1> 
  6752 00013F7A E98D99FFFF          <1> 	jmp	sysret
  6753                              <1> 
  6754                              <1> sysdma_4:
  6755                              <1> 	; Get current DMA channel number
  6756                              <1> 	; 28/08/2017
  6757 00013F7F 8A25[F1A00100]      <1> 	mov	ah, [dma_user]
  6758 00013F85 20E4                <1> 	and	ah, ah
  6759 00013F87 750F                <1> 	jnz	short sysdma_42
  6760                              <1> 
  6761                              <1> sysdma_41:	
  6762                              <1> 	; Not a valid dma channel (in use)
  6763 00013F89 C705[64030300]FFFF- <1> 	mov	dword [u.r0], -1 ; 0FFFFFFFFh
  6763 00013F91 FFFF                <1>
  6764 00013F93 E97499FFFF          <1> 	jmp	sysret
  6765                              <1> 
  6766                              <1> sysdma_42:
  6767 00013F98 8B35[F4A00100]      <1> 	mov	esi, [dma_addr]
  6768 00013F9E 21F6                <1> 	and	esi, esi
  6769 00013FA0 74E7                <1> 	jz	short sysdma_41
  6770                              <1> 
  6771 00013FA2 46                  <1> 	inc	esi ; -1 -> 0
  6772 00013FA3 74E4                <1> 	jz	short sysdma_41
  6773                              <1> 
  6774 00013FA5 A0[F2A00100]        <1> 	mov	al, [dma_channel]
  6775                              <1> 
  6776 00013FAA 3A25[B3030300]      <1> 	cmp	ah, [u.uno]
  6777 00013FB0 7502                <1> 	jne	short sysdma_43
  6778                              <1> 
  6779 00013FB2 30E4                <1> 	xor	ah, ah ; DMA channel in use by current user
  6780                              <1> 
  6781                              <1> sysdma_43:
  6782 00013FB4 A3[64030300]        <1> 	mov	[u.r0], eax ; AL = dma channel number
  6783                              <1> 			    ; AH > 0 if the the channel
  6784                              <1> 			    ; in use by another user/process
  6785 00013FB9 E94E99FFFF          <1> 	jmp	sysret
  6786                              <1> 
  6787                              <1> sysdma_6:
  6788 00013FBE 80FF06              <1> 	cmp	bh, 6
  6789 00013FC1 7710                <1> 	ja	short sysdma_7
  6790                              <1> 
  6791                              <1> 	; 28/08/2017
  6792                              <1> 	; Get current DMA buffer addr and size
  6793 00013FC3 A1[F4A00100]        <1> 	mov	eax, [dma_addr] ; dma buffer address
  6794 00013FC8 8B0D[F8A00100]      <1> 	mov	ecx, [dma_size] ; dma buffer size (in bytes)
  6795                              <1> 
  6796 00013FCE E927FFFFFF          <1> 	jmp	sysdma_51
  6797                              <1> 
  6798                              <1> sysdma_7:
  6799                              <1> 	; DMA service STOP
  6800 00013FD3 A0[B3030300]        <1> 	mov	al, [u.uno]
  6801 00013FD8 3A05[F1A00100]      <1> 	cmp	al, [dma_user]
  6802 00013FDE 751D                <1> 	jne	short sysdma_72
  6803                              <1> 	
  6804 00013FE0 28C0                <1> 	sub	al, al ; 0
  6805                              <1> 
  6806 00013FE2 A2[F1A00100]        <1> 	mov	[dma_user], al ; clear user
  6807                              <1> 
  6808 00013FE7 8605[F3A00100]      <1> 	xchg	al, [dma_mode]
  6809 00013FED 20C0                <1> 	and	al, al
  6810                              <1> 	;jz	short sysdma_err
  6811 00013FEF 7527                <1> 	jnz	short sysdma_73	
  6812                              <1> 
  6813                              <1> sysdma_71:
  6814 00013FF1 31C0                <1> 	xor	eax, eax
  6815 00013FF3 A3[64030300]        <1> 	mov	[u.r0], eax; 0
  6816 00013FF8 E90F99FFFF          <1> 	jmp	sysret
  6817                              <1> 
  6818                              <1> sysdma_72:
  6819                              <1> 	; 28/08/2017
  6820 00013FFD 803D[F1A00100]00    <1> 	cmp	byte [dma_user], 0
  6821 00014004 76EB                <1> 	jna	short sysdma_71 ; Nothing to do !
  6822                              <1> 
  6823 00014006 833D[F4A00100]00    <1> 	cmp	dword [dma_addr], 0
  6824 0001400D 0F8799FDFFFF        <1> 	ja	sysdma_0_err
  6825                              <1> 	
  6826 00014013 A2[F1A00100]        <1> 	mov	[dma_user], al ; reset to current user
  6827                              <1> 
  6828                              <1> sysdma_73:
  6829                              <1> 	; 28/08/2017
  6830 00014018 0FB635[F2A00100]    <1> 	movzx	esi, byte [dma_channel]
  6831 0001401F 0FB696[204A0100]    <1> 	movzx	edx, byte [dma_mask+esi]
  6832 00014026 A0[F2A00100]        <1> 	mov	al, [dma_channel]
  6833 0001402B 0C04                <1> 	or	al, 4
  6834 0001402D EE                  <1> 	out	dx, al
  6835                              <1> 
  6836 0001402E EBC1                <1> 	jmp	short sysdma_71
  6837                              <1> 
  6838                              <1> dma_init:
  6839                              <1> 	; 28/08/2017
  6840                              <1> 	; 20/08/2017
  6841                              <1> 	; DMA initialization
  6842                              <1> 	; 14/08/2017
  6843                              <1> 	; 03/08/2017, 06/08/2017, 08/08/2017
  6844                              <1> 	; 02/07/2017, 13/07/2017, 16/07/2017, 30/07/2017
  6845                              <1> 	; (Derived from 'DMA_INIT' procedure in SB16MOD.ASM)
  6846                              <1> 	; Modified for TRDOS 386 DMA buffer allocation & initialization !
  6847                              <1> 
  6848 00014030 8B1D[FCA00100]      <1> 	mov	ebx, [dma_start]
  6849 00014036 8B0D[00A10100]      <1> 	mov	ecx, [dma_count]
  6850                              <1> 
  6851 0001403C 0FB635[F2A00100]    <1> 	movzx	esi, byte [dma_channel]
  6852                              <1> 
  6853 00014043 6683FE04            <1> 	cmp	si, 4
  6854 00014047 7205                <1> 	jb	short gdmi1
  6855                              <1> 	; 08/08/2017
  6856 00014049 66D1E9              <1> 	shr	cx, 1 ; word count
  6857 0001404C D1EB                <1> 	shr	ebx, 1 ; convert byte offset to word offset
  6858                              <1> gdmi1:
  6859                              <1> 	;mov	[dma_poff], bx ; 08/08/2017
  6860 0001404E 6649                <1> 	dec	cx			; dma size = block size - 1
  6861                              <1> 	
  6862 00014050 0FB696[204A0100]    <1> 	movzx	edx, byte [dma_mask+esi] ; 30/07/2017
  6863 00014057 A0[F2A00100]        <1> 	mov	al, [dma_channel]
  6864 0001405C 0C04                <1> 	or	al, 4
  6865 0001405E EE                  <1> 	out	dx, al			; dma channel mask
  6866                              <1> 
  6867 0001405F 30C0                <1> 	xor	al, al ; 0 ; any value ! 08/08/2017
  6868 00014061 8A96[304A0100]      <1> 	mov	dl, [dma_flip+esi]
  6869 00014067 EE                  <1> 	out	dx, al			; flip-flop clear
  6870                              <1> 	
  6871 00014068 8A96[284A0100]      <1> 	mov	dl, [dma_mod+esi]
  6872 0001406E A0[F2A00100]        <1> 	mov	al, [dma_channel]  ; 13/07/2017
  6873 00014073 2403                <1> 	and	al, 3
  6874                              <1> 	; 08/08/2017
  6875 00014075 0A05[F3A00100]      <1> 	or	al, [dma_mode] ; 58h    ; dma mode for SB16
  6876 0001407B EE                  <1> 	out	dx, al			
  6877                              <1> 
  6878 0001407C 8A96[084A0100]      <1> 	mov	dl, [dma_adr+esi]	
  6879 00014082 88D8                <1> 	mov	al, bl			
  6880 00014084 EE                  <1> 	out	dx, al			; offset low
  6881                              <1> 
  6882 00014085 88F8                <1> 	mov	al, bh
  6883 00014087 EE                  <1> 	out	dx, al			; offset high
  6884                              <1> 
  6885 00014088 8A96[104A0100]      <1> 	mov	dl, [dma_cnt+esi]
  6886 0001408E 88C8                <1> 	mov	al, cl
  6887 00014090 EE                  <1> 	out	dx, al			; size low
  6888                              <1> 
  6889 00014091 88E8                <1> 	mov	al, ch
  6890 00014093 EE                  <1> 	out	dx, al			; size high
  6891                              <1> 
  6892 00014094 8A96[184A0100]      <1> 	mov	dl, [dma_page+esi]
  6893                              <1> 	; 14/08/2017 
  6894 0001409A 6683FE04            <1> 	cmp	si, 4
  6895 0001409E 7305                <1> 	jnb	short gdmi2
  6896 000140A0 C1EB10              <1> 	shr	ebx, 16
  6897 000140A3 EB06                <1> 	jmp	short gdmi3
  6898                              <1> gdmi2:
  6899                              <1> 	; 09/08/2017
  6900 000140A5 C1EB0F              <1> 	shr	ebx, 15	 ; complete 16 bit shift
  6901 000140A8 80E3FE              <1> 	and	bl, 0FEh ; clear bit 0 (not necessary)
  6902                              <1> gdmi3:	
  6903 000140AB 88D8                <1> 	mov	al, bl
  6904 000140AD EE                  <1> 	out	dx, al			; page			
  6905                              <1> 	
  6906 000140AE 8A96[204A0100]      <1> 	mov	dl, [dma_mask+esi]
  6907 000140B4 A0[F2A00100]        <1> 	mov	al, [dma_channel]  ; 13/07/2017
  6908 000140B9 2403                <1> 	and	al, 3
  6909 000140BB EE                  <1> 	out	dx, al			; dma channel unmask
  6910                              <1> 
  6911                              <1> 	;retn
  6912                              <1> 	; 28/08/2017
  6913 000140BC E94B98FFFF          <1> 	jmp	sysret
  6914                              <1> 
  6915                              <1> otty:
  6916                              <1> sret:
  6917                              <1> ocvt:
  6918                              <1> ctty:
  6919                              <1> cret:
  6920                              <1> ccvt:
  6921                              <1> rtty:
  6922                              <1> wtty:
  6923                              <1> rmem:
  6924                              <1> wmem:
  6925                              <1> rfd:
  6926                              <1> rhd:
  6927                              <1> wfd:
  6928                              <1> whd:
  6929                              <1> rlpt:
  6930                              <1> wlpt:
  6931                              <1> rcvt:
  6932                              <1> xmtt:
  6933 000140C1 C3                  <1> 	retn
  3095                                  %include 'trdosk9.s' ; 04/01/2016
  3096                              <1> ; ****************************************************************************
  3097                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.3) - INITIALIZED DATA : trdosk9.s
  3098                              <1> ; ----------------------------------------------------------------------------
  3099                              <1> ; Last Update: 07/03/2021
  3100                              <1> ; ----------------------------------------------------------------------------
  3101                              <1> ; Beginning: 04/01/2016
  3102                              <1> ; ----------------------------------------------------------------------------
  3103                              <1> ; ----------------------------------------------------------------------------
  3104                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
  3105                              <1> ; ----------------------------------------------------------------------------
  3106                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
  3107                              <1> ; TRDOS2.ASM (09/11/2011)
  3108                              <1> ; ****************************************************************************
  3109                              <1> ; DRV_INIT.ASM [26/09/2009] Last Update: 07/08/2011
  3110                              <1> ; MAINPROG.ASM [17/01/2004] Last Update: 09/11/2011
  3111                              <1> ; CMD_INTR.ASM [29/01/2005] Last Update: 09/11/2011
  3112                              <1> ; FILE.ASM [29/10/2009] Last Update: 09/10/2011
  3113                              <1> 
  3114                              <1> ; 12/02/2016
  3115                              <1> Last_DOS_DiskNo: 
  3116 000140C2 01                  <1> 		db 1 ; A: = 0 & B: = 1
  3117                              <1> 
  3118                              <1> Restore_CDIR:	
  3119 000140C3 FF                  <1> 		db 0FFh ; Initial value -> any number except 0
  3120                              <1> 
  3121                              <1> msg_CRLF_temp:  
  3122 000140C4 070D0A00            <1> 		db 07h, 0Dh, 0Ah, 0
  3123                              <1> 
  3124                              <1> Magic_Bytes:
  3125 000140C8 04                  <1> 		db 4
  3126 000140C9 01                  <1> 		db 1
  3127                              <1> mainprog_Version:
  3128 000140CA 07                  <1> 		db 7
  3129 000140CB 5B5452444F535D204D- <1> 		db "[TRDOS] Main Program v2.0.070321"
  3129 000140D4 61696E2050726F6772- <1>
  3129 000140DD 616D2076322E302E30- <1>
  3129 000140E6 3730333231          <1>
  3130 000140EB 0D0A                <1> 		db 0Dh, 0Ah
  3131 000140ED 286329204572646F67- <1> 		db "(c) Erdogan Tan 2005-2021"
  3131 000140F6 616E2054616E203230- <1>
  3131 000140FF 30352D32303231      <1>
  3132 00014106 0D0A00              <1> 		db 0Dh, 0Ah, 0
  3133                              <1> 
  3134                              <1> MainProgCfgFile: ; 14/04/2016
  3135 00014109 4D41494E50524F472E- <1> 		db "MAINPROG.CFG", 0
  3135 00014112 43464700            <1>
  3136                              <1> 
  3137                              <1> TRDOSPromptLabel:
  3138 00014116 5452444F53          <1> 		db "TRDOS"
  3139 0001411B 00                  <1> 		db 0
  3140 0001411C 00<rep 5h>          <1>                 times 5 db 0
  3141 00014121 00                  <1> 		db 0
  3142                              <1> 
  3143                              <1> ; INTERNAL COMMANDS
  3144                              <1> Command_List:
  3145 00014122 44495200            <1> Cmd_Dir:	db "DIR", 0
  3146 00014126 434400              <1> Cmd_Cd:		db "CD", 0
  3147 00014129 433A00              <1> Cmd_Drive:	db "C:", 0
  3148 0001412C 56455200            <1> Cmd_Ver:	db "VER", 0
  3149 00014130 4558495400          <1> Cmd_Exit:	db "EXIT", 0
  3150 00014135 50524F4D505400      <1> Cmd_Prompt:	db "PROMPT", 0
  3151 0001413C 564F4C554D4500      <1> Cmd_Volume:	db "VOLUME", 0
  3152 00014143 4C4F4E474E414D4500  <1> Cmd_LongName:	db "LONGNAME", 0
  3153 0001414C 4441544500          <1> Cmd_Date:	db "DATE", 0
  3154 00014151 54494D4500          <1> Cmd_Time:	db "TIME", 0
  3155 00014156 52554E00            <1> Cmd_Run:	db "RUN", 0
  3156 0001415A 53455400            <1> Cmd_Set:	db "SET", 0 
  3157 0001415E 434C5300            <1> Cmd_Cls:	db "CLS", 0
  3158 00014162 53484F5700          <1> Cmd_Show:	db "SHOW", 0
  3159 00014167 44454C00            <1> Cmd_Del:	db "DEL", 0
  3160 0001416B 41545452494200      <1> Cmd_Attrib:	db "ATTRIB", 0
  3161 00014172 52454E414D4500      <1> Cmd_Rename:	db "RENAME", 0
  3162 00014179 524D44495200        <1> Cmd_Rmdir:	db "RMDIR", 0
  3163 0001417F 4D4B44495200        <1> Cmd_Mkdir:	db "MKDIR", 0
  3164 00014185 434F505900          <1> Cmd_Copy:	db "COPY", 0
  3165 0001418A 4D4F564500          <1> Cmd_Move:	db "MOVE", 0
  3166 0001418F 5041544800          <1> Cmd_Path:	db "PATH", 0
  3167 00014194 4D454D00            <1> Cmd_Mem:	db "MEM", 0
  3168 00014198 00                  <1> 		db 0
  3169 00014199 46494E4400          <1> Cmd_Find:	db "FIND", 0
  3170 0001419E 4543484F00          <1> Cmd_Echo:	db "ECHO", 0
  3171 000141A3 2A00                <1> Cmd_Remark:	db "*", 0
  3172 000141A5 3F00                <1> Cmd_Help:	db "?", 0
  3173 000141A7 44455649434500      <1> Cmd_Device:	db "DEVICE", 0
  3174 000141AE 4445564C49535400    <1> Cmd_DevList:	db "DEVLIST", 0
  3175 000141B6 434844495200        <1> Cmd_Chdir:	db "CHDIR", 0
  3176 000141BC 4245455000          <1> Cmd_Beep:	db "BEEP", 0
  3177                              <1> 		
  3178 000141C1 00                  <1> 		db 0
  3179                              <1> 
  3180                              <1> ; 15/02/2016 (FILE.ASM, 09/10/2011)
  3181                              <1> invalid_fname_chars:
  3182 000141C2 222728292A2B2C2F    <1> 		db 22h, 27h, 28h, 29h, 2Ah, 2Bh, 2Ch, 2Fh
  3183 000141CA 3A3B3C3D3E3F40      <1> 		db 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh, 40h
  3184 000141D1 5B5C5D5E60          <1> 		db 5Bh, 5Ch, 5Dh, 5Eh, 60h
  3185                              <1> sizeInvFnChars  equ ($ - invalid_fname_chars)                
  3186                              <1> ;
  3187                              <1> 
  3188                              <1> Msg_Enter_Date:
  3189 000141D6 456E746572206E6577- <1>                 db 'Enter new date (dd-mm-yy): '
  3189 000141DF 206461746520286464- <1>
  3189 000141E8 2D6D6D2D7979293A20  <1>
  3190 000141F1 00                  <1>                 db 0
  3191                              <1> Msg_Show_Date:
  3192 000141F2 43757272656E742064- <1>                 db   'Current date is '
  3192 000141FB 61746520697320      <1>
  3193 00014202 30                  <1> Day:            db   '0'
  3194 00014203 30                  <1> 		db   '0'
  3195 00014204 2F                  <1>                 db   '/'
  3196 00014205 30                  <1> Month:          db   '0'
  3197 00014206 30                  <1> 		db   '0'
  3198 00014207 2F                  <1>                 db   '/'
  3199 00014208 30                  <1> Century:        db   '0'
  3200 00014209 30                  <1>                 db   '0'
  3201 0001420A 30                  <1> Year:           db   '0'
  3202 0001420B 30                  <1> 		db   '0'
  3203 0001420C 0D0A00              <1>                 db   0Dh, 0Ah, 0
  3204                              <1> 
  3205                              <1> Msg_Enter_Time:
  3206 0001420F 456E746572206E6577- <1> 		db 'Enter new time: '
  3206 00014218 2074696D653A20      <1>
  3207 0001421F 00                  <1> 		db 0
  3208                              <1> Msg_Show_Time:
  3209 00014220 43757272656E742074- <1> 		db   'Current time is '
  3209 00014229 696D6520697320      <1>
  3210 00014230 30                  <1> Hour:           db   '0'
  3211 00014231 30                  <1> 		db   '0'
  3212 00014232 3A                  <1> 		db   ':'
  3213 00014233 30                  <1> Minute:         db   '0'
  3214 00014234 30                  <1> 		db   '0'
  3215 00014235 3A                  <1> 		db   ':'
  3216 00014236 30                  <1> Second:         db   '0'
  3217 00014237 30                  <1> 		db   '0'
  3218 00014238 0D0A00              <1> 		db   0Dh, 0Ah, 0
  3219                              <1> 
  3220                              <1> ;VolSize_Unit1:   dd 0
  3221                              <1> ;VolSize_Unit2:   dd 0
  3222                              <1> 
  3223                              <1> VolSize_KiloBytes:
  3224 0001423B 206B696C6F62797465- <1> 		db " kilobytes", 0Dh, 0Ah, 0
  3224 00014244 730D0A00            <1>
  3225                              <1> VolSize_Bytes:
  3226 00014248 2062797465730D0A00  <1> 		db " bytes", 0Dh, 0Ah, 0
  3227                              <1> Volume_in_drive:
  3228 00014251 0D0A                <1> 		db 0Dh, 0Ah
  3229                              <1> Vol_FS_Name:
  3230 00014253 54522046533120      <1> 		db "TR FS1 "
  3231 0001425A 566F6C756D6520696E- <1> 		db "Volume in drive "
  3231 00014263 20647269766520      <1>
  3232 0001426A 30                  <1> Vol_Drv_Name:   db 30h
  3233 0001426B 3A                  <1> 		db ":"
  3234 0001426C 20697320            <1> 		db " is "
  3235 00014270 0D0A00              <1> 		db 0Dh, 0Ah, 0
  3236                              <1> Dir_Drive_Str:
  3237 00014273 54522D444F53204472- <1>                 db "TR-DOS Drive "
  3237 0001427C 69766520            <1>
  3238                              <1> Dir_Drive_Name:
  3239 00014280 303A                <1>                 db "0:"
  3240 00014282 0D0A                <1>                 db  0Dh, 0Ah
  3241                              <1> Vol_Str_Header:
  3242 00014284 566F6C756D65204E61- <1>                 db "Volume Name: "
  3242 0001428D 6D653A20            <1>
  3243                              <1> Vol_Name:
  3244 00014291 00<rep 40h>         <1> 		times 64 db 0
  3245 000142D1 00                  <1> 		db 0
  3246                              <1> Vol_Serial_Header:
  3247 000142D2 0D0A                <1> 		db 0Dh, 0Ah
  3248 000142D4 566F6C756D65205365- <1> 		db "Volume Serial No: "
  3248 000142DD 7269616C204E6F3A20  <1>
  3249                              <1> Vol_Serial1:
  3250 000142E6 30303030            <1> 		db "0000"
  3251 000142EA 2D                  <1> 		db "-"
  3252                              <1> Vol_Serial2:
  3253 000142EB 30303030            <1> 		db "0000"
  3254 000142EF 0D0A00              <1> 		db 0Dh, 0Ah, 0
  3255                              <1> 
  3256                              <1> ;Vol_Tot_Sec_Str_Start:
  3257                              <1> ;		dd 0
  3258                              <1> Vol_Total_Sector_Header:
  3259 000142F2 0D0A                <1> 		db 0Dh, 0Ah
  3260 000142F4 566F6C756D65205369- <1> 		db "Volume Size : ", 0
  3260 000142FD 7A65203A2000        <1>
  3261                              <1> ;Vol_Tot_Sec_Str: 
  3262                              <1> ;		db "0000000000"
  3263                              <1> ;Vol_Tot_Sec_Str_End:
  3264                              <1> ;		db 0
  3265                              <1> ;Vol_Free_Sectors_Str_Start:
  3266                              <1> ;		dd 0
  3267                              <1> Vol_Free_Sectors_Header:
  3268 00014303 467265652053706163- <1> 		db "Free Space  : ", 0
  3268 0001430C 6520203A2000        <1>
  3269                              <1> ;Vol_Free_Sectors_Str:
  3270                              <1> ;		db "0000000000"
  3271                              <1> ;Vol_Free_Sectors_Str_End:
  3272                              <1> ;		db 0
  3273                              <1> 
  3274                              <1> Dir_Str_Header:
  3275 00014312 4469726563746F7279- <1>                 db "Directory: "
  3275 0001431B 3A20                <1>
  3276 0001431D 2F                  <1> Dir_Str_Root:   db "/"
  3277 0001431E 00<rep 40h>         <1> Dir_Str:        times 64 db 0
  3278 0001435E 00000000            <1>                 dd 0
  3279 00014362 00                  <1>                 db 0
  3280                              <1> 
  3281                              <1> Msg_Bad_Command:
  3282 00014363 42616420636F6D6D61- <1>                 db "Bad command or file name!"
  3282 0001436C 6E64206F722066696C- <1>
  3282 00014375 65206E616D6521      <1>
  3283 0001437C 0D0A00              <1>                 db 0Dh, 0Ah, 0
  3284                              <1> 
  3285                              <1> msgl_drv_not_ready: 
  3286 0001437F 070D0A              <1> 		db 07h, 0Dh, 0Ah
  3287                              <1> 
  3288                              <1> ; CMD_INTR.ASM - 09/11/2011 - Messages
  3289                              <1> 
  3290                              <1> Msg_Not_Ready_Read_Err:
  3291 00014382 4472697665206E6F74- <1>                 db "Drive not ready or read error!"
  3291 0001438B 207265616479206F72- <1>
  3291 00014394 207265616420657272- <1>
  3291 0001439D 6F7221              <1>
  3292 000143A0 0D0A00              <1>                 db 0Dh, 0Ah, 0
  3293                              <1> 
  3294                              <1> Msg_Not_Ready_Write_Err:
  3295 000143A3 4472697665206E6F74- <1>                 db "Drive not ready or write error!"
  3295 000143AC 207265616479206F72- <1>
  3295 000143B5 207772697465206572- <1>
  3295 000143BE 726F7221            <1>
  3296 000143C2 0D0A00              <1>                 db 0Dh, 0Ah, 0
  3297                              <1> 
  3298                              <1> Msg_Dir_Not_Found:
  3299 000143C5 4469726563746F7279- <1>                 db "Directory not found!"
  3299 000143CE 206E6F7420666F756E- <1>
  3299 000143D7 6421                <1>
  3300 000143D9 0D0A00              <1>                 db 0Dh, 0Ah, 0
  3301                              <1> 
  3302                              <1> Msg_File_Not_Found:
  3303 000143DC 46696C65206E6F7420- <1>                 db "File not found!"
  3303 000143E5 666F756E6421        <1>
  3304 000143EB 0D0A00              <1>                 db 0Dh, 0Ah, 0
  3305                              <1> 
  3306                              <1> Msg_File_Directory_Not_Found:
  3307 000143EE 46696C65206F722064- <1>                 db "File or directory not found!"
  3307 000143F7 69726563746F727920- <1>
  3307 00014400 6E6F7420666F756E64- <1>
  3307 00014409 21                  <1>
  3308 0001440A 0D0A00              <1>                 db 0Dh, 0Ah, 0
  3309                              <1> 
  3310                              <1> Msg_LongName_Not_Found:
  3311 0001440D 4C6F6E67206E616D65- <1>                 db "Long name not found!"
  3311 00014416 206E6F7420666F756E- <1>
  3311 0001441F 6421                <1>
  3312 00014421 0D0A00              <1>                 db 0Dh, 0Ah, 0
  3313                              <1> 
  3314                              <1> beep_Insufficient_Memory: ; 20/02/2017
  3315 00014424 0D0A                <1> 		db 0Dh, 0Ah
  3316 00014426 07                  <1> 		db 07h
  3317                              <1> Msg_Insufficient_Memory:
  3318 00014427 496E73756666696369- <1>                 db "Insufficient memory!"
  3318 00014430 656E74206D656D6F72- <1>
  3318 00014439 7921                <1>
  3319 0001443B 0D0A00              <1>                 db 0Dh, 0Ah, 0
  3320                              <1> 
  3321                              <1> Msg_Error_Code:
  3322 0001443E 436F6D6D616E642066- <1>                 db 'Command failed! Error code : '
  3322 00014447 61696C656421204572- <1>
  3322 00014450 726F7220636F646520- <1>
  3322 00014459 3A20                <1>
  3323 0001445B 303068              <1> error_code_hex: db '00h'
  3324 0001445E 0A0A00              <1>                 db 0Ah, 0Ah, 0
  3325                              <1> 
  3326 00014461 90                  <1> align 2
  3327                              <1> 
  3328                              <1> ; 10/02/2016
  3329                              <1> ; DIR.ASM - 09/10/2011
  3330                              <1> 
  3331 00014462 3C4449523E20202020- <1> Type_Dir:       db '<DIR>     ' ; 10 bytes
  3331 0001446B 20                  <1>
  3332                              <1> 
  3333                              <1> File_Name:
  3334 0001446C 20<rep Ch>          <1>                 times 12 db 20h
  3335 00014478 20                  <1> 		db 20h
  3336                              <1> Dir_Or_FileSize:
  3337 00014479 20<rep Ah>          <1>                 times 10 db 20h
  3338 00014483 20                  <1> 		db 20h
  3339                              <1> File_Attribute:
  3340 00014484 20202020            <1> 		dd 20202020h
  3341 00014488 20                  <1> 		db 20h
  3342                              <1> File_Day:
  3343 00014489 3030                <1>                 db '0','0'
  3344 0001448B 2F                  <1> 		db '/'
  3345                              <1> File_Month:
  3346 0001448C 3030                <1>                 db '0','0'
  3347 0001448E 2F                  <1> 		db '/'
  3348                              <1> File_Year:
  3349 0001448F 30303030            <1>                 db '0','0','0','0'
  3350 00014493 20                  <1> 		db 20h
  3351                              <1> File_Hour:
  3352 00014494 3030                <1>                 db '0','0'
  3353 00014496 3A                  <1> 		db ':'
  3354                              <1> File_Minute:
  3355 00014497 3030                <1>                 db '0','0'
  3356 00014499 00                  <1> 		db 0
  3357                              <1> 
  3358                              <1> Decimal_File_Count_Header:
  3359 0001449A 0D0A                <1> 		db 0Dh, 0Ah
  3360                              <1> Decimal_File_Count:
  3361 0001449C 00<rep 6h>          <1> 		times 6 db 0
  3362                              <1> 
  3363 000144A2 2066696C6528732920- <1> str_files:	db " file(s) & "
  3363 000144AB 2620                <1>
  3364                              <1> Decimal_Dir_Count: 
  3365 000144AD 00<rep 6h>          <1> 		times 6 db 0
  3366                              <1> str_dirs:       
  3367 000144B3 206469726563746F72- <1> 		db " directory(s) "
  3367 000144BC 7928732920          <1>
  3368 000144C1 0D0A00              <1> 		db 0Dh, 0Ah, 0
  3369                              <1> 
  3370 000144C4 206279746528732920- <1> str_bytes:	db " byte(s) in file(s)"
  3370 000144CD 696E2066696C652873- <1>
  3370 000144D6 29                  <1>
  3371 000144D7 0D0A00              <1> 		db 0Dh, 0Ah, 0
  3372                              <1> 
  3373                              <1> ; CMD_INTR.ASM - 09/11/2011
  3374                              <1> ; 07/10/2010
  3375                              <1> Msg_invalid_name_chars:
  3376 000144DA 496E76616C69642066- <1>                 db "Invalid file or directory name characters!"
  3376 000144E3 696C65206F72206469- <1>
  3376 000144EC 726563746F7279206E- <1>
  3376 000144F5 616D65206368617261- <1>
  3376 000144FE 637465727321        <1>
  3377 00014504 0D0A00              <1>         	db 0Dh, 0Ah, 0
  3378                              <1> ; 21/02/2016
  3379 00014507 46696C65206F722064- <1> Msg_Name_Exists: db "File or directory name exists!"
  3379 00014510 69726563746F727920- <1>
  3379 00014519 6E616D652065786973- <1>
  3379 00014522 747321              <1>
  3380 00014525 0D0A00              <1>                 db 0Dh, 0Ah, 0
  3381                              <1> Msg_DoYouWantMkdir:
  3382 00014528 446F20796F75207761- <1>                 db "Do you want to make directory ", 0
  3382 00014531 6E7420746F206D616B- <1>
  3382 0001453A 65206469726563746F- <1>
  3382 00014543 72792000            <1>
  3383 00014547 2028592F4E29203F20- <1> Msg_YesNo:      db " (Y/N) ? ", 0  
  3383 00014550 00                  <1>
  3384 00014551 000D0A00            <1> Y_N_nextline:	db 0, 0Dh, 0Ah, 0 
  3385 00014555 4F4B2E0D0A00        <1> Msg_OK:		db "OK.", 0Dh, 0Ah, 0
  3386                              <1> 
  3387                              <1> ; 27/02/2016
  3388                              <1> Msg_DoYouWantRmDir:
  3389 0001455B 446F20796F75207761- <1>                 db "Do you want to delete directory ", 0
  3389 00014564 6E7420746F2064656C- <1>
  3389 0001456D 657465206469726563- <1>
  3389 00014576 746F72792000        <1>
  3390                              <1> Msg_Dir_Not_Empty:
  3391 0001457C 4469726563746F7279- <1>                 db "Directory not empty!"
  3391 00014585 206E6F7420656D7074- <1>
  3391 0001458E 7921                <1>
  3392 00014590 0D0A00              <1>                 db 0Dh, 0Ah, 0
  3393                              <1> 
  3394                              <1> Msg_DoYouWantDelete:
  3395 00014593 446F20796F75207761- <1>                 db "Do you want to delete file ",0
  3395 0001459C 6E7420746F2064656C- <1>
  3395 000145A5 6574652066696C6520- <1>
  3395 000145AE 00                  <1>
  3396                              <1> 
  3397 000145AF 44656C657465642E2E- <1> Msg_Deleted:    db "Deleted...", 0Dh, 0Ah, 0
  3397 000145B8 2E0D0A00            <1>
  3398                              <1> 
  3399                              <1> Msg_Permission_Denied:
  3400 000145BC 07                  <1>                 db 7
  3401 000145BD 5065726D697373696F- <1>                 db "Permission denied!", 0Dh, 0Ah, 0
  3401 000145C6 6E2064656E69656421- <1>
  3401 000145CF 0D0A00              <1>
  3402                              <1> 
  3403                              <1> ; 04/03/2016
  3404 000145D2 4E657720            <1> Msg_New:        db "New "
  3405 000145D6 00                  <1>                 db 0
  3406                              <1> Str_Attributes:
  3407 000145D7 417474726962757465- <1>                 db "Attributes : "
  3407 000145E0 73203A20            <1>
  3408 000145E4 4E4F524D414C        <1> Attr_Chars:     db "NORMAL"
  3409 000145EA 00                  <1>                 db 0
  3410                              <1> 
  3411                              <1> ; 06/03/2016
  3412                              <1> ; CMD_INTR.ASM - 16/11/2010 
  3413                              <1> Msg_DoYouWantRename:
  3414 000145EB 446F20796F75207761- <1>                 db "Do you want to rename ", 0
  3414 000145F4 6E7420746F2072656E- <1>
  3414 000145FD 616D652000          <1>
  3415 00014602 66696C652000        <1> Rename_File:    db "file ", 0
  3416 00014608 6469726563746F7279- <1> Rename_Directory: db "directory ", 0
  3416 00014611 2000                <1>
  3417 00014613 00<rep Dh>          <1> Rename_OldName: times 13 db 0
  3418 00014620 20617320            <1> Msg_File_rename_as: db " as "
  3419 00014624 00<rep Dh>          <1> Rename_NewName: times 13 db 0
  3420                              <1> 
  3421                              <1> ; 08/03/2016
  3422                              <1> ; CMD_INTR.ASM - 01/08/2010 - 23/04/2011
  3423                              <1> msg_not_same_drv:
  3424 00014631 4E6F742073616D6520- <1>                 db "Not same drive!" 
  3424 0001463A 647269766521        <1>
  3425 00014640 0D0A00              <1>                 db 0Dh, 0Ah, 0 
  3426                              <1> 
  3427                              <1> Msg_DoYouWantMoveFile:
  3428 00014643 446F20796F75207761- <1>                 db "Do you want to move file", 0
  3428 0001464C 6E7420746F206D6F76- <1>
  3428 00014655 652066696C6500      <1>
  3429                              <1> 
  3430                              <1> msg_insufficient_disk_space:
  3431 0001465C 496E73756666696369- <1>                 db "Insufficient disk space!" 
  3431 00014665 656E74206469736B20- <1>
  3431 0001466E 737061636521        <1>
  3432 00014674 0D0A00              <1>                 db 0Dh, 0Ah, 0
  3433                              <1> 
  3434                              <1> ; 01/08/2010
  3435                              <1> msg_source_file: 
  3436 00014677 0D0A536F7572636520- <1> 		db 0Dh, 0Ah, "Source file name      :   "
  3436 00014680 66696C65206E616D65- <1>
  3436 00014689 2020202020203A2020- <1>
  3436 00014692 20                  <1>
  3437                              <1> msg_source_file_drv: 
  3438 00014693 203A00              <1> 		db " :", 0
  3439                              <1> msg_destination_file: 
  3440 00014696 0D0A44657374696E61- <1> 		db 0Dh, 0Ah, "Destination file name :   "
  3440 0001469F 74696F6E2066696C65- <1>
  3440 000146A8 206E616D65203A2020- <1>
  3440 000146B1 20                  <1>
  3441                              <1> msg_destination_file_drv: 
  3442 000146B2 203A00              <1> 		db " :", 0
  3443                              <1> msg_copy_nextline: 
  3444 000146B5 0D0A00              <1> 		db 0Dh, 0Ah, 0
  3445                              <1> 
  3446                              <1> ; 15/03/2016
  3447                              <1> ; CMD_INTR.ASM
  3448                              <1> 
  3449                              <1> Msg_DoYouWantOverWriteFile:
  3450 000146B8 446F20796F75207761- <1>                 db "Do you want to overwrite file ",0
  3450 000146C1 6E7420746F206F7665- <1>
  3450 000146CA 727772697465206669- <1>
  3450 000146D3 6C652000            <1>
  3451                              <1>   
  3452                              <1> Msg_DoYouWantCopyFile:
  3453 000146D7 446F20796F75207761- <1>                 db "Do you want to copy file",0
  3453 000146E0 6E7420746F20636F70- <1>
  3453 000146E9 792066696C6500      <1>
  3454                              <1> 
  3455                              <1> Msg_read_file_error_before_EOF:
  3456 000146F0 46696C652072656164- <1> 		db "File reading error! (before EOF)"
  3456 000146F9 696E67206572726F72- <1>
  3456 00014702 2120286265666F7265- <1>
  3456 0001470B 20454F4629          <1>
  3457 00014710 0A0A00              <1> 		db 0Ah, 0Ah, 0
  3458                              <1> 
  3459                              <1> ; 18/03/2016
  3460                              <1> ; TRDOS 386 (v2.0) mainprog copy procedure
  3461                              <1> msg_reading:
  3462 00014713 52656164696E672E2E- <1> 		db "Reading... ", 0
  3462 0001471C 2E2000              <1>
  3463                              <1> msg_writing:
  3464 0001471F 57726974696E672E2E- <1> 		db "Writing... ", 0
  3464 00014728 2E2000              <1>
  3465                              <1> percentagestr:
  3466 0001472B 2020202500          <1> 		db "   %", 0  ; "  0%" .. "100%"
  3467                              <1> ; 11/04/2016
  3468                              <1> Msg_No_Set_Space:
  3469 00014730 496E73756666696369- <1>                 db "Insufficient environment space!"
  3469 00014739 656E7420656E766972- <1>
  3469 00014742 6F6E6D656E74207370- <1>
  3469 0001474B 61636521            <1>
  3470 0001474F 0D0A00              <1>                 db 0Dh, 0Ah, 0
  3471                              <1> ; 18/04/2016
  3472                              <1> isc_msg:	
  3473 00014752 0D0A                <1> 		db 0Dh, 0Ah
  3474 00014754 494E56414C49442053- <1> 		db "INVALID SYSTEM CALL", 0
  3474 0001475D 595354454D2043414C- <1>
  3474 00014766 4C00                <1>
  3475                              <1> usi_msg:
  3476 00014768 0D0A                <1> 		db 0Dh, 0Ah
  3477 0001476A 554E444546494E4544- <1> 		db "UNDEFINED SOFTWARE INTERRUPT", 0
  3477 00014773 20534F465457415245- <1>
  3477 0001477C 20494E544552525550- <1>
  3477 00014785 5400                <1>
  3478                              <1> ifc_msg:
  3479 00014787 0D0A                <1> 		db 0Dh, 0Ah
  3480 00014789 494E56414C49442046- <1> 		db "INVALID FUNCTION CALL"
  3480 00014792 554E4354494F4E2043- <1>
  3480 0001479B 414C4C              <1>
  3481                              <1> inv_msg_for_trdos_v2:
  3482 0001479E 20                  <1> 		db 20h
  3483 0001479F 666F72205452444F53- <1> 		db "for TRDOS v2!"
  3483 000147A8 20763221            <1>
  3484 000147AC 07                  <1> 		db 07h
  3485 000147AD 0D0A                <1> 		db 0Dh, 0Ah
  3486 000147AF 0D0A                <1> 		db 0Dh, 0Ah
  3487 000147B1 494E5420            <1> 		db "INT "
  3488 000147B5 303068              <1> int_num_str:	db "00h"
  3489 000147B8 0D0A                <1> 		db 0Dh, 0Ah
  3490 000147BA 454158203A20        <1> 		db "EAX : "
  3491 000147C0 303030303030303068- <1> eax_str:	db "00000000h", 0Dh, 0Ah
  3491 000147C9 0D0A                <1>
  3492 000147CB 454950203A20        <1> 		db "EIP : "
  3493 000147D1 303030303030303068- <1> eip_str:	db "00000000h", 0Dh, 0Ah, 0
  3493 000147DA 0D0A00              <1>
  3494                              <1> 
  3495                              <1> ; 07/10/2016
  3496                              <1> ; Device names & parameters (for kernel devices)
  3497                              <1> 
  3498 000147DD 90                  <1> align 2
  3499                              <1> KDEV_NAME:
  3500 000147DE 5454590000000000    <1> 		db 'TTY',0,0,0,0,0 ; 1
  3501 000147E6 4D454D0000000000    <1> 		db 'MEM',0,0,0,0,0 ; 2
  3502 000147EE 4644300000000000    <1> 		db 'FD0',0,0,0,0,0 ; 3
  3503 000147F6 4644310000000000    <1> 		db 'FD1',0,0,0,0,0 ; 4
  3504 000147FE 4844300000000000    <1> 		db 'HD0',0,0,0,0,0 ; 5
  3505 00014806 4844310000000000    <1> 		db 'HD1',0,0,0,0,0 ; 6
  3506 0001480E 4844320000000000    <1> 		db 'HD2',0,0,0,0,0 ; 7
  3507 00014816 4844330000000000    <1> 		db 'HD3',0,0,0,0,0 ; 8
  3508 0001481E 4C50540000000000    <1> 		db 'LPT',0,0,0,0,0 ; 9
  3509 00014826 5454593000000000    <1> 		db 'TTY0',0,0,0,0 ; 10
  3510 0001482E 5454593100000000    <1> 		db 'TTY1',0,0,0,0 ; 11
  3511 00014836 5454593200000000    <1> 		db 'TTY2',0,0,0,0 ; 12
  3512 0001483E 5454593300000000    <1> 		db 'TTY3',0,0,0,0 ; 13
  3513 00014846 5454593400000000    <1> 		db 'TTY4',0,0,0,0 ; 14
  3514 0001484E 5454593500000000    <1> 		db 'TTY5',0,0,0,0 ; 15
  3515 00014856 5454593600000000    <1> 		db 'TTY6',0,0,0,0 ; 16
  3516 0001485E 5454593700000000    <1> 		db 'TTY7',0,0,0,0 ; 17
  3517 00014866 5454593800000000    <1> 		db 'TTY8',0,0,0,0 ; 18
  3518 0001486E 5454593900000000    <1> 		db 'TTY9',0,0,0,0 ; 19
  3519 00014876 434F4D3100000000    <1> 		db 'COM1',0,0,0,0 ; 18
  3520 0001487E 434F4D3200000000    <1> 		db 'COM2',0,0,0,0 ; 19
  3521                              <1> 		;db 'CONSOLE',0	  ; 1
  3522                              <1> 		;db 'PRINTER',0   ; 9
  3523                              <1> 		;db 'CDROM'	  ; 20
  3524                              <1> 		;db 'CDROM0'	  ; 20
  3525                              <1> 		;db 'CDROM1'	  ; 21		
  3526                              <1> 		;db 'DVD'	  ; 22
  3527                              <1> 		;db 'DVD0'	  ; 22
  3528                              <1> 		;db 'DVD1'	  ; 23		
  3529                              <1> 		;db 'USB'	  ; 24
  3530                              <1> 		;db 'USB0'	  ; 24
  3531                              <1> 		;db 'USB1'	  ; 25
  3532                              <1> 		;db 'USB2'	  ; 26
  3533                              <1> 		;db 'USB3'        ; 27
  3534                              <1> 		;db 'KEYBOARD'	  ; 1	
  3535                              <1> 		;db 'MOUSE'	  ; 28
  3536                              <1> 		;db 'SOUND'	  ; 29
  3537                              <1> 		;db 'VGA',0,0,0,0 ; 30
  3538                              <1> 		;db 'CGA',0,0,0,0 ; 31
  3539                              <1> 		;db 'AUDIO',0,0,0 ; 29
  3540                              <1> 		;db 'VIDEO',0,0,0 ; 32
  3541                              <1> 		;db 'MUSIC',0,0,0 ; 33
  3542                              <1> 		;db 'ETHERNET'	  ; 34 		
  3543                              <1> 		;db 'SD0',0,0,0,0,0 ; 35
  3544                              <1> 		;db 'SD1',0,0,0,0,0 ; 36
  3545                              <1> 		;db 'SD2',0,0,0,0,0 ; 37
  3546                              <1> 		;db 'SD3',0,0,0,0,0 ; 38
  3547                              <1> 		;db 'SATA0'	  ; 35
  3548                              <1> 		;db 'SATA1'	  ; 36
  3549                              <1> 		;db 'SATA2'        ; 37
  3550                              <1> 		;db 'SATA3'        ; 38
  3551                              <1> 		;db 'PATA0',0,0,0  ; 5
  3552                              <1> 		;db 'PATA1',0,0,0  ; 6
  3553                              <1> 		;db 'PATA2',0,0,0  ; 7
  3554                              <1> 		;db 'PATA3',0,0,0  ; 8
  3555                              <1> 		;db 'WIRELESS'	  ; 39
  3556                              <1> 		;db 'HDMI',0,0,0,0 ; 40
  3557 00014886 4E554C4C00000000    <1> 		db 'NULL',0,0,0,0 ; 0
  3558                              <1> 
  3559                              <1> NumOfKernelDevNames equ ($-KDEV_NAME) / 8 ; 20 (07/10/2016)
  3560                              <1> 
  3561                              <1> KDEV_NUMBER:
  3562 0001488E 010203040506070809  <1> 		db 1,2,3,4,5,6,7,8,9
  3563 00014897 0A0B0C0D0E0F101112- <1> 		db 10,11,12,13,14,15,16,17,18,19
  3563 000148A0 13                  <1>
  3564 000148A1 121300              <1> 		db 18,19,0
  3565                              <1> 
  3566                              <1> NumOfKernelDevices equ $ - KDEV_NUMBER
  3567                              <1> 
  3568                              <1> KDEV_OADDR:
  3569 000148A4 [C1400100]          <1> 		dd otty ;tty  ; 1
  3570 000148A8 [C1400100]          <1> 		dd sret ;mem  ; 2
  3571 000148AC [C1400100]          <1>  		dd sret ;fd0  ; 3
  3572 000148B0 [C1400100]          <1>  		dd sret ;fd1  ; 4
  3573 000148B4 [C1400100]          <1>  		dd sret ;hd0  ; 5
  3574 000148B8 [C1400100]          <1>  		dd sret ;hd1  ; 6
  3575 000148BC [C1400100]          <1>  		dd sret ;hd2  ; 7
  3576 000148C0 [C1400100]          <1>  		dd sret ;hd3  ; 8
  3577 000148C4 [C1400100]          <1>  		dd sret ;lpt  ; 9
  3578 000148C8 [C1400100]          <1>  		dd ocvt ;tty0 ; 10
  3579 000148CC [C1400100]          <1> 		dd ocvt ;tty1 ; 11
  3580 000148D0 [C1400100]          <1>  		dd ocvt ;tty2 ; 12
  3581 000148D4 [C1400100]          <1>  		dd ocvt ;tty3 ; 13
  3582 000148D8 [C1400100]          <1>  		dd ocvt ;tty4 ; 14
  3583 000148DC [C1400100]          <1>  		dd ocvt ;tty5 ; 15
  3584 000148E0 [C1400100]          <1>  		dd ocvt ;tty6 ; 16
  3585 000148E4 [C1400100]          <1>  		dd ocvt ;tty7 ; 17
  3586 000148E8 [C1400100]          <1>  		dd ocvt ;tty8 ; 18
  3587 000148EC [C1400100]          <1>  		dd ocvt ;tty9 ; 19
  3588                              <1>  		;dd ocvt ;com1 ; 18
  3589                              <1>  		;dd ocvt ;com2 ; 19
  3590 000148F0 [C1400100]          <1> 		dd sret ;null ; 20  
  3591                              <1> KDEV_CADDR:
  3592 000148F4 [C1400100]          <1> 		dd ctty ;tty  ; 1
  3593 000148F8 [C1400100]          <1> 		dd cret ;mem  ; 2
  3594 000148FC [C1400100]          <1>  		dd cret ;fd0  ; 3
  3595 00014900 [C1400100]          <1>  		dd cret ;fd1  ; 4
  3596 00014904 [C1400100]          <1>  		dd cret ;hd0  ; 5
  3597 00014908 [C1400100]          <1>  		dd cret ;hd1  ; 6
  3598 0001490C [C1400100]          <1>  		dd cret ;hd2  ; 7
  3599 00014910 [C1400100]          <1>  		dd cret ;hd3  ; 8
  3600 00014914 [C1400100]          <1>  		dd cret ;lpt  ; 9
  3601 00014918 [C1400100]          <1>  		dd ocvt ;tty0 ; 10
  3602 0001491C [C1400100]          <1> 		dd ccvt ;tty1 ; 11
  3603 00014920 [C1400100]          <1>  		dd ccvt ;tty2 ; 12
  3604 00014924 [C1400100]          <1>  		dd ccvt ;tty3 ; 13
  3605 00014928 [C1400100]          <1>  		dd ccvt ;tty4 ; 14
  3606 0001492C [C1400100]          <1>  		dd ccvt ;tty5 ; 15
  3607 00014930 [C1400100]          <1>  		dd ccvt ;tty6 ; 16
  3608 00014934 [C1400100]          <1>  		dd ccvt ;tty7 ; 17
  3609 00014938 [C1400100]          <1>  		dd ccvt ;tty8 ; 18
  3610 0001493C [C1400100]          <1>  		dd ccvt ;tty9 ; 19
  3611                              <1>  		;dd ccvt ;com1 ; 18
  3612                              <1>  		;dd ccvt ;com2 ; 19
  3613 00014940 [C1400100]          <1> 		dd cret ;null ; 20
  3614                              <1> 
  3615                              <1> KDEV_RADDR:
  3616 00014944 [C1400100]          <1> 		dd rtty ;tty  ; 1
  3617 00014948 [C1400100]          <1> 		dd rmem ;mem  ; 2
  3618 0001494C [C1400100]          <1>  		dd rfd  ;fd0  ; 3
  3619 00014950 [C1400100]          <1>  		dd rfd  ;fd1  ; 4
  3620 00014954 [C1400100]          <1>  		dd rhd  ;hd0  ; 5
  3621 00014958 [C1400100]          <1>  		dd rhd  ;hd1  ; 6
  3622 0001495C [C1400100]          <1>  		dd rhd  ;hd2  ; 7
  3623 00014960 [C1400100]          <1>  		dd rhd  ;hd3  ; 8
  3624 00014964 [C1400100]          <1>  		dd rlpt ;lpt  ; 9
  3625 00014968 [C1400100]          <1>  		dd rcvt ;tty0 ; 10
  3626 0001496C [C1400100]          <1> 		dd rcvt ;tty1 ; 11
  3627 00014970 [C1400100]          <1>  		dd rcvt ;tty2 ; 12
  3628 00014974 [C1400100]          <1>  		dd rcvt ;tty3 ; 13
  3629 00014978 [C1400100]          <1>  		dd rcvt ;tty4 ; 14
  3630 0001497C [C1400100]          <1>  		dd rcvt ;tty5 ; 15
  3631 00014980 [C1400100]          <1>  		dd rcvt ;tty6 ; 16
  3632 00014984 [C1400100]          <1>  		dd rcvt ;tty7 ; 17
  3633 00014988 [C1400100]          <1>  		dd rcvt ;tty8 ; 18
  3634 0001498C [C1400100]          <1>  		dd rcvt ;tty9 ; 19
  3635                              <1>  		;dd rcvt ;com1 ; 18
  3636                              <1>  		;dd rcvt ;com2 ; 19
  3637 00014990 [A5340100]          <1> 		dd rnull ;null ; 20  
  3638                              <1> KDEV_WADDR:
  3639 00014994 [C1400100]          <1> 		dd wtty ;tty  ; 1
  3640 00014998 [C1400100]          <1> 		dd wmem ;mem  ; 2
  3641 0001499C [C1400100]          <1>  		dd wfd  ;fd0  ; 3
  3642 000149A0 [C1400100]          <1>  		dd wfd  ;fd1  ; 4
  3643 000149A4 [C1400100]          <1>  		dd whd  ;hd0  ; 5
  3644 000149A8 [C1400100]          <1>  		dd whd  ;hd1  ; 6
  3645 000149AC [C1400100]          <1>  		dd whd  ;hd2  ; 7
  3646 000149B0 [C1400100]          <1>  		dd whd  ;hd3  ; 8
  3647 000149B4 [C1400100]          <1>  		dd wlpt ;lpt  ; 9
  3648 000149B8 [C1400100]          <1>  		dd xmtt ;tty0 ; 10
  3649 000149BC [C1400100]          <1> 		dd xmtt ;tty1 ; 11
  3650 000149C0 [C1400100]          <1>  		dd xmtt ;tty2 ; 12
  3651 000149C4 [C1400100]          <1>  		dd xmtt ;tty3 ; 13
  3652 000149C8 [C1400100]          <1>  		dd xmtt ;tty4 ; 14
  3653 000149CC [C1400100]          <1>  		dd xmtt ;tty5 ; 15
  3654 000149D0 [C1400100]          <1>  		dd xmtt ;tty6 ; 16
  3655 000149D4 [C1400100]          <1>  		dd xmtt ;tty7 ; 17
  3656 000149D8 [C1400100]          <1>  		dd xmtt ;tty8 ; 18
  3657 000149DC [C1400100]          <1>  		dd xmtt ;tty9 ; 19
  3658                              <1>  		;dd xmtt ;com1 ; 18
  3659                              <1>  		;dd xmtt ;com2 ; 19
  3660 000149E0 [A6340100]          <1> 		dd wnull ;null ; 20  
  3661                              <1> 
  3662                              <1> ; DEV_ACCESS bits:
  3663                              <1> 	; bit 0 = accessable by normal users
  3664                              <1> 	; bit 1 = read access permission
  3665                              <1> 	; bit 2 = write access permission
  3666                              <1> 	; bit 3 = IOCTL permission to users
  3667                              <1> 	; bit 4 = block device if it is set
  3668                              <1> 	; bit 5 = 16 bit or 1024 byte data
  3669                              <1> 	; bit 6 = 32 bit or 2048 byte data
  3670                              <1> 	; bit 7 = installable device driver	
  3671                              <1> 
  3672                              <1> KDEV_ACCESS: ; 08/10/2016
  3673 000149E4 07                  <1> 		db  00000111b	; tty, 1
  3674 000149E5 07                  <1> 		db  00000111b	; mem, 2	
  3675 000149E6 8F                  <1> 		db  10001111b	; fd0, 3	
  3676 000149E7 8F                  <1> 		db  10001111b	; fd1, 4
  3677 000149E8 8F                  <1> 		db  10001111b	; hd0, 5
  3678 000149E9 8F                  <1> 		db  10001111b	; hd1, 6
  3679 000149EA 8F                  <1> 		db  10001111b	; hd2, 7
  3680 000149EB 8F                  <1> 		db  10001111b	; hd3, 8
  3681 000149EC 07                  <1> 		db  00000111b   ; lpt, 9
  3682 000149ED 07                  <1> 		db  00000111b	; tty0, 10
  3683 000149EE 07                  <1> 		db  00000111b	; tty1, 11
  3684 000149EF 07                  <1> 		db  00000111b	; tty2, 12
  3685 000149F0 07                  <1> 		db  00000111b	; tty3, 13
  3686 000149F1 07                  <1> 		db  00000111b	; tty4, 14
  3687 000149F2 07                  <1> 		db  00000111b	; tty5, 15
  3688 000149F3 07                  <1> 		db  00000111b	; tty6, 16
  3689 000149F4 07                  <1> 		db  00000111b	; tty7, 17
  3690 000149F5 07                  <1> 		db  00000111b	; tty8, 18
  3691 000149F6 07                  <1> 		db  00000111b	; tty9, 19
  3692                              <1> 		;db 00000111b	; com1, 18
  3693                              <1> 		;db 00000111b	; com2, 19
  3694 000149F7 00                  <1> 		db  00000000b   ; null, 0
  3695                              <1> 
  3696                              <1> ; 07/10/2016
  3697                              <1> NumOfInstallableDevices equ 8
  3698                              <1> NUMIDEV		equ NumOfInstallableDevices ; 8
  3699                              <1> NUMOFDEVICES	equ NumOfKernelDevices + NumOfInstallableDevices
  3700                              <1> 
  3701                              <1> ; 26/02/2017
  3702                              <1> ; IRQ Callback (& Signal Response Byte) service availibity
  3703                              <1> ; 'syscalbac'
  3704                              <1> ; ***************************************************
  3705                              <1> ; IRQ 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
  3706                              <1> ; --- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  3707                              <1> ; --- 00 00 00 01 02 03 00 04 00 05 06 07 08 09 00 00
  3708                              <1> ; ***************************************************
  3709                              <1> IRQenum:
  3710 000149F8 000000010203000400- <1> 	db  0,0,0,1,2,3,0,4,0,5,6,7,8,9,0,0
  3710 00014A01 05060708090000      <1>
  3711                              <1> 
  3712                              <1> ; 28/08/2017
  3713                              <1> ; 20/08/2017
  3714                              <1> ; DMA Registers (for 'sysdma')
  3715                              <1> ; 02/07/2017 (sb16mod.s)
  3716 00014A08 00020406C0C4C8CC    <1> dma_adr:	db 0,2,4,6,0C0h,0C4h,0C8h,0CCh
  3717 00014A10 01030507C2C6CACE    <1> dma_cnt:	db 1,3,5,7,0C2h,0C6h,0CAh,0CEh
  3718 00014A18 878381828F8B898A    <1> dma_page:	db 87h,83h,81h,82h,8Fh,8Bh,89h,8Ah ; 03/08/2017
  3719 00014A20 0A0A0A0AD4D4D4D4    <1> dma_mask:	db 0Ah,0Ah,0Ah,0Ah,0D4h,0D4h,0D4h,0D4h
  3720 00014A28 0B0B0B0BD6D6D6D6    <1> dma_mod:	db 0Bh,0Bh,0Bh,0Bh,0D6h,0D6h,0D6h,0D6h
  3721 00014A30 0C0C0C0CD8D8D8D8    <1> dma_flip:	db 0Ch,0Ch,0Ch,0Ch,0D8h,0D8h,0D8h,0D8h	
  3096                                  
  3097                                  ; 27/08/2014
  3098                                  scr_row:
  3099 00014A38 E0810B00                	dd 0B8000h + 0A0h + 0A0h + 0A0h ; Row 3
  3100                                  scr_col:
  3101 00014A3C 00000000                	dd 0
  3102                                  
  3103                                  Align 4
  3104                                  	; 15/04/2016
  3105                                  	; TRDOS 386 (TRDOS v2.0)
  3106                                  
  3107                                  	; 21/08/2014
  3108                                  ilist:
  3109                                  	;times 	32 dd cpu_except ; INT 0 to INT 1Fh
  3110                                  	;
  3111                                  	; Exception list
  3112                                  	; 25/08/2014	
  3113 00014A40 [EA0B0000]              	dd	exc0	; 0h,  Divide-by-zero Error
  3114 00014A44 [F10B0000]              	dd	exc1	
  3115 00014A48 [F80B0000]              	dd 	exc2	
  3116 00014A4C [FF0B0000]              	dd	exc3	
  3117 00014A50 [030C0000]              	dd	exc4	
  3118 00014A54 [070C0000]              	dd	exc5	
  3119 00014A58 [0B0C0000]              	dd 	exc6	; 06h,  Invalid Opcode
  3120 00014A5C [0F0C0000]              	dd	exc7	
  3121 00014A60 [130C0000]              	dd	exc8	
  3122 00014A64 [170C0000]              	dd	exc9	
  3123 00014A68 [1B0C0000]              	dd 	exc10	
  3124 00014A6C [1F0C0000]              	dd	exc11
  3125 00014A70 [230C0000]              	dd	exc12
  3126 00014A74 [270C0000]              	dd	exc13	; 0Dh, General Protection Fault
  3127 00014A78 [2B0C0000]              	dd 	exc14	; 0Eh, Page Fault
  3128 00014A7C [2F0C0000]              	dd	exc15
  3129 00014A80 [330C0000]              	dd	exc16
  3130 00014A84 [370C0000]              	dd	exc17
  3131 00014A88 [3B0C0000]              	dd 	exc18
  3132 00014A8C [3F0C0000]              	dd	exc19
  3133 00014A90 [430C0000]              	dd 	exc20
  3134 00014A94 [470C0000]              	dd	exc21
  3135 00014A98 [4B0C0000]              	dd	exc22
  3136 00014A9C [4F0C0000]              	dd	exc23
  3137 00014AA0 [530C0000]              	dd 	exc24
  3138 00014AA4 [570C0000]              	dd	exc25
  3139 00014AA8 [5B0C0000]              	dd	exc26
  3140 00014AAC [5F0C0000]              	dd	exc27
  3141 00014AB0 [630C0000]              	dd 	exc28
  3142 00014AB4 [670C0000]              	dd	exc29
  3143 00014AB8 [6B0C0000]              	dd 	exc30
  3144 00014ABC [6F0C0000]              	dd	exc31
  3145                                  IRQ_list: ; 28/02/2017 ('syscalbac')
  3146                                  	; Interrupt list
  3147 00014AC0 [5E090000]              	dd	timer_int	; INT 20h
  3148                                  		;dd	irq0	
  3149 00014AC4 [D6100000]              	dd	kb_int		; 24/01/2016
  3150                                  		;dd	irq1
  3151 00014AC8 [400B0000]              	dd	irq2
  3152                                  		; COM2 int
  3153 00014ACC [440B0000]              	dd	irq3
  3154                                  		; COM1 int
  3155 00014AD0 [4F0B0000]              	dd	irq4
  3156 00014AD4 [5A0B0000]              	dd	irq5
  3157                                  ;DISKETTE_INT: ;06/02/2015
  3158 00014AD8 [DB510000]              	dd	fdc_int		; 16/02/2015, IRQ 6 handler	
  3159                                  		;dd	irq6
  3160                                  ; Default IRQ 7 handler against spurious IRQs (from master PIC)
  3161                                  ; 25/02/2015 (source: http://wiki.osdev.org/8259_PIC)
  3162 00014ADC [C90E0000]              	dd	default_irq7	; 25/02/2015
  3163                                  		;dd	irq7
  3164                                  ; Real Time Clock Interrupt
  3165 00014AE0 [C90A0000]              	dd	rtc_int		; 23/02/2015, IRQ 8 handler
  3166                                  		;dd	irq8	; INT 28h
  3167 00014AE4 [6A0B0000]              	dd	irq9
  3168 00014AE8 [6E0B0000]              	dd	irq10
  3169 00014AEC [720B0000]              	dd	irq11
  3170 00014AF0 [760B0000]              	dd	irq12
  3171 00014AF4 [7A0B0000]              	dd	irq13
  3172                                  ;HDISK_INT1:  ;06/02/2015 	
  3173 00014AF8 [8E5B0000]              	dd	hdc1_int 	; 21/02/2015, IRQ 14 handler		
  3174                                  		;dd	irq14
  3175                                  ;HDISK_INT2:  ;06/02/2015
  3176 00014AFC [B55B0000]              	dd	hdc2_int 	; 21/02/2015, IRQ 15 handler		
  3177                                  		;dd	irq15	; INT 2Fh
  3178                                  		; 14/08/2015
  3179                                  	;dd	sysent		; INT 30h (system calls)
  3180                                  
  3181                                  	; 15/04/2016
  3182                                  	; TRDOS 386(TRDOS v2.0) Software Interrupts
  3183                                  
  3184 00014B00 [5D4B0100]              	dd	int30h		; Reserved for
  3185                                  				; !!! Retro UNIX (RUNIX) !!!
  3186                                  				; !!! SINGLIX !!! System Calls
  3187 00014B04 [C9170000]              	dd	int31h		; Video BIOS (IBM PC/AT, Int 10h)
  3188 00014B08 [F50E0000]              	dd	int32h		; Keyboard Functions (IBM PC/AT, Int 16h)
  3189 00014B0C [92520000]              	dd	int33h		; DISK I/O (IBM PC/AT, Int 13h)
  3190 00014B10 [582D0100]              	dd	int34h		; #IOCTL# (I/O port access support for ring 3)
  3191 00014B14 [466A0000]              	dd	int35h		; Time/Date Functions (IBM PC/AT, Int 1Ah)
  3192 00014B18 [7D0D0000]              	dd	ignore_int	; INT 36h : Timer Functions	
  3193 00014B1C [7D0D0000]              	dd	ignore_int	; INT 37h	
  3194 00014B20 [7D0D0000]              	dd	ignore_int	; INT 38h
  3195 00014B24 [7D0D0000]              	dd	ignore_int	; INT 39h
  3196 00014B28 [7D0D0000]              	dd	ignore_int	; INT 3Ah	
  3197 00014B2C [7D0D0000]              	dd	ignore_int	; INT 3Bh
  3198 00014B30 [7D0D0000]              	dd	ignore_int	; INT 3Ch
  3199 00014B34 [7D0D0000]              	dd	ignore_int	; INT 3Dh	
  3200 00014B38 [7D0D0000]              	dd	ignore_int	; INT 3Eh
  3201 00014B3C [7D0D0000]              	dd	ignore_int	; INT 3Fh
  3202 00014B40 [BAD70000]              	dd	sysent		; INT 40h : !!! TRDOS 386 System Calls !!!
  3203                                  	;dd	ignore_int
  3204 00014B44 00000000                	dd	0
  3205                                  
  3206                                  ; 20/08/2014
  3207                                    ; /* This is the default interrupt "handler" :-) */ 
  3208                                    ; Linux v0.12 (head.s)
  3209                                  int_msg:
  3210 00014B48 556E6B6E6F776E2069-     	db "Unknown interrupt ! ", 0
  3210 00014B51 6E7465727275707420-
  3210 00014B5A 212000             
  3211                                  
  3212                                  ; 15/04/2016
  3213                                  ; TRDOS 386 (TRDOS v2.0)
  3214                                  
  3215                                  ; 29/04/2016
  3216                                  int30h:
  3217                                  trdos_isc_routine:
  3218                                  	; 02/05/2016
  3219                                  	; 01/05/2016
  3220                                  	; 29/04/2016
  3221                                  	; 18/04/2016
  3222                                  	; 15/04/2016 (TRDOS 386 = TRDOS v2.0)
  3223                                  	; 17/04/2011 (TRDOS v1.0, 'IFC.ASM')
  3224                                  	; 03/02/2011 ('trdos_ifc_routine')
  3225                                  	;
  3226 00014B5D 8B1C24                  	mov	ebx, [esp] ; EIP (next)
  3227 00014B60 83EB02                  	sub	ebx, 2 ; EIP (CD ##h)
  3228                                  
  3229 00014B63 89C1                    	mov	ecx, eax
  3230 00014B65 8A4301                  	mov	al, [ebx+1] ; CDh ##h
  3231                                  
  3232 00014B68 66BA1000                	mov	dx, KDATA
  3233 00014B6C 8EDA                    	mov	ds, dx
  3234 00014B6E 8EC2                    	mov	es, dx
  3235                                  
  3236 00014B70 FC                      	cld
  3237 00014B71 8B15[308A0100]          	mov	edx, [k_page_dir]
  3238 00014B77 0F22DA                  	mov	cr3, edx
  3239                                  
  3240 00014B7A E856F7FEFF              	call	bytetohex
  3241 00014B7F 66A3[B5470100]          	mov	[int_num_str], ax
  3242                                  
  3243 00014B85 89D8                    	mov	eax, ebx ; EIP
  3244 00014B87 E889F7FEFF              	call	dwordtohex
  3245 00014B8C 8915[D1470100]          	mov	[eip_str], edx
  3246 00014B92 A3[D5470100]            	mov	[eip_str+4], eax
  3247                                  
  3248 00014B97 89C8                    	mov	eax, ecx
  3249 00014B99 E877F7FEFF              	call	dwordtohex
  3250 00014B9E 8915[C0470100]          	mov	[eax_str], edx
  3251 00014BA4 A3[C4470100]            	mov	[eax_str+4], eax 	
  3252                                  
  3253 00014BA9 43                      	inc	ebx
  3254 00014BAA 8A03                    	mov	al, [ebx] ; Interrupt number
  3255                                  
  3256                                  trdos_isc_handler:
  3257 00014BAC 80FE30                  	cmp	dh, 30h ; Retro UNIX, SINGLIX System calls
  3258 00014BAF 7507                    	jne	short trdos_usi_handler
  3259 00014BB1 BE[52470100]            	mov	esi, isc_msg
  3260 00014BB6 EB05                    	jmp	short loc_write_inv_system_call_msg
  3261                                  
  3262                                  trdos_usi_handler:
  3263 00014BB8 BE[68470100]            	mov	esi, usi_msg
  3264                                  
  3265                                  loc_write_inv_system_call_msg:
  3266 00014BBD E8A329FFFF              	call	print_msg
  3267                                  	; 29/04/2016
  3268 00014BC2 BE[9E470100]            	mov	esi, inv_msg_for_trdos_v2
  3269 00014BC7 E89929FFFF              	call	print_msg
  3270                                  
  3271                                  loc_ifc_terminate_process:
  3272                                  	; u.uno = process number
  3273                                  	; 29/04/2016
  3274                                  
  3275                                  	; 02/05/2016
  3276 00014BCC FE05[5B030300]          	inc	byte [sysflg] ; 0FFh -> 0
  3277                                  
  3278 00014BD2 B801000000              	mov	eax, 1
  3279 00014BD7 E9B78EFFFF              	jmp	sysexit
  3280                                  
  3281                                  ; 07/03/2015
  3282                                  ; Temporary Code
  3283                                  display_disks:
  3284 00014BDC 803D[0E6E0000]00        	cmp 	byte [fd0_type], 0
  3285 00014BE3 7605                    	jna 	short ddsks1
  3286 00014BE5 E87D000000              	call	pdskm
  3287                                  ddsks1:
  3288 00014BEA 803D[0F6E0000]00        	cmp	byte [fd1_type], 0
  3289 00014BF1 760C                    	jna	short ddsks2
  3290 00014BF3 C605[374D0100]31        	mov	byte [dskx], '1'
  3291 00014BFA E868000000              	call	pdskm
  3292                                  ddsks2:
  3293 00014BFF 803D[106E0000]00        	cmp	byte [hd0_type], 0
  3294 00014C06 7654                    	jna	short ddsk6
  3295 00014C08 66C705[354D0100]68-     	mov	word [dsktype], 'hd'
  3295 00014C10 64                 
  3296 00014C11 C605[374D0100]30        	mov	byte [dskx], '0'
  3297 00014C18 E84A000000              	call	pdskm
  3298                                  ddsks3:
  3299 00014C1D 803D[116E0000]00        	cmp	byte [hd1_type], 0
  3300 00014C24 7636                    	jna	short ddsk6
  3301 00014C26 C605[374D0100]31        	mov	byte [dskx], '1'
  3302 00014C2D E835000000              	call	pdskm
  3303                                  ddsks4:
  3304 00014C32 803D[126E0000]00        	cmp	byte [hd2_type], 0
  3305 00014C39 7621                    	jna	short ddsk6
  3306 00014C3B C605[374D0100]32        	mov	byte [dskx], '2'
  3307 00014C42 E820000000              	call	pdskm
  3308                                  ddsks5:
  3309 00014C47 803D[136E0000]00        	cmp	byte [hd3_type], 0
  3310 00014C4E 760C                    	jna	short ddsk6
  3311 00014C50 C605[374D0100]33        	mov	byte [dskx], '3'
  3312 00014C57 E80B000000              	call	pdskm
  3313                                  ddsk6:
  3314 00014C5C BE[5F4D0100]            	mov	esi, nextline
  3315 00014C61 E806000000              	call	pdskml
  3316                                  pdskm_ok:
  3317 00014C66 C3                      	retn
  3318                                  pdskm:
  3319 00014C67 BE[334D0100]            	mov	esi, dsk_ready_msg
  3320                                  pdskml:	
  3321 00014C6C AC                      	lodsb
  3322 00014C6D 08C0                    	or	al, al
  3323 00014C6F 74F5                    	jz	short pdskm_ok
  3324 00014C71 56                      	push	esi
  3325                                  	; 13/05/2016
  3326 00014C72 BB07000000                      mov     ebx, 7  ; Black background, 
  3327                                  			; light gray forecolor
  3328                                  			; Video page 0 (bh=0)
  3329 00014C77 E889D6FEFF              	call	_write_tty
  3330 00014C7C 5E                      	pop	esi
  3331 00014C7D EBED                    	jmp	short pdskml
  3332                                  
  3333 00014C7F 90                      Align 2
  3334                                  	; 21/08/2014
  3335                                  exc_msg:
  3336 00014C80 435055206578636570-     	db "CPU exception ! "
  3336 00014C89 74696F6E202120     
  3337                                  excnstr: 		; 25/08/2014
  3338 00014C90 3F3F68202045495020-     	db "??h", "  EIP : "
  3338 00014C99 3A20               
  3339                                  EIPstr: ; 29/08/2014
  3340 00014C9B 00<rep Ch>              	times 12 db 0
  3341                                  
  3342                                  	; 23/02/2015
  3343                                  	; 25/08/2014
  3344                                  ;scounter:
  3345                                  ;	db 5
  3346                                  ;	db 19
  3347                                  
  3348                                  ; 06/11/2014
  3349                                  ; Memory Information message
  3350                                  ; 14/08/2015
  3351                                  msg_memory_info:
  3352 00014CA7 07                      	db	07h
  3353 00014CA8 0D0A                    	db	0Dh, 0Ah
  3354                                  	;db 	"MEMORY ALLOCATION INFO", 0Dh, 0Ah, 0Dh, 0Ah
  3355 00014CAA 546F74616C206D656D-     	db	"Total memory : "
  3355 00014CB3 6F7279203A20       
  3356                                  mem_total_b_str: ; 10 digits
  3357 00014CB9 303030303030303030-     	db	"0000000000 bytes", 0Dh, 0Ah
  3357 00014CC2 302062797465730D0A 
  3358 00014CCB 202020202020202020-     	db	"               ", 20h, 20h, 20h
  3358 00014CD4 202020202020202020 
  3359                                  mem_total_p_str: ; 7 digits
  3360 00014CDD 303030303030302070-     	db	"0000000 pages", 0Dh, 0Ah
  3360 00014CE6 616765730D0A       
  3361 00014CEC 0D0A                    	db 	0Dh, 0Ah
  3362 00014CEE 46726565206D656D6F-     	db	"Free memory  : "
  3362 00014CF7 727920203A20       
  3363                                  free_mem_b_str:  ; 10 digits
  3364 00014CFD 3F3F3F3F3F3F3F3F3F-     	db	"?????????? bytes", 0Dh, 0Ah
  3364 00014D06 3F2062797465730D0A 
  3365 00014D0F 202020202020202020-     	db	"               ", 20h, 20h, 20h
  3365 00014D18 202020202020202020 
  3366                                  free_mem_p_str:  ; 7 digits
  3367 00014D21 3F3F3F3F3F3F3F2070-     	db	"??????? pages", 0Dh, 0Ah
  3367 00014D2A 616765730D0A       
  3368 00014D30 0D0A00                  	db	0Dh, 0Ah, 0
  3369                                  
  3370                                  dsk_ready_msg:
  3371 00014D33 0D0A                    	db 	0Dh, 0Ah
  3372                                  dsktype:
  3373 00014D35 6664                    	db	'fd'
  3374                                  dskx:
  3375 00014D37 30                      	db	'0'
  3376 00014D38 20                      	db	20h
  3377 00014D39 697320524541445920-     	db 	'is READY ...'
  3377 00014D42 2E2E2E             
  3378 00014D45 00                      	db 	0
  3379                                  
  3380                                  setup_error_msg:
  3381 00014D46 0D0A                    	db 0Dh, 0Ah
  3382 00014D48 4469736B2053657475-     	db 'Disk Setup Error !' 
  3382 00014D51 70204572726F722021 
  3383 00014D5A 0D0A00                  	db 0Dh, 0Ah,0
  3384                                  
  3385                                  next2line: ; 08/02/2016
  3386 00014D5D 0D0A                    	db	0Dh, 0Ah
  3387                                  nextline:
  3388 00014D5F 0D0A00                  	db 	0Dh, 0Ah, 0
  3389                                  
  3390                                  ; temporary
  3391                                  ; 19/12/2020
  3392                                  msg_lfb_addr:
  3393                                  	;db	0Dh, 0Ah
  3394 00014D62 4C696E656172206672-     	db	"Linear frame buffer at "
  3394 00014D6B 616D65206275666665-
  3394 00014D74 7220617420         
  3395                                  lfb_addr_str: ; 8 (hex) digits
  3396 00014D79 303030303030303068-     	db	"00000000h", 0Dh, 0Ah
  3396 00014D82 0D0A               
  3397 00014D84 0D0A00                  	db	0Dh, 0Ah, 0
  3398                                  
  3399                                  ; KERNEL - SYSINIT Messages
  3400                                  ; 24/08/2015
  3401                                  ; 13/04/2015 - (Retro UNIX 386 v1 Beginning)
  3402                                  ; 14/07/2013
  3403                                  ;kernel_init_err_msg:
  3404                                  ;	db 0Dh, 0Ah
  3405                                  ;	db 07h
  3406                                  ;	db 'Kernel initialization ERROR !'
  3407                                  ;	db 0Dh, 0Ah, 0 
  3408                                  
  3409                                  ;welcome_msg: 
  3410                                  ;	db 0Dh, 0Ah
  3411                                  ;	db 07h
  3412                                  ;	db 'Welcome to TRDOS 386 Operating System !'
  3413                                  ;	db 0Dh, 0Ah
  3414                                  ;	db 'by Erdogan Tan - 31/12/2017 (v2.0.0)'
  3415                                  ;	db 0Dh, 0Ah, 0
  3416                                  
  3417                                  panic_msg:
  3418 00014D87 0D0A07                  	db 0Dh, 0Ah, 07h
  3419 00014D8A 4552524F523A204B65-     	db 'ERROR: Kernel Panic !'
  3419 00014D93 726E656C2050616E69-
  3419 00014D9C 632021             
  3420 00014D9F 0D0A00                  	db 0Dh, 0Ah, 0
  3421                                  
  3422                                  ;msgl_drv_not_ready: 
  3423                                  ;	db 07h, 0Dh, 0Ah
  3424                                  ;       db 'Drive not ready or read error !'
  3425                                  ;       db 0Dh, 0Ah, 0
  3426                                  
  3427                                  starting_msg:
  3428 00014DA2 5475726B6973682052-     	db "Turkish Rational DOS v2.0 [07/03/2021] ...", 0
  3428 00014DAB 6174696F6E616C2044-
  3428 00014DB4 4F532076322E30205B-
  3428 00014DBD 30372F30332F323032-
  3428 00014DC6 315D202E2E2E00     
  3429                                  NextLine:
  3430 00014DCD 0D0A00                  	db 0Dh, 0Ah, 0
  3431                                  
  3432                                  %include 'audio.s' ; 03/04/2017
  3433                              <1> ; ****************************************************************************
  3434                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.2 - audio.s
  3435                              <1> ; ----------------------------------------------------------------------------
  3436                              <1> ; Last Update: 01/09/2020
  3437                              <1> ; ----------------------------------------------------------------------------
  3438                              <1> ; Beginning: 03/04/2017
  3439                              <1> ; ----------------------------------------------------------------------------
  3440                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
  3441                              <1> ; ****************************************************************************
  3442                              <1> 
  3443                              <1> ; AUDIO CONTROLLER & CODEC DEFINITIONS & CODE FOR TRDOS 386
  3444                              <1> 
  3445                              <1> ;=============================================================================
  3446                              <1> ;               EQUATES
  3447                              <1> ;=============================================================================
  3448                              <1> 
  3449                              <1> ; PCI EQUATES
  3450                              <1> 
  3451                              <1> BIT0  EQU 1
  3452                              <1> BIT1  EQU 2
  3453                              <1> BIT2  EQU 4
  3454                              <1> BIT3  EQU 8
  3455                              <1> BIT4  EQU 10h
  3456                              <1> BIT5  EQU 20h
  3457                              <1> BIT6  EQU 40h
  3458                              <1> BIT7  EQU 80h
  3459                              <1> BIT8  EQU 100h
  3460                              <1> BIT9  EQU 200h
  3461                              <1> BIT10 EQU 400h
  3462                              <1> BIT11 EQU 800h
  3463                              <1> BIT12 EQU 1000h
  3464                              <1> BIT13 EQU 2000h
  3465                              <1> BIT14 EQU 4000h
  3466                              <1> BIT15 EQU 8000h
  3467                              <1> BIT16 EQU 10000h
  3468                              <1> BIT17 EQU 20000h
  3469                              <1> BIT18 EQU 40000h
  3470                              <1> BIT19 EQU 80000h
  3471                              <1> BIT20 EQU 100000h
  3472                              <1> BIT21 EQU 200000h
  3473                              <1> BIT22 EQU 400000h
  3474                              <1> BIT23 EQU 800000h
  3475                              <1> BIT24 EQU 1000000h
  3476                              <1> BIT25 EQU 2000000h
  3477                              <1> BIT26 EQU 4000000h
  3478                              <1> BIT27 EQU 8000000h
  3479                              <1> BIT28 EQU 10000000h
  3480                              <1> BIT29 EQU 20000000h
  3481                              <1> BIT30 EQU 40000000h
  3482                              <1> BIT31 EQU 80000000h
  3483                              <1> NOT_BIT31 EQU 7FFFFFFFh
  3484                              <1> 
  3485                              <1> ; PCI equates
  3486                              <1> ; PCI function address (PFA)
  3487                              <1> ; bit 31 = 1
  3488                              <1> ; bit 23:16 = bus number     (0-255)
  3489                              <1> ; bit 15:11 = device number  (0-31)
  3490                              <1> ; bit 10:8 = function number (0-7)
  3491                              <1> ; bit 7:0 = register number  (0-255)
  3492                              <1> 
  3493                              <1> IO_ADDR_MASK    EQU     0FFFEh	; mask off bit 0 for reading BARs
  3494                              <1> PCI_INDEX_PORT  EQU     0CF8h
  3495                              <1> PCI_DATA_PORT   EQU     0CFCh
  3496                              <1> PCI32           EQU     BIT31	; bitflag to signal 32bit access
  3497                              <1> PCI16           EQU     BIT30	; bitflag for 16bit access
  3498                              <1> NOT_PCI32_PCI16	EQU	03FFFFFFFh ; NOT BIT31+BIT30 ; 19/03/2017
  3499                              <1> 
  3500                              <1> PCI_FN0         EQU     0 << 8
  3501                              <1> PCI_FN1         EQU     1 << 8
  3502                              <1> PCI_FN2         EQU     2 << 8
  3503                              <1> PCI_FN3         EQU     3 << 8
  3504                              <1> PCI_FN4         EQU     4 << 8
  3505                              <1> PCI_FN5         EQU     5 << 8
  3506                              <1> PCI_FN6         EQU     6 << 8
  3507                              <1> PCI_FN7         EQU     7 << 8
  3508                              <1> 
  3509                              <1> PCI_CMD_REG	EQU	04h	; reg 04, command reg
  3510                              <1> IO_ENA		EQU	BIT0	; i/o decode enable
  3511                              <1> MEM_ENA		EQU	BIT1	; memory decode enable
  3512                              <1> BM_ENA		EQU     BIT2	; bus master enable
  3513                              <1> 
  3514                              <1> ; VIA VT8233 EQUATES
  3515                              <1> 
  3516                              <1> VIA_VID		equ 1106h	; VIA's PCI vendor ID
  3517                              <1> VT8233_DID      equ 3059h	; VT8233 (VT8235) device ID
  3518                              <1> 		
  3519                              <1> PCI_IO_BASE          equ 10h
  3520                              <1> AC97_INT_LINE        equ 3Ch
  3521                              <1> VIA_ACLINK_CTRL      equ 41h
  3522                              <1> VIA_ACLINK_STAT      equ 40h
  3523                              <1> VIA_ACLINK_C00_READY equ 01h ; primary codec ready
  3524                              <1> 	
  3525                              <1> VIA_REG_AC97	     equ 80h ; dword
  3526                              <1> 
  3527                              <1> VIA_ACLINK_CTRL_ENABLE	equ   80h ; 0: disable, 1: enable
  3528                              <1> VIA_ACLINK_CTRL_RESET	equ   40h ; 0: assert, 1: de-assert
  3529                              <1> VIA_ACLINK_CTRL_SYNC	equ   20h ; 0: release SYNC, 1: force SYNC hi
  3530                              <1> VIA_ACLINK_CTRL_VRA	equ   08h ; 0: disable VRA, 1: enable VRA
  3531                              <1> VIA_ACLINK_CTRL_PCM	equ   04h ; 0: disable PCM, 1: enable PCM
  3532                              <1> 					; 3D Audio Channel slots 3/4
  3533                              <1> VIA_ACLINK_CTRL_INIT	equ  (VIA_ACLINK_CTRL_ENABLE +                               VIA_ACLINK_CTRL_RESET +                               VIA_ACLINK_CTRL_PCM +                               VIA_ACLINK_CTRL_VRA)
  3537                              <1> 
  3538                              <1> CODEC_AUX_VOL		equ   04h
  3539                              <1> VIA_REG_AC97_BUSY	equ   01000000h ;(1<<24) 
  3540                              <1> VIA_REG_AC97_CMD_SHIFT	equ   10h ; 16
  3541                              <1> VIA_REG_AC97_PRIMARY_VALID equ 02000000h ;(1<<25)
  3542                              <1> VIA_REG_AC97_READ	equ   00800000h ;(1<<23)
  3543                              <1> VIA_REG_AC97_CODEC_ID_SHIFT   equ  1Eh ; 30
  3544                              <1> VIA_REG_AC97_CODEC_ID_PRIMARY equ  0
  3545                              <1> VIA_REG_AC97_DATA_SHIFT equ   0
  3546                              <1> VIADEV_PLAYBACK         equ   0
  3547                              <1> VIA_REG_OFFSET_STATUS   equ   0    ;; byte - channel status
  3548                              <1> VIA_REG_OFFSET_CONTROL  equ   01h  ;; byte - channel control
  3549                              <1> VIA_REG_CTRL_START	equ   80h  ;; WO
  3550                              <1> VIA_REG_CTRL_TERMINATE  equ   40h  ;; WO
  3551                              <1> VIA_REG_CTRL_PAUSE      equ   08h  ;; RW
  3552                              <1> VIA_REG_CTRL_RESET      equ   01h  ;; RW - probably reset? undocumented
  3553                              <1> VIA_REG_OFFSET_STOP_IDX equ   08h  ;; dword - stop index, channel type, sample rate
  3554                              <1> VIA8233_REG_TYPE_16BIT  equ   200000h ;; RW
  3555                              <1> VIA8233_REG_TYPE_STEREO equ   100000h ;; RW
  3556                              <1> VIA_REG_OFFSET_CURR_INDEX equ 0Fh ;; byte - channel current index (for via8233 only)
  3557                              <1> VIA_REG_OFFSET_TABLE_PTR equ  04h  ;; dword - channel table pointer
  3558                              <1> VIA_REG_OFFSET_CURR_PTR equ   04h  ;; dword - channel current pointer
  3559                              <1> VIA_REG_OFS_PLAYBACK_VOLUME_L equ  02h ;; byte
  3560                              <1> VIA_REG_OFS_PLAYBACK_VOLUME_R equ  03h ;; byte
  3561                              <1> VIA_REG_CTRL_AUTOSTART	equ   20h
  3562                              <1> VIA_REG_CTRL_INT_EOL	equ   02h
  3563                              <1> VIA_REG_CTRL_INT_FLAG	equ   01h
  3564                              <1> VIA_REG_CTRL_INT	equ  (VIA_REG_CTRL_INT_FLAG +                               VIA_REG_CTRL_INT_EOL +                               VIA_REG_CTRL_AUTOSTART)
  3567                              <1> 
  3568                              <1> VIA_REG_STAT_STOP_IDX	equ   10h    ;; RO ; 27/07/2020
  3569                              <1> 				     ; current index = stop index
  3570                              <1> VIA_REG_STAT_STOPPED	equ   04h    ;; RWC
  3571                              <1> VIA_REG_STAT_EOL	equ   02h    ;; RWC
  3572                              <1> VIA_REG_STAT_FLAG	equ   01h    ;; RWC
  3573                              <1> VIA_REG_STAT_ACTIVE	equ   80h    ;; RO
  3574                              <1> ; 28/11/2016
  3575                              <1> VIA_REG_STAT_LAST	equ   40h    ;; RO
  3576                              <1> VIA_REG_STAT_TRIGGER_QUEUED equ 08h  ;; RO
  3577                              <1> VIA_REG_CTRL_INT_STOP	equ   04h  ; Interrupt on Current Index = Stop Index
  3578                              <1> 		   		   ; and End of Block
  3579                              <1> 
  3580                              <1> VIA_REG_OFFSET_CURR_COUNT equ 0Ch ;; dword - channel current count, index
  3581                              <1> 
  3582                              <1> PORTB		EQU	061h
  3583                              <1> REFRESH_STATUS	EQU	010h	; Refresh signal status
  3584                              <1> 
  3585                              <1> ; AC97 Codec registers.
  3586                              <1> 
  3587                              <1> ; 22/07/2020
  3588                              <1> ; REALTEK ALC655 and ADI SOUNDMAX AD1980 CODEC MIXER REGISTERS
  3589                              <1> 
  3590                              <1> ; each codec/mixer register is 16bits
  3591                              <1> 
  3592                              <1> CODEC_RESET_REG                 equ     00h	; reset codec
  3593                              <1> CODEC_MASTER_VOL_REG            equ     02h	; master volume
  3594                              <1> CODEC_HP_VOL_REG                equ     04h	; headphone volume ; AD1980
  3595                              <1> CODEC_MASTER_MONO_VOL_REG       equ     06h	; master mono volume (mono-out)
  3596                              <1> ;CODEC_MASTER_TONE_REG          equ     08h	; master tone (R+L) ; (not used)
  3597                              <1> CODEC_PCBEEP_VOL_REG            equ     0Ah	; PC beep volume ; ALC655
  3598                              <1> CODEC_PHONE_VOL_REG             equ     0Ch	; phone volume
  3599                              <1> CODEC_MIC_VOL_REG               equ     0Eh	; mic volume
  3600                              <1> CODEC_LINE_IN_VOL_REG           equ     10h	; line in volume
  3601                              <1> CODEC_CD_VOL_REG                equ     12h	; CD volume
  3602                              <1> ;CODEC_VID_VOL_REG              equ     14h	; video volume ; (not used)
  3603                              <1> CODEC_AUX_VOL_REG               equ     16h	; aux volume
  3604                              <1> CODEC_PCM_OUT_REG               equ     18h	; PCM out volume
  3605                              <1> CODEC_RECORD_SELECT_REG         equ     1Ah	; record select
  3606                              <1> CODEC_RECORD_VOL_REG            equ     1Ch	; record volume (record gain)
  3607                              <1> ;CODEC_RECORD_MIC_VOL_REG       equ     1Eh	; record mic volume ; (not used)
  3608                              <1> CODEC_GP_REG                    equ     20h	; general purpose
  3609                              <1> ;CODEC_3D_CONTROL_REG           equ     22h	; 3D control
  3610                              <1> ;;CODEC_AUDIO_INT_PAGING_REG    equ	24h	; audio int & paging ; (not used) 
  3611                              <1> CODEC_POWER_CTRL_REG            equ     26h	; power down control
  3612                              <1> CODEC_EXT_AUDIO_REG             equ     28h	; extended audio ID
  3613                              <1> CODEC_EXT_AUDIO_CTRL_REG        equ     2Ah	; extended audio status/control
  3614                              <1> CODEC_PCM_FRONT_DACRATE_REG     equ     2Ch	; PCM front sample rate
  3615                              <1> CODEC_PCM_SURND_DACRATE_REG     equ     2Eh	; PCM surround sample rate
  3616                              <1> CODEC_PCM_LFE_DACRATE_REG       equ     30h	; PCM Center/LFE sample rate
  3617                              <1> CODEC_LR_ADCRATE_REG            equ     32h	; PCM input sample rate
  3618                              <1> CODEC_MIC_ADCRATE_REG           equ     34h	; mic in sample rate  ; AD1980
  3619                              <1> CODEC_PCM_LFE_VOL_REG           equ     36h	; PCM Center/LFE volume
  3620                              <1> CODEC_PCM_SURND_VOL_REG         equ     38h	; PCM surround volume
  3621                              <1> ;CODEC_SPDIF_CTRL_REG           equ     3Ah	; S/PDIF control
  3622                              <1> ; 22/07/2020
  3623                              <1> CODEC_MISC_CRTL_BITS_REG	equ	76h	; misc control bits ; AD1980
  3624                              <1> ;	
  3625                              <1> CODEC_VENDOR_ID1		equ	7Ch	; REALTEK: 414Ch, ADI: 4144h	
  3626                              <1> CODEC_VENDOR_ID2		equ	7Eh	; REALTEK: 4760h, ADI: 5370h	
  3627                              <1> 
  3628                              <1> ; VT8233 SGD bits (21/04/2017)
  3629                              <1> FLAG	EQU BIT30
  3630                              <1> EOL	EQU BIT31
  3631                              <1> 
  3632                              <1> ; INTEL ICH EQUATES
  3633                              <1> ; 28/05/2017
  3634                              <1> INTEL_VID	equ	8086h	; Intel's PCI vendor ID
  3635                              <1> ICH_DID		equ	2415h	; ICH (82801AA) device ID
  3636                              <1> NAMBAR_REG      equ	10h	; native audio mixer Base Address Register
  3637                              <1> NABMBAR_REG     equ	14h	; native audio bus mastering Base Addr Reg
  3638                              <1> 
  3639                              <1> PI_CR_REG       equ     0Bh     ; PCM in Control Register
  3640                              <1> PO_CR_REG	equ     1Bh     ; PCM out Control Register
  3641                              <1> MC_CR_REG	equ     2Bh     ; MIC in Control Register
  3642                              <1> 
  3643                              <1> PI_SR_REG	equ     6       ; PCM in Status register
  3644                              <1> PO_SR_REG	equ     16h     ; PCM out Status register
  3645                              <1> MC_SR_REG	equ     26h     ; MIC in Status register
  3646                              <1> 
  3647                              <1> IOCE 		equ     BIT4    ; interrupt on complete enable.
  3648                              <1> FEIFE		equ     BIT3    ; set if you want an interrupt to fire
  3649                              <1> LVBIE		equ     BIT2    ; last valid buffer interrupt enable.
  3650                              <1> RR 		equ     BIT1    ; reset registers. Nukes all regs
  3651                              <1>                                 ; except bits 4:2 of this register.
  3652                              <1>                                 ; Only set this bit if BIT 0 is 0
  3653                              <1> RPBM		equ     BIT0    ; Run/Pause
  3654                              <1> 				; set this bit to start the codec!
  3655                              <1> 
  3656                              <1> PI_BDBAR_REG	equ     0       ; PCM in buffer descriptor BAR
  3657                              <1> PO_BDBAR_REG	equ     10h     ; PCM out buffer descriptor BAR
  3658                              <1> MC_BDBAR_REG	equ     20h     ; MIC in buffer descriptor BAR
  3659                              <1> 
  3660                              <1> PI_CIV_REG	equ     4       ; PCM in current Index value (RO)
  3661                              <1> PO_CIV_REG	equ     14h     ; PCM out current Index value (RO)
  3662                              <1> MC_CIV_REG 	equ     24h     ; MIC in current Index value (RO)
  3663                              <1> 
  3664                              <1> PI_LVI_REG	equ     5       ; PCM in Last Valid Index
  3665                              <1> PO_LVI_REG	equ     15h     ; PCM out Last Valid Index
  3666                              <1> MC_LVI_REG	equ     25h     ; MIC in Last Valid Index
  3667                              <1> 
  3668                              <1> IOC		equ     BIT31	; Fire an interrupt whenever this
  3669                              <1>                 		; buffer is complete.
  3670                              <1> BUP		equ     BIT30	; Buffer Underrun Policy.
  3671                              <1> 
  3672                              <1> GLOB_CNT_REG	equ     2Ch     ; Global Control Register
  3673                              <1> GLOB_STS_REG	equ     30h     ; Global Status register (RO)
  3674                              <1> 
  3675                              <1> CTRL_ST_CREADY	equ   BIT8+BIT9+BIT28 ; Primary Codec Ready
  3676                              <1> 
  3677                              <1> CODEC_REG_POWERDOWN   equ 26h
  3678                              <1> CODEC_REG_ST          equ 26h
  3679                              <1> 
  3680                              <1> ; 22/06/2017
  3681                              <1> PO_PICB_REG	equ 18h	; PCM Out Position In Current Buffer Register
  3682                              <1> 
  3683                              <1> ;=============================================================================
  3684                              <1> ;               CODE
  3685                              <1> ;=============================================================================
  3686                              <1> 
  3687                              <1> ; CODE for INTEL ICH AC'97 AUDIO CONTROLLER
  3688                              <1> 
  3689                              <1> DetectICH:
  3690                              <1> 	; 10/06/2017
  3691                              <1> 	; 05/06/2017
  3692                              <1> 	; 29/05/2017
  3693                              <1> 	; 28/05/2017
  3694 00014DD0 B886801524          <1> 	mov     eax, (ICH_DID << 16) + INTEL_VID
  3695 00014DD5 E876000000          <1>         call    pciFindDevice
  3696 00014DDA 730D                <1>         jnc     short d_ac97_1
  3697                              <1> d_ac97_0:
  3698                              <1> ; couldn't find the audio device!
  3699 00014DDC C3                  <1> 	retn
  3700                              <1> 
  3701                              <1> ; CODE for VIA VT8233 AUDIO CONTROLLER
  3702                              <1> 
  3703                              <1> DetectVT8233:
  3704                              <1> 	; 10/06/2017
  3705                              <1> 	; 05/06/2017
  3706                              <1> 	; 29/05/2017
  3707                              <1> 	; 03/04/2017
  3708 00014DDD B806115930          <1> 	mov     eax, (VT8233_DID << 16) + VIA_VID
  3709 00014DE2 E869000000          <1>         call    pciFindDevice
  3710                              <1> ;       jnc     short d_vt8233_0
  3711                              <1> ; couldn't find the audio device!
  3712                              <1> ;	retn
  3713 00014DE7 72F3                <1> 	jc	short d_ac97_0  ; 28/05/2017
  3714                              <1> d_vt8233_0:
  3715                              <1> 	; 24/03/2017 ('player.asm')
  3716                              <1> 	; 12/11/2016 
  3717                              <1> 	; Erdogan Tan - 8/11/2016
  3718                              <1> 	; References: Kolibrios - vt823x.asm (2016)
  3719                              <1> 	;	      VIA VT8235 V-Link South Bridge (VT8235-VIA.PDF)(2002)
  3720                              <1> 	;	      lowlevel.eu - AC97 (2016)
  3721                              <1> 	;	      .wav player for DOS by Jeff Leyda (2002) -this file-
  3722                              <1> 	;	      Linux kernel - via82xx.c (2016)
  3723                              <1> d_ac97_1:
  3724                              <1> 	; eax = BUS/DEV/FN
  3725                              <1> 	;	00000000BBBBBBBBDDDDDFFF00000000
  3726                              <1> 	; edx = DEV/VENDOR
  3727                              <1> 	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
  3728                              <1> 
  3729 00014DE9 A3[B89C0100]        <1> 	mov	[audio_dev_id], eax
  3730 00014DEE 8915[BC9C0100]      <1> 	mov	[audio_vendor], edx
  3731                              <1> 
  3732                              <1> 	; init controller
  3733 00014DF4 B004                <1> 	mov	al, PCI_CMD_REG ; command register (04h)
  3734 00014DF6 E8E2000000          <1> 	call	pciRegRead32
  3735                              <1> 
  3736                              <1> 	; eax = BUS/DEV/FN/REG
  3737                              <1> 	; edx = STATUS/COMMAND
  3738                              <1> 	; 	SSSSSSSSSSSSSSSSCCCCCCCCCCCCCCCC
  3739 00014DFB 8915[C09C0100]      <1> 	mov	[audio_stats_cmd], edx
  3740                              <1> 
  3741 00014E01 B010                <1> 	mov	al, PCI_IO_BASE ; IO base address register (10h)
  3742                              <1> 	;mov	al, NAMBAR_REG	; Native Audio Mixer BAR (10h)
  3743 00014E03 E8D5000000          <1> 	call	pciRegRead32
  3744                              <1> 
  3745 00014E08 66813D[BC9C0100]86- <1> 	cmp	word [audio_vendor], 8086h ; AC'97 ?
  3745 00014E10 80                  <1>
  3746 00014E11 751F                <1> 	jne	short d_vt8233_1
  3747                              <1> 
  3748 00014E13 6683E2FE            <1> 	and	dx, 0FFFEh ; Audio Codec IO_ADDR_MASK
  3749 00014E17 668915[E89C0100]    <1> 	mov	[NAMBAR], dx
  3750                              <1> 
  3751 00014E1E B014                <1> 	mov	al, NABMBAR_REG ; Native Audio Bus Mastering BAR (14h)
  3752 00014E20 E8B8000000          <1> 	call	pciRegRead32	
  3753                              <1> 
  3754 00014E25 6683E2C0            <1> 	and	dx, 0FFC0h ; Audio Controller IO_ADDR_MASK
  3755 00014E29 668915[EA9C0100]    <1> 	mov	[NABMBAR], dx
  3756                              <1>         ;mov	[audio_io_base], dx
  3757                              <1> 	
  3758 00014E30 EB0B                <1> 	jmp	short d_ac97_2
  3759                              <1> 
  3760                              <1> d_vt8233_1:
  3761 00014E32 6683E2C0            <1> 	and     dx, 0FFC0h ; Audio Controller IO_ADDR_MASK 
  3762 00014E36 668915[B69C0100]    <1>         mov     [audio_io_base], dx
  3763                              <1> 
  3764                              <1> d_ac97_2:
  3765                              <1> 	; 10/06/2017
  3766 00014E3D B03C                <1> 	mov	al, AC97_INT_LINE ; Interrupt Line Register (3Ch)
  3767                              <1> 	;call	pciRegRead32
  3768 00014E3F E886000000          <1> 	call	pciRegRead8
  3769                              <1> 
  3770                              <1> 	;and 	edx, 0FFh
  3771 00014E44 6681E2FF00          <1> 	and	dx, 0FFh
  3772                              <1> 
  3773 00014E49 8815[B39C0100]      <1>   	mov     [audio_intr], dl
  3774                              <1> 
  3775 00014E4F C3                  <1> 	retn
  3776                              <1> 
  3777                              <1> 	;; (Note: Interrupts are already enabled by TRDOS 386 kernel!)
  3778                              <1> 	;mov	cx, dx
  3779                              <1> 	
  3780                              <1> 	;in	al, 0A1h ; irq 8-15
  3781                              <1> 	;mov	ah, al
  3782                              <1> 	;in	al, 21h  ; irq 0-7 
  3783                              <1> 	;btr	ax, dx	 ; unmask ; 17/03/2017
  3784                              <1> 	;;bts	ax, dx   ; MASK interrupt ; 10/06/2017 
  3785                              <1> 	;out	21h, al  ; irq <= 7
  3786                              <1> 	;mov	al, ah
  3787                              <1> 	;out	0A1h, al ; irq > 7
  3788                              <1> 	;
  3789                              <1> 	
  3790                              <1> 	; 10/06/2017
  3791                              <1> 	; === Intel ICH I/O Controller Hub Datasheet, Section 8.1.16 ===
  3792                              <1> 	; PRQ[n]_ROUT Register (61h, PRQB) Bit 7:
  3793                              <1> 	; Interrupt Routing Enable (IRQEN).
  3794                              <1> 	; 0 = The corresponding PIRQ is routed to one of the ISA-compatible
  3795                              <1> 	;     interrupts specified in bits[3:0].
  3796                              <1> 	; 1 = The PIRQ is not routed to the 8259.
  3797                              <1> 	; Note: If the PIRQ is intended to cause an interrupt to the ICHs 
  3798                              <1> 	;	integrated I/O APIC, then this bit should be set to 0 and 
  3799                              <1> 	;	the APIC_EN bit should be set to 1. 
  3800                              <1> 	;	The IRQEN must be set to 0 and the PIRQ routed to 
  3801                              <1> 	;	an 8259 interrupt via the IRQ Routing filed (bits[3:0).
  3802                              <1> 	;	The corresponding 8259 interrupt must be masked via the 
  3803                              <1> 	;	appropriated bit in the 8259s OCW1 (Interrupt Mask)
  3804                              <1> 	;	register. The IOAPIC must then be enabled by setting 
  3805                              <1> 	;	the APIC_EN bit in the GEN_CNTL register.
  3806                              <1> 
  3807                              <1> 	;mov	eax, 0F861h  ; D31:F0
  3808                              <1> 		;AL=61h : PIRQ[B] Routing Control Reg, LPC interface
  3809                              <1> 	;;mov	dl, [audio_intr]
  3810                              <1> 	;call	pciRegWrite8
  3811                              <1> 	;;mov	al, 0D0h ; General Control Register (GEN_CTL)
  3812                              <1> 	;;call	pciRegRead32
  3813                              <1> 	;;or	edx, 100h ; Bit 8, APIC_EN (Enable I/O APIC) 
  3814                              <1> 	;;;call	pciRegWrite32
  3815                              <1> 	;;and	edx, ~100h
  3816                              <1> 	;;call	pciRegWrite32 ; ; Bit 8, APIC_EN (Disable I/O APIC) 
  3817                              <1> 	;
  3818                              <1> 
  3819                              <1> 	;mov	dx, 4D1h	; 8259 ELCR2
  3820                              <1>     	;in	al, dx
  3821                              <1> 	;mov	ah, al
  3822                              <1> 	;;mov	dx, 4D0h 	; 8259 ELCR1
  3823                              <1> 	;dec	dl
  3824                              <1> 	;in	al, dx
  3825                              <1> 	;bts	ax, cx
  3826                              <1> 	;;mov	dx, 4D0h
  3827                              <1> 	;out	dx, al		; set level-triggered mode
  3828                              <1> 	;mov	al, ah ; 29/05/2017
  3829                              <1> 	;;mov	dx, 4D1h
  3830                              <1> 	;inc	dl
  3831                              <1> 	;out	dx, al		; set level-triggered mode
  3832                              <1> 
  3833                              <1> 	;xor	eax, eax ; 0
  3834                              <1> 
  3835                              <1> 	;retn
  3836                              <1> 
  3837                              <1> ; CODE for PCI
  3838                              <1> 
  3839                              <1> pciFindDevice:
  3840                              <1> 	; 03/04/2017 ('pci.asm', 20/03/2017)
  3841                              <1> 	;
  3842                              <1> 	; scan through PCI space looking for a device+vendor ID
  3843                              <1> 	;
  3844                              <1> 	; Entry: EAX=Device+Vendor ID
  3845                              <1> 	;
  3846                              <1> 	; Exit: EAX=PCI address if device found
  3847                              <1> 	;	 EDX=Device+Vendor ID
  3848                              <1> 	;        CY clear if found, set if not found. EAX invalid if CY set.
  3849                              <1> 	;
  3850                              <1> 	; Destroys: ebx, esi, edi, cl
  3851                              <1> 	;
  3852                              <1> 
  3853                              <1> 	;push	ecx
  3854 00014E50 50                  <1> 	push	eax
  3855                              <1> 	;push	esi
  3856                              <1> 	;push	edi
  3857                              <1> 
  3858 00014E51 89C6                <1>         mov     esi, eax                ; save off vend+device ID
  3859 00014E53 BF00FFFF7F          <1>         mov     edi, (80000000h - 100h) ; start with bus 0, dev 0 func 0
  3860                              <1> 
  3861                              <1> nextPCIdevice:
  3862 00014E58 81C700010000        <1>         add     edi, 100h
  3863 00014E5E 81FF00F8FF80        <1>         cmp     edi, 80FFF800h		; scanned all devices?
  3864 00014E64 F9                  <1>         stc
  3865 00014E65 740C                <1>         je      short PCIScanExit       ; not found
  3866                              <1> 
  3867 00014E67 89F8                <1>         mov     eax, edi                ; read PCI registers
  3868 00014E69 E86F000000          <1>         call    pciRegRead32
  3869 00014E6E 39F2                <1>         cmp     edx, esi                ; found device?
  3870 00014E70 75E6                <1>         jne     short nextPCIdevice
  3871 00014E72 F8                  <1>         clc
  3872                              <1> 
  3873                              <1> PCIScanExit:
  3874 00014E73 9C                  <1> 	pushf
  3875 00014E74 B8FFFFFF7F          <1> 	mov	eax, NOT_BIT31 	; 19/03/2017
  3876 00014E79 21F8                <1> 	and	eax, edi	; return only bus/dev/fn #
  3877 00014E7B 9D                  <1> 	popf
  3878                              <1> 
  3879                              <1> 	;pop	edi
  3880                              <1> 	;pop	esi
  3881 00014E7C 5A                  <1> 	pop	edx
  3882                              <1> 	;pop	ecx
  3883 00014E7D C3                  <1> 	retn
  3884                              <1> 
  3885                              <1> pciRegRead:
  3886                              <1> 	; 03/04/2017 ('pci.asm', 20/03/2017)
  3887                              <1> 	;
  3888                              <1> 	; 8/16/32bit PCI reader
  3889                              <1> 	;
  3890                              <1> 	; Entry: EAX=PCI Bus/Device/fn/register number
  3891                              <1> 	;           BIT30 set if 32 bit access requested
  3892                              <1> 	;           BIT29 set if 16 bit access requested
  3893                              <1> 	;           otherwise defaults to 8 bit read
  3894                              <1> 	;
  3895                              <1> 	; Exit:  DL,DX,EDX register data depending on requested read size
  3896                              <1> 	;
  3897                              <1> 	; Note1: this routine is meant to be called via pciRegRead8,
  3898                              <1> 	;	 pciRegread16 or pciRegRead32, listed below.
  3899                              <1> 	;
  3900                              <1> 	; Note2: don't attempt to read 32 bits of data from a non dword
  3901                              <1> 	;	 aligned reg number. Likewise, don't do 16 bit reads from
  3902                              <1> 	;	 non word aligned reg #
  3903                              <1> 	
  3904 00014E7E 53                  <1> 	push	ebx
  3905 00014E7F 51                  <1> 	push	ecx
  3906 00014E80 89C3                <1>         mov     ebx, eax		; save eax, dh
  3907 00014E82 88F1                <1>         mov     cl, dh
  3908                              <1> 
  3909 00014E84 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; clear out data size request
  3910 00014E89 0D00000080          <1>         or      eax, BIT31		; make a PCI access request
  3911 00014E8E 24FC                <1>         and     al, ~3 ; NOT 3		; force index to be dword
  3912                              <1> 
  3913 00014E90 66BAF80C            <1>         mov     dx, PCI_INDEX_PORT
  3914 00014E94 EF                  <1>         out	dx, eax			; write PCI selector
  3915                              <1> 	
  3916 00014E95 66BAFC0C            <1>         mov     dx, PCI_DATA_PORT
  3917 00014E99 88D8                <1>         mov     al, bl
  3918 00014E9B 2403                <1>         and     al, 3			; figure out which port to
  3919 00014E9D 00C2                <1>         add     dl, al			; read to
  3920                              <1> 
  3921 00014E9F F7C3000000C0        <1> 	test    ebx, PCI32+PCI16
  3922 00014EA5 7507                <1>         jnz     short _pregr0
  3923 00014EA7 EC                  <1> 	in	al, dx			; return 8 bits of data
  3924 00014EA8 88C2                <1>         mov	dl, al
  3925 00014EAA 88CE                <1> 	mov     dh, cl			; restore dh for 8 bit read
  3926 00014EAC EB12                <1> 	jmp	short _pregr2
  3927                              <1> _pregr0:	
  3928 00014EAE F7C300000080        <1> 	test    ebx, PCI32
  3929 00014EB4 7507                <1>         jnz	short _pregr1
  3930 00014EB6 66ED                <1> 	in	ax, dx
  3931 00014EB8 6689C2              <1>         mov     dx, ax			; return 16 bits of data
  3932 00014EBB EB03                <1> 	jmp	short _pregr2
  3933                              <1> _pregr1:
  3934 00014EBD ED                  <1> 	in	eax, dx			; return 32 bits of data
  3935 00014EBE 89C2                <1> 	mov	edx, eax
  3936                              <1> _pregr2:
  3937 00014EC0 89D8                <1> 	mov     eax, ebx		; restore eax
  3938 00014EC2 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; clear out data size request
  3939 00014EC7 59                  <1> 	pop	ecx
  3940 00014EC8 5B                  <1> 	pop	ebx
  3941 00014EC9 C3                  <1> 	retn
  3942                              <1> 
  3943                              <1> pciRegRead8:
  3944 00014ECA 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 8 bit read size
  3945 00014ECF EBAD                <1>         jmp     short pciRegRead	; call generic PCI access
  3946                              <1> 
  3947                              <1> pciRegRead16:
  3948 00014ED1 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 16 bit read size
  3949 00014ED6 0D00000040          <1>         or      eax, PCI16		; call generic PCI access
  3950 00014EDB EBA1                <1>         jmp     short pciRegRead
  3951                              <1> 
  3952                              <1> pciRegRead32:
  3953 00014EDD 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 32 bit read size
  3954 00014EE2 0D00000080          <1>         or      eax, PCI32		; call generic PCI access
  3955 00014EE7 EB95                <1>         jmp     pciRegRead
  3956                              <1> 
  3957                              <1> pciRegWrite:
  3958                              <1> 	; 03/04/2017 ('pci.asm', 29/11/2016)
  3959                              <1> 	;
  3960                              <1> 	; 8/16/32bit PCI writer
  3961                              <1> 	;
  3962                              <1> 	; Entry: EAX=PCI Bus/Device/fn/register number
  3963                              <1> 	;           BIT31 set if 32 bit access requested
  3964                              <1> 	;           BIT30 set if 16 bit access requested
  3965                              <1> 	;           otherwise defaults to 8bit read
  3966                              <1> 	;        DL/DX/EDX data to write depending on size
  3967                              <1> 	;
  3968                              <1> 	; Note1: this routine is meant to be called via pciRegWrite8, 
  3969                              <1> 	;	 pciRegWrite16 or pciRegWrite32 as detailed below.
  3970                              <1> 	;
  3971                              <1> 	; Note2: don't attempt to write 32bits of data from a non dword
  3972                              <1> 	;	 aligned reg number. Likewise, don't do 16 bit writes from
  3973                              <1> 	;	 non word aligned reg #
  3974                              <1> 
  3975 00014EE9 53                  <1> 	push	ebx
  3976 00014EEA 51                  <1> 	push	ecx
  3977 00014EEB 89C3                <1>         mov     ebx, eax		; save eax, edx
  3978 00014EED 89D1                <1>         mov     ecx, edx
  3979 00014EEF 25FFFFFF3F          <1> 	and     eax, NOT_PCI32_PCI16	; clear out data size request
  3980 00014EF4 0D00000080          <1>         or      eax, BIT31		; make a PCI access request
  3981 00014EF9 24FC                <1>         and     al, ~3 ; NOT 3		; force index to be dword
  3982                              <1> 
  3983 00014EFB 66BAF80C            <1>         mov     dx, PCI_INDEX_PORT
  3984 00014EFF EF                  <1>         out	dx, eax			; write PCI selector
  3985                              <1> 	
  3986 00014F00 66BAFC0C            <1>         mov     dx, PCI_DATA_PORT
  3987 00014F04 88D8                <1>         mov     al, bl
  3988 00014F06 2403                <1>         and     al, 3			; figure out which port to
  3989 00014F08 00C2                <1>         add     dl, al			; write to
  3990                              <1> 
  3991 00014F0A F7C3000000C0        <1> 	test    ebx, PCI32+PCI16
  3992 00014F10 7505                <1>         jnz     short _pregw0
  3993 00014F12 88C8                <1> 	mov	al, cl 			; put data into al
  3994 00014F14 EE                  <1> 	out	dx, al
  3995 00014F15 EB12                <1> 	jmp	short _pregw2
  3996                              <1> _pregw0:
  3997 00014F17 F7C300000080        <1> 	test    ebx, PCI32
  3998 00014F1D 7507                <1>         jnz     short _pregw1
  3999 00014F1F 6689C8              <1> 	mov	ax, cx			; put data into ax
  4000 00014F22 66EF                <1> 	out	dx, ax
  4001 00014F24 EB03                <1> 	jmp	short _pregw2
  4002                              <1> _pregw1:
  4003 00014F26 89C8                <1> 	mov	eax, ecx		; put data into eax 		
  4004 00014F28 EF                  <1> 	out	dx, eax
  4005                              <1> _pregw2:
  4006 00014F29 89D8                <1>         mov     eax, ebx		; restore eax
  4007 00014F2B 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; clear out data size request
  4008 00014F30 89CA                <1>         mov     edx, ecx		; restore dx
  4009 00014F32 59                  <1> 	pop	ecx
  4010 00014F33 5B                  <1> 	pop	ebx
  4011 00014F34 C3                  <1> 	retn
  4012                              <1> 
  4013                              <1> pciRegWrite8:
  4014 00014F35 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 8 bit write size
  4015 00014F3A EBAD                <1>         jmp	short pciRegWrite	; call generic PCI access
  4016                              <1> 
  4017                              <1> pciRegWrite16:
  4018 00014F3C 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 16 bit write size
  4019 00014F41 0D00000040          <1>         or      eax, PCI16		; call generic PCI access
  4020 00014F46 EBA1                <1>         jmp	short pciRegWrite
  4021                              <1> 
  4022                              <1> pciRegWrite32:
  4023 00014F48 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 32 bit write size
  4024 00014F4D 0D00000080          <1>         or      eax, PCI32		; call generic PCI access
  4025 00014F52 EB95                <1>         jmp	pciRegWrite
  4026                              <1> 
  4027                              <1> init_codec:
  4028                              <1> 	; 05/06/2017
  4029                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
  4030                              <1> 	;
  4031 00014F54 A1[B89C0100]        <1> 	mov	eax, [audio_dev_id]	
  4032 00014F59 B041                <1> 	mov	al, VIA_ACLINK_CTRL
  4033 00014F5B E86AFFFFFF          <1> 	call	pciRegRead8
  4034                              <1> 	; ?
  4035 00014F60 B040                <1> 	mov	al, VIA_ACLINK_STAT
  4036 00014F62 E863FFFFFF          <1> 	call	pciRegRead8
  4037 00014F67 F6C201              <1> 	test	dl, VIA_ACLINK_C00_READY
  4038 00014F6A 7508                <1>         jnz     short _codec_ready_1
  4039 00014F6C E80E000000          <1> 	call	reset_codec
  4040 00014F71 7306                <1> 	jnc	short _codec_ready_2 ; eax = 1
  4041 00014F73 C3                  <1> 	retn
  4042                              <1> _codec_ready_1:
  4043 00014F74 B801000000          <1> 	mov	eax, 1
  4044                              <1> _codec_ready_2:
  4045 00014F79 E886000000          <1> 	call	codec_io_w16
  4046                              <1> detect_codec:
  4047 00014F7E C3                  <1> 	retn
  4048                              <1> 
  4049                              <1> reset_codec:
  4050                              <1> 	; 16/04/2017
  4051                              <1> 	; 23/03/2017 
  4052                              <1> 	; ('codec.asm')
  4053                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
  4054 00014F7F A1[B89C0100]        <1> 	mov	eax, [audio_dev_id]
  4055 00014F84 B041                <1>  	mov	al, VIA_ACLINK_CTRL
  4056 00014F86 B2E0                <1>        	mov	dl, VIA_ACLINK_CTRL_ENABLE + VIA_ACLINK_CTRL_RESET + VIA_ACLINK_CTRL_SYNC
  4057 00014F88 E8A8FFFFFF          <1> 	call	pciRegWrite8
  4058                              <1> 
  4059 00014F8D E849000000          <1> 	call	delay_100ms 	; wait 100 ms
  4060                              <1> _rc_cold:
  4061 00014F92 E814000000          <1>         call    cold_reset
  4062 00014F97 7301                <1>         jnc     short _reset_codec_ok
  4063                              <1> 	
  4064                              <1> 	; 16/04/2017
  4065                              <1>         ;xor     eax, eax         ; timeout error
  4066                              <1>        	;stc
  4067 00014F99 C3                  <1> 	retn
  4068                              <1> 
  4069                              <1> _reset_codec_ok:
  4070                              <1> 	; 01/09/2020
  4071                              <1> 	; 15/08/2020
  4072                              <1> 	; 27/07/2020
  4073                              <1> 	; also reset codec by using index control register 0 of AD1980 or ALC655
  4074                              <1> 	; (to fix line out -2 channels audio playing- problem on AD1980 codec)  
  4075                              <1> 
  4076 00014F9A 29C0                <1> 	sub	eax, eax
  4077 00014F9C BA00000000          <1> 	mov	edx, CODEC_RESET_REG ; 00h ; Reset register
  4078 00014FA1 E8CA000000          <1> 	call	codec_write
  4079                              <1> 
  4080                              <1> 	;sub	eax, eax
  4081                              <1> 	; 01/09/2020
  4082                              <1> 	; 15/08/2020
  4083                              <1> 	; AD1980 BugFix
  4084                              <1> 	; (set HPSEL -headphone amp to be driven from mixer- and
  4085                              <1> 	;      CLDIS - center and LFE disable- bits)	
  4086                              <1> 	;mov	eax, 0C00h ; HPSEL = bit 10, CLDIS = bit 11 ; 01/09/2020
  4087                              <1>  	;mov	edx, CODEC_MISC_CRTL_BITS_REG ; 76h ; Misc Ctrl Bits ; AD1980
  4088                              <1> 	;call	codec_write
  4089                              <1> 
  4090 00014FA6 31C0                <1>         xor     eax, eax
  4091                              <1>         ;mov	al, VIA_ACLINK_C00_READY ; 1
  4092 00014FA8 FEC0                <1>         inc	al
  4093 00014FAA C3                  <1> 	retn
  4094                              <1> 
  4095                              <1> cold_reset:
  4096                              <1> 	; 16/04/2017
  4097                              <1> 	; 23/03/2017
  4098                              <1> 	; ('codec.asm')
  4099                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
  4100                              <1> 	;mov	eax, [audio_dev_id]
  4101                              <1> 	;mov	al, VIA_ACLINK_CTRL
  4102 00014FAB 30D2                <1> 	xor	dl, dl ; 0
  4103 00014FAD E883FFFFFF          <1> 	call	pciRegWrite8
  4104                              <1> 
  4105 00014FB2 E824000000          <1> 	call	delay_100ms 	; wait 100 ms
  4106                              <1> 
  4107                              <1> 	;; ACLink on, deassert ACLink reset, VSR, SGD data out
  4108                              <1>         ;; note - FM data out has trouble with non VRA codecs !!
  4109                              <1>         
  4110                              <1> 	;mov	eax, [audio_dev_id]
  4111                              <1> 	;mov	al, VIA_ACLINK_CTRL
  4112 00014FB7 B2CC                <1> 	mov	dl, VIA_ACLINK_CTRL_INIT
  4113 00014FB9 E877FFFFFF          <1> 	call	pciRegWrite8
  4114                              <1> 
  4115 00014FBE B910000000          <1> 	mov	ecx, 16	; total 2s
  4116                              <1> 
  4117                              <1> _crst_wait:
  4118                              <1> 	;mov	eax, [audio_dev_id]
  4119 00014FC3 B040                <1> 	mov	al, VIA_ACLINK_STAT
  4120 00014FC5 E800FFFFFF          <1> 	call	pciRegRead8	
  4121                              <1> 
  4122 00014FCA F6C201              <1>         test    dl, VIA_ACLINK_C00_READY
  4123 00014FCD 750B                <1>         jnz     short _crst_ok
  4124                              <1> 
  4125 00014FCF 51                  <1> 	push	ecx
  4126 00014FD0 E806000000          <1> 	call	delay_100ms
  4127 00014FD5 59                  <1> 	pop	ecx
  4128                              <1> 
  4129 00014FD6 49                  <1>         dec     ecx
  4130 00014FD7 75EA                <1>         jnz     short _crst_wait
  4131                              <1> 
  4132                              <1> _crst_fail:
  4133 00014FD9 F9                  <1>         stc
  4134                              <1> _crst_ok:
  4135 00014FDA C3                  <1> 	retn
  4136                              <1> 
  4137                              <1> delay_100ms:
  4138                              <1> 	; 29/05/2017
  4139                              <1> 	; 24/03/2017 ('codec.asm')
  4140                              <1> 	; wait 100 ms
  4141 00014FDB B990010000          <1> 	mov	ecx, 400  ; 400*0.25ms
  4142                              <1> _delay_x_ms:
  4143 00014FE0 E803000000          <1> 	call	delay1_4ms
  4144 00014FE5 E2F9                <1>         loop	_delay_x_ms
  4145 00014FE7 C3                  <1> 	retn
  4146                              <1> 
  4147                              <1> ;       delay1_4ms - Delay for 1/4 millisecond.
  4148                              <1> ;	    1mS = 1000us
  4149                              <1> ;       Entry:
  4150                              <1> ;         None
  4151                              <1> ;       Exit:
  4152                              <1> ;	  None
  4153                              <1> ;
  4154                              <1> ;       Modified:
  4155                              <1> ;         None
  4156                              <1> ;
  4157                              <1> 
  4158                              <1> 	; 29/05/2017
  4159                              <1> 	; 23/04/2017
  4160                              <1> 	; 05/03/2017 (TRDOS 386)
  4161                              <1> 	; ('UTILS.ASM')
  4162                              <1> delay1_4ms:
  4163 00014FE8 50                  <1>         push    eax 
  4164 00014FE9 51                  <1>         push    ecx
  4165 00014FEA B110                <1>         mov	cl, 16		; close enough.
  4166                              <1> 
  4167 00014FEC E461                <1> 	in	al, PORTB ; 61h
  4168                              <1> 		
  4169 00014FEE 2410                <1> 	and	al, REFRESH_STATUS ; 10h
  4170 00014FF0 88C5                <1> 	mov	ch, al		; Start toggle state
  4171                              <1> _d4ms1:	
  4172 00014FF2 E461                <1> 	in	al, PORTB	; Read system control port
  4173                              <1> 	
  4174 00014FF4 2410                <1> 	and	al, REFRESH_STATUS ; Refresh toggles 15.085 microseconds
  4175 00014FF6 38C5                <1> 	cmp	ch, al
  4176 00014FF8 74F8                <1> 	je	short _d4ms1	; Wait for state change
  4177                              <1> 
  4178 00014FFA 88C5                <1> 	mov	ch, al		; Update with new state
  4179 00014FFC FEC9                <1> 	dec	cl
  4180 00014FFE 75F2                <1> 	jnz	short _d4ms1
  4181                              <1> 
  4182 00015000 F8                  <1> 	clc	; 29/05/2017
  4183                              <1> 
  4184 00015001 59                  <1>         pop     ecx
  4185 00015002 58                  <1>         pop     eax
  4186 00015003 C3                  <1>         retn
  4187                              <1> 
  4188                              <1> ; 10/04/2017 (TRDOS 386)
  4189                              <1> ; 12/11/2016
  4190                              <1> 
  4191                              <1> codec_io_w16: ;w32
  4192                              <1> 	; ('codec.asm')
  4193 00015004 668B15[B69C0100]    <1>         mov	dx, [audio_io_base]
  4194 0001500B 6681C28000          <1>         add     dx, VIA_REG_AC97
  4195 00015010 EF                  <1> 	out	dx, eax
  4196 00015011 C3                  <1>         retn
  4197                              <1> 
  4198                              <1> codec_io_r16: ;r32
  4199                              <1> 	; ('codec.asm')
  4200 00015012 668B15[B69C0100]    <1>         mov     dx, [audio_io_base]
  4201 00015019 6681C28000          <1>         add     dx, VIA_REG_AC97
  4202 0001501E ED                  <1>         in	eax, dx
  4203 0001501F C3                  <1>         retn
  4204                              <1> 
  4205                              <1> ctrl_io_w8:
  4206                              <1> 	; ('codec.asm')
  4207 00015020 660315[B69C0100]    <1>         add     dx, [audio_io_base]
  4208 00015027 EE                  <1>         out	dx, al
  4209 00015028 C3                  <1>         retn
  4210                              <1> 
  4211                              <1> ctrl_io_r8:
  4212                              <1> 	; ('codec.asm')
  4213 00015029 660315[B69C0100]    <1>         add     dx, [audio_io_base]
  4214 00015030 EC                  <1>         in	al, dx
  4215 00015031 C3                  <1>         retn
  4216                              <1> 
  4217                              <1> ctrl_io_w32:
  4218                              <1> 	; ('codec.asm')
  4219 00015032 660315[B69C0100]    <1>         add     dx, [audio_io_base]
  4220 00015039 EF                  <1>         out	dx, eax
  4221 0001503A C3                  <1>         retn
  4222                              <1> 
  4223                              <1> ctrl_io_r32:
  4224                              <1> 	; ('codec.asm')
  4225 0001503B 660315[B69C0100]    <1>         add	dx, [audio_io_base]
  4226 00015042 ED                  <1> 	in	eax, dx
  4227 00015043 C3                  <1>         retn
  4228                              <1> 
  4229                              <1> codec_read:
  4230                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
  4231                              <1>         ; Use only primary codec.
  4232                              <1>         ; eax = register
  4233 00015044 C1E010              <1>         shl     eax, VIA_REG_AC97_CMD_SHIFT
  4234 00015047 0D00008002          <1>         or      eax, VIA_REG_AC97_PRIMARY_VALID + VIA_REG_AC97_READ
  4235                              <1> 
  4236 0001504C E8B3FFFFFF          <1> 	call    codec_io_w16
  4237                              <1> 
  4238                              <1>       	; codec_valid
  4239 00015051 E831000000          <1> 	call	codec_check_ready
  4240 00015056 7301                <1>         jnc	short _cr_ok
  4241                              <1> 
  4242 00015058 C3                  <1> 	retn
  4243                              <1> 
  4244                              <1> _cr_ok:
  4245                              <1> 	; wait 25 ms
  4246 00015059 B950000000          <1> 	mov	ecx, 80 ; (100*0.25 ms)
  4247                              <1> _cr_wloop:
  4248 0001505E E885FFFFFF          <1> 	call	delay1_4ms
  4249 00015063 E2F9                <1> 	loop	_cr_wloop
  4250                              <1> 
  4251 00015065 E8A8FFFFFF          <1>         call    codec_io_r16
  4252 0001506A 25FFFF0000          <1>         and     eax, 0FFFFh
  4253 0001506F C3                  <1>         retn
  4254                              <1> 
  4255                              <1> codec_write:
  4256                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
  4257                              <1>         ; Use only primary codec.
  4258                              <1>         
  4259                              <1> 	; eax = data (volume)
  4260                              <1> 	; edx = register (mixer register)
  4261                              <1> 	
  4262 00015070 C1E210              <1> 	shl     edx, VIA_REG_AC97_CMD_SHIFT
  4263                              <1> 
  4264 00015073 C1E000              <1>         shl     eax, VIA_REG_AC97_DATA_SHIFT ; shl eax, 0
  4265 00015076 09C2                <1>         or      edx, eax
  4266                              <1> 
  4267 00015078 B800000000          <1>         mov     eax, VIA_REG_AC97_CODEC_ID_PRIMARY
  4268 0001507D C1E01E              <1>         shl     eax, VIA_REG_AC97_CODEC_ID_SHIFT
  4269 00015080 09D0                <1>         or      eax, edx
  4270                              <1> 
  4271 00015082 E87DFFFFFF          <1>         call    codec_io_w16
  4272                              <1>         ;mov    [codec.regs+esi], ax
  4273                              <1> 
  4274                              <1>         ;call	codec_check_ready
  4275                              <1>        	;retn
  4276                              <1> 	;jmp	short _codec_check_ready	
  4277                              <1> 
  4278                              <1> codec_check_ready:
  4279                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
  4280                              <1> 
  4281                              <1> _codec_check_ready:
  4282 00015087 B914000000          <1> 	mov	ecx, 20	; total 2s
  4283                              <1> _ccr_wait:
  4284 0001508C 51                  <1> 	push	ecx
  4285                              <1> 
  4286 0001508D E880FFFFFF          <1>         call    codec_io_r16
  4287 00015092 A900000001          <1>         test    eax, VIA_REG_AC97_BUSY
  4288 00015097 740B                <1>         jz      short _ccr_ok
  4289                              <1> 
  4290 00015099 E83DFFFFFF          <1> 	call	delay_100ms
  4291                              <1> 
  4292 0001509E 59                  <1> 	pop	ecx
  4293                              <1> 
  4294 0001509F 49                  <1> 	dec     ecx
  4295 000150A0 75EA                <1>         jnz     short _ccr_wait
  4296                              <1> 
  4297 000150A2 F9                  <1>         stc
  4298 000150A3 C3                  <1>         retn
  4299                              <1> 
  4300                              <1> _ccr_ok:
  4301 000150A4 59                  <1> 	pop	ecx
  4302 000150A5 25FFFF0000          <1> 	and     eax, 0FFFFh
  4303 000150AA C3                  <1>         retn
  4304                              <1> 
  4305                              <1> codec_config:
  4306                              <1> 	; 10/06/2017
  4307                              <1> 	; 29/05/2017
  4308                              <1> 	; 24/04/2017
  4309                              <1> 	; 21/04/2017
  4310                              <1> 	; 16/04/2017 (TRDOS 386 Kernel) 
  4311                              <1> 	; 15/11/2016 ('codec.asm', 'player.com')
  4312                              <1> 	; 14/11/2016
  4313                              <1> 	; 12/11/2016 - Erdogan Tan
  4314                              <1> 	;	     (Ref: KolibriOS, 'setup_codec', codec.inc)
  4315                              <1> 
  4316 000150AB B802020000          <1> 	mov     eax, 0202h
  4317 000150B0 66A3[E69C0100]      <1> 	mov	[audio_master_volume], ax
  4318 000150B6 66B81F1F            <1> 	mov	ax, 1F1Fh ; 31,31
  4319 000150BA BA02000000          <1> 	mov	edx, CODEC_MASTER_VOL_REG ; 02h ; Line Out
  4320 000150BF E8ACFFFFFF          <1> 	call	codec_write
  4321                              <1> 	;jc	short cconfig_error
  4322                              <1> 
  4323                              <1>  	;mov    eax, 0202h
  4324 000150C4 66B80202            <1> 	mov     ax, 0202h
  4325 000150C8 BA18000000          <1> 	mov	edx, CODEC_PCM_OUT_REG ; 18h ; Wave Output (Stereo)
  4326 000150CD E89EFFFFFF          <1> 	call	codec_write
  4327                              <1> 	;jc	short cconfig_error
  4328                              <1>       
  4329                              <1>  	;mov    eax, 0202h
  4330 000150D2 66B80202            <1> 	mov	ax, 0202h
  4331 000150D6 BA04000000          <1> 	mov	edx, CODEC_AUX_VOL ; 04h ; CODEC_HP_VOL_REG ; HeadPhone
  4332 000150DB E890FFFFFF          <1> 	call	codec_write
  4333                              <1> 	;jc	short cconfig_error
  4334                              <1> 
  4335                              <1>  	;mov    eax, 08h
  4336                              <1>         ;mov    ax,  08h
  4337 000150E0 66B80880            <1> 	mov	ax, 8008h ; Mute
  4338 000150E4 BA0C000000          <1> 	mov	edx, 0Ch  ; AC97_PHONE_VOL ; TAD Input (Mono)
  4339 000150E9 E882FFFFFF          <1> 	call	codec_write
  4340                              <1> 	;jc	short cconfig_error
  4341                              <1> 
  4342                              <1>  	;mov    eax, 0808h
  4343 000150EE 66B80808            <1>         mov     ax,  0808h
  4344 000150F2 BA10000000          <1>         mov	edx, CODEC_LINE_IN_VOL_REG ; 10h ; Line Input (Stereo)	
  4345 000150F7 E874FFFFFF          <1> 	call	codec_write
  4346                              <1> 	;jc	short cconfig_error
  4347                              <1> 
  4348                              <1>  	;mov    eax, 0808h
  4349 000150FC 66B80808            <1> 	mov     ax,  0808h
  4350 00015100 BA12000000          <1>         mov	edx, CODEC_CD_VOL_REG ; 12h ; CR Input (Stereo)
  4351 00015105 E866FFFFFF          <1> 	call	codec_write
  4352                              <1> 	;jc	short cconfig_error
  4353                              <1> 
  4354                              <1>  	;mov    eax, 0808h
  4355 0001510A 66B80808            <1> 	mov     ax,  0808h
  4356 0001510E BA16000000          <1>         mov	edx, CODEC_AUX_VOL_REG ; 16h ; Aux Input (Stereo)
  4357                              <1> 	;call	codec_write
  4358                              <1> 	;;jc	short cconfig_error
  4359 00015113 E958FFFFFF          <1> 	jmp	codec_write ; 10/06/2017
  4360                              <1> 
  4361                              <1> ;	; Extended Audio Status (2Ah)
  4362                              <1> ;	mov	eax, CODEC_EXT_AUDIO_CTRL_REG ; 2Ah 
  4363                              <1> ;	call	codec_read
  4364                              <1> ;	and     eax, 0FFFFh - 2		; clear DRA (BIT1)
  4365                              <1> ;	;or     eax, 1			; set VRA (BIT0)
  4366                              <1> ;	or	eax, 5  	; VRA (BIT0) & S/PDIF (BIT2) ; 14/11/2016
  4367                              <1> ;	mov	edx, CODEC_EXT_AUDIO_CTRL_REG
  4368                              <1> ;	call	codec_write
  4369                              <1> ;	;jc	short cconfig_error
  4370                              <1> ;
  4371                              <1> ;set_sample_rate:
  4372                              <1> ;	;movzx	eax, word [audio_freq]
  4373                              <1> ;	mov	ax, [audio_freq]
  4374                              <1> ;	mov	edx, CODEC_PCM_FRONT_DACRATE_REG ; 2Ch ; PCM Front DAC Rate
  4375                              <1> ;	;call	codec_write
  4376                              <1> ;	;retn
  4377                              <1> ;	jmp	codec_write
  4378                              <1> 	
  4379                              <1> ;cconfig_error:
  4380                              <1> ;	retn
  4381                              <1> 
  4382                              <1> vt8233_int_handler:
  4383                              <1> 	; 27/07/2020
  4384                              <1> 	; 22/07/2020
  4385                              <1> 	; Interrupt Handler for VIA VT8237R Audio Controller
  4386                              <1> 	; Note: called by 'dev_IRQ_service'
  4387                              <1> 	; 14/10/2017 
  4388                              <1> 	; 09/10/2017, 10/10/2017, 12/10/2017
  4389                              <1> 	; 13/06/2017
  4390                              <1> 	; 21/04/2017 (TRDOS 386 kernel, 'audio.s')
  4391                              <1> 	; 24/03/2017 - 'PLAYER.COM' ('player.asm') 
  4392                              <1> 
  4393                              <1> 	;push	eax ; * must be saved !
  4394                              <1> 	;push	edx
  4395                              <1> 	;push	ecx
  4396                              <1> 	;push	ebx ; * must be saved !
  4397                              <1> 	;push	esi
  4398                              <1> 	;push	edi
  4399                              <1> 
  4400                              <1> 	;cmp	byte [audio_busy], 1
  4401                              <1> 	;jnb	short _ih0 ; 09/10/2017
  4402                              <1> 
  4403                              <1> 	;mov	byte [audio_flag_eol], 0
  4404                              <1> 
  4405 00015118 66BA0000            <1>         mov     dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_STATUS
  4406 0001511C E808FFFFFF          <1>         call    ctrl_io_r8
  4407                              <1> 
  4408 00015121 A880                <1> 	test    al, VIA_REG_STAT_ACTIVE
  4409 00015123 7417                <1>         jz      short _ih0 ; 09/10/2017
  4410                              <1> 
  4411 00015125 2407                <1>         and     al, VIA_REG_STAT_EOL + VIA_REG_STAT_FLAG + VIA_REG_STAT_STOPPED
  4412 00015127 A2[E59C0100]        <1> 	mov	[audio_flag_eol], al
  4413 0001512C 740E                <1>         jz	short _ih0 ; 09/10/2017
  4414                              <1> 
  4415                              <1> 	; 09/10/2017
  4416                              <1> 	;mov	byte [audio_busy], 1
  4417                              <1> 
  4418 0001512E 803D[E49C0100]01    <1> 	cmp	byte [audio_play_cmd], 1
  4419 00015135 7315                <1> 	jnb	short _ih1 ; 10/10/2017
  4420                              <1> 
  4421 00015137 E84A000000          <1> 	call	channel_reset
  4422                              <1> _ih0:
  4423                              <1> 	; 09/10/2017
  4424 0001513C A0[E59C0100]        <1>         mov     al, [audio_flag_eol]   ;; ack ;;
  4425 00015141 66BA0000            <1>         mov     dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_STATUS
  4426 00015145 E8D6FEFFFF          <1>         call    ctrl_io_w8
  4427 0001514A EB39                <1> 	jmp	short _ih4
  4428                              <1> _ih1:
  4429                              <1> vt8233_tuneLoop:
  4430 0001514C A0[E59C0100]        <1>         mov     al, [audio_flag_eol]   ;; ack ;;
  4431 00015151 66BA0000            <1>         mov     dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_STATUS
  4432 00015155 E8C6FEFFFF          <1>         call    ctrl_io_w8
  4433                              <1> 
  4434                              <1> 	; 22/07/2020
  4435                              <1> 	;; 12/10/2017
  4436                              <1> 	;mov	byte [audio_flag], 0 ; Reset	
  4437                              <1> 
  4438                              <1> 	; 10/10/2017
  4439                              <1> 	; 09/10/2017
  4440                              <1> 	;test	byte [audio_flag_eol], VIA_REG_STAT_FLAG
  4441                              <1> 	;jz	short _ih2 ; EOL
  4442                              <1> 
  4443                              <1> 	; 22/07/2020
  4444                              <1> 	; 14/10/2017
  4445                              <1> 	;test	byte [audio_flag_eol], VIA_REG_STAT_EOL
  4446                              <1> 	;jnz	short _ih2 ; EOL
  4447                              <1> 	;		   ; (Half Buffer 2 has been completed 
  4448                              <1> 	;		   ; and Half Buffer 1 will be played.)
  4449                              <1> 	
  4450                              <1> 	; FLAG  
  4451                              <1> 	; (Half Buffer 1 has been completed 
  4452                              <1> 	;  and Half Buffer 2 will be played.)
  4453                              <1> 
  4454                              <1> 	; 14/10/2017
  4455                              <1> 	;; (Continue to play.)
  4456                              <1> 	;mov	al, VIA_REG_CTRL_INT
  4457                              <1>        	;or	al, VIA_REG_CTRL_START
  4458                              <1>        	;mov	dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_CONTROL
  4459                              <1>         ;call	ctrl_io_w8
  4460                              <1> 	; 12/10/2017
  4461                              <1> 	;mov	byte [audio_flag], 1 
  4462                              <1> 
  4463                              <1> 	; 22/07/2020
  4464                              <1> 	;inc	byte [audio_flag] ; = 1
  4465                              <1> _ih2: 
  4466                              <1> 	; 10/10/2017
  4467 0001515A 8B3D[D09C0100]      <1> 	mov	edi, [audio_dma_buff]
  4468 00015160 8B0D[D49C0100]      <1> 	mov	ecx, [audio_dmabuff_size]
  4469 00015166 D1E9                <1> 	shr	ecx, 1 ; dma buff size / 2 = half buffer size
  4470                              <1> 	
  4471                              <1> 	; 22/07/2020
  4472                              <1> 	; 12/10/2017
  4473                              <1> 	;cmp	byte [audio_flag], 0
  4474                              <1> 	;ja	short _ih3 ; Playing Half Buffer 2 (Current: FLAG)
  4475                              <1> 	
  4476                              <1> 	; 27/07/2020
  4477                              <1> 	; 22/07/2020
  4478 00015168 F605[D89C0100]01    <1> 	test	byte [audio_flag], 1  ; Current flag value
  4479 0001516F 7402                <1> 	jz	short _ih3 ; Half Buffer 1 must be filled
  4480                              <1> 
  4481                              <1> 	; Half Buffer 2 must be filled
  4482 00015171 01CF                <1> 	add	edi, ecx
  4483                              <1> _ih3:
  4484                              <1> 	; Update half buffer 2 while playing half buffer 1
  4485                              <1> 	; Update half buffer 1 while playing half buffer 2
  4486                              <1> 
  4487 00015173 8B35[C89C0100]      <1> 	mov	esi, [audio_p_buffer] ; phy addr of audio buff
  4488 00015179 C1E902              <1> 	shr	ecx, 2 ; half buff size / 4
  4489 0001517C F3A5                <1> 	rep	movsd
  4490                              <1> 
  4491                              <1> 	; switch flag value ;
  4492 0001517E 8035[D89C0100]01    <1> 	xor	byte [audio_flag], 1
  4493                              <1> 	; 12/10/2017
  4494                              <1> 	; [audio_flag] = 0 : Playing dma half buffer 2
  4495                              <1> 			   ; Next buffer (to update) is dma half buff 1
  4496                              <1> 	; 	       = 1 : Playing dma half buffer 1
  4497                              <1> 			   ; Next buffer (to update) is dma half buff 2
  4498                              <1> _ih4:	
  4499                              <1> 	; 28/05/2017
  4500                              <1> 	;mov	byte [audio_busy], 0 ; 09/10/2017
  4501                              <1> 	;
  4502                              <1> 	;pop	edi
  4503                              <1> 	;pop	esi
  4504                              <1> 	;pop	ebx ; * must be restored !
  4505                              <1> 	;pop	ecx
  4506                              <1> 	;pop	edx
  4507                              <1> 	;pop	eax ; * must be restored !
  4508                              <1> 
  4509 00015185 C3                  <1> 	retn
  4510                              <1> 
  4511                              <1> channel_reset:
  4512                              <1> 	; 24/06/2017
  4513                              <1> 	; 29/05/2017
  4514                              <1> 	; 23/03/2017
  4515                              <1> 	; 14/11/2016 - Erdogan Tan
  4516                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
  4517 00015186 BA01000000          <1>         mov	edx, VIA_REG_OFFSET_CONTROL
  4518                              <1>         ;mov	eax, VIA_REG_CTRL_PAUSE + VIA_REG_CTRL_TERMINATE + VIA_REG_CTRL_RESET
  4519 0001518B B848000000          <1>         mov	eax, VIA_REG_CTRL_PAUSE + VIA_REG_CTRL_TERMINATE ; 24/06/2017       
  4520 00015190 E88BFEFFFF          <1> 	call    ctrl_io_w8
  4521                              <1> 
  4522                              <1>         ;mov	edx, VIA_REG_OFFSET_CONTROL
  4523                              <1>         ;call   ctrl_io_r8
  4524                              <1> 
  4525                              <1> 	; wait for 50 ms
  4526 00015195 B9A0000000          <1> 	mov	ecx, 160 ; (200*0.25 ms) ; 29/05/2017	
  4527                              <1> _ch_rst_wait:
  4528 0001519A E849FEFFFF          <1> 	call	delay1_4ms
  4529 0001519F 49                  <1> 	dec	ecx
  4530 000151A0 75F8                <1> 	jnz	short _ch_rst_wait     
  4531                              <1> 
  4532                              <1>         ; disable interrupts
  4533 000151A2 BA01000000          <1>         mov	edx, VIA_REG_OFFSET_CONTROL
  4534 000151A7 31C0                <1>         xor     eax, eax
  4535 000151A9 E872FEFFFF          <1>         call    ctrl_io_w8
  4536                              <1> 
  4537                              <1>         ; clear interrupts
  4538 000151AE BA00000000          <1>         mov	edx, VIA_REG_OFFSET_STATUS
  4539 000151B3 B803000000          <1> 	mov	eax, 3
  4540 000151B8 E863FEFFFF          <1>         call	ctrl_io_w8
  4541                              <1> 
  4542                              <1> 	;mov	edx, VIA_REG_OFFSET_CURR_PTR
  4543                              <1> 	;xor	eax, eax
  4544                              <1> 	;call	ctrl_io_w32
  4545                              <1> 
  4546 000151BD C3                  <1>         retn	
  4547                              <1> 
  4548                              <1> vt8233_stop: ; 22/04/2017
  4549 000151BE C605[E49C0100]00    <1> 	mov	byte [audio_play_cmd], 0 ; stop !
  4550                              <1> _tlp2:
  4551                              <1> 	; 24/06/2017
  4552                              <1>         ; finished with song, stop everything
  4553                              <1> 	;mov	al, VIA_REG_CTRL_INT
  4554                              <1>         ;or	al, VIA_REG_CTRL_TERMINATE
  4555                              <1> 	;mov	dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_CONTROL
  4556                              <1>         ;call	ctrl_io_w8
  4557                              <1> 
  4558                              <1>         ;call	channel_reset
  4559                              <1> 	;retn
  4560                              <1> 
  4561 000151C5 EBBF                <1> 	jmp	short channel_reset
  4562                              <1> 
  4563                              <1> set_vt8233_bdl: ; Set VT8237R Buffer Descriptor List
  4564                              <1> 	; 22/07/2020 - TRDOS 386 v2.0.2
  4565                              <1> 	; 28/05/2017
  4566                              <1> 	; 21/04/2017 (TRDOS 386 kernel, 'audio.s')
  4567                              <1> 	; 24/03/2017 - 'PLAYER.COM' ('via_wav.asm' - 29/11/2016) 
  4568                              <1> 	
  4569                              <1> 	; eax = dma buffer address = [audio_DMA_buff]
  4570                              <1> 	; ecx = dma buffer buffer size = [audio_dmabuff_size]
  4571                              <1> 
  4572 000151C7 D1E9                <1> 	shr	ecx, 1 ; dma half buffer size
  4573 000151C9 89CE                <1> 	mov	esi, ecx
  4574                              <1> 
  4575 000151CB BF[EC9C0100]        <1>         mov     edi, audio_bdl_buff	; get BDL address
  4576 000151D0 B910000000          <1>         mov     ecx, 32 / 2		; make 32 entries in BDL
  4577                              <1> 
  4578 000151D5 EB05                <1> 	jmp	short s_vt8233_bdl1 
  4579                              <1> 
  4580                              <1> s_vt8233_bdl0:
  4581                              <1> 	; set buffer descriptor 0 to start of data file in memory
  4582                              <1> 
  4583 000151D7 A1[D09C0100]        <1>  	mov	eax, [audio_dma_buff]	; Physical address of DMA buffer
  4584                              <1>  
  4585                              <1> s_vt8233_bdl1:
  4586 000151DC AB                  <1> 	stosd				; store dmabuffer1 address
  4587                              <1> 
  4588 000151DD 89C2                <1> 	mov	edx, eax
  4589                              <1> 
  4590                              <1> ; VIA VT8235.PDF: (Page 110) (Erdogan Tan, 29/11/2016)
  4591                              <1> 	;
  4592                              <1> 	; 	Audio SGD Table Format
  4593                              <1> 	;	-------------------------------
  4594                              <1> 	;	63   62    61-56    55-32  31-0
  4595                              <1> 	;	--   --   --------  -----  ----
  4596                              <1> 	;	EOL FLAG -reserved- Base   Base
  4597                              <1> 	;		    	    Count  Address
  4598                              <1> 	;		            [23:0] [31:0]
  4599                              <1> 	;	EOL: End Of Link. 
  4600                              <1> 	;	     1 indicates this block is the last of the link.
  4601                              <1> 	;	     If the channel Interrupt on EOL bit is set, then
  4602                              <1> 	;	     an interrupt is generated at the end of the transfer.
  4603                              <1> 	;
  4604                              <1> 	;	FLAG: Block Flag. If set, transfer pauses at the end of this
  4605                              <1> 	;	      block. If the channel Interrupt on FLAG bit is set,
  4606                              <1> 	;	      then an interrupt is generated at the end of this block.
  4607                              <1> 
  4608 000151DF 89F0                <1> 	mov	eax, esi ; DMA half buffer size
  4609 000151E1 01C2                <1> 	add	edx, eax
  4610 000151E3 0D00000040          <1> 	or	eax, FLAG
  4611                              <1> 	;or	eax, EOL
  4612 000151E8 AB                  <1> 	stosd
  4613                              <1> 
  4614                              <1> ; 2nd buffer:
  4615                              <1> 
  4616 000151E9 89D0                <1>         mov	eax, edx ; Physical address of the 2nd half of DMA buffer	
  4617 000151EB AB                  <1> 	stosd		 ; store dmabuffer2 address
  4618                              <1> 
  4619                              <1> ; set length to [audio_dmabuff_size]/2
  4620                              <1> ; Set control (bits 31:16) to BUP, bits 15:0=number of samples
  4621                              <1> ; 
  4622 000151EC 89F0                <1> 	mov	eax, esi ; DMA half buffer size
  4623                              <1> 	; 22/07/2020
  4624                              <1> 	;or	eax, EOL
  4625 000151EE 0D00000040          <1> 	or	eax, FLAG
  4626 000151F3 AB                  <1> 	stosd
  4627                              <1> 
  4628 000151F4 E2E1                <1> 	loop    s_vt8233_bdl0
  4629                              <1> 
  4630                              <1> 	; 22/07/2020
  4631 000151F6 814FFC00000080      <1> 	or	dword [edi-4], EOL
  4632                              <1> 	
  4633 000151FD C3                  <1> 	retn
  4634                              <1> 
  4635                              <1> vt8233_start_play:
  4636                              <1> 	; 01/09/2020 
  4637                              <1> 	; 22/07/2020 
  4638                              <1> 	; start to play audio data via VT8233 audio controller
  4639                              <1> 	; 13/06/2017
  4640                              <1> 	; 10/06/2017
  4641                              <1> 	; 24/04/2017 
  4642                              <1> 	; 21/04/2017 (TRDOS 386 kernel, 'audio.s')
  4643                              <1> 	; 24/03/2017 - 'PLAYER.COM' ('via_wav.asm' - 29/11/2016) 
  4644                              <1> 	; write buffer descriptor list address
  4645                              <1> 
  4646                              <1> 	; Extended Audio Status (2Ah)
  4647 000151FE B82A000000          <1> 	mov	eax, CODEC_EXT_AUDIO_CTRL_REG ; 2Ah 
  4648 00015203 E83CFEFFFF          <1> 	call	codec_read
  4649 00015208 25FDFF0000          <1> 	and     eax, 0FFFFh - 2		; clear DRA (BIT1)
  4650                              <1> 	;or     eax, 1			; set VRA (BIT0)
  4651                              <1> 	;or	eax, 5  	; VRA (BIT0) & S/PDIF (BIT2) ; 14/11/2016
  4652 0001520D 0C05                <1> 	or	al, 5
  4653                              <1> 	; 01/09/2020	
  4654                              <1> 	;or	eax, 3805h ; AD1980 (PRK, PRJ, PRI = 1 .. only front DAC)
  4655                              <1> 	; 01/09/2020
  4656                              <1> 	;mov	edx, CODEC_EXT_AUDIO_CTRL_REG
  4657                              <1> 	;cmp	word [audio_freq], 0BB80h ; 48 kHz
  4658                              <1> 	;jne	short set_extd_audio_status_1
  4659                              <1> 	;and	al, 0FEh ; disable VRA bit (set sample rate to 48000 Hz)
  4660                              <1> 	;jmp	short set_extd_audio_status_2
  4661                              <1> ;set_extd_audio_status_1:
  4662 0001520F BA2A000000          <1> 	mov	edx, CODEC_EXT_AUDIO_CTRL_REG
  4663 00015214 E857FEFFFF          <1> 	call	codec_write
  4664                              <1> 	;jc	short cconfig_error
  4665                              <1> 
  4666                              <1> set_sample_rate:
  4667                              <1> 	;movzx	eax, word [audio_freq]
  4668 00015219 66A1[E29C0100]      <1> 	mov	ax, [audio_freq]
  4669 0001521F BA2C000000          <1> 	mov	edx, CODEC_PCM_FRONT_DACRATE_REG ; 2Ch ; PCM Front DAC Rate
  4670                              <1> ;set_extd_audio_status_2:
  4671 00015224 E847FEFFFF          <1> 	call	codec_write
  4672                              <1> 
  4673                              <1> 	; 01/09/2020
  4674                              <1> 	; set AD1980 MCB register (Index 76h) to 0C00h
  4675                              <1> 	; (CLDIS, HPSEL)
  4676                              <1> 	;mov	ax, 0C00h
  4677                              <1> 	;mov	edx, CODEC_MISC_CRTL_BITS_REG ; 76h 
  4678                              <1> 	;			; Miscellaneous Control Bit Register
  4679                              <1> 	;call	codec_write
  4680                              <1> 	;
  4681                              <1> 
  4682 00015229 B8[EC9C0100]        <1>         mov	eax, audio_bdl_buff
  4683                              <1>   
  4684                              <1> 	; 12/11/2016 - Erdogan Tan 
  4685                              <1> 	; (Ref: KolibriOS, vt823x.asm, 'create_primary_buff')
  4686 0001522E BA04000000          <1> 	mov	edx, VIADEV_PLAYBACK + VIA_REG_OFFSET_TABLE_PTR
  4687 00015233 E8FAFDFFFF          <1>         call	ctrl_io_w32
  4688                              <1> 
  4689                              <1> 	;call	codec_check_ready
  4690                              <1> 
  4691 00015238 66BA0200            <1>   	mov	dx, VIADEV_PLAYBACK + VIA_REG_OFS_PLAYBACK_VOLUME_L
  4692                              <1>         ;mov	eax, 2	; 31
  4693 0001523C B01F                <1> 	mov	al, 31
  4694 0001523E 2A05[E69C0100]      <1>         sub	al, [audio_master_volume_l]
  4695 00015244 E8D7FDFFFF          <1> 	call	ctrl_io_w8
  4696                              <1> 
  4697                              <1> 	;call	codec_check_ready
  4698                              <1> 
  4699 00015249 66BA0300            <1>         mov     dx, VIADEV_PLAYBACK + VIA_REG_OFS_PLAYBACK_VOLUME_R
  4700                              <1>         ;mov	ax, 2	; 31
  4701 0001524D B01F                <1> 	mov	al, 31
  4702 0001524F 2A05[E79C0100]      <1>         sub	al, [audio_master_volume_r]
  4703 00015255 E8C6FDFFFF          <1> 	call    ctrl_io_w8
  4704                              <1> 
  4705                              <1> 	;call	codec_check_ready
  4706                              <1> ;
  4707                              <1> ;
  4708                              <1> ; All set. Let's play some music.
  4709                              <1> ;
  4710                              <1> ;
  4711                              <1>        	;mov    dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_STOP_IDX
  4712                              <1>         ;mov    ax, VIA8233_REG_TYPE_16BIT or VIA8233_REG_TYPE_STEREO or 0xfffff or 0xff000000
  4713                              <1>         ;call   ctrl_io_w32
  4714                              <1> 
  4715                              <1> 	;call	codec_check_ready
  4716                              <1> 
  4717                              <1> 	; 08/12/2016
  4718                              <1> 	; 07/10/2016
  4719                              <1>         ;;mov    al, 1
  4720                              <1>         ;mov	al, 31
  4721                              <1> 	; 22/07/2020
  4722 0001525A B0FF                <1> 	mov	al, 0FFh
  4723 0001525C E813000000          <1> 	call    set_VT8233_LastValidIndex
  4724                              <1> 
  4725 00015261 C605[E49C0100]01    <1> 	mov	byte [audio_play_cmd], 1 ; play command (do not stop) !
  4726                              <1> 
  4727                              <1> 	; 22/07/2020
  4728                              <1> 	;mov	byte [audio_flag], 0  ; clear half buffer flag
  4729                              <1> 
  4730                              <1> vt8233_play: ; continue to play
  4731                              <1> 	; 22/04/2017
  4732                              <1> 	;mov	al, VIA_REG_CTRL_INT
  4733                              <1>        	;or	al, VIA_REG_CTRL_START
  4734                              <1>         ;;mov	al, VIA_REG_CTRL_AUTOSTART + VIA_REG_CTRL_START
  4735                              <1> 	; 22/07/2020	
  4736 00015268 B0A1                <1> 	mov	al, VIA_REG_CTRL_AUTOSTART + VIA_REG_CTRL_START + VIA_REG_CTRL_INT_FLAG
  4737                              <1> 
  4738 0001526A 66BA0100            <1> 	mov     dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_CONTROL
  4739 0001526E E8ADFDFFFF          <1>         call    ctrl_io_w8
  4740                              <1> 	;call	codec_check_ready
  4741                              <1> 	;retn
  4742                              <1> 	;jmp	codec_check_ready
  4743 00015273 C3                  <1> 	retn
  4744                              <1> 
  4745                              <1> ;input AL = index # to stop on
  4746                              <1> set_VT8233_LastValidIndex:
  4747                              <1> 	; 23/07/2020
  4748                              <1> 	; 10/06/2017
  4749                              <1> 	; 21/04/2017 (TRDOS 386 kernel, 'audio.s')
  4750                              <1> 	; 24/03/2017 - 'PLAYER.COM' ('via_wav.asm' - 29/11/2016) 
  4751                              <1> 	; 19/11/2016
  4752                              <1> 	; 14/11/2016 - Erdogan Tan (Ref: VIA VT8235.PDF, Page 110)
  4753                              <1> 	; 12/11/2016 - Erdogan Tan
  4754                              <1> 	; (Ref: KolibriOS, vt823x.asm, 'create_primary_buff')
  4755                              <1> 	;push	edx
  4756                              <1> 	;push	ax
  4757 00015274 50                  <1> 	push	eax ; 23/07/2020
  4758                              <1> 	;push	ecx
  4759 00015275 0FB705[E29C0100]    <1> 	movzx	eax, word [audio_freq] ; Hertz
  4760 0001527C BA00001000          <1> 	mov	edx, 100000h ; 2^20 = 1048576
  4761 00015281 F7E2                <1> 	mul	edx
  4762 00015283 B980BB0000          <1> 	mov	ecx, 48000	
  4763 00015288 F7F1                <1> 	div	ecx
  4764                              <1> 	;and	eax, 0FFFFFh
  4765                              <1> 	;pop	ecx
  4766                              <1> 	;pop	dx 
  4767 0001528A 5A                  <1> 	pop	edx ; 23/07/2020
  4768 0001528B C1E218              <1> 	shl	edx, 24  ; STOP Index Setting: Bit 24 to 31
  4769 0001528E 09D0                <1> 	or	eax, edx
  4770                              <1> 	; 19/11/2016
  4771 00015290 803D[E09C0100]10    <1> 	cmp	byte [audio_bps], 16
  4772 00015297 7505                <1> 	jne	short sLVI_1
  4773 00015299 0D00002000          <1> 	or	eax, VIA8233_REG_TYPE_16BIT
  4774                              <1> sLVI_1:
  4775 0001529E 803D[E19C0100]02    <1> 	cmp	byte [audio_stmo], 2
  4776 000152A5 7505                <1> 	jne	short sLVI_2
  4777 000152A7 0D00001000          <1> 	or	eax, VIA8233_REG_TYPE_STEREO
  4778                              <1> sLVI_2:
  4779 000152AC BA08000000          <1> 	mov     edx, VIADEV_PLAYBACK + VIA_REG_OFFSET_STOP_IDX
  4780 000152B1 E87CFDFFFF          <1>         call    ctrl_io_w32
  4781                              <1> 	;call	codec_check_ready
  4782                              <1> 	;pop	edx
  4783 000152B6 C3                  <1> 	retn
  4784                              <1> 
  4785                              <1> vt8233_pause: ; pause
  4786                              <1> 	; 10/06/2017
  4787                              <1> 	; 22/04/2017
  4788                              <1> 	;mov     al, VIA_REG_CTRL_INT
  4789                              <1>         ;or      al, VIA_REG_CTRL_PAUSE
  4790                              <1> 	; 23/07/2020
  4791 000152B7 B029                <1> 	mov	al, VIA_REG_CTRL_PAUSE+VIA_REG_CTRL_INT_FLAG+VIA_REG_CTRL_AUTOSTART
  4792                              <1> 	
  4793 000152B9 66BA0100            <1> 	mov     dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_CONTROL
  4794 000152BD E85EFDFFFF          <1>         call    ctrl_io_w8
  4795                              <1> 	;call	codec_check_ready
  4796                              <1> 	;retn
  4797                              <1> 	;jmp	codec_check_ready
  4798 000152C2 C3                  <1> 	retn
  4799                              <1> 
  4800                              <1> vt8233_reset: 
  4801                              <1> 	; 22/04/2017
  4802                              <1> 	; reset VT8237R (vt8233) Audio Controller
  4803                              <1> 	;cmp	byte [audio_play_cmd], 1
  4804                              <1> 	;jna	short vt8233_rst_0
  4805 000152C3 C605[E49C0100]00    <1> 	mov	byte [audio_play_cmd], 0 ; stop !
  4806                              <1> vt8233_rst_0:
  4807 000152CA E8B0FCFFFF          <1> 	call	reset_codec
  4808 000152CF 720A                <1> 	jc	short vt8233_rst_1 ; codec error !
  4809                              <1> 	; eax = 1
  4810 000152D1 E82EFDFFFF          <1> 	call	codec_io_w16 ; w32
  4811 000152D6 E8ABFEFFFF          <1> 	call	channel_reset
  4812                              <1> vt8233_rst_1:
  4813 000152DB C3                  <1> 	retn
  4814                              <1> 
  4815                              <1> vt8233_volume:
  4816                              <1> 	; set VT8237R (vt8233) sound volume level
  4817                              <1> 	; 24/04/2017
  4818                              <1> 	; 22/04/2017
  4819                              <1> 	; bl = component (0 = master/playback/lineout volume)
  4820                              <1> 	; cl = left channel volume level (0 to 31)
  4821                              <1> 	; ch = right channel volume level (0 to 31)
  4822                              <1> 
  4823 000152DC 08DB                <1> 	or	bl, bl
  4824 000152DE 7520                <1> 	jnz	short vt8233_vol_1 ; temporary !
  4825 000152E0 66B81F1F            <1> 	mov	ax, 1F1Fh ; 31,31
  4826 000152E4 38C1                <1> 	cmp	cl, al
  4827 000152E6 7718                <1> 	ja	short vt8233_vol_1 ; temporary !
  4828 000152E8 38E5                <1> 	cmp	ch, ah
  4829 000152EA 7714                <1> 	ja	short vt8233_vol_1 ; temporary !
  4830 000152EC 66890D[E69C0100]    <1> 	mov	[audio_master_volume], cx
  4831 000152F3 6629C8              <1> 	sub	ax, cx
  4832 000152F6 BA02000000          <1> 	mov	edx, CODEC_MASTER_VOL_REG ; 02h ; Line Out
  4833 000152FB E870FDFFFF          <1> 	call	codec_write
  4834                              <1> vt8233_vol_1:
  4835 00015300 C3                  <1> 	retn
  4836                              <1> 
  4837                              <1> ; CODE for SOUND BLASTER 16
  4838                              <1> 
  4839                              <1> DetectSB:
  4840                              <1> 	; 24/04/2017
  4841                              <1> 	;pushad
  4842                              <1> ScanPort:
  4843 00015301 66BB1002            <1> 	mov     bx, 210h	; start scanning ports
  4844                              <1> 				; 210h, 220h, .. 260h
  4845                              <1> ResetDSP:       
  4846 00015305 6689DA              <1> 	mov     dx, bx		; try to reset the DSP.
  4847 00015308 6683C206            <1> 	add     dx, 06h
  4848 0001530C B001                <1> 	mov	al, 1
  4849 0001530E EE                  <1> 	out	dx, al
  4850                              <1> 
  4851 0001530F EC                  <1> 	in	al, dx
  4852 00015310 EC                  <1> 	in	al, dx
  4853 00015311 EC                  <1> 	in	al, dx
  4854 00015312 EC                  <1> 	in	al, dx
  4855                              <1> 
  4856 00015313 30C0                <1> 	xor     al, al
  4857 00015315 EE                  <1> 	out	dx, al
  4858                              <1> 
  4859 00015316 6683C208            <1> 	add     dx, 08h
  4860 0001531A 66B96400            <1> 	mov	cx, 100
  4861                              <1> WaitID:
  4862 0001531E EC                  <1> 	in	al, dx
  4863 0001531F 08C0                <1> 	or      al, al
  4864 00015321 7804                <1> 	js      short GetID
  4865 00015323 E2F9                <1> 	loop    WaitID
  4866 00015325 EB0F                <1> 	jmp     short NextPort
  4867                              <1> GetID:          
  4868 00015327 6683EA04            <1> 	sub     dx, 04h
  4869 0001532B EC                  <1> 	in	al, dx
  4870 0001532C 3CAA                <1> 	cmp     al, 0AAh
  4871 0001532E 7413                <1> 	je      short Found
  4872 00015330 6683C204            <1> 	add     dx, 04h
  4873 00015334 E2E8                <1> 	loop    WaitID
  4874                              <1> NextPort:
  4875 00015336 6683C310            <1> 	add     bx, 10h		; if not response,
  4876 0001533A 6681FB6002          <1> 	cmp     bx, 260h	; try the next port.
  4877 0001533F 76C4                <1> 	jbe     short ResetDSP
  4878 00015341 F9                  <1> 	stc
  4879 00015342 C3                  <1> 	retn
  4880                              <1> Found:
  4881 00015343 66891D[B69C0100]    <1> 	mov     [audio_io_base], bx	; SB Port Address Found!
  4882                              <1> ScanIRQ:
  4883                              <1> SetIrqs:
  4884 0001534A 28C0                <1> 	sub 	al, al ; 0
  4885 0001534C A2[AE9C0100]        <1> 	mov 	[IRQnum], al ; reset
  4886 00015351 A2[B39C0100]        <1> 	mov	[audio_intr], al ; reset
  4887                              <1> 
  4888                              <1> 	; ah > 0 -> set IRQ vector
  4889                              <1> 	; al = IRQ number
  4890                              <1> 	;mov	ax, 103h ; IRQ 3
  4891                              <1> 	;call	set_hardware_int_vector
  4892                              <1> 	;mov	ax, 104h ; IRQ 4
  4893                              <1> 	;call	set_hardware_int_vector
  4894 00015356 66B80501            <1> 	mov	ax, 105h ; IRQ 5
  4895 0001535A E8CADDFFFF          <1> 	call	set_hardware_int_vector
  4896 0001535F 66B80701            <1> 	mov	ax, 107h ; IRQ 7
  4897 00015363 E8C1DDFFFF          <1> 	call	set_hardware_int_vector
  4898                              <1> 
  4899 00015368 668B15[B69C0100]    <1> 	mov     dx, [audio_io_base] ; tells to the SB to
  4900 0001536F 6683C20C            <1> 	add     dx, 0Ch		    ; generate a IRQ!
  4901                              <1> WaitSb:
  4902 00015373 EC                  <1> 	in	al, dx
  4903 00015374 08C0                <1> 	or      al, al
  4904 00015376 78FB                <1> 	js      short WaitSb
  4905 00015378 B0F2                <1> 	mov     al, 0F2h
  4906 0001537A EE                  <1> 	out	dx, al
  4907                              <1> 
  4908 0001537B 31C9                <1> 	xor     ecx, ecx	; wait until IRQ level
  4909                              <1> WaitIRQ: 
  4910 0001537D A0[AE9C0100]        <1> 	mov	al, [IRQnum]
  4911 00015382 3C00                <1> 	cmp     al, 0 ; is changed or timeout.
  4912 00015384 7706                <1> 	ja	short IrqOk
  4913 00015386 6649                <1> 	dec	cx
  4914 00015388 75F3                <1> 	jnz	short WaitIRQ
  4915 0001538A EB15                <1> 	jmp	short RestoreIrqs
  4916                              <1> IrqOk:
  4917 0001538C A2[B39C0100]        <1> 	mov	[audio_intr], al ; set   
  4918 00015391 668B15[B69C0100]    <1> 	mov     dx, [audio_io_base]
  4919 00015398 6683C20E            <1> 	add     dx, 0Eh
  4920 0001539C EC                  <1> 	in	al, dx	; SB acknowledge.
  4921 0001539D B020                <1> 	mov	al, 20h
  4922 0001539F E620                <1> 	out	20h, al	; Hardware acknowledge.
  4923                              <1> 
  4924                              <1> RestoreIrqs:
  4925                              <1> 	; ah = 0 -> reset IRQ vector
  4926                              <1> 	; al = IRQ number
  4927                              <1> 	;mov	ax, 3 ; IRQ 3
  4928                              <1> 	;call	set_hardware_int_vector
  4929                              <1> 	;mov	ax, 4 ; IRQ 4
  4930                              <1> 	;call	set_hardware_int_vector
  4931 000153A1 66B80500            <1> 	mov	ax, 5 ; IRQ 5
  4932 000153A5 E87FDDFFFF          <1> 	call	set_hardware_int_vector
  4933 000153AA 66B80700            <1> 	mov	ax, 7 ; IRQ 7
  4934 000153AE E876DDFFFF          <1> 	call	set_hardware_int_vector
  4935                              <1> 
  4936 000153B3 31D2                <1> 	xor	edx, edx
  4937 000153B5 8915[B89C0100]      <1> 	mov	[audio_dev_id], edx ; 0
  4938 000153BB 8915[BC9C0100]      <1> 	mov	[audio_vendor], edx ; 0
  4939 000153C1 8915[C09C0100]      <1> 	mov	[audio_stats_cmd], edx ; 0
  4940                              <1> 
  4941                              <1> 	;popad
  4942                              <1> 
  4943 000153C7 803D[B39C0100]01    <1> 	cmp     byte [audio_intr], 1 ; IRQ level was changed?
  4944                              <1> 	
  4945 000153CE C3                  <1> 	retn
  4946                              <1> 
  4947                              <1> %macro	SbOut	1
  4948                              <1> %%Wait:
  4949                              <1> 	in	al, dx
  4950                              <1> 	or	al, al
  4951                              <1> 	js	short %%Wait
  4952                              <1> 	mov	al, %1
  4953                              <1> 	out	dx, al
  4954                              <1> %endmacro
  4955                              <1> 
  4956                              <1> SbInit_play:
  4957                              <1> 	; 22/10/2017
  4958                              <1> 	; 20/10/2017
  4959                              <1> 	; 06/10/2017
  4960                              <1> 	; 13/07/2017, 09/08/2017
  4961                              <1> 	; 24/04/2017, 15/05/2017, 24/06/2017
  4962                              <1> 	;pushad
  4963                              <1> SetBuffer:
  4964                              <1> 	;mov	byte [DmaFlag], 0
  4965                              <1> 
  4966 000153CF 8B1D[D09C0100]      <1> 	mov	ebx, [audio_dma_buff] ; physical addr of DMA buff
  4967 000153D5 89DF                <1> 	mov	edi, ebx
  4968 000153D7 8B0D[D49C0100]      <1> 	mov     ecx, [audio_dmabuff_size]
  4969                              <1> 
  4970 000153DD 803D[E09C0100]10    <1> 	cmp	byte [audio_bps], 16
  4971 000153E4 7531                <1> 	jne	short sbInit_0 ; set 8 bit DMA buffer
  4972                              <1> 	
  4973                              <1> 	; 09/08/2017
  4974                              <1> 	; convert byte count to word count
  4975 000153E6 D1E9                <1> 	shr	ecx, 1
  4976 000153E8 49                  <1> 	dec	ecx ; word count - 1
  4977                              <1> 	; convert byte offset to word offset
  4978 000153E9 D1EB                <1> 	shr	ebx, 1
  4979                              <1> 
  4980                              <1> 	; 16 bit DMA buffer setting (DMA channel 5)
  4981 000153EB B005                <1> 	mov     al, 05h  ; set mask bit for channel 5  (4+1)
  4982 000153ED E6D4                <1> 	out	0D4h, al
  4983                              <1> 	
  4984 000153EF 30C0                <1> 	xor     al, al   ; stops all DMA processes on selected channel
  4985 000153F1 E6D8                <1> 	out	0D8h, al ; clear selected channel register
  4986                              <1> 
  4987 000153F3 88D8                <1> 	mov     al, bl	 ; byte 0 of DMA buffer offset in words (physical) 
  4988 000153F5 E6C4                <1> 	out	0C4h, al ; DMA channel 5 port number
  4989                              <1> 
  4990 000153F7 88F8                <1> 	mov     al, bh   ; byte 1 of DMA buffer offset in words (physical)   
  4991 000153F9 E6C4                <1> 	out	0C4h, al
  4992                              <1> 	
  4993                              <1> 	; 09/08/2017
  4994 000153FB C1EB0F              <1> 	shr	ebx, 15	 ; complete 16 bit shift
  4995 000153FE 80E3FE              <1> 	and	bl, 0FEh ; clear bit 0 (not necessary, it will be ignored)
  4996                              <1> 
  4997 00015401 88D8                <1> 	mov     al, bl   ; byte 2 of DMA buffer address (physical) 
  4998 00015403 E68B                <1> 	out	8Bh, al  ; page register port addr for channel 5 ; 13/07/2017
  4999                              <1> 
  5000 00015405 88C8                <1> 	mov     al, cl   ; low byte of DMA count - 1
  5001 00015407 E6C6                <1> 	out	0C6h, al ; count register port addr for channel 1
  5002                              <1> 
  5003 00015409 88E8                <1> 	mov     al, ch   ; high byte of DMA count - 1
  5004 0001540B E6C6                <1> 	out	0C6h, al
  5005                              <1> 
  5006                              <1> 	; channel 5, read, autoinitialized, single mode
  5007                              <1> 	;mov	al, 49h
  5008 0001540D B059                <1> 	mov	al, 59h  ; 06/10/2017 
  5009 0001540F E6D6                <1> 	out	0D6h, al ; DMA mode register port address
  5010                              <1> 
  5011 00015411 B001                <1> 	mov     al, 01h  ; clear mask bit for channel 1
  5012 00015413 E6D4                <1> 	out	0D4h, al ; DMA mask register port address
  5013                              <1> 
  5014 00015415 EB28                <1> 	jmp	short ClearBuffer
  5015                              <1> 
  5016                              <1> sbInit_0:    
  5017 00015417 49                  <1> 	dec     ecx ; 09/08/2017
  5018                              <1> 
  5019                              <1> 	; 8 bit DMA buffer setting (DMA channel 1)
  5020 00015418 B005                <1> 	mov     al, 05h ; set mask bit for channel 1  (4+1)
  5021 0001541A E60A                <1> 	out	0Ah, al ; DMA mask register
  5022                              <1> 
  5023 0001541C 30C0                <1> 	xor     al, al  ; stops all DMA processes on selected channel
  5024 0001541E E60C                <1> 	out	0Ch, al ; clear selected channel register
  5025                              <1> 
  5026 00015420 88D8                <1> 	mov     al, bl	; byte 0 of DMA buffer address (physical)   
  5027 00015422 E602                <1> 	out	02h, al ; DMA channel 1 port number
  5028                              <1> 
  5029 00015424 88F8                <1> 	mov     al, bh  ; byte 1 of DMA buffer address (physical)   
  5030 00015426 E602                <1> 	out	02h, al
  5031                              <1> 
  5032 00015428 C1EB10              <1> 	shr	ebx, 16
  5033                              <1> 
  5034 0001542B 88D8                <1> 	mov     al, bl  ; byte 2 of DMA buffer address (physical)   
  5035 0001542D E683                <1> 	out	83h, al ; page register port addr for channel 1
  5036                              <1> 
  5037 0001542F 88C8                <1> 	mov     al, cl  ; low byte of DMA count - 1
  5038 00015431 E603                <1> 	out	03h, al ; count register port addr for channel 1
  5039                              <1> 
  5040 00015433 88E8                <1> 	mov     al, ch  ; high byte of DMA count - 1
  5041 00015435 E603                <1> 	out	03h, al
  5042                              <1> 
  5043                              <1> 	; channel 1, read, autoinitialized, single mode
  5044                              <1> 	;mov	al, 49h
  5045 00015437 B059                <1> 	mov	al, 59h ; 06/10/2017 
  5046 00015439 E60B                <1> 	out	0Bh, al ; DMA mode register port address
  5047                              <1> 
  5048 0001543B B001                <1> 	mov     al, 01h ; clear mask bit for channel 1
  5049 0001543D E60A                <1> 	out	0Ah, al ; DMA mask register port address
  5050                              <1> 
  5051                              <1> ClearBuffer:
  5052                              <1> 	;;mov	edi, [audio_dma_buff]
  5053                              <1> 	;;mov	ecx, [audio_dmabuff_size]
  5054                              <1> 	;inc	ecx
  5055                              <1> 	;mov     al, 80h
  5056                              <1> 	;;cld
  5057                              <1> 	;rep     stosb
  5058                              <1> SetIrq:
  5059                              <1> 	;mov	ebx, SbIrqhandler
  5060                              <1> 	;mov	al, [audio_intr] ; IRQ number	
  5061                              <1> 	;call	set_dev_IRQ_service
  5062                              <1> 	;; SETUP (audio) INTERRUPT CALLBACK SERVICE
  5063                              <1> 	;mov	bl, [audio_intr] ; IRQ number
  5064                              <1> 	;mov	bh, [audio_cb_mode]
  5065                              <1> 	;inc	bh  ; 1 = Signal Response Byte method (fixed value)
  5066                              <1> 	;	    ; 2 = Callback service method
  5067                              <1> 	;	    ; 3 = Auto Increment S.R.B. method 	
  5068                              <1> 	;mov	cl, [audio_srb]
  5069                              <1> 	;mov	edx, [audio_cb_addr]
  5070                              <1> 	;mov	al, [audio_user]
  5071                              <1>  	;call	set_irq_callback_service
  5072                              <1> ResetDsp:
  5073 0001543F 668B15[B69C0100]    <1> 	mov     dx, [audio_io_base]
  5074 00015446 6683C206            <1> 	add     dx, 06h
  5075 0001544A B001                <1> 	mov     al, 1
  5076 0001544C EE                  <1> 	out	dx, al
  5077                              <1> 
  5078 0001544D EC                  <1> 	in	al, dx
  5079 0001544E EC                  <1> 	in	al, dx
  5080 0001544F EC                  <1> 	in	al, dx
  5081 00015450 EC                  <1> 	in	al, dx
  5082                              <1> 
  5083 00015451 30C0                <1> 	xor     al, al
  5084 00015453 EE                  <1> 	out	dx, al
  5085                              <1> 
  5086 00015454 66B96400            <1> 	mov     cx, 100
  5087 00015458 28E4                <1> 	sub	ah, ah ; 0
  5088                              <1> WaitId:         
  5089 0001545A 668B15[B69C0100]    <1> 	mov     dx, [audio_io_base]
  5090 00015461 6683C20E            <1> 	add     dx, 0Eh
  5091 00015465 EC                  <1> 	in	al, dx
  5092 00015466 08C0                <1> 	or      al, al
  5093 00015468 7807                <1> 	js      short sb_GetId
  5094 0001546A E2EE                <1> 	loop    WaitId
  5095 0001546C E9B4000000          <1> 	jmp     sb_Exit
  5096                              <1> sb_GetId:
  5097 00015471 668B15[B69C0100]    <1> 	mov     dx, [audio_io_base]
  5098 00015478 6683C20A            <1> 	add     dx, 0Ah
  5099 0001547C EC                  <1> 	in	al, dx
  5100 0001547D 3CAA                <1> 	cmp     al, 0AAh
  5101 0001547F 7407                <1> 	je      short SbOk
  5102 00015481 E2D7                <1> 	loop    WaitId
  5103 00015483 E99D000000          <1> 	jmp	sb_Exit
  5104                              <1> SbOk:
  5105 00015488 668B15[B69C0100]    <1> 	mov     dx, [audio_io_base]
  5106 0001548F 6683C20C            <1> 	add     dx, 0Ch
  5107                              <1> 	SbOut   0D1h ; Turn on speaker
  4948                              <2> %%Wait:
  4949 00015493 EC                  <2>  in al, dx
  4950 00015494 08C0                <2>  or al, al
  4951 00015496 78FB                <2>  js short %%Wait
  4952 00015498 B0D1                <2>  mov al, %1
  4953 0001549A EE                  <2>  out dx, al
  5108                              <1> 	SbOut   41h ; 8 bit or 16 bit transfer
  4948                              <2> %%Wait:
  4949 0001549B EC                  <2>  in al, dx
  4950 0001549C 08C0                <2>  or al, al
  4951 0001549E 78FB                <2>  js short %%Wait
  4952 000154A0 B041                <2>  mov al, %1
  4953 000154A2 EE                  <2>  out dx, al
  5109 000154A3 668B1D[E29C0100]    <1> 	mov	bx, [audio_freq] ; sampling rate (Hz)
  5110                              <1> 	SbOut	bh ; sampling rate high byte
  4948                              <2> %%Wait:
  4949 000154AA EC                  <2>  in al, dx
  4950 000154AB 08C0                <2>  or al, al
  4951 000154AD 78FB                <2>  js short %%Wait
  4952 000154AF 88F8                <2>  mov al, %1
  4953 000154B1 EE                  <2>  out dx, al
  5111                              <1> 	SbOut	bl ; sampling rate low byte
  4948                              <2> %%Wait:
  4949 000154B2 EC                  <2>  in al, dx
  4950 000154B3 08C0                <2>  or al, al
  4951 000154B5 78FB                <2>  js short %%Wait
  4952 000154B7 88D8                <2>  mov al, %1
  4953 000154B9 EE                  <2>  out dx, al
  5112                              <1> 
  5113                              <1> 	; 22/05/2017
  5114 000154BA E8C0000000          <1> 	call	sb16_volume_initial ; 15/05/2017
  5115                              <1> 	; 20/05/2017
  5116                              <1> 	;call	sb16_volume
  5117                              <1> 
  5118                              <1> StartDma:  
  5119                              <1> 	; autoinitialized mode
  5120 000154BF 803D[E09C0100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit samples
  5121 000154C6 7411                <1> 	je	short sb_play_1
  5122                              <1> 	; 8 bit samples
  5123 000154C8 66BBC600            <1> 	mov	bx, 0C6h ; 8 bit output (0C6h)
  5124 000154CC 803D[E19C0100]02    <1> 	cmp	byte [audio_stmo], 2 ; 1 = mono, 2 = stereo
  5125 000154D3 7214                <1> 	jb	short sb_play_2
  5126 000154D5 B720                <1> 	mov	bh, 20h	; 8 bit stereo (20h)
  5127 000154D7 EB10                <1> 	jmp	short sb_play_2
  5128                              <1> sb_play_1:
  5129                              <1> 	; 16 bit samples
  5130 000154D9 66BBB610            <1> 	mov	bx, 10B6h ; 16 bit output (0B6h)
  5131 000154DD 803D[E19C0100]02    <1> 	cmp	byte [audio_stmo], 2 ; 1 = mono, 2 = stereo
  5132 000154E4 7203                <1> 	jb	short sb_play_2
  5133 000154E6 80C720              <1> 	add	bh, 20h	; 16 bit stereo (30h)
  5134                              <1> sb_play_2:     
  5135                              <1> 	; PCM output (8/16 bit mono autoinitialized transfer)
  5136                              <1> 	SbOut   bl ; bCommand
  4948                              <2> %%Wait:
  4949 000154E9 EC                  <2>  in al, dx
  4950 000154EA 08C0                <2>  or al, al
  4951 000154EC 78FB                <2>  js short %%Wait
  4952 000154EE 88D8                <2>  mov al, %1
  4953 000154F0 EE                  <2>  out dx, al
  5137                              <1> 	SbOut	bh ; bMode
  4948                              <2> %%Wait:
  4949 000154F1 EC                  <2>  in al, dx
  4950 000154F2 08C0                <2>  or al, al
  4951 000154F4 78FB                <2>  js short %%Wait
  4952 000154F6 88F8                <2>  mov al, %1
  4953 000154F8 EE                  <2>  out dx, al
  5138 000154F9 8B1D[D49C0100]      <1> 	mov	ebx, [audio_dmabuff_size]  ; 15/05/2017
  5139 000154FF D1EB                <1> 	shr	ebx, 1 ; half buffer size
  5140                              <1> 	; 20/10/2017	
  5141 00015501 803D[E09C0100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit DMA
  5142 00015508 7502                <1> 	jne	short sb_play_3
  5143 0001550A D1EB                <1> 	shr	ebx, 1 ; byte count to word count
  5144                              <1> sb_play_3: 
  5145 0001550C 664B                <1> 	dec	bx  ; wBlkSize is one less than the actual size 
  5146                              <1> 	SbOut   bl
  4948                              <2> %%Wait:
  4949 0001550E EC                  <2>  in al, dx
  4950 0001550F 08C0                <2>  or al, al
  4951 00015511 78FB                <2>  js short %%Wait
  4952 00015513 88D8                <2>  mov al, %1
  4953 00015515 EE                  <2>  out dx, al
  5147                              <1> 	SbOut   bh
  4948                              <2> %%Wait:
  4949 00015516 EC                  <2>  in al, dx
  4950 00015517 08C0                <2>  or al, al
  4951 00015519 78FB                <2>  js short %%Wait
  4952 0001551B 88F8                <2>  mov al, %1
  4953 0001551D EE                  <2>  out dx, al
  5148                              <1> 
  5149 0001551E C605[E49C0100]01    <1> 	mov	byte [audio_play_cmd], 1 ; playing !
  5150                              <1> 
  5151                              <1> 	;; Set Voice and master volumes
  5152                              <1> 	;mov	dx, [audio_io_base]
  5153                              <1> 	;add	dl, 4 ; Mixer chip Register Address Port
  5154                              <1> 	;SbOut	30h   ; select Master Volume Register (L)
  5155                              <1> 	;inc	dl    ; Mixer chip Register Data Port
  5156                              <1> 	;SbOut	0F8h  ; Max. volume value is 31 (31*8)
  5157                              <1> 	;dec	dl
  5158                              <1> 	;SbOut	31h   ; select Master Volume Register (R)
  5159                              <1> 	;inc	dl
  5160                              <1> 	;SbOut	0F8h  ; Max. volume value is 31 (31*8)
  5161                              <1> 	;dec	dl
  5162                              <1> 	;SbOut	32h   ; select Voice Volume Register (L)
  5163                              <1> 	;inc	dl
  5164                              <1> 	;SbOut	0F8h  ; Max. volume value is 31 (31*8)
  5165                              <1> 	;dec	dl
  5166                              <1> 	;SbOut	33h   ; select Voice Volume Register (R)
  5167                              <1> 	;inc	dl
  5168                              <1> 	;SbOut	0F8h  ; Max. volume value is 31 (31*8)	
  5169                              <1> 	;;
  5170                              <1> 	;dec	dl
  5171                              <1> 	;SbOut	44h   ; select Treble Register (L)
  5172                              <1> 	;inc	dl
  5173                              <1> 	;SbOut	0F0h  ; Max. Treble value is 15 (15*16)
  5174                              <1> 	;dec	dl
  5175                              <1> 	;SbOut	45h   ; select Treble Register (R)
  5176                              <1> 	;inc	dl
  5177                              <1> 	;SbOut	0F0h  ; Max. Treble value is 15 (15*16)
  5178                              <1> 	;dec	dl
  5179                              <1> 	;SbOut	46h   ; select Bass Register (L)
  5180                              <1> 	;inc	dl
  5181                              <1> 	;SbOut	0F0h  ; Max. Bass value is 15 (15*16)
  5182                              <1> 	;dec	dl
  5183                              <1> 	;SbOut	47h   ; select Bass Register (R)
  5184                              <1> 	;inc	dl
  5185                              <1> 	;SbOut	0F0h  ; Max. Bass value is 15 (15*16)	
  5186                              <1> 
  5187                              <1> sb_Exit:           
  5188                              <1> 	;popad
  5189 00015525 C3                  <1> 	retn
  5190                              <1> 
  5191                              <1> sb16_int_handler:
  5192                              <1> 	; Interrupt Handler for Sound Blaster 16 Audio Card
  5193                              <1> 	; Note: called by 'dev_IRQ_service'
  5194                              <1> 	; 20/10/2017
  5195                              <1> 	; 12/10/2017
  5196                              <1> 	; 10/10/2017 
  5197                              <1> 	; 12/05/2017, 09/10/2017
  5198                              <1> 	; 24/04/2017 (TRDOS 386 kernel, 'audio.s')
  5199                              <1> 	; 10/03/2017 - 'PLAYWAV.PRG' ('playwav.s') 
  5200                              <1> 
  5201                              <1> 	;push	eax ; * must be saved !
  5202                              <1> 	;push	ebx ; * must be saved !
  5203                              <1> 	;push	ecx
  5204                              <1> 	;push	edx
  5205                              <1> 	;push	esi
  5206                              <1> 	;push	edi
  5207                              <1> 
  5208 00015526 668B15[B69C0100]    <1> 	mov     dx, [audio_io_base]
  5209                              <1> 	; 20/10/2017
  5210 0001552D 80C20F              <1> 	add     dl, 0Fh ; 2xFh (DSP 16 bit intr ack)
  5211 00015530 803D[E09C0100]10    <1> 	cmp	byte [audio_bps], 16
  5212 00015537 7402                <1> 	je	short sb_irq_16bit_ack
  5213                              <1> sb_irq_8bit_ack:
  5214 00015539 FECA                <1> 	dec	dl  ; 2xEh (DSP 8 bit intr ack)
  5215                              <1> sb_irq_16bit_ack:
  5216 0001553B EC                  <1> 	in	al, dx
  5217                              <1> 
  5218                              <1> 	;cmp	byte [audio_busy], 0
  5219                              <1> 	;ja	short sb_irq_h3
  5220                              <1> 
  5221                              <1> 	;mov	byte [audio_busy], 1
  5222                              <1> 
  5223 0001553C 803D[E49C0100]01    <1> 	cmp	byte [audio_play_cmd], 1
  5224 00015543 7307                <1> 	jnb	short sb_irq_h1
  5225                              <1> sb_irq_h0:
  5226 00015545 E8A9000000          <1> 	call	sb16_stop
  5227 0001554A EB2B                <1> 	jmp	short sb_irq_h3
  5228                              <1> sb_irq_h1:
  5229                              <1> 	;call	sb16_tuneloop
  5230                              <1> 	; 09/10/2017
  5231                              <1> sb16_tuneloop:
  5232 0001554C 8B3D[D09C0100]      <1> 	mov	edi, [audio_dma_buff]
  5233 00015552 8B0D[D49C0100]      <1> 	mov	ecx, [audio_dmabuff_size]
  5234 00015558 D1E9                <1> 	shr	ecx, 1 ; dma buff size / 2 = half buffer size
  5235                              <1> 
  5236                              <1> 	; 22/05/2017
  5237 0001555A F605[D89C0100]01    <1> 	test	byte [audio_flag], 1  ; Current flag value
  5238 00015561 7402                <1> 	jz	short sb_tlp1 ; EOL (Half Buffer 1 must be filled)
  5239                              <1> 	; FLAG (Half Buffer 2 must be filled)
  5240 00015563 01CF                <1> 	add	edi, ecx
  5241                              <1> 	; 15/05/2017
  5242                              <1> sb_tlp1: 
  5243 00015565 8B35[C89C0100]      <1> 	mov	esi, [audio_p_buffer] ; phy addr of audio buff
  5244                              <1> 	;rep	movsb
  5245 0001556B C1E902              <1> 	shr	ecx, 2 ; half buff size / 4
  5246 0001556E F3A5                <1> 	rep	movsd 
  5247                              <1> 	;retn
  5248                              <1> 
  5249                              <1> 	; 10/10/2017
  5250                              <1> 	; switch flag value
  5251 00015570 8035[D89C0100]01    <1> 	xor	byte [audio_flag], 1
  5252                              <1> 
  5253                              <1> 	; 12/10/2017
  5254                              <1> 	; [audio_flag] = 0 : Playing dma half buffer 2 (odd intr count)
  5255                              <1> 			   ; Next buffer (to update) is dma half buff 1
  5256                              <1> 	; 	       = 1 : Playing dma half buffer 1 (even intr count)
  5257                              <1> 			   ; Next buffer (to update) is dma half buff 2
  5258                              <1> 
  5259                              <1> sb_irq_h3:
  5260                              <1> 	;mov	byte [audio_busy], 0
  5261                              <1> 
  5262                              <1> 	;pop	edi
  5263                              <1> 	;pop	esi
  5264                              <1> 	;pop	edx
  5265                              <1> 	;pop	ecx
  5266                              <1> 	;pop	ebx ; * must be restored !
  5267                              <1> 	;pop	eax ; * must be restored !
  5268                              <1> 	
  5269 00015577 C3                  <1> 	retn
  5270                              <1> 
  5271                              <1> sb16_volume:
  5272                              <1> 	; 22/10/2017
  5273                              <1> 	; mov [audio_master_volume_l], cl 
  5274                              <1> 	; mov [audio_master_volume_h], ch 
  5275 00015578 66890D[E69C0100]    <1> 	mov	[audio_master_volume], cx
  5276                              <1> sb16_volume_initial:
  5277 0001557F 6652                <1> 	push	dx ; DX (port address) must be saved
  5278 00015581 668B15[B69C0100]    <1> 	mov	dx, [audio_io_base]
  5279 00015588 6683C204            <1> 	add	dx, 4 ; Mixer chip address port
  5280 0001558C B022                <1> 	mov	al, 22h ; master volume
  5281 0001558E EE                  <1> 	out	dx, al
  5282 0001558F 6642                <1> 	inc	dx
  5283 00015591 8A25[E69C0100]      <1> 	mov	ah, [audio_master_volume_l]
  5284 00015597 C0EC02              <1> 	shr	ah, 2 ; 32 -> 8 level
  5285 0001559A C0E405              <1> 	shl	ah, 5 ; bit 5 to 7
  5286 0001559D A0[E79C0100]        <1> 	mov	al, [audio_master_volume_r]	
  5287 000155A2 C0E802              <1> 	shr	al, 2 ; 32 -> 8 level
  5288                              <1> 	;and	al, 0Fh
  5289 000155A5 D0E0                <1> 	shl	al, 1 ; bit 1 to 3
  5290 000155A7 08E0                <1> 	or	al, ah
  5291 000155A9 EE                  <1> 	out	dx, al
  5292 000155AA 665A                <1> 	pop	dx ; DX (port address) must be restored
  5293 000155AC C3                  <1> 	retn
  5294                              <1> 
  5295                              <1> sb16_pause:
  5296 000155AD 668B15[B69C0100]    <1> 	mov	dx, [audio_io_base]
  5297 000155B4 6683C20C            <1> 	add	dx, 0Ch ; Command & Data Port
  5298 000155B8 803D[E09C0100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit samples
  5299 000155BF 7404                <1> 	je	short sb_pause_1
  5300                              <1> 	; 8 bit samples
  5301 000155C1 B3D0                <1> 	mov	bl, 0D0h ; 8 bit DMA mode
  5302 000155C3 EB02                <1> 	jmp	short sb_pause_2
  5303                              <1> sb_pause_1:
  5304                              <1> 	; 16 bit samples
  5305 000155C5 B3D5                <1> 	mov	bl, 0D5h ; 16 bit DMA mode
  5306                              <1> sb_pause_2:     
  5307                              <1> 	SbOut   bl ; bCommand
  4948                              <2> %%Wait:
  4949 000155C7 EC                  <2>  in al, dx
  4950 000155C8 08C0                <2>  or al, al
  4951 000155CA 78FB                <2>  js short %%Wait
  4952 000155CC 88D8                <2>  mov al, %1
  4953 000155CE EE                  <2>  out dx, al
  5308                              <1> sb_pause_3:
  5309 000155CF C3                  <1> 	retn
  5310                              <1> 
  5311                              <1> sb16_continue:
  5312 000155D0 668B15[B69C0100]    <1> 	mov	dx, [audio_io_base]
  5313 000155D7 6683C20C            <1> 	add	dx, 0Ch ; Command & Data Port
  5314 000155DB 803D[E09C0100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit samples
  5315 000155E2 7404                <1> 	je	short sb_cont_1
  5316                              <1> 	; 8 bit samples
  5317 000155E4 B3D4                <1> 	mov	bl, 0D4h ; 8 bit DMA mode
  5318 000155E6 EB02                <1> 	jmp	short sb_cont_2
  5319                              <1> sb_cont_1:
  5320                              <1> 	; 16 bit samples
  5321 000155E8 B3D6                <1> 	mov	bl, 0D6h ; 16 bit DMA mode
  5322                              <1> sb_cont_2:     
  5323                              <1> 	SbOut   bl ; bCommand
  4948                              <2> %%Wait:
  4949 000155EA EC                  <2>  in al, dx
  4950 000155EB 08C0                <2>  or al, al
  4951 000155ED 78FB                <2>  js short %%Wait
  4952 000155EF 88D8                <2>  mov al, %1
  4953 000155F1 EE                  <2>  out dx, al
  5324                              <1> sb_cont_3:
  5325 000155F2 C3                  <1> 	retn
  5326                              <1> 
  5327                              <1> sb16_stop:
  5328                              <1> 	; 24/04/2017
  5329 000155F3 803D[E49C0100]00    <1> 	cmp	byte [audio_play_cmd], 0
  5330 000155FA 7648                <1> 	jna	short sb16_stop_4
  5331                              <1> 
  5332                              <1> 	; 22/05/2017
  5333 000155FC 668B15[B69C0100]    <1> 	mov	dx, [audio_io_base]
  5334 00015603 6683C20C            <1> 	add	dx, 0Ch
  5335                              <1> 
  5336 00015607 B3D9                <1> 	mov	bl, 0D9h ; exit auto-initialize 16 bit transfer
  5337                              <1> 	; stop  autoinitialized DMA transfer mode 
  5338 00015609 803D[E09C0100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit samples
  5339 00015610 7402                <1> 	je	short sb16_stop_1
  5340                              <1> 	;mov	bl, 0DAh ; exit auto-initialize 8 bit transfer
  5341 00015612 FEC3                <1> 	inc	bl
  5342                              <1> sb16_stop_1:
  5343                              <1> 	SbOut	bl ; exit auto-initialize transfer command
  4948                              <2> %%Wait:
  4949 00015614 EC                  <2>  in al, dx
  4950 00015615 08C0                <2>  or al, al
  4951 00015617 78FB                <2>  js short %%Wait
  4952 00015619 88D8                <2>  mov al, %1
  4953 0001561B EE                  <2>  out dx, al
  5344                              <1> 
  5345 0001561C 30C0                <1> 	xor     al, al ; stops all DMA processes on selected channel
  5346                              <1> 
  5347 0001561E 803D[E09C0100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit samples
  5348 00015625 7404                <1> 	je	short sb16_stop_2
  5349 00015627 E60C                <1> 	out	0Ch, al ; clear selected channel register
  5350 00015629 EB02                <1> 	jmp	short sb16_stop_3
  5351                              <1> 
  5352                              <1> sb16_stop_2:
  5353 0001562B E6D8                <1> 	out	0D8h, al ; clear selected channel register
  5354                              <1> 
  5355                              <1> sb16_stop_3:
  5356 0001562D C605[E49C0100]00    <1> 	mov	byte [audio_play_cmd], 0 ; stop !
  5357                              <1> SbDone:
  5358                              <1> 	;mov	dx, [audio_io_base]
  5359                              <1> 	;add	dx, 0Ch
  5360                              <1> 	SbOut   0D0h
  4948                              <2> %%Wait:
  4949 00015634 EC                  <2>  in al, dx
  4950 00015635 08C0                <2>  or al, al
  4951 00015637 78FB                <2>  js short %%Wait
  4952 00015639 B0D0                <2>  mov al, %1
  4953 0001563B EE                  <2>  out dx, al
  5361                              <1> 	SbOut   0D3h
  4948                              <2> %%Wait:
  4949 0001563C EC                  <2>  in al, dx
  4950 0001563D 08C0                <2>  or al, al
  4951 0001563F 78FB                <2>  js short %%Wait
  4952 00015641 B0D3                <2>  mov al, %1
  4953 00015643 EE                  <2>  out dx, al
  5362                              <1> sb16_stop_4:
  5363 00015644 C3                  <1> 	retn
  5364                              <1> 
  5365                              <1> sb16_reset:
  5366                              <1> 	; 24/04/2017      
  5367 00015645 668B15[B69C0100]    <1> 	mov     dx, [audio_io_base] ; try to reset the DSP.
  5368 0001564C 6683C206            <1> 	add     dx, 06h
  5369 00015650 B001                <1> 	mov	al, 1
  5370 00015652 EE                  <1> 	out	dx, al
  5371                              <1> 
  5372 00015653 EC                  <1> 	in	al, dx
  5373 00015654 EC                  <1> 	in	al, dx
  5374 00015655 EC                  <1> 	in	al, dx
  5375 00015656 EC                  <1> 	in	al, dx
  5376                              <1> 
  5377 00015657 30C0                <1> 	xor     al, al
  5378 00015659 EE                  <1> 	out	dx, al
  5379                              <1> 
  5380 0001565A 6683C208            <1> 	add     dx, 08h
  5381 0001565E 66B96400            <1> 	mov	cx, 100
  5382                              <1> sbrstWaitID:
  5383 00015662 EC                  <1> 	in	al, dx
  5384 00015663 08C0                <1> 	or      al, al
  5385 00015665 7804                <1> 	js      short sbrstGetID
  5386 00015667 E2F9                <1> 	loop    sbrstWaitID
  5387 00015669 F9                  <1> 	stc
  5388 0001566A C3                  <1> 	retn
  5389                              <1> sbrstGetID:          
  5390 0001566B 6683EA04            <1> 	sub     dx, 04h
  5391 0001566F EC                  <1> 	in	al, dx
  5392 00015670 3CAA                <1> 	cmp     al, 0AAh
  5393 00015672 7406                <1> 	je      short sb_rst_retn
  5394 00015674 6683C204            <1> 	add     dx, 04h
  5395 00015678 E2E8                <1> 	loop    sbrstWaitID
  5396                              <1> sb_rst_retn:
  5397 0001567A C3                  <1> 	retn
  5398                              <1> 
  5399                              <1> ac97_codec_config:
  5400                              <1> 	; 10/06/2017
  5401                              <1> 	; 05/06/2017
  5402                              <1> 	; 29/05/2017
  5403                              <1> 	; 28/05/2017 (TRDOS 386, 'audio.s')
  5404                              <1> 	; 07/11/2016 (Erdogan Tan)
  5405                              <1> 	; Derived from 'codecConfig' procedure in 'CODEC.ASM'
  5406                              <1> 	; .wav player for DOS by Jeff Leyda (02/09/2002)
  5407                              <1> 
  5408                              <1> 	;; 'PLAYER.ASM'
  5409                              <1> 	;; get ICH base address regs for mixer and bus master
  5410                              <1> 
  5411                              <1> init_ac97_controller: ; 10/06/2017
  5412 0001567B A1[B89C0100]        <1> 	mov	eax, [audio_dev_id]
  5413                              <1>         ;mov	al, NAMBAR_REG
  5414                              <1>         ;;call  pciRegRead16			; read PCI registers 10-11
  5415                              <1>         ;call	pciRegRead32
  5416                              <1> 	;and	dx, IO_ADDR_MASK 		; mask off BIT0
  5417                              <1> 	;;and	edx, IO_ADDR_MASK 
  5418                              <1> 
  5419                              <1>         ;mov	[NAMBAR], dx			; save audio mixer base addr
  5420                              <1> 
  5421                              <1>         ;mov    al, NABMBAR_REG
  5422                              <1>         ;;call	pciRegRead16
  5423                              <1>         ;call	pciRegRead32
  5424                              <1> 	;and	dx, 0FFC0h ; IO_ADDR_MASK
  5425                              <1> 	;;and	edx, 0FFC0h
  5426                              <1> 
  5427                              <1>         ;mov    [NABMBAR], dx			; save bus master base addr
  5428                              <1> 
  5429                              <1> 	;mov	eax, [audio_dev_id]
  5430 00015680 B004                <1>         mov     al, PCI_CMD_REG
  5431                              <1>         ;call	pciRegRead8			; read PCI command register
  5432 00015682 E84AF8FFFF          <1>         call	pciRegRead16
  5433 00015687 80CA05              <1> 	or      dl, IO_ENA+BM_ENA               ; enable IO and bus master
  5434                              <1>         ;call 	pciRegWrite8
  5435 0001568A E8ADF8FFFF          <1> 	call	pciRegWrite16
  5436                              <1> 
  5437                              <1> 	; 'CODEC.ASM'
  5438                              <1> 
  5439                              <1> 	; enable codec, unmute stuff, set output rate
  5440                              <1> ;	; entry: [audio_freq] = desired sample rate
  5441                              <1> 		
  5442                              <1> ;	mov    	dx, [NAMBAR]               	
  5443                              <1> ;	add    	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah  	  
  5444                              <1> ;	in     	ax, dx
  5445                              <1> ;	or	ax, 1
  5446                              <1> ;	out	dx, ax 				; Enable variable rate audio
  5447                              <1> 
  5448                              <1> ;       ;call    delay1_4ms
  5449                              <1> ;       ;call    delay1_4ms
  5450                              <1> ;       ;call    delay1_4ms
  5451                              <1> ;       ;call    delay1_4ms
  5452                              <1> 
  5453                              <1> ;	mov	ax, [audio_freq]		; sample rate
  5454                              <1> 
  5455                              <1> ;	mov    	dx, [NAMBAR]               	
  5456                              <1> ;	add    	dx, CODEC_PCM_FRONT_DACRATE_REG	; 2Ch  	  
  5457                              <1> ;	out	dx, ax 				; out sample rate
  5458                              <1> 		
  5459                              <1> ;       ;call	delay1_4ms
  5460                              <1> ;       ;call	delay1_4ms
  5461                              <1> ;       ;call	delay1_4ms
  5462                              <1> ;       ;call	delay1_4ms
  5463                              <1> 
  5464                              <1> 	;mov	dx, [NAMBAR]			; mixer base address
  5465                              <1>         ;add	dx, CODEC_RESET_REG  		; reset register
  5466                              <1>         ;mov	ax, 42
  5467                              <1> 	;out	dx, ax                          ; reset
  5468                              <1> 
  5469                              <1> 	;mov    dx, [NABMBAR]			; bus master base address
  5470                              <1>         ;add	dx, GLOB_STS_REG
  5471                              <1>         ;mov	ax, 2
  5472                              <1> 	;out	dx, ax                         
  5473                              <1> 
  5474 0001568F E847F9FFFF          <1>         call    delay_100ms ; 29/05/2017
  5475                              <1> 
  5476                              <1> init_ac97_codec:
  5477                              <1> 	; 10/06/2017
  5478                              <1> 	; 29/05/2017
  5479                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  5480                              <1> 	;	
  5481 00015694 66BA2C00            <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
  5482 00015698 660315[EA9C0100]    <1> 	add	dx, [NABMBAR]
  5483 0001569F ED                  <1> 	in	eax, dx
  5484                              <1> 	; ?
  5485 000156A0 66BA3000            <1> 	mov	dx, GLOB_STS_REG ; 30h
  5486 000156A4 660315[EA9C0100]    <1> 	add	dx, [NABMBAR]
  5487 000156AB ED                  <1> 	in	eax, dx
  5488                              <1> 
  5489 000156AC 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh ; -1
  5490 000156AF 744B                <1> 	je	short init_ac97_codec_err1
  5491                              <1> 
  5492 000156B1 A900030010          <1> 	test	eax, CTRL_ST_CREADY
  5493 000156B6 7507                <1> 	jnz	short _ac97_codec_ready
  5494                              <1> 
  5495 000156B8 E8EF020000          <1> 	call	reset_ac97_codec
  5496 000156BD 723E                <1> 	jc	short init_ac97_codec_err2
  5497                              <1> 
  5498                              <1> _ac97_codec_ready:
  5499 000156BF 668B15[E89C0100]    <1> 	mov	dx, [NAMBAR]
  5500                              <1> 	;add	dx, 0 ; ac_reg_0 ; reset register
  5501 000156C6 66EF                <1> 	out	dx, ax
  5502                              <1> 
  5503 000156C8 31C0                <1> 	xor	eax, eax ; 0
  5504 000156CA 668B15[E89C0100]    <1> 	mov	dx, [NAMBAR]
  5505 000156D1 6683C226            <1> 	add	dx, CODEC_REG_POWERDOWN	
  5506 000156D5 66EF                <1> 	out	dx, ax
  5507                              <1> 
  5508                              <1> 	; 10/06/2017
  5509                              <1> 	; 29/05/2017
  5510                              <1> 	; wait for 1 second
  5511 000156D7 B9E8030000          <1> 	mov	ecx, 1000 ; 1000*0.25ms = 1s
  5512                              <1> _ac97_codec_rloop:
  5513 000156DC E807F9FFFF          <1> 	call	delay1_4ms
  5514 000156E1 E802F9FFFF          <1> 	call	delay1_4ms
  5515 000156E6 E8FDF8FFFF          <1> 	call	delay1_4ms
  5516 000156EB E8F8F8FFFF          <1> 	call	delay1_4ms
  5517                              <1> 	;mov	dx, [NAMBAR]
  5518                              <1> 	;add	dx, CODEC_REG_POWERDOWN
  5519 000156F0 66ED                <1> 	in	ax, dx	
  5520 000156F2 6683E00F            <1> 	and	ax, 0Fh
  5521 000156F6 3C0F                <1> 	cmp	al, 0Fh
  5522 000156F8 7404                <1> 	je	short _ac97_codec_init_ok
  5523 000156FA E2E0                <1> 	loop	_ac97_codec_rloop 
  5524                              <1> 
  5525                              <1> init_ac97_codec_err1:
  5526 000156FC F9                  <1> 	stc
  5527                              <1> init_ac97_codec_err2:
  5528 000156FD C3                  <1> 	retn
  5529                              <1> 
  5530                              <1> _ac97_codec_init_ok:
  5531 000156FE B002                <1>         mov     al, 2 ; force set 16-bit 2-channel PCM
  5532 00015700 66BA2C00            <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
  5533 00015704 660315[EA9C0100]    <1> 	add	dx, [NABMBAR]
  5534 0001570B EF                  <1> 	out	dx, eax
  5535                              <1> 
  5536                              <1> 	;call	delay1_4ms
  5537                              <1> 
  5538                              <1> 	; 10/06/2017
  5539 0001570C E849020000          <1> 	call 	reset_ac97_controller
  5540                              <1> 
  5541                              <1> ;	call 	setup_ac97_codec
  5542                              <1> ;
  5543                              <1> ;detect_ac97_codec:
  5544                              <1> ;	retn
  5545                              <1> 
  5546                              <1> setup_ac97_codec:
  5547                              <1> 	; 22/07/2020
  5548                              <1> 	; 10/06/2017
  5549                              <1> 	; 29/05/2017
  5550 00015711 B802020000          <1> 	mov     eax, 0202h
  5551 00015716 66A3[E69C0100]      <1> 	mov	[audio_master_volume], ax
  5552 0001571C 66B81F1F            <1> 	mov	ax, 1F1Fh ; 31, 31
  5553                              <1> 	
  5554 00015720 668B15[E89C0100]    <1>   	mov     dx, [NAMBAR]
  5555 00015727 6683C202            <1>   	add     dx, CODEC_MASTER_VOL_REG	;02h 
  5556 0001572B 6631C0              <1>   	xor	ax, ax 	; volume attenuation = 0 (max. volume)
  5557 0001572E 66EF                <1>   	out     dx, ax
  5558                              <1>  
  5559 00015730 668B15[E89C0100]    <1>   	mov     dx, [NAMBAR]
  5560 00015737 6683C206            <1>   	add     dx, CODEC_MASTER_MONO_VOL_REG	;06h 
  5561                              <1> 	;xor	ax, ax
  5562 0001573B 66EF                <1>   	out     dx, ax
  5563                              <1> 
  5564 0001573D 668B15[E89C0100]    <1>   	mov     dx, [NAMBAR]
  5565 00015744 6683C20A            <1>   	add     dx, CODEC_PCBEEP_VOL_REG	;0Ah 
  5566                              <1>   	;xor    ax, ax
  5567 00015748 66EF                <1>   	out     dx, ax
  5568                              <1> 
  5569 0001574A 668B15[E89C0100]    <1>   	mov     dx, [NAMBAR]
  5570 00015751 6683C218            <1>   	add     dx, CODEC_PCM_OUT_REG		;18h 
  5571                              <1>   	;xor    ax, ax
  5572 00015755 66EF                <1>   	out     dx, ax
  5573                              <1> 
  5574 00015757 66B80880            <1> 	mov     ax, 8008h ; Mute
  5575 0001575B 668B15[E89C0100]    <1>   	mov     dx, [NAMBAR]
  5576                              <1> 	; 22/07/2020
  5577 00015762 6683C20C            <1> 	add	dx, CODEC_PHONE_VOL_REG		;0Ch
  5578                              <1> 				 ; AC97_PHONE_VOL ; TAD Input (Mono)
  5579 00015766 66EF                <1>   	out     dx, ax
  5580                              <1> 
  5581 00015768 66B80808            <1>         mov	ax, 0808h
  5582 0001576C 668B15[E89C0100]    <1>   	mov     dx, [NAMBAR]
  5583 00015773 6683C210            <1>         add	dx, CODEC_LINE_IN_VOL_REG ;10h ; Line Input (Stereo)	
  5584 00015777 66EF                <1>   	out     dx, ax
  5585                              <1> 
  5586                              <1> 	;mov	ax, 0808h
  5587 00015779 668B15[E89C0100]    <1>   	mov     dx, [NAMBAR]
  5588 00015780 6683C212            <1>         add	dx, CODEC_CD_VOL_REG ;12h ; CR Input (Stereo)
  5589 00015784 66EF                <1>   	out     dx, ax
  5590                              <1> 
  5591                              <1> 	;mov	ax, 0808h
  5592 00015786 668B15[E89C0100]    <1>   	mov     dx, [NAMBAR]
  5593 0001578D 6683C216            <1>         add	dx, CODEC_AUX_VOL_REG ;16h ; Aux Input (Stereo)
  5594 00015791 66EF                <1>   	out     dx, ax
  5595                              <1> 
  5596                              <1>         ;call    delay1_4ms
  5597                              <1>         ;call    delay1_4ms
  5598                              <1>         ;call    delay1_4ms
  5599                              <1>         ;call    delay1_4ms
  5600                              <1> 
  5601                              <1> detect_ac97_codec:
  5602 00015793 C3                  <1>         retn
  5603                              <1> 
  5604                              <1> set_ac97_bdl: ; Set AC97 (ICH) Buffer Descriptor List
  5605                              <1> 	; 17/06/2017
  5606                              <1> 	; 11/06/2017
  5607                              <1> 	; 28/05/2017
  5608                              <1> 	; eax = dma buffer address = [audio_DMA_buff]
  5609                              <1> 	; ecx = dma buffer buffer size = [audio_dmabuff_size]
  5610                              <1> 
  5611 00015794 D1E9                <1> 	shr	ecx, 1 ; dma half buffer size
  5612 00015796 89CE                <1> 	mov	esi, ecx
  5613                              <1> 
  5614 00015798 BF[EC9C0100]        <1>         mov     edi, audio_bdl_buff	; get BDL address
  5615 0001579D B910000000          <1>         mov     ecx, 32 / 2		; make 32 entries in BDL
  5616                              <1> 
  5617 000157A2 EB05                <1> 	jmp	short s_ac97_bdl1 
  5618                              <1> 
  5619                              <1> s_ac97_bdl0:
  5620                              <1> 	; set buffer descriptor 0 to start of data file in memory
  5621                              <1> 
  5622 000157A4 A1[D09C0100]        <1>  	mov	eax, [audio_dma_buff]	; Physical address of DMA buffer
  5623                              <1>  
  5624                              <1> s_ac97_bdl1:
  5625 000157A9 AB                  <1> 	stosd				; store dmabuffer1 address
  5626                              <1> 
  5627 000157AA 89C2                <1> 	mov	edx, eax
  5628                              <1> 
  5629                              <1> ;
  5630                              <1> ; Buffer Descriptors List
  5631                              <1> ; As stated earlier, each buffer descriptor list is a set of (up to) 32 
  5632                              <1> ; descriptors, each 8 bytes in length. Bytes 0-3 of a descriptor entry point
  5633                              <1> ; to a chunk of memory to either play from or record to. Bytes 4-7 of an
  5634                              <1> ; entry describe various control things detailed below.
  5635                              <1> ; 
  5636                              <1> ; Buffer pointers must always be aligned on a Dword boundry.
  5637                              <1> ;
  5638                              <1> ;
  5639                              <1> 
  5640                              <1> ;IOC                     equ     BIT31	; Fire an interrupt whenever this
  5641                              <1>                                         ; buffer is complete.
  5642                              <1> 
  5643                              <1> ;BUP                     equ     BIT30  ; Buffer Underrun Policy.
  5644                              <1>                                         ; if this buffer is the last buffer
  5645                              <1>                                         ; in a playback, fill the remaining
  5646                              <1>                                         ; samples with 0 (silence) or not.
  5647                              <1>                                         ; It's a good idea to set this to 1
  5648                              <1>                                         ; for the last buffer in playback,
  5649                              <1>                                         ; otherwise you're likely to get a lot
  5650                              <1>                                         ; of noise at the end of the sound.
  5651                              <1> 
  5652                              <1> ;
  5653                              <1> ; Bits 15:0 contain the length of the buffer, in number of samples, which
  5654                              <1> ; are 16 bits each, coupled in left and right pairs, or 32bits each.
  5655                              <1> ; Luckily for us, that's the same format as .wav files.
  5656                              <1> ;
  5657                              <1> ; A value of FFFF is 65536 samples. Running at 44.1Khz, that's just about
  5658                              <1> ; 1.5 seconds of sample time. FFFF * 32bits is 1FFFFh bytes or 128k of data.
  5659                              <1> ;
  5660                              <1> ; A value of 0 in these bits means play no samples.
  5661                              <1> ;
  5662                              <1> 
  5663 000157AC 89F0                <1> 	mov	eax, esi ; DMA half buffer size
  5664 000157AE 01C2                <1> 	add	edx, eax
  5665 000157B0 D1E8                <1> 	shr	eax, 1 ; count of 16 bit samples
  5666                              <1> 	;or	eax, IOC+BUP
  5667 000157B2 0D00000080          <1> 	or	eax, IOC ; 11/06/2017
  5668 000157B7 AB                  <1> 	stosd
  5669                              <1> 
  5670                              <1> ; 2nd buffer:
  5671                              <1> 
  5672 000157B8 89D0                <1>         mov	eax, edx ; Physical address of the 2nd half of DMA buffer	
  5673 000157BA AB                  <1> 	stosd		 ; store dmabuffer2 address
  5674                              <1> 
  5675                              <1> ; set length to [audio_dmabuff_size]/2
  5676                              <1> ; Set control (bits 31:16) to BUP, bits 15:0=number of samples
  5677                              <1> ; 
  5678 000157BB 89F0                <1> 	mov	eax, esi ; DMA half buffer size
  5679 000157BD D1E8                <1> 	shr	eax, 1 ; count of 16 bit samples
  5680                              <1> 	;or	eax, IOC+BUP
  5681 000157BF 0D00000080          <1> 	or	eax, IOC ; 11/06/2017
  5682 000157C4 AB                  <1> 	stosd
  5683                              <1> 
  5684 000157C5 E2DD                <1> 	loop    s_ac97_bdl0
  5685                              <1> 	
  5686 000157C7 C3                  <1> 	retn
  5687                              <1> 
  5688                              <1> ac97_start_play:  
  5689                              <1> 	; 28/05/2017
  5690                              <1> 	; Derived from 'playWav' procedure in 'ICHWAV.ASM'
  5691                              <1> 	; .wav player for DOS by Jeff Leyda (02/09/2002)
  5692                              <1> 
  5693                              <1> 	; set output rate
  5694                              <1> 	; entry: [audio_freq] = desired sample rate
  5695                              <1> 		
  5696 000157C8 668B15[E89C0100]    <1> 	mov    	dx, [NAMBAR]               	
  5697 000157CF 6683C22A            <1> 	add    	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah  	  
  5698 000157D3 66ED                <1> 	in     	ax, dx
  5699 000157D5 6683C801            <1> 	or	ax, 1
  5700 000157D9 66EF                <1> 	out	dx, ax 				; Enable variable rate audio
  5701                              <1> 
  5702                              <1>        ;call    delay1_4ms
  5703                              <1>        ;call    delay1_4ms
  5704                              <1>        ;call    delay1_4ms
  5705                              <1>        ;call    delay1_4ms
  5706                              <1> 
  5707 000157DB 66A1[E29C0100]      <1> 	mov	ax, [audio_freq]		; sample rate
  5708                              <1> 
  5709 000157E1 668B15[E89C0100]    <1> 	mov    	dx, [NAMBAR]               	
  5710 000157E8 6683C22C            <1> 	add    	dx, CODEC_PCM_FRONT_DACRATE_REG	; 2Ch  	  
  5711 000157EC 66EF                <1> 	out	dx, ax 				; out sample rate
  5712                              <1> 		
  5713                              <1>        ;call    delay1_4ms
  5714                              <1>        ;call    delay1_4ms
  5715                              <1>        ;call    delay1_4ms
  5716                              <1>        ;call    delay1_4ms
  5717                              <1> 
  5718                              <1> ;
  5719                              <1> ; register reset the DMA engine. This may cause a pop noise on the output
  5720                              <1> ; lines when the device is reset. Prolly a better idea to mute output, then
  5721                              <1> ; reset.
  5722                              <1> ;
  5723 000157EE 668B15[EA9C0100]    <1>         mov     dx, [NABMBAR]
  5724 000157F5 6683C21B            <1>         add     dx, PO_CR_REG                  ; set pointer to Cntl reg
  5725 000157F9 B002                <1>         mov     al, RR                         ; set reset
  5726 000157FB EE                  <1>         out     dx, al                         ; self clearing bit
  5727                              <1> ;
  5728                              <1> ;	mov	edi, audio_bdl_buff
  5729                              <1> ;	mov	edx, [audio_dmabuff_size]
  5730                              <1> ;	shr	edx, 1
  5731                              <1> ;	mov	ecx, 32/2
  5732                              <1> ;ac97_set_bdl_buffer:
  5733                              <1> ;	; 1st half of DMA buffer
  5734                              <1> ;	mov	eax, [audio_dma_buff]
  5735                              <1> ;	push	eax
  5736                              <1> ;	stosd
  5737                              <1> ;	mov	eax, edx ; dma buffer size / 2
  5738                              <1> ;	or	eax, IOC+BUP
  5739                              <1> ;	stosd
  5740                              <1> ;	pop	eax
  5741                              <1> ;	; 2nd half of DMA buffer
  5742                              <1> ;	add	eax, edx
  5743                              <1> ;	stosd
  5744                              <1> ;	mov	eax, edx ; dma buffer size / 2
  5745                              <1> ;	or	eax, IOC+BUP
  5746                              <1> ;	stosd
  5747                              <1> ;	loop	ac97_set_bdl_buffer
  5748                              <1>  	
  5749                              <1> ; tell the DMA engine where to find our list of Buffer Descriptors.
  5750                              <1> ; this 32bit value is a flat mode memory offset (ie no segment:offset)
  5751                              <1> ;
  5752                              <1> ; write NABMBAR+10h with offset of buffer descriptor list
  5753                              <1> ;
  5754 000157FC B8[EC9C0100]        <1>         mov	eax, audio_bdl_buff
  5755 00015801 668B15[EA9C0100]    <1> 	mov	dx, [NABMBAR]
  5756 00015808 6683C210            <1> 	add	dx, PO_BDBAR_REG
  5757 0001580C EF                  <1> 	out	dx, eax
  5758                              <1> ;
  5759                              <1> ; All set. Let's play some music.
  5760                              <1> ;
  5761                              <1> ;
  5762 0001580D B81F000000          <1> 	mov	eax, 31
  5763 00015812 E816000000          <1> 	call    set_ac97_LastValidIndex
  5764                              <1> 
  5765 00015817 C605[E49C0100]01    <1> 	mov	byte [audio_play_cmd], 1 ; play command (do not stop) !
  5766                              <1> 
  5767                              <1> ac97_play: ; continue to play (after pause)
  5768                              <1> 	; 11/06/2017
  5769                              <1> 	; 29/05/2017
  5770                              <1> 	; 28/05/2017
  5771 0001581E 668B15[EA9C0100]    <1>         mov     dx, [NABMBAR]
  5772 00015825 6683C21B            <1>         add     dx, PO_CR_REG		; PCM out control register
  5773 00015829 B011                <1>         mov	al, IOCE+RPBM ; 29/05/2017
  5774                              <1>         ;mov	al, 1Dh ; (Ref: KolibriOS, intelac97.asm, 'play:')
  5775 0001582B EE                  <1> 	out     dx, al			; set start!
  5776                              <1> 
  5777                              <1> 	;mov	byte [audio_play_cmd], 1 ; play command (do not stop) !
  5778                              <1> 
  5779 0001582C C3                  <1> 	retn
  5780                              <1> 
  5781                              <1> ;input AL = index # to stop on
  5782                              <1> set_ac97_LastValidIndex:
  5783                              <1> 	; 28/05/2017
  5784                              <1> 	; Derived from 'setLastValidIndex' procedure in 'ICHWAV.ASM'
  5785                              <1> 	; .wav player for DOS by Jeff Leyda (02/09/2002)
  5786 0001582D 668B15[EA9C0100]    <1> 	mov	dx, [NABMBAR]
  5787 00015834 6683C215            <1> 	add	dx, PO_LVI_REG
  5788 00015838 EE                  <1>         out     dx, al
  5789                              <1> 	;mov	[audio_lvi], al ; for ac97_int_handler
  5790 00015839 C3                  <1> 	retn
  5791                              <1> 
  5792                              <1> ac97_volume:
  5793                              <1> 	; 28/05/2017
  5794                              <1> 	; bl = component (0 = master/playback/lineout volume)
  5795                              <1> 	; cl = left channel volume level (0 to 31)
  5796                              <1> 	; ch = right channel volume level (0 to 31)
  5797                              <1> 
  5798 0001583A 08DB                <1> 	or	bl, bl
  5799 0001583C 7523                <1> 	jnz	short ac97_vol_1 ; temporary !
  5800 0001583E 66B81F1F            <1> 	mov	ax, 1F1Fh ; 31,31
  5801 00015842 38C1                <1> 	cmp	cl, al
  5802 00015844 771B                <1> 	ja	short ac97_vol_1 ; temporary !
  5803 00015846 38E5                <1> 	cmp	ch, ah
  5804 00015848 7717                <1> 	ja	short ac97_vol_1 ; temporary !
  5805 0001584A 66890D[E69C0100]    <1> 	mov	[audio_master_volume], cx
  5806 00015851 6629C8              <1> 	sub	ax, cx
  5807 00015854 668B15[E89C0100]    <1>   	mov     dx, [NAMBAR]
  5808 0001585B 6683C202            <1>   	add     dx, CODEC_MASTER_VOL_REG  ; 02h ; Line Out 
  5809 0001585F 66EF                <1>   	out     dx, ax
  5810                              <1> ac97_vol_1:
  5811 00015861 C3                  <1> 	retn
  5812                              <1> 
  5813                              <1> ac97_int_handler:
  5814                              <1> 	; 12/10/2017
  5815                              <1> 	; 10/10/2017
  5816                              <1> 	; 09/10/2017
  5817                              <1> 	; 13/06/2017, 13/06/2017
  5818                              <1> 	; 10/06/2017, 11/06/2017
  5819                              <1> 	; Interrupt Handler for AC97 (ICH) Audio Controller
  5820                              <1> 	; Note: called by 'dev_IRQ_service' 
  5821                              <1> 	; 28/05/2017
  5822                              <1> 
  5823                              <1> 	;push	eax ; * must be saved !
  5824                              <1> 	;push	edx
  5825                              <1> 	;push	ecx
  5826                              <1> 	;push	ebx ; * must be saved !
  5827                              <1> 	;push	esi
  5828                              <1> 	;push	edi
  5829                              <1> 
  5830                              <1> 	;cmp	byte [audio_busy], 1
  5831                              <1> 	;jnb	_ac97_ih2	; busy !
  5832                              <1> 
  5833 00015862 66BA3000            <1>         mov     dx, GLOB_STS_REG
  5834 00015866 660315[EA9C0100]    <1>         add	dx, [NABMBAR]
  5835 0001586D ED                  <1> 	in	eax, dx
  5836                              <1> 
  5837 0001586E 83F8FF              <1>         cmp     eax, 0FFFFFFFFh ; -1
  5838 00015871 0F849A000000        <1>         je      _ac97_ih3 ; exit
  5839                              <1> 
  5840 00015877 A940000000          <1>         test    eax, 40h ; PCM Out Interrupt
  5841 0001587C 750E                <1>         jnz     short _ac97_ih0
  5842                              <1> 
  5843 0001587E 85C0                <1> 	test	eax, eax
  5844 00015880 0F848B000000        <1> 	jz	_ac97_ih3 ; exit
  5845                              <1> 
  5846                              <1>  	;mov	dx, GLOB_STS_REG
  5847                              <1>         ;add	dx, [NABMBAR]
  5848 00015886 EF                  <1> 	out	dx, eax
  5849                              <1> 
  5850 00015887 E985000000          <1> 	jmp	_ac97_ih3 ; exit
  5851                              <1> 
  5852                              <1> _ac97_ih0:
  5853 0001588C 50                  <1> 	push	eax
  5854                              <1> 	; 09/10/2017
  5855 0001588D 803D[E49C0100]01    <1> 	cmp	byte [audio_play_cmd], 1
  5856 00015894 727C                <1> 	jb	short _ac97_ih4 ; stop command !
  5857                              <1> 
  5858                              <1> 	;mov	byte [audio_busy], 1
  5859                              <1> 
  5860                              <1> 	;mov	al, 10h
  5861                              <1> 	;mov	dx, PO_CR_REG
  5862                              <1>         ;add	dx, [NABMBAR]
  5863                              <1> 	;out	dx, al
  5864                              <1> 
  5865 00015896 66B81C00            <1> 	mov	ax, 1Ch ; FIFOE(=16)+BCIS(=8)+LVBCI(=4)
  5866 0001589A 66BA1600            <1> 	mov	dx, PO_SR_REG
  5867 0001589E 660315[EA9C0100]    <1>         add	dx, [NABMBAR]
  5868 000158A5 66EF                <1> 	out	dx, ax
  5869                              <1> 
  5870 000158A7 66BA1400            <1> 	mov	dx, PO_CIV_REG
  5871 000158AB 660315[EA9C0100]    <1>         add	dx, [NABMBAR]
  5872 000158B2 EC                  <1> 	in	al, dx
  5873                              <1> 
  5874                              <1> 	;cmp	al, [audio_civ] ; [audio_flag]
  5875                              <1> 	;je	short _ac97_ih2
  5876                              <1> 
  5877 000158B3 A2[E59C0100]        <1> 	mov	[audio_civ], al
  5878 000158B8 FEC8                <1> 	dec	al
  5879                              <1> 	;inc	al ; 11/06/2017
  5880 000158BA 241F                <1> 	and	al, 1Fh
  5881                              <1> 
  5882 000158BC 66BA1500            <1>         mov     dx, PO_LVI_REG
  5883 000158C0 660315[EA9C0100]    <1>         add	dx, [NABMBAR]
  5884 000158C7 EE                  <1>         out	dx, al
  5885                              <1> 
  5886                              <1> 	; 12/10/2017
  5887 000158C8 A0[E59C0100]        <1> 	mov	al, [audio_civ]
  5888 000158CD FEC0                <1> 	inc	al
  5889 000158CF 2401                <1> 	and	al, 1
  5890 000158D1 A2[D89C0100]        <1> 	mov	[audio_flag], al 
  5891                              <1> 	;; [audio_flag] : 0 = Buffer 1, 1 = Buffer 2
  5892                              <1> 	;
  5893 000158D6 58                  <1> 	pop	eax
  5894                              <1> 	;
  5895 000158D7 83E040              <1> 	and     eax, 40h
  5896 000158DA 668B15[EA9C0100]    <1>         mov	dx, [NABMBAR]
  5897 000158E1 6683C230            <1> 	add	dx, GLOB_STS_REG
  5898 000158E5 EF                  <1> 	out	dx, eax
  5899                              <1> 
  5900                              <1> 	;; 13/06/2017
  5901                              <1> 	;mov	al, 11h ; IOCE + RPBM
  5902                              <1> 	;mov	dx, PO_CR_REG
  5903                              <1>         ;add	dx, [NABMBAR]
  5904                              <1> 	;out	dx, al
  5905                              <1> 
  5906                              <1> ac97_tuneloop:
  5907                              <1> 	; 09/10/2017
  5908 000158E6 8B3D[D09C0100]      <1> 	mov	edi, [audio_dma_buff]
  5909 000158EC 8B0D[D49C0100]      <1> 	mov	ecx, [audio_dmabuff_size]
  5910 000158F2 D1E9                <1> 	shr	ecx, 1 ; dma buff size / 2 = half buffer size
  5911                              <1> 
  5912                              <1> 	; 12/10/2017
  5913 000158F4 803D[D89C0100]00    <1> 	cmp 	byte [audio_flag], 0
  5914 000158FB 7702                <1> 	ja	short _ac97_ih1  ; Playing Half Buffer 2 (Current: FLAG)
  5915                              <1> 	; Playing Half Buffer 1 (Current: EOL)	
  5916 000158FD 01CF                <1> 	add	edi, ecx
  5917                              <1> _ac97_ih1: 
  5918                              <1> 	; Update half buffer 2 while playing half buffer 1 (next: FLAG)
  5919                              <1> 	; Update half buffer 1 while playing half buffer 2 (next: EOL)
  5920                              <1> 
  5921 000158FF 8B35[C89C0100]      <1> 	mov	esi, [audio_p_buffer] ; phy addr of audio buff
  5922 00015905 C1E902              <1> 	shr	ecx, 2 ; half buff size / 4
  5923 00015908 F3A5                <1> 	rep	movsd 
  5924                              <1> 
  5925                              <1> 	; 10/10/2017
  5926                              <1> 	; switch flag value
  5927 0001590A 8035[D89C0100]01    <1> 	xor	byte [audio_flag], 1
  5928                              <1> 	; 12/10/2017
  5929                              <1> 	; [audio_flag] = 0 : Playing dma half buffer 2 (even index value)
  5930                              <1> 			   ; Next buffer (to update) is dma half buff 1
  5931                              <1> 	; 	       = 1 : Playing dma half buffer 1 (odd index value)
  5932                              <1> 			   ; Next buffer (to update) is dma half buff 2
  5933                              <1> 
  5934                              <1> _ac97_ih2:
  5935                              <1> 	;mov	byte [audio_busy], 0
  5936                              <1> _ac97_ih3:
  5937                              <1> 	;pop	edi
  5938                              <1> 	;pop	esi
  5939                              <1> 	;pop	ebx ; * must be restored !
  5940                              <1> 	;pop	ecx
  5941                              <1> 	;pop	edx
  5942                              <1> 	;pop	eax ; * must be restored !
  5943                              <1> 
  5944 00015911 C3                  <1> 	retn
  5945                              <1> 
  5946                              <1> _ac97_ih4:
  5947                              <1> 	; 09/10/2017
  5948 00015912 E818000000          <1> 	call	_ac97_stop
  5949                              <1> 	;
  5950 00015917 58                  <1> 	pop	eax
  5951                              <1> 	;
  5952 00015918 83E040              <1> 	and     eax, 40h
  5953 0001591B 668B15[EA9C0100]    <1>         mov	dx, [NABMBAR]
  5954 00015922 6683C230            <1> 	add	dx, GLOB_STS_REG
  5955 00015926 EF                  <1> 	out	dx, eax
  5956                              <1> 
  5957                              <1> 	;; 13/06/2017
  5958                              <1> 	;mov	al, 11h ; IOCE + RPBM
  5959                              <1> 	;dx, PO_CR_REG
  5960                              <1>         ;add	dx, [NABMBAR]
  5961                              <1> 	;out	dx, al
  5962                              <1> 
  5963                              <1> 	; 10/10/2017
  5964                              <1> 	;jmp	short _ac97_ih3  ; exit
  5965 00015927 C3                  <1> 	retn
  5966                              <1> 
  5967                              <1> ac97_stop: 
  5968                              <1> 	; 28/05/2017
  5969 00015928 C605[E49C0100]00    <1> 	mov	byte [audio_play_cmd], 0 ; stop !
  5970                              <1> _ac97_stop: ; 09/10/2017
  5971                              <1> 	; 29/05/2017
  5972                              <1> 	;mov	dx, [NABMBAR]
  5973                              <1> 	;add	dx, PO_CR_REG
  5974                              <1> 	;mov	al, 0
  5975                              <1> 	;out	dx, al
  5976                              <1> 
  5977                              <1> 	; 11/06/2017
  5978 0001592F 30C0                <1> 	xor	al, al ; 0
  5979 00015931 E813000000          <1> 	call	ac97_po_cmd
  5980                              <1> 
  5981                              <1> 	; (Ref: KolibriOS, intelac97.asm, 'stop:')
  5982                              <1> 	; Clear FIFOE, BCIS, LVBCI (Ref: Intel ICH hub manual)
  5983 00015936 66B81C00            <1> 	mov     ax, 1Ch
  5984 0001593A 668B15[EA9C0100]    <1> 	mov     dx, [NABMBAR]
  5985 00015941 6683C216            <1> 	add     dx, PO_SR_REG
  5986 00015945 66EF                <1> 	out     dx, ax
  5987                              <1> 
  5988                              <1> 	;retn
  5989                              <1> 
  5990                              <1> 	; 11/06/2017
  5991 00015947 B002                <1> 	mov     al, RR
  5992                              <1> ac97_po_cmd:
  5993                              <1> 	 ;11/06/2017
  5994                              <1> 	; 29/05/2017
  5995 00015949 668B15[EA9C0100]    <1> 	mov     dx, [NABMBAR]
  5996 00015950 6683C21B            <1>         add     dx, PO_CR_REG		; PCM out control register
  5997 00015954 EE                  <1> 	out	dx, al
  5998 00015955 C3                  <1> 	retn
  5999                              <1> 
  6000                              <1> ac97_pause:
  6001                              <1> 	; 11/06/2017
  6002                              <1> 	; 29/05/2017
  6003 00015956 B010                <1> 	mov 	al, IOCE
  6004 00015958 EBEF                <1> 	jmp	short ac97_po_cmd
  6005                              <1> 
  6006                              <1> reset_ac97_controller:
  6007                              <1> 	; 10/06/2017
  6008                              <1> 	; 29/05/2017
  6009                              <1> 	; 28/05/2017
  6010                              <1> 	; reset AC97 audio controller registers
  6011 0001595A 31C0                <1> 	xor     eax, eax
  6012 0001595C 66BA0B00            <1>         mov	dx, PI_CR_REG
  6013 00015960 660315[EA9C0100]    <1> 	add	dx, [NABMBAR]
  6014 00015967 EE                  <1> 	out     dx, al
  6015                              <1> 
  6016 00015968 66BA1B00            <1>         mov     dx, PO_CR_REG
  6017 0001596C 660315[EA9C0100]    <1> 	add	dx, [NABMBAR]
  6018 00015973 EE                  <1> 	out     dx, al
  6019                              <1> 
  6020 00015974 66BA2B00            <1>         mov     dx, MC_CR_REG
  6021 00015978 660315[EA9C0100]    <1> 	add	dx, [NABMBAR]
  6022 0001597F EE                  <1> 	out     dx, al
  6023                              <1> 
  6024 00015980 B002                <1>         mov     al, RR
  6025 00015982 66BA0B00            <1>         mov     dx, PI_CR_REG
  6026 00015986 660315[EA9C0100]    <1> 	add	dx, [NABMBAR]
  6027 0001598D EE                  <1> 	out     dx, al
  6028                              <1> 
  6029 0001598E 66BA1B00            <1>         mov     dx, PO_CR_REG
  6030 00015992 660315[EA9C0100]    <1> 	add	dx, [NABMBAR]
  6031 00015999 EE                  <1> 	out     dx, al
  6032                              <1> 
  6033 0001599A 66BA2B00            <1>         mov     dx, MC_CR_REG
  6034 0001599E 660315[EA9C0100]    <1> 	add	dx, [NABMBAR]
  6035 000159A5 EE                  <1> 	out     dx, al
  6036                              <1> 
  6037 000159A6 C3                  <1> 	retn
  6038                              <1> 
  6039                              <1> ac97_reset:
  6040                              <1> 	; 10/06/2017
  6041                              <1> 	; 29/05/2017
  6042                              <1> 	; 28/05/2017
  6043 000159A7 E8AEFFFFFF          <1> 	call	reset_ac97_controller
  6044                              <1> 	; 29/05/2017
  6045                              <1> 	;jmp	reset_ac97_codec
  6046                              <1> reset_ac97_codec:
  6047                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  6048 000159AC 66BA2C00            <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
  6049 000159B0 660315[EA9C0100]    <1> 	add	dx, [NABMBAR]
  6050 000159B7 ED                  <1> 	in	eax, dx
  6051                              <1> 
  6052 000159B8 A902000000          <1> 	test	eax, 2
  6053 000159BD 7407                <1> 	jz	short _r_ac97codec_cold	
  6054                              <1> 
  6055 000159BF E80F000000          <1> 	call	warm_ac97codec_reset
  6056 000159C4 7308                <1> 	jnc	short _r_ac97codec_ok
  6057                              <1> _r_ac97codec_cold:
  6058 000159C6 E83D000000          <1>         call    cold_ac97codec_reset
  6059 000159CB 7301                <1>         jnc     short _r_ac97codec_ok
  6060                              <1> 	
  6061                              <1> 	; 16/04/2017
  6062                              <1>         ;xor     eax, eax         ; timeout error
  6063                              <1>        	;stc
  6064 000159CD C3                  <1> 	retn
  6065                              <1> 
  6066                              <1> _r_ac97codec_ok:
  6067 000159CE 31C0                <1>         xor     eax, eax
  6068                              <1>         ;mov	al, VIA_ACLINK_C00_READY ; 1
  6069 000159D0 FEC0                <1>         inc	al
  6070 000159D2 C3                  <1> 	retn
  6071                              <1> 
  6072                              <1> warm_ac97codec_reset:
  6073                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  6074 000159D3 B806000000          <1>         mov     eax, 6
  6075 000159D8 66BA2C00            <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
  6076 000159DC 660315[EA9C0100]    <1> 	add	dx, [NABMBAR]
  6077 000159E3 EF                  <1> 	out	dx, eax
  6078                              <1> 
  6079 000159E4 B90A000000          <1> 	mov	ecx, 10	; total 1s
  6080                              <1> _warm_ac97c_rst_wait:
  6081 000159E9 51                  <1> 	push	ecx
  6082 000159EA E8ECF5FFFF          <1> 	call	delay_100ms
  6083 000159EF 59                  <1> 	pop	ecx
  6084                              <1> 
  6085 000159F0 66BA3000            <1> 	mov	dx, GLOB_STS_REG ; 30h
  6086 000159F4 660315[EA9C0100]    <1> 	add	dx, [NABMBAR]
  6087 000159FB ED                  <1> 	in	eax, dx
  6088                              <1> 
  6089 000159FC A900030010          <1> 	test	eax, CTRL_ST_CREADY
  6090 00015A01 7504                <1> 	jnz	short _warm_ac97c_rst_ok
  6091                              <1> 
  6092 00015A03 49                  <1>         dec     ecx
  6093 00015A04 75E3                <1>         jnz     short _warm_ac97c_rst_wait
  6094                              <1> 
  6095                              <1> _warm_ac97c_rst_fail:
  6096 00015A06 F9                  <1>         stc
  6097                              <1> _warm_ac97c_rst_ok:
  6098 00015A07 C3                  <1> 	retn
  6099                              <1> 
  6100                              <1> cold_ac97codec_reset:
  6101                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  6102 00015A08 B802000000          <1>         mov     eax, 2
  6103 00015A0D 66BA2C00            <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
  6104 00015A11 660315[EA9C0100]    <1> 	add	dx, [NABMBAR]
  6105 00015A18 EF                  <1> 	out	dx, eax
  6106                              <1> 
  6107 00015A19 E8BDF5FFFF          <1> 	call	delay_100ms 	; wait 100 ms
  6108 00015A1E E8B8F5FFFF          <1> 	call	delay_100ms 	; wait 100 ms
  6109 00015A23 E8B3F5FFFF          <1> 	call	delay_100ms 	; wait 100 ms
  6110 00015A28 E8AEF5FFFF          <1> 	call	delay_100ms 	; wait 100 ms
  6111                              <1> 
  6112 00015A2D B910000000          <1> 	mov	ecx, 16	; total 20*100 ms = 2s
  6113                              <1> _cold_ac97c_rst_wait:
  6114 00015A32 66BA3000            <1> 	mov	dx, GLOB_STS_REG ; 30h
  6115 00015A36 660315[EA9C0100]    <1> 	add	dx, [NABMBAR]
  6116 00015A3D ED                  <1> 	in	eax, dx
  6117                              <1> 
  6118 00015A3E A900030010          <1> 	test	eax, CTRL_ST_CREADY
  6119 00015A43 750B                <1> 	jnz	short _cold_ac97c_rst_ok
  6120                              <1> 
  6121 00015A45 51                  <1> 	push	ecx
  6122 00015A46 E890F5FFFF          <1> 	call	delay_100ms
  6123 00015A4B 59                  <1> 	pop	ecx
  6124                              <1> 
  6125 00015A4C 49                  <1>         dec     ecx
  6126 00015A4D 75E3                <1>         jnz     short _cold_ac97c_rst_wait
  6127                              <1> 
  6128                              <1> _cold_ac97c_rst_fail:
  6129 00015A4F F9                  <1>         stc
  6130                              <1> _cold_ac97c_rst_ok:
  6131 00015A50 C3                  <1> 	retn
  6132                              <1> 
  6133                              <1> sb16_current_sound_data:
  6134                              <1> 	; 20/08/2017
  6135                              <1> 	; 24/06/2017
  6136                              <1> 	; 22/06/2017
  6137                              <1> 	; get current sound (PCM out) data for graphics
  6138                              <1> 	; (for Sound Blaster 16)
  6139                              <1> 	; ebx = Physical address (on page boundary)
  6140                              <1> 	; ecx = Byte count
  6141                              <1> 	; [audio_buff_size]
  6142                              <1> 
  6143                              <1> 	;;mov	edi, [audio_buff_size]
  6144                              <1> 	;mov	edi, [audio_dmabuff_size]
  6145                              <1> 	;mov	esi, [audio_dma_buff]
  6146 00015A51 39CF                <1> 	cmp	edi, ecx
  6147 00015A53 7302                <1> 	jnb	short sb16_gcd_0
  6148 00015A55 89F9                <1> 	mov	ecx, edi
  6149                              <1> sb16_gcd_0:
  6150                              <1> 	; 20/08/2017
  6151 00015A57 803D[E09C0100]10    <1> 	cmp	byte [audio_bps], 16
  6152 00015A5E 750F                <1> 	jne	short sb16_gcd_1 ; 8 bit DMA channel
  6153 00015A60 E4C6                <1> 	in	al, 0C6h ; DMA channel 5 count register
  6154 00015A62 88C2                <1> 	mov	dl, al	
  6155 00015A64 E4C6                <1> 	in	al, 0C6h
  6156 00015A66 88C6                <1> 	mov     dh, al
  6157 00015A68 0FB7C2              <1> 	movzx	eax, dx
  6158 00015A6B D1E0                <1> 	shl	eax, 1 ; word count -> byte count
  6159 00015A6D EB4E                <1> 	jmp	short sb16_gcd_2	
  6160                              <1> sb16_gcd_1:
  6161 00015A6F E403                <1> 	in	al, 03h ; DMA channel 1 count register
  6162 00015A71 88C2                <1> 	mov	dl, al	
  6163 00015A73 E403                <1> 	in	al, 03h
  6164 00015A75 88C6                <1> 	mov     dh, al
  6165 00015A77 0FB7C2              <1> 	movzx	eax, dx
  6166 00015A7A EB41                <1> 	jmp	short sb16_gcd_2
  6167                              <1> ;sb16_gcd_2:	
  6168                              <1> ;	cmp	eax, ecx
  6169                              <1> ;	jnb	short sb16_gcd_3 
  6170                              <1> ;	; remain count < graphics bytes
  6171                              <1> ;	mov	eax, ecx ; fix remain count to data size
  6172                              <1> ;sb16_gcd_3:	
  6173                              <1> ;	sub	edi, eax
  6174                              <1> ;	jna	short sb16_gcd_4
  6175                              <1> ;	add	esi, edi ; dma buffer offset
  6176                              <1> ;sb16_gcd_4:
  6177                              <1> ;	mov	edi, ebx ; buffer address (for graphics) 
  6178                              <1> ;	mov	[u.r0], ecx
  6179                              <1> ;	rep	movsb
  6180                              <1> ;	retn
  6181                              <1> 
  6182                              <1> get_current_sound_data:
  6183                              <1> 	; 24/06/2017
  6184                              <1> 	; 22/06/2017
  6185                              <1> 	; get current sound (PCM out) data for graphics
  6186                              <1> 	;
  6187                              <1> 	; ebx = Physical address (on page boundary)
  6188                              <1> 	; ecx = Byte count
  6189                              <1> 	; [audio_buff_size]
  6190                              <1> 
  6191                              <1> 	;mov	edi, [audio_buff_size]
  6192 00015A7C 8B3D[D49C0100]      <1> 	mov	edi, [audio_dmabuff_size]
  6193 00015A82 8B35[D09C0100]      <1> 	mov	esi, [audio_dma_buff]
  6194 00015A88 803D[B19C0100]02    <1> 	cmp	byte [audio_device], 2
  6195 00015A8F 72C0                <1> 	jb	short sb16_current_sound_data ; = 1
  6196 00015A91 D1EF                <1> 	shr	edi, 1
  6197 00015A93 39CF                <1> 	cmp	edi, ecx
  6198 00015A95 7302                <1> 	jnb	short gcd_0
  6199 00015A97 89F9                <1> 	mov	ecx, edi
  6200                              <1> gcd_0:
  6201 00015A99 803D[B19C0100]03    <1> 	cmp	byte [audio_device], 3
  6202 00015AA0 7232                <1> 	jb	short ac97_current_sound_data ; = 2
  6203                              <1> 	; = 3
  6204                              <1> vt8233_current_sound_data:
  6205                              <1> 	; 22/06/2017
  6206                              <1> 	; 21/06/2017
  6207                              <1> 	; get current sound (PCM out) data for graphics
  6208                              <1> 	; (for VT 8233, VT 8237R)
  6209                              <1> 	; ebx = Physical address (on page boundary)
  6210                              <1> 	; ecx = Byte count
  6211                              <1> 	; [audio_buff_size]
  6212                              <1> 	
  6213                              <1> 	;;mov	edi, [audio_buff_size]
  6214                              <1> 	;mov	edi, [audio_dmabuff_size]
  6215                              <1> 	;mov	esi, [audio_dma_buff]
  6216                              <1> 	;shr	edi, 1
  6217                              <1> 	;cmp	edi, ecx
  6218                              <1> 	;jnb	short vt8233_gcd_1
  6219                              <1> 	;mov	ecx, edi
  6220                              <1> vt8233_gcd_1:
  6221 00015AA2 BA0C000000          <1> 	mov	edx, VIA_REG_OFFSET_CURR_COUNT
  6222 00015AA7 E88FF5FFFF          <1> 	call	ctrl_io_r32
  6223 00015AAC 89C2                <1> 	mov	edx, eax ; remain count (bits 23-0),
  6224                              <1> 			 ; SGD index (bits 31-24) 
  6225 00015AAE 81E200000001        <1> 	and	edx, 1000000h ; SGD index (0 = 1st half)
  6226 00015AB4 7402                <1> 	jz	short vt8233_gcd_2
  6227                              <1> 	; the second half of DMA buffer
  6228 00015AB6 01FE                <1> 	add	esi, edi 
  6229                              <1> vt8233_gcd_2:	
  6230 00015AB8 25FFFFFF00          <1> 	and	eax, 0FFFFFFh ; bits 23-0
  6231                              <1> ac97_gcd_2:
  6232                              <1> sb16_gcd_2:
  6233 00015ABD 39C8                <1> 	cmp	eax, ecx
  6234 00015ABF 7302                <1> 	jnb	short vt8233_gcd_3 
  6235                              <1> 	; remain count < graphics bytes
  6236 00015AC1 89C8                <1> 	mov	eax, ecx ; fix remain count to data size
  6237                              <1> vt8233_gcd_3:
  6238 00015AC3 29C7                <1> 	sub	edi, eax
  6239 00015AC5 7602                <1> 	jna	short vt8233_gcd_4
  6240 00015AC7 01FE                <1> 	add	esi, edi ; dma buffer offset
  6241                              <1> vt8233_gcd_4:
  6242 00015AC9 89DF                <1> 	mov	edi, ebx ; buffer address (for graphics) 
  6243 00015ACB 890D[64030300]      <1> 	mov	[u.r0], ecx
  6244 00015AD1 F3A4                <1> 	rep	movsb
  6245                              <1> vt8233_gcd_5:
  6246 00015AD3 C3                  <1> 	retn
  6247                              <1> 
  6248                              <1> ac97_current_sound_data:
  6249                              <1> 	; 23/06/2017
  6250                              <1> 	; 22/06/2017
  6251                              <1> 	; get current sound (PCM out) data for graphics
  6252                              <1> 	; (for AC'97, ICH)
  6253                              <1> 	; ebx = Physical address (on page boundary)
  6254                              <1> 	; ecx = Byte count
  6255                              <1> 	; [audio_buff_size]
  6256                              <1> 	
  6257                              <1> 	;;mov	edi, [audio_buff_size]
  6258                              <1> 	;mov	edi, [audio_dmabuff_size]
  6259                              <1> 	;mov	esi, [audio_dma_buff]
  6260                              <1> 	;shr	edi, 1
  6261                              <1> 	;cmp	edi, ecx
  6262                              <1> 	;jnb	short ac97_gcd_0
  6263                              <1> 	;mov	ecx, edi
  6264                              <1> ac97_gcd_0:
  6265 00015AD4 66BA1400            <1> 	mov	dx, PO_CIV_REG ; Position In Current Buff Reg
  6266 00015AD8 660315[EA9C0100]    <1> 	add	dx, [NABMBAR]
  6267 00015ADF EC                  <1> 	in	al, dx ; current index value
  6268 00015AE0 A801                <1> 	test	al, 1
  6269 00015AE2 7402                <1> 	jz	short ac97_gcd_1
  6270 00015AE4 01FE                <1> 	add	esi, edi
  6271                              <1> ac97_gcd_1:
  6272 00015AE6 31C0                <1> 	xor	eax, eax
  6273 00015AE8 66BA1800            <1> 	mov	dx, PO_PICB_REG ; Position In Current Buff Reg
  6274 00015AEC 660315[EA9C0100]    <1> 	add	dx, [NABMBAR]
  6275 00015AF3 66ED                <1> 	in	ax, dx ; remain dwords
  6276 00015AF5 C1E002              <1> 	shl	eax, 2 ; remain bytes ; 23/06/2017 
  6277 00015AF8 EBC3                <1> 	jmp	short ac97_gcd_2
  6278                              <1> ;	cmp	eax, ecx
  6279                              <1> ;	jnb	short ac97_gcd_2 
  6280                              <1> ;	; remain count < graphics bytes
  6281                              <1> ;	mov	eax, ecx ; fix remain count to data size
  6282                              <1> ;ac97_gcd_2:	
  6283                              <1> ;	sub	edi, eax
  6284                              <1> ;	jna	short ac97_gcd_3
  6285                              <1> ;	add	esi, edi ; dma buffer offset
  6286                              <1> ;ac97_gcd_3:
  6287                              <1> ;	mov	edi, ebx ; buffer address (for graphics) 
  6288                              <1> ;	mov	[u.r0], ecx
  6289                              <1> ;	rep	movsb
  6290                              <1> ;	retn
  6291                              <1> 
  6292                              <1> sb16_get_dma_buff_off:
  6293                              <1> 	; 28/10/2017
  6294                              <1> 	; 24/06/2017
  6295                              <1> 	; 22/06/2017
  6296                              <1> 	; get current (PCM OUT DMA buffer) pointer
  6297                              <1> 	; (for Sound Blaster 16)
  6298                              <1> 
  6299                              <1> 	;mov	ecx, [audio_dmabuff_size]
  6300                              <1> 	;xor	ebx, ebx
  6301                              <1> 	;shr	ecx, 1
  6302                              <1> sb16_gdmabo_0:
  6303                              <1> 	; 28/10/2017
  6304 00015AFA 803D[E09C0100]10    <1> 	cmp	byte [audio_bps], 16
  6305 00015B01 750F                <1> 	jne	short sb16_gdmabo_1 ; 8 bit DMA channel
  6306                              <1> 	; 16 bit DMA channel
  6307 00015B03 E4C6                <1> 	in	al, 0C6h ; DMA channel 5 count register
  6308 00015B05 88C2                <1> 	mov	dl, al	
  6309 00015B07 E4C6                <1> 	in	al, 0C6h
  6310 00015B09 88C6                <1> 	mov     dh, al
  6311 00015B0B 0FB7C2              <1> 	movzx	eax, dx
  6312 00015B0E D1E0                <1> 	shl	eax, 1 ; word count -> byte count
  6313 00015B10 EB3D                <1> 	jmp	short sb16_gdmabo_2	
  6314                              <1> sb16_gdmabo_1:
  6315 00015B12 E403                <1> 	in	al, 03h ; DMA channel 1 count register
  6316 00015B14 88C2                <1> 	mov	dl, al	
  6317 00015B16 E403                <1> 	in	al, 03h
  6318 00015B18 88C6                <1> 	mov     dh, al
  6319 00015B1A 0FB7C2              <1> 	movzx	eax, dx
  6320 00015B1D EB30                <1> 	jmp	short sb16_gdmabo_2
  6321                              <1> 
  6322                              <1> get_dma_buffer_offset:
  6323                              <1> 	; 24/06/2017
  6324                              <1> 	; 22/06/2017
  6325                              <1> 	; get current sound (PCM out) data for graphics
  6326                              <1> 	;
  6327                              <1> 	; ebx = Physical address (on page boundary)
  6328                              <1> 	; ecx = Byte count
  6329                              <1> 	; [audio_buff_size]
  6330                              <1> 
  6331 00015B1F 8B0D[D49C0100]      <1> 	mov	ecx, [audio_dmabuff_size]
  6332 00015B25 31DB                <1> 	xor	ebx, ebx
  6333                              <1> gdmabo_0:
  6334 00015B27 803D[B19C0100]02    <1> 	cmp	byte [audio_device], 2
  6335 00015B2E 72CA                <1> 	jb	short sb16_get_dma_buff_off
  6336 00015B30 742A                <1> 	je	short ac97_get_dma_buff_off
  6337                              <1> 
  6338                              <1> vt8233_get_dma_buff_off:
  6339                              <1> 	; 24/06/2017
  6340                              <1> 	; 22/06/2017
  6341                              <1> 	; get current (PCM OUT DMA buffer) pointer
  6342                              <1> 	; (for VT 8233, VT 8237R)
  6343                              <1> 	
  6344                              <1> 	;mov	ecx, [audio_dmabuff_size]
  6345                              <1> 	;xor	ebx, ebx
  6346 00015B32 D1E9                <1> 	shr	ecx, 1
  6347                              <1> vt8233_gdmabo_0:
  6348 00015B34 BA0C000000          <1> 	mov	edx, VIA_REG_OFFSET_CURR_COUNT
  6349 00015B39 E8FDF4FFFF          <1> 	call	ctrl_io_r32
  6350 00015B3E 89C2                <1> 	mov	edx, eax ; remain count (bits 23-0),
  6351                              <1> 			 ; SGD index (bits 31-24) 
  6352 00015B40 81E200000001        <1> 	and	edx, 1000000h ; SGD index (0 = 1st half)
  6353 00015B46 7402                <1> 	jz	short vt8233_gdmabo_1
  6354                              <1> 	; the second half of DMA buffer
  6355 00015B48 89CB                <1> 	mov	ebx, ecx 
  6356                              <1> vt8233_gdmabo_1:	
  6357 00015B4A 25FFFFFF00          <1> 	and	eax, 0FFFFFFh ; bits 23-0
  6358                              <1> sb16_gdmabo_2:
  6359                              <1> ac97_gdmabo_2:
  6360 00015B4F 29C1                <1> 	sub	ecx, eax
  6361 00015B51 7602                <1> 	jna	short vt8233_gdmabo_2
  6362 00015B53 01CB                <1> 	add	ebx, ecx ; dma buffer offset
  6363                              <1> vt8233_gdmabo_2:
  6364 00015B55 891D[64030300]      <1> 	mov	[u.r0], ebx
  6365 00015B5B C3                  <1> 	retn
  6366                              <1> 
  6367                              <1> ac97_get_dma_buff_off:
  6368                              <1> 	; 24/06/2017
  6369                              <1> 	; 22/06/2017
  6370                              <1> 	; get current (PCM OUT DMA buffer) pointer
  6371                              <1> 	; (for AC'97, ICH)
  6372                              <1> 	; ebx = Physical address (on page boundary)
  6373                              <1> 	; ecx = Byte count
  6374                              <1> 	; [audio_buff_size]
  6375                              <1> 	
  6376                              <1> 	;mov	ecx, [audio_dmabuff_size]
  6377                              <1> 	;xor	ebx, ebx
  6378 00015B5C D1E9                <1> 	shr	ecx, 1
  6379                              <1> ac97_gdmabo_0:
  6380 00015B5E 66BA1400            <1> 	mov	dx, PO_CIV_REG ; Position In Current Buff Reg
  6381 00015B62 660315[EA9C0100]    <1> 	add	dx, [NABMBAR]
  6382 00015B69 EC                  <1> 	in	al, dx ; current index value
  6383 00015B6A A801                <1> 	test	al, 1
  6384 00015B6C 7402                <1> 	jz	short ac97_gdmabo_1
  6385 00015B6E 89CB                <1> 	mov	ebx, ecx
  6386                              <1> ac97_gdmabo_1:
  6387 00015B70 31C0                <1> 	xor	eax, eax
  6388 00015B72 66BA1800            <1> 	mov	dx, PO_PICB_REG ; Position In Current Buff Reg
  6389 00015B76 660315[EA9C0100]    <1> 	add	dx, [NABMBAR]
  6390 00015B7D 66ED                <1> 	in	ax, dx ; remain dwords
  6391 00015B7F EBCE                <1> 	jmp	short ac97_gdmabo_2
  3433                                  
  3434 00015B81 90<rep 3h>              align 4
  3435                                  
  3436                                  %include 'vgadata.s' ; 04/07/2016
  3437                              <1> ; ****************************************************************************************************
  3438                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.3 - vgadata.s  (palette and font data)
  3439                              <1> ; -----------------------------------------------------------------------------
  3440                              <1> ; Last Update: 01/01/2021
  3441                              <1> ; -----------------------------------------------------------------------------
  3442                              <1> ; Beginning: 16/01/2016
  3443                              <1> ; -----------------------------------------------------------------------------
  3444                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
  3445                              <1> ; -----------------------------------------------------------------------------
  3446                              <1> ; Turkish Rational DOS
  3447                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
  3448                              <1> ;
  3449                              <1> ; Derived from 'Plex86/Bochs VGABios' source code, vgabios-0.7a (2011)
  3450                              <1> ; by the LGPL VGABios Developers Team (2001-2008), 'vgatables.h'
  3451                              <1> ;
  3452                              <1> ; Oracle VirtualBox 5.0.24 VGABios Source Code 
  3453                              <1> ; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
  3454                              <1> ;
  3455                              <1> ; Palette and font data in assembly language format:
  3456                              <1> ; 'VBoxVgaBiosAlternative.asm'
  3457                              <1> 
  3458                              <1> ; ****************************************************************************************************
  3459                              <1> 
  3460                              <1> ; 25/11/2020 (TRDOS 386 v2.0.3)
  3461                              <1> ; ('vgatables.h' - 30/12/2019 - vruppert)
  3462                              <1>  
  3463                              <1> ; 04/07/2016
  3464                              <1> ; COLOR DATA
  3465                              <1> 
  3466                              <1> palette0: ; (63+1)*3
  3467 00015B84 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3467 00015B8D 00000000000000      <1>
  3468 00015B94 00000000000000002A- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
  3468 00015B9D 2A2A2A2A2A2A2A      <1>
  3469 00015BA4 2A2A2A2A2A2A2A2A2A- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
  3469 00015BAD 2A2A2A2A2A2A2A      <1>
  3470 00015BB4 2A2A2A2A2A2A2A2A2A- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
  3470 00015BBD 2A2A2A2A2A2A2A      <1>
  3471 00015BC4 2A2A2A2A2A2A2A2A3F- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh
  3471 00015BCD 3F3F3F3F3F3F3F      <1>
  3472 00015BD4 3F3F3F3F3F3F3F3F3F- <1>     db  03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh
  3472 00015BDD 3F3F3F3F3F3F3F      <1>
  3473 00015BE4 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3473 00015BED 00000000000000      <1>
  3474 00015BF4 00000000000000002A- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
  3474 00015BFD 2A2A2A2A2A2A2A      <1>
  3475 00015C04 2A2A2A2A2A2A2A2A2A- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
  3475 00015C0D 2A2A2A2A2A2A2A      <1>
  3476 00015C14 2A2A2A2A2A2A2A2A2A- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
  3476 00015C1D 2A2A2A2A2A2A2A      <1>
  3477 00015C24 2A2A2A2A2A2A2A2A3F- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh
  3477 00015C2D 3F3F3F3F3F3F3F      <1>
  3478 00015C34 3F3F3F3F3F3F3F3F3F- <1>     db  03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh
  3478 00015C3D 3F3F3F3F3F3F3F      <1>
  3479                              <1> palette1: ; (63+1)*3	
  3480 00015C44 00000000002A002A00- <1>     db  000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah, 000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah
  3480 00015C4D 002A2A2A00002A      <1>
  3481 00015C54 002A2A15002A2A2A00- <1>     db  000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah
  3481 00015C5D 000000002A002A      <1>
  3482 00015C64 00002A2A2A00002A00- <1>     db  000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah, 000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah
  3482 00015C6D 2A2A15002A2A2A      <1>
  3483 00015C74 15151515153F153F15- <1>     db  015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh, 015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh
  3483 00015C7D 153F3F3F15153F      <1>
  3484 00015C84 153F3F3F153F3F3F15- <1>     db  015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh
  3484 00015C8D 151515153F153F      <1>
  3485 00015C94 15153F3F3F15153F15- <1>     db  015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh
  3485 00015C9D 3F3F3F153F3F3F      <1>
  3486 00015CA4 00000000002A002A00- <1>     db  000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah, 000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah
  3486 00015CAD 002A2A2A00002A      <1>
  3487 00015CB4 002A2A15002A2A2A00- <1>     db  000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah
  3487 00015CBD 000000002A002A      <1>
  3488 00015CC4 00002A2A2A00002A00- <1>     db  000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah, 000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah
  3488 00015CCD 2A2A15002A2A2A      <1>
  3489 00015CD4 15151515153F153F15- <1>     db  015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh, 015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh
  3489 00015CDD 153F3F3F15153F      <1>
  3490 00015CE4 153F3F3F153F3F3F15- <1>     db  015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh
  3490 00015CED 151515153F153F      <1>
  3491 00015CF4 15153F3F3F15153F15- <1>     db  015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh
  3491 00015CFD 3F3F3F153F3F3F      <1>
  3492                              <1> palette2: ; (63+1)*3
  3493 00015D04 00000000002A002A00- <1>     db  000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah, 000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah
  3493 00015D0D 002A2A2A00002A      <1>
  3494 00015D14 002A2A2A002A2A2A00- <1>     db  000h, 02ah, 02ah, 02ah, 000h, 02ah, 02ah, 02ah, 000h, 000h, 015h, 000h, 000h, 03fh, 000h, 02ah
  3494 00015D1D 001500003F002A      <1>
  3495 00015D24 15002A3F2A00152A00- <1>     db  015h, 000h, 02ah, 03fh, 02ah, 000h, 015h, 02ah, 000h, 03fh, 02ah, 02ah, 015h, 02ah, 02ah, 03fh
  3495 00015D2D 3F2A2A152A2A3F      <1>
  3496 00015D34 00150000152A003F00- <1>     db  000h, 015h, 000h, 000h, 015h, 02ah, 000h, 03fh, 000h, 000h, 03fh, 02ah, 02ah, 015h, 000h, 02ah
  3496 00015D3D 003F2A2A15002A      <1>
  3497 00015D44 152A2A3F002A3F2A00- <1>     db  015h, 02ah, 02ah, 03fh, 000h, 02ah, 03fh, 02ah, 000h, 015h, 015h, 000h, 015h, 03fh, 000h, 03fh
  3497 00015D4D 151500153F003F      <1>
  3498 00015D54 15003F3F2A15152A15- <1>     db  015h, 000h, 03fh, 03fh, 02ah, 015h, 015h, 02ah, 015h, 03fh, 02ah, 03fh, 015h, 02ah, 03fh, 03fh
  3498 00015D5D 3F2A3F152A3F3F      <1>
  3499 00015D64 15000015002A152A00- <1>     db  015h, 000h, 000h, 015h, 000h, 02ah, 015h, 02ah, 000h, 015h, 02ah, 02ah, 03fh, 000h, 000h, 03fh
  3499 00015D6D 152A2A3F00003F      <1>
  3500 00015D74 002A3F2A003F2A2A15- <1>     db  000h, 02ah, 03fh, 02ah, 000h, 03fh, 02ah, 02ah, 015h, 000h, 015h, 015h, 000h, 03fh, 015h, 02ah
  3500 00015D7D 001515003F152A      <1>
  3501 00015D84 15152A3F3F00153F00- <1>     db  015h, 015h, 02ah, 03fh, 03fh, 000h, 015h, 03fh, 000h, 03fh, 03fh, 02ah, 015h, 03fh, 02ah, 03fh
  3501 00015D8D 3F3F2A153F2A3F      <1>
  3502 00015D94 15150015152A153F00- <1>     db  015h, 015h, 000h, 015h, 015h, 02ah, 015h, 03fh, 000h, 015h, 03fh, 02ah, 03fh, 015h, 000h, 03fh
  3502 00015D9D 153F2A3F15003F      <1>
  3503 00015DA4 152A3F3F003F3F2A15- <1>     db  015h, 02ah, 03fh, 03fh, 000h, 03fh, 03fh, 02ah, 015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh
  3503 00015DAD 151515153F153F      <1>
  3504 00015DB4 15153F3F3F15153F15- <1>     db  015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh
  3504 00015DBD 3F3F3F153F3F3F      <1>
  3505                              <1> palette3: ; 256*3
  3506 00015DC4 00000000002A002A00- <1>     db  000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah, 000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah
  3506 00015DCD 002A2A2A00002A      <1>
  3507 00015DD4 002A2A15002A2A2A15- <1>     db  000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah, 015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh
  3507 00015DDD 151515153F153F      <1>
  3508 00015DE4 15153F3F3F15153F15- <1>     db  015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh
  3508 00015DED 3F3F3F153F3F3F      <1>
  3509 00015DF4 000000050505080808- <1>     db  000h, 000h, 000h, 005h, 005h, 005h, 008h, 008h, 008h, 00bh, 00bh, 00bh, 00eh, 00eh, 00eh, 011h
  3509 00015DFD 0B0B0B0E0E0E11      <1>
  3510 00015E04 11111414141818181C- <1>     db  011h, 011h, 014h, 014h, 014h, 018h, 018h, 018h, 01ch, 01ch, 01ch, 020h, 020h, 020h, 024h, 024h
  3510 00015E0D 1C1C2020202424      <1>
  3511 00015E14 242828282D2D2D3232- <1>     db  024h, 028h, 028h, 028h, 02dh, 02dh, 02dh, 032h, 032h, 032h, 038h, 038h, 038h, 03fh, 03fh, 03fh
  3511 00015E1D 323838383F3F3F      <1>
  3512 00015E24 00003F10003F1F003F- <1>     db  000h, 000h, 03fh, 010h, 000h, 03fh, 01fh, 000h, 03fh, 02fh, 000h, 03fh, 03fh, 000h, 03fh, 03fh
  3512 00015E2D 2F003F3F003F3F      <1>
  3513 00015E34 002F3F001F3F00103F- <1>     db  000h, 02fh, 03fh, 000h, 01fh, 03fh, 000h, 010h, 03fh, 000h, 000h, 03fh, 010h, 000h, 03fh, 01fh
  3513 00015E3D 00003F10003F1F      <1>
  3514 00015E44 003F2F003F3F002F3F- <1>     db  000h, 03fh, 02fh, 000h, 03fh, 03fh, 000h, 02fh, 03fh, 000h, 01fh, 03fh, 000h, 010h, 03fh, 000h
  3514 00015E4D 001F3F00103F00      <1>
  3515 00015E54 003F00003F10003F1F- <1>     db  000h, 03fh, 000h, 000h, 03fh, 010h, 000h, 03fh, 01fh, 000h, 03fh, 02fh, 000h, 03fh, 03fh, 000h
  3515 00015E5D 003F2F003F3F00      <1>
  3516 00015E64 2F3F001F3F00103F1F- <1>     db  02fh, 03fh, 000h, 01fh, 03fh, 000h, 010h, 03fh, 01fh, 01fh, 03fh, 027h, 01fh, 03fh, 02fh, 01fh
  3516 00015E6D 1F3F271F3F2F1F      <1>
  3517 00015E74 3F371F3F3F1F3F3F1F- <1>     db  03fh, 037h, 01fh, 03fh, 03fh, 01fh, 03fh, 03fh, 01fh, 037h, 03fh, 01fh, 02fh, 03fh, 01fh, 027h
  3517 00015E7D 373F1F2F3F1F27      <1>
  3518 00015E84 3F1F1F3F271F3F2F1F- <1>     db  03fh, 01fh, 01fh, 03fh, 027h, 01fh, 03fh, 02fh, 01fh, 03fh, 037h, 01fh, 03fh, 03fh, 01fh, 037h
  3518 00015E8D 3F371F3F3F1F37      <1>
  3519 00015E94 3F1F2F3F1F273F1F1F- <1>     db  03fh, 01fh, 02fh, 03fh, 01fh, 027h, 03fh, 01fh, 01fh, 03fh, 01fh, 01fh, 03fh, 027h, 01fh, 03fh
  3519 00015E9D 3F1F1F3F271F3F      <1>
  3520 00015EA4 2F1F3F371F3F3F1F37- <1>     db  02fh, 01fh, 03fh, 037h, 01fh, 03fh, 03fh, 01fh, 037h, 03fh, 01fh, 02fh, 03fh, 01fh, 027h, 03fh
  3520 00015EAD 3F1F2F3F1F273F      <1>
  3521 00015EB4 2D2D3F312D3F362D3F- <1>     db  02dh, 02dh, 03fh, 031h, 02dh, 03fh, 036h, 02dh, 03fh, 03ah, 02dh, 03fh, 03fh, 02dh, 03fh, 03fh
  3521 00015EBD 3A2D3F3F2D3F3F      <1>
  3522 00015EC4 2D3A3F2D363F2D313F- <1>     db  02dh, 03ah, 03fh, 02dh, 036h, 03fh, 02dh, 031h, 03fh, 02dh, 02dh, 03fh, 031h, 02dh, 03fh, 036h
  3522 00015ECD 2D2D3F312D3F36      <1>
  3523 00015ED4 2D3F3A2D3F3F2D3A3F- <1>     db  02dh, 03fh, 03ah, 02dh, 03fh, 03fh, 02dh, 03ah, 03fh, 02dh, 036h, 03fh, 02dh, 031h, 03fh, 02dh
  3523 00015EDD 2D363F2D313F2D      <1>
  3524 00015EE4 2D3F2D2D3F312D3F36- <1>     db  02dh, 03fh, 02dh, 02dh, 03fh, 031h, 02dh, 03fh, 036h, 02dh, 03fh, 03ah, 02dh, 03fh, 03fh, 02dh
  3524 00015EED 2D3F3A2D3F3F2D      <1>
  3525 00015EF4 3A3F2D363F2D313F00- <1>     db  03ah, 03fh, 02dh, 036h, 03fh, 02dh, 031h, 03fh, 000h, 000h, 01ch, 007h, 000h, 01ch, 00eh, 000h
  3525 00015EFD 001C07001C0E00      <1>
  3526 00015F04 1C15001C1C001C1C00- <1>     db  01ch, 015h, 000h, 01ch, 01ch, 000h, 01ch, 01ch, 000h, 015h, 01ch, 000h, 00eh, 01ch, 000h, 007h
  3526 00015F0D 151C000E1C0007      <1>
  3527 00015F14 1C00001C07001C0E00- <1>     db  01ch, 000h, 000h, 01ch, 007h, 000h, 01ch, 00eh, 000h, 01ch, 015h, 000h, 01ch, 01ch, 000h, 015h
  3527 00015F1D 1C15001C1C0015      <1>
  3528 00015F24 1C000E1C00071C0000- <1>     db  01ch, 000h, 00eh, 01ch, 000h, 007h, 01ch, 000h, 000h, 01ch, 000h, 000h, 01ch, 007h, 000h, 01ch
  3528 00015F2D 1C00001C07001C      <1>
  3529 00015F34 0E001C15001C1C0015- <1>     db  00eh, 000h, 01ch, 015h, 000h, 01ch, 01ch, 000h, 015h, 01ch, 000h, 00eh, 01ch, 000h, 007h, 01ch
  3529 00015F3D 1C000E1C00071C      <1>
  3530 00015F44 0E0E1C110E1C150E1C- <1>     db  00eh, 00eh, 01ch, 011h, 00eh, 01ch, 015h, 00eh, 01ch, 018h, 00eh, 01ch, 01ch, 00eh, 01ch, 01ch
  3530 00015F4D 180E1C1C0E1C1C      <1>
  3531 00015F54 0E181C0E151C0E111C- <1>     db  00eh, 018h, 01ch, 00eh, 015h, 01ch, 00eh, 011h, 01ch, 00eh, 00eh, 01ch, 011h, 00eh, 01ch, 015h
  3531 00015F5D 0E0E1C110E1C15      <1>
  3532 00015F64 0E1C180E1C1C0E181C- <1>     db  00eh, 01ch, 018h, 00eh, 01ch, 01ch, 00eh, 018h, 01ch, 00eh, 015h, 01ch, 00eh, 011h, 01ch, 00eh
  3532 00015F6D 0E151C0E111C0E      <1>
  3533 00015F74 0E1C0E0E1C110E1C15- <1>     db  00eh, 01ch, 00eh, 00eh, 01ch, 011h, 00eh, 01ch, 015h, 00eh, 01ch, 018h, 00eh, 01ch, 01ch, 00eh
  3533 00015F7D 0E1C180E1C1C0E      <1>
  3534 00015F84 181C0E151C0E111C14- <1>     db  018h, 01ch, 00eh, 015h, 01ch, 00eh, 011h, 01ch, 014h, 014h, 01ch, 016h, 014h, 01ch, 018h, 014h
  3534 00015F8D 141C16141C1814      <1>
  3535 00015F94 1C1A141C1C141C1C14- <1>     db  01ch, 01ah, 014h, 01ch, 01ch, 014h, 01ch, 01ch, 014h, 01ah, 01ch, 014h, 018h, 01ch, 014h, 016h
  3535 00015F9D 1A1C14181C1416      <1>
  3536 00015FA4 1C14141C16141C1814- <1>     db  01ch, 014h, 014h, 01ch, 016h, 014h, 01ch, 018h, 014h, 01ch, 01ah, 014h, 01ch, 01ch, 014h, 01ah
  3536 00015FAD 1C1A141C1C141A      <1>
  3537 00015FB4 1C14181C14161C1414- <1>     db  01ch, 014h, 018h, 01ch, 014h, 016h, 01ch, 014h, 014h, 01ch, 014h, 014h, 01ch, 016h, 014h, 01ch
  3537 00015FBD 1C14141C16141C      <1>
  3538 00015FC4 18141C1A141C1C141A- <1>     db  018h, 014h, 01ch, 01ah, 014h, 01ch, 01ch, 014h, 01ah, 01ch, 014h, 018h, 01ch, 014h, 016h, 01ch
  3538 00015FCD 1C14181C14161C      <1>
  3539 00015FD4 000010040010080010- <1>     db  000h, 000h, 010h, 004h, 000h, 010h, 008h, 000h, 010h, 00ch, 000h, 010h, 010h, 000h, 010h, 010h
  3539 00015FDD 0C001010001010      <1>
  3540 00015FE4 000C10000810000410- <1>     db  000h, 00ch, 010h, 000h, 008h, 010h, 000h, 004h, 010h, 000h, 000h, 010h, 004h, 000h, 010h, 008h
  3540 00015FED 00001004001008      <1>
  3541 00015FF4 00100C001010000C10- <1>     db  000h, 010h, 00ch, 000h, 010h, 010h, 000h, 00ch, 010h, 000h, 008h, 010h, 000h, 004h, 010h, 000h
  3541 00015FFD 00081000041000      <1>
  3542 00016004 001000001004001008- <1>     db  000h, 010h, 000h, 000h, 010h, 004h, 000h, 010h, 008h, 000h, 010h, 00ch, 000h, 010h, 010h, 000h
  3542 0001600D 00100C00101000      <1>
  3543 00016014 0C1000081000041008- <1>     db  00ch, 010h, 000h, 008h, 010h, 000h, 004h, 010h, 008h, 008h, 010h, 00ah, 008h, 010h, 00ch, 008h
  3543 0001601D 08100A08100C08      <1>
  3544 00016024 100E08101008101008- <1>     db  010h, 00eh, 008h, 010h, 010h, 008h, 010h, 010h, 008h, 00eh, 010h, 008h, 00ch, 010h, 008h, 00ah
  3544 0001602D 0E10080C10080A      <1>
  3545 00016034 100808100A08100C08- <1>     db  010h, 008h, 008h, 010h, 00ah, 008h, 010h, 00ch, 008h, 010h, 00eh, 008h, 010h, 010h, 008h, 00eh
  3545 0001603D 100E081010080E      <1>
  3546 00016044 10080C10080A100808- <1>     db  010h, 008h, 00ch, 010h, 008h, 00ah, 010h, 008h, 008h, 010h, 008h, 008h, 010h, 00ah, 008h, 010h
  3546 0001604D 100808100A0810      <1>
  3547 00016054 0C08100E081010080E- <1>     db  00ch, 008h, 010h, 00eh, 008h, 010h, 010h, 008h, 00eh, 010h, 008h, 00ch, 010h, 008h, 00ah, 010h
  3547 0001605D 10080C10080A10      <1>
  3548 00016064 0B0B100C0B100D0B10- <1>     db  00bh, 00bh, 010h, 00ch, 00bh, 010h, 00dh, 00bh, 010h, 00fh, 00bh, 010h, 010h, 00bh, 010h, 010h
  3548 0001606D 0F0B10100B1010      <1>
  3549 00016074 0B0F100B0D100B0C10- <1>     db  00bh, 00fh, 010h, 00bh, 00dh, 010h, 00bh, 00ch, 010h, 00bh, 00bh, 010h, 00ch, 00bh, 010h, 00dh
  3549 0001607D 0B0B100C0B100D      <1>
  3550 00016084 0B100F0B10100B0F10- <1>     db  00bh, 010h, 00fh, 00bh, 010h, 010h, 00bh, 00fh, 010h, 00bh, 00dh, 010h, 00bh, 00ch, 010h, 00bh
  3550 0001608D 0B0D100B0C100B      <1>
  3551 00016094 0B100B0B100C0B100D- <1>     db  00bh, 010h, 00bh, 00bh, 010h, 00ch, 00bh, 010h, 00dh, 00bh, 010h, 00fh, 00bh, 010h, 010h, 00bh
  3551 0001609D 0B100F0B10100B      <1>
  3552 000160A4 0F100B0D100B0C1000- <1>     db  00fh, 010h, 00bh, 00dh, 010h, 00bh, 00ch, 010h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3552 000160AD 00000000000000      <1>
  3553 000160B4 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3553 000160BD 00000000000000      <1>
  3554                              <1> 
  3555                              <1> 
  3556                              <1> ; 04/07/2016
  3557                              <1> ; FONT DATA
  3558                              <1> 
  3559                              <1> CRT_CHAR_GEN:
  3560                              <1> vgafont8: 
  3561 000160C4 00000000000000007E- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07eh, 081h, 0a5h, 081h, 0bdh, 099h, 081h, 07eh
  3561 000160CD 81A581BD99817E      <1>
  3562 000160D4 7EFFDBFFC3E7FF7E6C- <1>     db  07eh, 0ffh, 0dbh, 0ffh, 0c3h, 0e7h, 0ffh, 07eh, 06ch, 0feh, 0feh, 0feh, 07ch, 038h, 010h, 000h
  3562 000160DD FEFEFE7C381000      <1>
  3563 000160E4 10387CFE7C38100038- <1>     db  010h, 038h, 07ch, 0feh, 07ch, 038h, 010h, 000h, 038h, 07ch, 038h, 0feh, 0feh, 07ch, 038h, 07ch
  3563 000160ED 7C38FEFE7C387C      <1>
  3564 000160F4 1010387CFE7C387C00- <1>     db  010h, 010h, 038h, 07ch, 0feh, 07ch, 038h, 07ch, 000h, 000h, 018h, 03ch, 03ch, 018h, 000h, 000h
  3564 000160FD 00183C3C180000      <1>
  3565 00016104 FFFFE7C3C3E7FFFF00- <1>     db  0ffh, 0ffh, 0e7h, 0c3h, 0c3h, 0e7h, 0ffh, 0ffh, 000h, 03ch, 066h, 042h, 042h, 066h, 03ch, 000h
  3565 0001610D 3C664242663C00      <1>
  3566 00016114 FFC399BDBD99C3FF0F- <1>     db  0ffh, 0c3h, 099h, 0bdh, 0bdh, 099h, 0c3h, 0ffh, 00fh, 007h, 00fh, 07dh, 0cch, 0cch, 0cch, 078h
  3566 0001611D 070F7DCCCCCC78      <1>
  3567 00016124 3C6666663C187E183F- <1>     db  03ch, 066h, 066h, 066h, 03ch, 018h, 07eh, 018h, 03fh, 033h, 03fh, 030h, 030h, 070h, 0f0h, 0e0h
  3567 0001612D 333F303070F0E0      <1>
  3568 00016134 7F637F636367E6C099- <1>     db  07fh, 063h, 07fh, 063h, 063h, 067h, 0e6h, 0c0h, 099h, 05ah, 03ch, 0e7h, 0e7h, 03ch, 05ah, 099h
  3568 0001613D 5A3CE7E73C5A99      <1>
  3569 00016144 80E0F8FEF8E0800002- <1>     db  080h, 0e0h, 0f8h, 0feh, 0f8h, 0e0h, 080h, 000h, 002h, 00eh, 03eh, 0feh, 03eh, 00eh, 002h, 000h
  3569 0001614D 0E3EFE3E0E0200      <1>
  3570 00016154 183C7E18187E3C1866- <1>     db  018h, 03ch, 07eh, 018h, 018h, 07eh, 03ch, 018h, 066h, 066h, 066h, 066h, 066h, 000h, 066h, 000h
  3570 0001615D 66666666006600      <1>
  3571 00016164 7FDBDB7B1B1B1B003E- <1>     db  07fh, 0dbh, 0dbh, 07bh, 01bh, 01bh, 01bh, 000h, 03eh, 063h, 038h, 06ch, 06ch, 038h, 0cch, 078h
  3571 0001616D 63386C6C38CC78      <1>
  3572 00016174 000000007E7E7E0018- <1>     db  000h, 000h, 000h, 000h, 07eh, 07eh, 07eh, 000h, 018h, 03ch, 07eh, 018h, 07eh, 03ch, 018h, 0ffh
  3572 0001617D 3C7E187E3C18FF      <1>
  3573 00016184 183C7E181818180018- <1>     db  018h, 03ch, 07eh, 018h, 018h, 018h, 018h, 000h, 018h, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h
  3573 0001618D 1818187E3C1800      <1>
  3574 00016194 00180CFE0C18000000- <1>     db  000h, 018h, 00ch, 0feh, 00ch, 018h, 000h, 000h, 000h, 030h, 060h, 0feh, 060h, 030h, 000h, 000h
  3574 0001619D 3060FE60300000      <1>
  3575 000161A4 0000C0C0C0FE000000- <1>     db  000h, 000h, 0c0h, 0c0h, 0c0h, 0feh, 000h, 000h, 000h, 024h, 066h, 0ffh, 066h, 024h, 000h, 000h
  3575 000161AD 2466FF66240000      <1>
  3576 000161B4 00183C7EFFFF000000- <1>     db  000h, 018h, 03ch, 07eh, 0ffh, 0ffh, 000h, 000h, 000h, 0ffh, 0ffh, 07eh, 03ch, 018h, 000h, 000h
  3576 000161BD FFFF7E3C180000      <1>
  3577 000161C4 000000000000000030- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 030h, 078h, 078h, 030h, 030h, 000h, 030h, 000h
  3577 000161CD 78783030003000      <1>
  3578 000161D4 6C6C6C00000000006C- <1>     db  06ch, 06ch, 06ch, 000h, 000h, 000h, 000h, 000h, 06ch, 06ch, 0feh, 06ch, 0feh, 06ch, 06ch, 000h
  3578 000161DD 6CFE6CFE6C6C00      <1>
  3579 000161E4 307CC0780CF8300000- <1>     db  030h, 07ch, 0c0h, 078h, 00ch, 0f8h, 030h, 000h, 000h, 0c6h, 0cch, 018h, 030h, 066h, 0c6h, 000h
  3579 000161ED C6CC183066C600      <1>
  3580 000161F4 386C3876DCCC760060- <1>     db  038h, 06ch, 038h, 076h, 0dch, 0cch, 076h, 000h, 060h, 060h, 0c0h, 000h, 000h, 000h, 000h, 000h
  3580 000161FD 60C00000000000      <1>
  3581 00016204 183060606030180060- <1>     db  018h, 030h, 060h, 060h, 060h, 030h, 018h, 000h, 060h, 030h, 018h, 018h, 018h, 030h, 060h, 000h
  3581 0001620D 30181818306000      <1>
  3582 00016214 00663CFF3C66000000- <1>     db  000h, 066h, 03ch, 0ffh, 03ch, 066h, 000h, 000h, 000h, 030h, 030h, 0fch, 030h, 030h, 000h, 000h
  3582 0001621D 3030FC30300000      <1>
  3583 00016224 000000000030306000- <1>     db  000h, 000h, 000h, 000h, 000h, 030h, 030h, 060h, 000h, 000h, 000h, 0fch, 000h, 000h, 000h, 000h
  3583 0001622D 0000FC00000000      <1>
  3584 00016234 000000000030300006- <1>     db  000h, 000h, 000h, 000h, 000h, 030h, 030h, 000h, 006h, 00ch, 018h, 030h, 060h, 0c0h, 080h, 000h
  3584 0001623D 0C183060C08000      <1>
  3585 00016244 7CC6CEDEF6E67C0030- <1>     db  07ch, 0c6h, 0ceh, 0deh, 0f6h, 0e6h, 07ch, 000h, 030h, 070h, 030h, 030h, 030h, 030h, 0fch, 000h
  3585 0001624D 7030303030FC00      <1>
  3586 00016254 78CC0C3860CCFC0078- <1>     db  078h, 0cch, 00ch, 038h, 060h, 0cch, 0fch, 000h, 078h, 0cch, 00ch, 038h, 00ch, 0cch, 078h, 000h
  3586 0001625D CC0C380CCC7800      <1>
  3587 00016264 1C3C6CCCFE0C1E00FC- <1>     db  01ch, 03ch, 06ch, 0cch, 0feh, 00ch, 01eh, 000h, 0fch, 0c0h, 0f8h, 00ch, 00ch, 0cch, 078h, 000h
  3587 0001626D C0F80C0CCC7800      <1>
  3588 00016274 3860C0F8CCCC7800FC- <1>     db  038h, 060h, 0c0h, 0f8h, 0cch, 0cch, 078h, 000h, 0fch, 0cch, 00ch, 018h, 030h, 030h, 030h, 000h
  3588 0001627D CC0C1830303000      <1>
  3589 00016284 78CCCC78CCCC780078- <1>     db  078h, 0cch, 0cch, 078h, 0cch, 0cch, 078h, 000h, 078h, 0cch, 0cch, 07ch, 00ch, 018h, 070h, 000h
  3589 0001628D CCCC7C0C187000      <1>
  3590 00016294 003030000030300000- <1>     db  000h, 030h, 030h, 000h, 000h, 030h, 030h, 000h, 000h, 030h, 030h, 000h, 000h, 030h, 030h, 060h
  3590 0001629D 30300000303060      <1>
  3591 000162A4 183060C06030180000- <1>     db  018h, 030h, 060h, 0c0h, 060h, 030h, 018h, 000h, 000h, 000h, 0fch, 000h, 000h, 0fch, 000h, 000h
  3591 000162AD 00FC0000FC0000      <1>
  3592 000162B4 6030180C1830600078- <1>     db  060h, 030h, 018h, 00ch, 018h, 030h, 060h, 000h, 078h, 0cch, 00ch, 018h, 030h, 000h, 030h, 000h
  3592 000162BD CC0C1830003000      <1>
  3593 000162C4 7CC6DEDEDEC0780030- <1>     db  07ch, 0c6h, 0deh, 0deh, 0deh, 0c0h, 078h, 000h, 030h, 078h, 0cch, 0cch, 0fch, 0cch, 0cch, 000h
  3593 000162CD 78CCCCFCCCCC00      <1>
  3594 000162D4 FC66667C6666FC003C- <1>     db  0fch, 066h, 066h, 07ch, 066h, 066h, 0fch, 000h, 03ch, 066h, 0c0h, 0c0h, 0c0h, 066h, 03ch, 000h
  3594 000162DD 66C0C0C0663C00      <1>
  3595 000162E4 F86C6666666CF800FE- <1>     db  0f8h, 06ch, 066h, 066h, 066h, 06ch, 0f8h, 000h, 0feh, 062h, 068h, 078h, 068h, 062h, 0feh, 000h
  3595 000162ED 6268786862FE00      <1>
  3596 000162F4 FE6268786860F0003C- <1>     db  0feh, 062h, 068h, 078h, 068h, 060h, 0f0h, 000h, 03ch, 066h, 0c0h, 0c0h, 0ceh, 066h, 03eh, 000h
  3596 000162FD 66C0C0CE663E00      <1>
  3597 00016304 CCCCCCFCCCCCCC0078- <1>     db  0cch, 0cch, 0cch, 0fch, 0cch, 0cch, 0cch, 000h, 078h, 030h, 030h, 030h, 030h, 030h, 078h, 000h
  3597 0001630D 30303030307800      <1>
  3598 00016314 1E0C0C0CCCCC7800E6- <1>     db  01eh, 00ch, 00ch, 00ch, 0cch, 0cch, 078h, 000h, 0e6h, 066h, 06ch, 078h, 06ch, 066h, 0e6h, 000h
  3598 0001631D 666C786C66E600      <1>
  3599 00016324 F06060606266FE00C6- <1>     db  0f0h, 060h, 060h, 060h, 062h, 066h, 0feh, 000h, 0c6h, 0eeh, 0feh, 0feh, 0d6h, 0c6h, 0c6h, 000h
  3599 0001632D EEFEFED6C6C600      <1>
  3600 00016334 C6E6F6DECEC6C60038- <1>     db  0c6h, 0e6h, 0f6h, 0deh, 0ceh, 0c6h, 0c6h, 000h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 06ch, 038h, 000h
  3600 0001633D 6CC6C6C66C3800      <1>
  3601 00016344 FC66667C6060F00078- <1>     db  0fch, 066h, 066h, 07ch, 060h, 060h, 0f0h, 000h, 078h, 0cch, 0cch, 0cch, 0dch, 078h, 01ch, 000h
  3601 0001634D CCCCCCDC781C00      <1>
  3602 00016354 FC66667C6C66E60078- <1>     db  0fch, 066h, 066h, 07ch, 06ch, 066h, 0e6h, 000h, 078h, 0cch, 0e0h, 070h, 01ch, 0cch, 078h, 000h
  3602 0001635D CCE0701CCC7800      <1>
  3603 00016364 FCB4303030307800CC- <1>     db  0fch, 0b4h, 030h, 030h, 030h, 030h, 078h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 0fch, 000h
  3603 0001636D CCCCCCCCCCFC00      <1>
  3604 00016374 CCCCCCCCCC783000C6- <1>     db  0cch, 0cch, 0cch, 0cch, 0cch, 078h, 030h, 000h, 0c6h, 0c6h, 0c6h, 0d6h, 0feh, 0eeh, 0c6h, 000h
  3604 0001637D C6C6D6FEEEC600      <1>
  3605 00016384 C6C66C38386CC600CC- <1>     db  0c6h, 0c6h, 06ch, 038h, 038h, 06ch, 0c6h, 000h, 0cch, 0cch, 0cch, 078h, 030h, 030h, 078h, 000h
  3605 0001638D CCCC7830307800      <1>
  3606 00016394 FEC68C183266FE0078- <1>     db  0feh, 0c6h, 08ch, 018h, 032h, 066h, 0feh, 000h, 078h, 060h, 060h, 060h, 060h, 060h, 078h, 000h
  3606 0001639D 60606060607800      <1>
  3607 000163A4 C06030180C06020078- <1>     db  0c0h, 060h, 030h, 018h, 00ch, 006h, 002h, 000h, 078h, 018h, 018h, 018h, 018h, 018h, 078h, 000h
  3607 000163AD 18181818187800      <1>
  3608 000163B4 10386CC60000000000- <1>     db  010h, 038h, 06ch, 0c6h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh
  3608 000163BD 000000000000FF      <1>
  3609 000163C4 303018000000000000- <1>     db  030h, 030h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 078h, 00ch, 07ch, 0cch, 076h, 000h
  3609 000163CD 00780C7CCC7600      <1>
  3610 000163D4 E060607C6666DC0000- <1>     db  0e0h, 060h, 060h, 07ch, 066h, 066h, 0dch, 000h, 000h, 000h, 078h, 0cch, 0c0h, 0cch, 078h, 000h
  3610 000163DD 0078CCC0CC7800      <1>
  3611 000163E4 1C0C0C7CCCCC760000- <1>     db  01ch, 00ch, 00ch, 07ch, 0cch, 0cch, 076h, 000h, 000h, 000h, 078h, 0cch, 0fch, 0c0h, 078h, 000h
  3611 000163ED 0078CCFCC07800      <1>
  3612 000163F4 386C60F06060F00000- <1>     db  038h, 06ch, 060h, 0f0h, 060h, 060h, 0f0h, 000h, 000h, 000h, 076h, 0cch, 0cch, 07ch, 00ch, 0f8h
  3612 000163FD 0076CCCC7C0CF8      <1>
  3613 00016404 E0606C766666E60030- <1>     db  0e0h, 060h, 06ch, 076h, 066h, 066h, 0e6h, 000h, 030h, 000h, 070h, 030h, 030h, 030h, 078h, 000h
  3613 0001640D 00703030307800      <1>
  3614 00016414 0C000C0C0CCCCC78E0- <1>     db  00ch, 000h, 00ch, 00ch, 00ch, 0cch, 0cch, 078h, 0e0h, 060h, 066h, 06ch, 078h, 06ch, 0e6h, 000h
  3614 0001641D 60666C786CE600      <1>
  3615 00016424 703030303030780000- <1>     db  070h, 030h, 030h, 030h, 030h, 030h, 078h, 000h, 000h, 000h, 0cch, 0feh, 0feh, 0d6h, 0c6h, 000h
  3615 0001642D 00CCFEFED6C600      <1>
  3616 00016434 0000F8CCCCCCCC0000- <1>     db  000h, 000h, 0f8h, 0cch, 0cch, 0cch, 0cch, 000h, 000h, 000h, 078h, 0cch, 0cch, 0cch, 078h, 000h
  3616 0001643D 0078CCCCCC7800      <1>
  3617 00016444 0000DC66667C60F000- <1>     db  000h, 000h, 0dch, 066h, 066h, 07ch, 060h, 0f0h, 000h, 000h, 076h, 0cch, 0cch, 07ch, 00ch, 01eh
  3617 0001644D 0076CCCC7C0C1E      <1>
  3618 00016454 0000DC766660F00000- <1>     db  000h, 000h, 0dch, 076h, 066h, 060h, 0f0h, 000h, 000h, 000h, 07ch, 0c0h, 078h, 00ch, 0f8h, 000h
  3618 0001645D 007CC0780CF800      <1>
  3619 00016464 10307C303034180000- <1>     db  010h, 030h, 07ch, 030h, 030h, 034h, 018h, 000h, 000h, 000h, 0cch, 0cch, 0cch, 0cch, 076h, 000h
  3619 0001646D 00CCCCCCCC7600      <1>
  3620 00016474 0000CCCCCC78300000- <1>     db  000h, 000h, 0cch, 0cch, 0cch, 078h, 030h, 000h, 000h, 000h, 0c6h, 0d6h, 0feh, 0feh, 06ch, 000h
  3620 0001647D 00C6D6FEFE6C00      <1>
  3621 00016484 0000C66C386CC60000- <1>     db  000h, 000h, 0c6h, 06ch, 038h, 06ch, 0c6h, 000h, 000h, 000h, 0cch, 0cch, 0cch, 07ch, 00ch, 0f8h
  3621 0001648D 00CCCCCC7C0CF8      <1>
  3622 00016494 0000FC983064FC001C- <1>     db  000h, 000h, 0fch, 098h, 030h, 064h, 0fch, 000h, 01ch, 030h, 030h, 0e0h, 030h, 030h, 01ch, 000h
  3622 0001649D 3030E030301C00      <1>
  3623 000164A4 1818180018181800E0- <1>     db  018h, 018h, 018h, 000h, 018h, 018h, 018h, 000h, 0e0h, 030h, 030h, 01ch, 030h, 030h, 0e0h, 000h
  3623 000164AD 30301C3030E000      <1>
  3624 000164B4 76DC00000000000000- <1>     db  076h, 0dch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 000h
  3624 000164BD 10386CC6C6FE00      <1>
  3625 000164C4 78CCC0CC78180C7800- <1>     db  078h, 0cch, 0c0h, 0cch, 078h, 018h, 00ch, 078h, 000h, 0cch, 000h, 0cch, 0cch, 0cch, 07eh, 000h
  3625 000164CD CC00CCCCCC7E00      <1>
  3626 000164D4 1C0078CCFCC078007E- <1>     db  01ch, 000h, 078h, 0cch, 0fch, 0c0h, 078h, 000h, 07eh, 0c3h, 03ch, 006h, 03eh, 066h, 03fh, 000h
  3626 000164DD C33C063E663F00      <1>
  3627 000164E4 CC00780C7CCC7E00E0- <1>     db  0cch, 000h, 078h, 00ch, 07ch, 0cch, 07eh, 000h, 0e0h, 000h, 078h, 00ch, 07ch, 0cch, 07eh, 000h
  3627 000164ED 00780C7CCC7E00      <1>
  3628 000164F4 3030780C7CCC7E0000- <1>     db  030h, 030h, 078h, 00ch, 07ch, 0cch, 07eh, 000h, 000h, 000h, 078h, 0c0h, 0c0h, 078h, 00ch, 038h
  3628 000164FD 0078C0C0780C38      <1>
  3629 00016504 7EC33C667E603C00CC- <1>     db  07eh, 0c3h, 03ch, 066h, 07eh, 060h, 03ch, 000h, 0cch, 000h, 078h, 0cch, 0fch, 0c0h, 078h, 000h
  3629 0001650D 0078CCFCC07800      <1>
  3630 00016514 E00078CCFCC07800CC- <1>     db  0e0h, 000h, 078h, 0cch, 0fch, 0c0h, 078h, 000h, 0cch, 000h, 070h, 030h, 030h, 030h, 078h, 000h
  3630 0001651D 00703030307800      <1>
  3631 00016524 7CC6381818183C00E0- <1>     db  07ch, 0c6h, 038h, 018h, 018h, 018h, 03ch, 000h, 0e0h, 000h, 070h, 030h, 030h, 030h, 078h, 000h
  3631 0001652D 00703030307800      <1>
  3632 00016534 C6386CC6FEC6C60030- <1>     db  0c6h, 038h, 06ch, 0c6h, 0feh, 0c6h, 0c6h, 000h, 030h, 030h, 000h, 078h, 0cch, 0fch, 0cch, 000h
  3632 0001653D 300078CCFCCC00      <1>
  3633 00016544 1C00FC607860FC0000- <1>     db  01ch, 000h, 0fch, 060h, 078h, 060h, 0fch, 000h, 000h, 000h, 07fh, 00ch, 07fh, 0cch, 07fh, 000h
  3633 0001654D 007F0C7FCC7F00      <1>
  3634 00016554 3E6CCCFECCCCCE0078- <1>     db  03eh, 06ch, 0cch, 0feh, 0cch, 0cch, 0ceh, 000h, 078h, 0cch, 000h, 078h, 0cch, 0cch, 078h, 000h
  3634 0001655D CC0078CCCC7800      <1>
  3635 00016564 00CC0078CCCC780000- <1>     db  000h, 0cch, 000h, 078h, 0cch, 0cch, 078h, 000h, 000h, 0e0h, 000h, 078h, 0cch, 0cch, 078h, 000h
  3635 0001656D E00078CCCC7800      <1>
  3636 00016574 78CC00CCCCCC7E0000- <1>     db  078h, 0cch, 000h, 0cch, 0cch, 0cch, 07eh, 000h, 000h, 0e0h, 000h, 0cch, 0cch, 0cch, 07eh, 000h
  3636 0001657D E000CCCCCC7E00      <1>
  3637 00016584 00CC00CCCC7C0CF8C3- <1>     db  000h, 0cch, 000h, 0cch, 0cch, 07ch, 00ch, 0f8h, 0c3h, 018h, 03ch, 066h, 066h, 03ch, 018h, 000h
  3637 0001658D 183C66663C1800      <1>
  3638 00016594 CC00CCCCCCCC780018- <1>     db  0cch, 000h, 0cch, 0cch, 0cch, 0cch, 078h, 000h, 018h, 018h, 07eh, 0c0h, 0c0h, 07eh, 018h, 018h
  3638 0001659D 187EC0C07E1818      <1>
  3639 000165A4 386C64F060E6FC00CC- <1>     db  038h, 06ch, 064h, 0f0h, 060h, 0e6h, 0fch, 000h, 0cch, 0cch, 078h, 0fch, 030h, 0fch, 030h, 030h
  3639 000165AD CC78FC30FC3030      <1>
  3640 000165B4 F8CCCCFAC6CFC6C70E- <1>     db  0f8h, 0cch, 0cch, 0fah, 0c6h, 0cfh, 0c6h, 0c7h, 00eh, 01bh, 018h, 03ch, 018h, 018h, 0d8h, 070h
  3640 000165BD 1B183C1818D870      <1>
  3641 000165C4 1C00780C7CCC7E0038- <1>     db  01ch, 000h, 078h, 00ch, 07ch, 0cch, 07eh, 000h, 038h, 000h, 070h, 030h, 030h, 030h, 078h, 000h
  3641 000165CD 00703030307800      <1>
  3642 000165D4 001C0078CCCC780000- <1>     db  000h, 01ch, 000h, 078h, 0cch, 0cch, 078h, 000h, 000h, 01ch, 000h, 0cch, 0cch, 0cch, 07eh, 000h
  3642 000165DD 1C00CCCCCC7E00      <1>
  3643 000165E4 00F800F8CCCCCC00FC- <1>     db  000h, 0f8h, 000h, 0f8h, 0cch, 0cch, 0cch, 000h, 0fch, 000h, 0cch, 0ech, 0fch, 0dch, 0cch, 000h
  3643 000165ED 00CCECFCDCCC00      <1>
  3644 000165F4 3C6C6C3E007E000038- <1>     db  03ch, 06ch, 06ch, 03eh, 000h, 07eh, 000h, 000h, 038h, 06ch, 06ch, 038h, 000h, 07ch, 000h, 000h
  3644 000165FD 6C6C38007C0000      <1>
  3645 00016604 30003060C0CC780000- <1>     db  030h, 000h, 030h, 060h, 0c0h, 0cch, 078h, 000h, 000h, 000h, 000h, 0fch, 0c0h, 0c0h, 000h, 000h
  3645 0001660D 0000FCC0C00000      <1>
  3646 00016614 000000FC0C0C0000C3- <1>     db  000h, 000h, 000h, 0fch, 00ch, 00ch, 000h, 000h, 0c3h, 0c6h, 0cch, 0deh, 033h, 066h, 0cch, 00fh
  3646 0001661D C6CCDE3366CC0F      <1>
  3647 00016624 C3C6CCDB376FCF0318- <1>     db  0c3h, 0c6h, 0cch, 0dbh, 037h, 06fh, 0cfh, 003h, 018h, 018h, 000h, 018h, 018h, 018h, 018h, 000h
  3647 0001662D 18001818181800      <1>
  3648 00016634 003366CC6633000000- <1>     db  000h, 033h, 066h, 0cch, 066h, 033h, 000h, 000h, 000h, 0cch, 066h, 033h, 066h, 0cch, 000h, 000h
  3648 0001663D CC663366CC0000      <1>
  3649 00016644 228822882288228855- <1>     db  022h, 088h, 022h, 088h, 022h, 088h, 022h, 088h, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah
  3649 0001664D AA55AA55AA55AA      <1>
  3650 00016654 DB77DBEEDB77DBEE18- <1>     db  0dbh, 077h, 0dbh, 0eeh, 0dbh, 077h, 0dbh, 0eeh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
  3650 0001665D 18181818181818      <1>
  3651 00016664 18181818F818181818- <1>     db  018h, 018h, 018h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 018h, 018h, 018h
  3651 0001666D 18F818F8181818      <1>
  3652 00016674 36363636F636363600- <1>     db  036h, 036h, 036h, 036h, 0f6h, 036h, 036h, 036h, 000h, 000h, 000h, 000h, 0feh, 036h, 036h, 036h
  3652 0001667D 000000FE363636      <1>
  3653 00016684 0000F818F818181836- <1>     db  000h, 000h, 0f8h, 018h, 0f8h, 018h, 018h, 018h, 036h, 036h, 0f6h, 006h, 0f6h, 036h, 036h, 036h
  3653 0001668D 36F606F6363636      <1>
  3654 00016694 363636363636363600- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 000h, 000h, 0feh, 006h, 0f6h, 036h, 036h, 036h
  3654 0001669D 00FE06F6363636      <1>
  3655 000166A4 3636F606FE00000036- <1>     db  036h, 036h, 0f6h, 006h, 0feh, 000h, 000h, 000h, 036h, 036h, 036h, 036h, 0feh, 000h, 000h, 000h
  3655 000166AD 363636FE000000      <1>
  3656 000166B4 1818F818F800000000- <1>     db  018h, 018h, 0f8h, 018h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 018h, 018h
  3656 000166BD 000000F8181818      <1>
  3657 000166C4 181818181F00000018- <1>     db  018h, 018h, 018h, 018h, 01fh, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 0ffh, 000h, 000h, 000h
  3657 000166CD 181818FF000000      <1>
  3658 000166D4 00000000FF18181818- <1>     db  000h, 000h, 000h, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 018h, 018h, 018h
  3658 000166DD 1818181F181818      <1>
  3659 000166E4 00000000FF00000018- <1>     db  000h, 000h, 000h, 000h, 0ffh, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 0ffh, 018h, 018h, 018h
  3659 000166ED 181818FF181818      <1>
  3660 000166F4 18181F181F18181836- <1>     db  018h, 018h, 01fh, 018h, 01fh, 018h, 018h, 018h, 036h, 036h, 036h, 036h, 037h, 036h, 036h, 036h
  3660 000166FD 36363637363636      <1>
  3661 00016704 363637303F00000000- <1>     db  036h, 036h, 037h, 030h, 03fh, 000h, 000h, 000h, 000h, 000h, 03fh, 030h, 037h, 036h, 036h, 036h
  3661 0001670D 003F3037363636      <1>
  3662 00016714 3636F700FF00000000- <1>     db  036h, 036h, 0f7h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0f7h, 036h, 036h, 036h
  3662 0001671D 00FF00F7363636      <1>
  3663 00016724 363637303736363600- <1>     db  036h, 036h, 037h, 030h, 037h, 036h, 036h, 036h, 000h, 000h, 0ffh, 000h, 0ffh, 000h, 000h, 000h
  3663 0001672D 00FF00FF000000      <1>
  3664 00016734 3636F700F736363618- <1>     db  036h, 036h, 0f7h, 000h, 0f7h, 036h, 036h, 036h, 018h, 018h, 0ffh, 000h, 0ffh, 000h, 000h, 000h
  3664 0001673D 18FF00FF000000      <1>
  3665 00016744 36363636FF00000000- <1>     db  036h, 036h, 036h, 036h, 0ffh, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0ffh, 018h, 018h, 018h
  3665 0001674D 00FF00FF181818      <1>
  3666 00016754 00000000FF36363636- <1>     db  000h, 000h, 000h, 000h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 03fh, 000h, 000h, 000h
  3666 0001675D 3636363F000000      <1>
  3667 00016764 18181F181F00000000- <1>     db  018h, 018h, 01fh, 018h, 01fh, 000h, 000h, 000h, 000h, 000h, 01fh, 018h, 01fh, 018h, 018h, 018h
  3667 0001676D 001F181F181818      <1>
  3668 00016774 000000003F36363636- <1>     db  000h, 000h, 000h, 000h, 03fh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 036h, 036h, 036h
  3668 0001677D 363636FF363636      <1>
  3669 00016784 1818FF18FF18181818- <1>     db  018h, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h, 000h, 000h, 000h
  3669 0001678D 181818F8000000      <1>
  3670 00016794 000000001F181818FF- <1>     db  000h, 000h, 000h, 000h, 01fh, 018h, 018h, 018h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
  3670 0001679D FFFFFFFFFFFFFF      <1>
  3671 000167A4 00000000FFFFFFFFF0- <1>     db  000h, 000h, 000h, 000h, 0ffh, 0ffh, 0ffh, 0ffh, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h
  3671 000167AD F0F0F0F0F0F0F0      <1>
  3672 000167B4 0F0F0F0F0F0F0F0FFF- <1>     db  00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 000h, 000h
  3672 000167BD FFFFFF00000000      <1>
  3673 000167C4 000076DCC8DC760000- <1>     db  000h, 000h, 076h, 0dch, 0c8h, 0dch, 076h, 000h, 000h, 078h, 0cch, 0f8h, 0cch, 0f8h, 0c0h, 0c0h
  3673 000167CD 78CCF8CCF8C0C0      <1>
  3674 000167D4 00FCCCC0C0C0C00000- <1>     db  000h, 0fch, 0cch, 0c0h, 0c0h, 0c0h, 0c0h, 000h, 000h, 0feh, 06ch, 06ch, 06ch, 06ch, 06ch, 000h
  3674 000167DD FE6C6C6C6C6C00      <1>
  3675 000167E4 FCCC603060CCFC0000- <1>     db  0fch, 0cch, 060h, 030h, 060h, 0cch, 0fch, 000h, 000h, 000h, 07eh, 0d8h, 0d8h, 0d8h, 070h, 000h
  3675 000167ED 007ED8D8D87000      <1>
  3676 000167F4 00666666667C60C000- <1>     db  000h, 066h, 066h, 066h, 066h, 07ch, 060h, 0c0h, 000h, 076h, 0dch, 018h, 018h, 018h, 018h, 000h
  3676 000167FD 76DC1818181800      <1>
  3677 00016804 FC3078CCCC7830FC38- <1>     db  0fch, 030h, 078h, 0cch, 0cch, 078h, 030h, 0fch, 038h, 06ch, 0c6h, 0feh, 0c6h, 06ch, 038h, 000h
  3677 0001680D 6CC6FEC66C3800      <1>
  3678 00016814 386CC6C66C6CEE001C- <1>     db  038h, 06ch, 0c6h, 0c6h, 06ch, 06ch, 0eeh, 000h, 01ch, 030h, 018h, 07ch, 0cch, 0cch, 078h, 000h
  3678 0001681D 30187CCCCC7800      <1>
  3679 00016824 00007EDBDB7E000006- <1>     db  000h, 000h, 07eh, 0dbh, 0dbh, 07eh, 000h, 000h, 006h, 00ch, 07eh, 0dbh, 0dbh, 07eh, 060h, 0c0h
  3679 0001682D 0C7EDBDB7E60C0      <1>
  3680 00016834 3860C0F8C060380078- <1>     db  038h, 060h, 0c0h, 0f8h, 0c0h, 060h, 038h, 000h, 078h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 000h
  3680 0001683D CCCCCCCCCCCC00      <1>
  3681 00016844 00FC00FC00FC000030- <1>     db  000h, 0fch, 000h, 0fch, 000h, 0fch, 000h, 000h, 030h, 030h, 0fch, 030h, 030h, 000h, 0fch, 000h
  3681 0001684D 30FC303000FC00      <1>
  3682 00016854 603018306000FC0018- <1>     db  060h, 030h, 018h, 030h, 060h, 000h, 0fch, 000h, 018h, 030h, 060h, 030h, 018h, 000h, 0fch, 000h
  3682 0001685D 3060301800FC00      <1>
  3683 00016864 0E1B1B181818181818- <1>     db  00eh, 01bh, 01bh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0d8h, 0d8h, 070h
  3683 0001686D 18181818D8D870      <1>
  3684 00016874 303000FC0030300000- <1>     db  030h, 030h, 000h, 0fch, 000h, 030h, 030h, 000h, 000h, 076h, 0dch, 000h, 076h, 0dch, 000h, 000h
  3684 0001687D 76DC0076DC0000      <1>
  3685 00016884 386C6C380000000000- <1>     db  038h, 06ch, 06ch, 038h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h
  3685 0001688D 00001818000000      <1>
  3686 00016894 00000000180000000F- <1>     db  000h, 000h, 000h, 000h, 018h, 000h, 000h, 000h, 00fh, 00ch, 00ch, 00ch, 0ech, 06ch, 03ch, 01ch
  3686 0001689D 0C0C0CEC6C3C1C      <1>
  3687 000168A4 786C6C6C6C00000070- <1>     db  078h, 06ch, 06ch, 06ch, 06ch, 000h, 000h, 000h, 070h, 018h, 030h, 060h, 078h, 000h, 000h, 000h
  3687 000168AD 18306078000000      <1>
  3688 000168B4 00003C3C3C3C000000- <1>     db  000h, 000h, 03ch, 03ch, 03ch, 03ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3688 000168BD 00000000000000      <1>
  3689                              <1> vgafont14:
  3690 000168C4 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3690 000168CD 00000000000000      <1>
  3691 000168D4 7E81A58181BD99817E- <1>     db  07eh, 081h, 0a5h, 081h, 081h, 0bdh, 099h, 081h, 07eh, 000h, 000h, 000h, 000h, 000h, 07eh, 0ffh
  3691 000168DD 00000000007EFF      <1>
  3692 000168E4 DBFFFFC3E7FF7E0000- <1>     db  0dbh, 0ffh, 0ffh, 0c3h, 0e7h, 0ffh, 07eh, 000h, 000h, 000h, 000h, 000h, 000h, 06ch, 0feh, 0feh
  3692 000168ED 000000006CFEFE      <1>
  3693 000168F4 FEFE7C381000000000- <1>     db  0feh, 0feh, 07ch, 038h, 010h, 000h, 000h, 000h, 000h, 000h, 000h, 010h, 038h, 07ch, 0feh, 07ch
  3693 000168FD 000010387CFE7C      <1>
  3694 00016904 381000000000000018- <1>     db  038h, 010h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 03ch, 03ch, 0e7h, 0e7h, 0e7h, 018h, 018h
  3694 0001690D 3C3CE7E7E71818      <1>
  3695 00016914 3C0000000000183C7E- <1>     db  03ch, 000h, 000h, 000h, 000h, 000h, 018h, 03ch, 07eh, 0ffh, 0ffh, 07eh, 018h, 018h, 03ch, 000h
  3695 0001691D FFFF7E18183C00      <1>
  3696 00016924 00000000000000183C- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 03ch, 03ch, 018h, 000h, 000h, 000h, 000h, 000h
  3696 0001692D 3C180000000000      <1>
  3697 00016934 FFFFFFFFFFE7C3C3E7- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0e7h, 0c3h, 0c3h, 0e7h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h
  3697 0001693D FFFFFFFFFF0000      <1>
  3698 00016944 00003C664242663C00- <1>     db  000h, 000h, 03ch, 066h, 042h, 042h, 066h, 03ch, 000h, 000h, 000h, 000h, 0ffh, 0ffh, 0ffh, 0ffh
  3698 0001694D 000000FFFFFFFF      <1>
  3699 00016954 C399BDBD99C3FFFFFF- <1>     db  0c3h, 099h, 0bdh, 0bdh, 099h, 0c3h, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 01eh, 00eh, 01ah, 032h
  3699 0001695D FF00001E0E1A32      <1>
  3700 00016964 78CCCCCC7800000000- <1>     db  078h, 0cch, 0cch, 0cch, 078h, 000h, 000h, 000h, 000h, 000h, 03ch, 066h, 066h, 066h, 03ch, 018h
  3700 0001696D 003C6666663C18      <1>
  3701 00016974 7E181800000000003F- <1>     db  07eh, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 03fh, 033h, 03fh, 030h, 030h, 030h, 070h, 0f0h
  3701 0001697D 333F30303070F0      <1>
  3702 00016984 E000000000007F637F- <1>     db  0e0h, 000h, 000h, 000h, 000h, 000h, 07fh, 063h, 07fh, 063h, 063h, 063h, 067h, 0e7h, 0e6h, 0c0h
  3702 0001698D 63636367E7E6C0      <1>
  3703 00016994 000000001818DB3CE7- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 0dbh, 03ch, 0e7h, 03ch, 0dbh, 018h, 018h, 000h, 000h, 000h
  3703 0001699D 3CDB1818000000      <1>
  3704 000169A4 000080C0E0F8FEF8E0- <1>     db  000h, 000h, 080h, 0c0h, 0e0h, 0f8h, 0feh, 0f8h, 0e0h, 0c0h, 080h, 000h, 000h, 000h, 000h, 000h
  3704 000169AD C0800000000000      <1>
  3705 000169B4 02060E3EFE3E0E0602- <1>     db  002h, 006h, 00eh, 03eh, 0feh, 03eh, 00eh, 006h, 002h, 000h, 000h, 000h, 000h, 000h, 018h, 03ch
  3705 000169BD 0000000000183C      <1>
  3706 000169C4 7E1818187E3C180000- <1>     db  07eh, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 066h, 066h
  3706 000169CD 00000066666666      <1>
  3707 000169D4 666600666600000000- <1>     db  066h, 066h, 000h, 066h, 066h, 000h, 000h, 000h, 000h, 000h, 07fh, 0dbh, 0dbh, 0dbh, 07bh, 01bh
  3707 000169DD 007FDBDBDB7B1B      <1>
  3708 000169E4 1B1B1B000000007CC6- <1>     db  01bh, 01bh, 01bh, 000h, 000h, 000h, 000h, 07ch, 0c6h, 060h, 038h, 06ch, 0c6h, 0c6h, 06ch, 038h
  3708 000169ED 60386CC6C66C38      <1>
  3709 000169F4 0CC67C000000000000- <1>     db  00ch, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 0feh, 0feh, 000h
  3709 000169FD 000000FEFEFE00      <1>
  3710 00016A04 00000000183C7E1818- <1>     db  000h, 000h, 000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 07eh, 03ch, 018h, 07eh, 000h, 000h
  3710 00016A0D 187E3C187E0000      <1>
  3711 00016A14 0000183C7E18181818- <1>     db  000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h, 000h
  3711 00016A1D 18180000000000      <1>
  3712 00016A24 1818181818187E3C18- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3712 00016A2D 00000000000000      <1>
  3713 00016A34 180CFE0C1800000000- <1>     db  018h, 00ch, 0feh, 00ch, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 030h, 060h
  3713 00016A3D 00000000003060      <1>
  3714 00016A44 FE6030000000000000- <1>     db  0feh, 060h, 030h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0c0h, 0c0h, 0c0h
  3714 00016A4D 00000000C0C0C0      <1>
  3715 00016A54 FE0000000000000000- <1>     db  0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 028h, 06ch, 0feh, 06ch, 028h, 000h
  3715 00016A5D 00286CFE6C2800      <1>
  3716 00016A64 000000000000001038- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 010h, 038h, 038h, 07ch, 07ch, 0feh, 0feh, 000h, 000h
  3716 00016A6D 387C7CFEFE0000      <1>
  3717 00016A74 0000000000FEFE7C7C- <1>     db  000h, 000h, 000h, 000h, 000h, 0feh, 0feh, 07ch, 07ch, 038h, 038h, 010h, 000h, 000h, 000h, 000h
  3717 00016A7D 38381000000000      <1>
  3718 00016A84 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3718 00016A8D 00000000000000      <1>
  3719 00016A94 183C3C3C1818001818- <1>     db  018h, 03ch, 03ch, 03ch, 018h, 018h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 066h, 066h, 066h
  3719 00016A9D 00000000666666      <1>
  3720 00016AA4 240000000000000000- <1>     db  024h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 06ch, 06ch, 0feh, 06ch
  3720 00016AAD 0000006C6CFE6C      <1>
  3721 00016AB4 6C6CFE6C6C00000018- <1>     db  06ch, 06ch, 0feh, 06ch, 06ch, 000h, 000h, 000h, 018h, 018h, 07ch, 0c6h, 0c2h, 0c0h, 07ch, 006h
  3721 00016ABD 187CC6C2C07C06      <1>
  3722 00016AC4 86C67C181800000000- <1>     db  086h, 0c6h, 07ch, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 0c2h, 0c6h, 00ch, 018h, 030h, 066h
  3722 00016ACD 00C2C60C183066      <1>
  3723 00016AD4 C60000000000386C6C- <1>     db  0c6h, 000h, 000h, 000h, 000h, 000h, 038h, 06ch, 06ch, 038h, 076h, 0dch, 0cch, 0cch, 076h, 000h
  3723 00016ADD 3876DCCCCC7600      <1>
  3724 00016AE4 000000303030600000- <1>     db  000h, 000h, 000h, 030h, 030h, 030h, 060h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3724 00016AED 00000000000000      <1>
  3725 00016AF4 00000C183030303030- <1>     db  000h, 000h, 00ch, 018h, 030h, 030h, 030h, 030h, 030h, 018h, 00ch, 000h, 000h, 000h, 000h, 000h
  3725 00016AFD 180C0000000000      <1>
  3726 00016B04 30180C0C0C0C0C1830- <1>     db  030h, 018h, 00ch, 00ch, 00ch, 00ch, 00ch, 018h, 030h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3726 00016B0D 00000000000000      <1>
  3727 00016B14 663CFF3C6600000000- <1>     db  066h, 03ch, 0ffh, 03ch, 066h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h
  3727 00016B1D 00000000001818      <1>
  3728 00016B24 7E1818000000000000- <1>     db  07eh, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3728 00016B2D 00000000000000      <1>
  3729 00016B34 181818300000000000- <1>     db  018h, 018h, 018h, 030h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 000h, 000h, 000h
  3729 00016B3D 000000FE000000      <1>
  3730 00016B44 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h
  3730 00016B4D 00000000181800      <1>
  3731 00016B54 0000000002060C1830- <1>     db  000h, 000h, 000h, 000h, 002h, 006h, 00ch, 018h, 030h, 060h, 0c0h, 080h, 000h, 000h, 000h, 000h
  3731 00016B5D 60C08000000000      <1>
  3732 00016B64 00007CC6CEDEF6E6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0ceh, 0deh, 0f6h, 0e6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h
  3732 00016B6D C67C0000000000      <1>
  3733 00016B74 18387818181818187E- <1>     db  018h, 038h, 078h, 018h, 018h, 018h, 018h, 018h, 07eh, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h
  3733 00016B7D 00000000007CC6      <1>
  3734 00016B84 060C183060C6FE0000- <1>     db  006h, 00ch, 018h, 030h, 060h, 0c6h, 0feh, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 006h, 006h
  3734 00016B8D 0000007CC60606      <1>
  3735 00016B94 3C0606C67C00000000- <1>     db  03ch, 006h, 006h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 00ch, 01ch, 03ch, 06ch, 0cch, 0feh
  3735 00016B9D 000C1C3C6CCCFE      <1>
  3736 00016BA4 0C0C1E0000000000FE- <1>     db  00ch, 00ch, 01eh, 000h, 000h, 000h, 000h, 000h, 0feh, 0c0h, 0c0h, 0c0h, 0fch, 006h, 006h, 0c6h
  3736 00016BAD C0C0C0FC0606C6      <1>
  3737 00016BB4 7C00000000003860C0- <1>     db  07ch, 000h, 000h, 000h, 000h, 000h, 038h, 060h, 0c0h, 0c0h, 0fch, 0c6h, 0c6h, 0c6h, 07ch, 000h
  3737 00016BBD C0FCC6C6C67C00      <1>
  3738 00016BC4 00000000FEC6060C18- <1>     db  000h, 000h, 000h, 000h, 0feh, 0c6h, 006h, 00ch, 018h, 030h, 030h, 030h, 030h, 000h, 000h, 000h
  3738 00016BCD 30303030000000      <1>
  3739 00016BD4 00007CC6C6C67CC6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 07ch, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h
  3739 00016BDD C67C0000000000      <1>
  3740 00016BE4 7CC6C6C67E06060C78- <1>     db  07ch, 0c6h, 0c6h, 0c6h, 07eh, 006h, 006h, 00ch, 078h, 000h, 000h, 000h, 000h, 000h, 000h, 018h
  3740 00016BED 00000000000018      <1>
  3741 00016BF4 180000001818000000- <1>     db  018h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h
  3741 00016BFD 00000000181800      <1>
  3742 00016C04 000018183000000000- <1>     db  000h, 000h, 018h, 018h, 030h, 000h, 000h, 000h, 000h, 000h, 006h, 00ch, 018h, 030h, 060h, 030h
  3742 00016C0D 00060C18306030      <1>
  3743 00016C14 180C06000000000000- <1>     db  018h, 00ch, 006h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07eh, 000h, 000h, 07eh, 000h
  3743 00016C1D 00007E00007E00      <1>
  3744 00016C24 000000000000603018- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 060h, 030h, 018h, 00ch, 006h, 00ch, 018h, 030h, 060h, 000h
  3744 00016C2D 0C060C18306000      <1>
  3745 00016C34 000000007CC6C60C18- <1>     db  000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 00ch, 018h, 018h, 000h, 018h, 018h, 000h, 000h, 000h
  3745 00016C3D 18001818000000      <1>
  3746 00016C44 00007CC6C6DEDEDEDC- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0deh, 0deh, 0deh, 0dch, 0c0h, 07ch, 000h, 000h, 000h, 000h, 000h
  3746 00016C4D C07C0000000000      <1>
  3747 00016C54 10386CC6C6FEC6C6C6- <1>     db  010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h, 000h, 0fch, 066h
  3747 00016C5D 0000000000FC66      <1>
  3748 00016C64 66667C666666FC0000- <1>     db  066h, 066h, 07ch, 066h, 066h, 066h, 0fch, 000h, 000h, 000h, 000h, 000h, 03ch, 066h, 0c2h, 0c0h
  3748 00016C6D 0000003C66C2C0      <1>
  3749 00016C74 C0C0C2663C00000000- <1>     db  0c0h, 0c0h, 0c2h, 066h, 03ch, 000h, 000h, 000h, 000h, 000h, 0f8h, 06ch, 066h, 066h, 066h, 066h
  3749 00016C7D 00F86C66666666      <1>
  3750 00016C84 666CF80000000000FE- <1>     db  066h, 06ch, 0f8h, 000h, 000h, 000h, 000h, 000h, 0feh, 066h, 062h, 068h, 078h, 068h, 062h, 066h
  3750 00016C8D 66626878686266      <1>
  3751 00016C94 FE0000000000FE6662- <1>     db  0feh, 000h, 000h, 000h, 000h, 000h, 0feh, 066h, 062h, 068h, 078h, 068h, 060h, 060h, 0f0h, 000h
  3751 00016C9D 6878686060F000      <1>
  3752 00016CA4 000000003C66C2C0C0- <1>     db  000h, 000h, 000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0deh, 0c6h, 066h, 03ah, 000h, 000h, 000h
  3752 00016CAD DEC6663A000000      <1>
  3753 00016CB4 0000C6C6C6C6FEC6C6- <1>     db  000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h, 000h
  3753 00016CBD C6C60000000000      <1>
  3754 00016CC4 3C181818181818183C- <1>     db  03ch, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 01eh, 00ch
  3754 00016CCD 00000000001E0C      <1>
  3755 00016CD4 0C0C0C0CCCCC780000- <1>     db  00ch, 00ch, 00ch, 00ch, 0cch, 0cch, 078h, 000h, 000h, 000h, 000h, 000h, 0e6h, 066h, 06ch, 06ch
  3755 00016CDD 000000E6666C6C      <1>
  3756 00016CE4 786C6C66E600000000- <1>     db  078h, 06ch, 06ch, 066h, 0e6h, 000h, 000h, 000h, 000h, 000h, 0f0h, 060h, 060h, 060h, 060h, 060h
  3756 00016CED 00F06060606060      <1>
  3757 00016CF4 6266FE0000000000C6- <1>     db  062h, 066h, 0feh, 000h, 000h, 000h, 000h, 000h, 0c6h, 0eeh, 0feh, 0feh, 0d6h, 0c6h, 0c6h, 0c6h
  3757 00016CFD EEFEFED6C6C6C6      <1>
  3758 00016D04 C60000000000C6E6F6- <1>     db  0c6h, 000h, 000h, 000h, 000h, 000h, 0c6h, 0e6h, 0f6h, 0feh, 0deh, 0ceh, 0c6h, 0c6h, 0c6h, 000h
  3758 00016D0D FEDECEC6C6C600      <1>
  3759 00016D14 00000000386CC6C6C6- <1>     db  000h, 000h, 000h, 000h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 06ch, 038h, 000h, 000h, 000h
  3759 00016D1D C6C66C38000000      <1>
  3760 00016D24 0000FC6666667C6060- <1>     db  000h, 000h, 0fch, 066h, 066h, 066h, 07ch, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h, 000h
  3760 00016D2D 60F00000000000      <1>
  3761 00016D34 7CC6C6C6C6D6DE7C0C- <1>     db  07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0d6h, 0deh, 07ch, 00ch, 00eh, 000h, 000h, 000h, 000h, 0fch, 066h
  3761 00016D3D 0E00000000FC66      <1>
  3762 00016D44 66667C6C6666E60000- <1>     db  066h, 066h, 07ch, 06ch, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 060h
  3762 00016D4D 0000007CC6C660      <1>
  3763 00016D54 380CC6C67C00000000- <1>     db  038h, 00ch, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 07eh, 07eh, 05ah, 018h, 018h, 018h
  3763 00016D5D 007E7E5A181818      <1>
  3764 00016D64 18183C0000000000C6- <1>     db  018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h
  3764 00016D6D C6C6C6C6C6C6C6      <1>
  3765 00016D74 7C0000000000C6C6C6- <1>     db  07ch, 000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 06ch, 038h, 010h, 000h
  3765 00016D7D C6C6C66C381000      <1>
  3766 00016D84 00000000C6C6C6C6D6- <1>     db  000h, 000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0d6h, 0d6h, 0feh, 07ch, 06ch, 000h, 000h, 000h
  3766 00016D8D D6FE7C6C000000      <1>
  3767 00016D94 0000C6C66C3838386C- <1>     db  000h, 000h, 0c6h, 0c6h, 06ch, 038h, 038h, 038h, 06ch, 0c6h, 0c6h, 000h, 000h, 000h, 000h, 000h
  3767 00016D9D C6C60000000000      <1>
  3768 00016DA4 666666663C1818183C- <1>     db  066h, 066h, 066h, 066h, 03ch, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 0feh, 0c6h
  3768 00016DAD 0000000000FEC6      <1>
  3769 00016DB4 8C183060C2C6FE0000- <1>     db  08ch, 018h, 030h, 060h, 0c2h, 0c6h, 0feh, 000h, 000h, 000h, 000h, 000h, 03ch, 030h, 030h, 030h
  3769 00016DBD 0000003C303030      <1>
  3770 00016DC4 303030303C00000000- <1>     db  030h, 030h, 030h, 030h, 03ch, 000h, 000h, 000h, 000h, 000h, 080h, 0c0h, 0e0h, 070h, 038h, 01ch
  3770 00016DCD 0080C0E070381C      <1>
  3771 00016DD4 0E060200000000003C- <1>     db  00eh, 006h, 002h, 000h, 000h, 000h, 000h, 000h, 03ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch
  3771 00016DDD 0C0C0C0C0C0C0C      <1>
  3772 00016DE4 3C00000010386CC600- <1>     db  03ch, 000h, 000h, 000h, 010h, 038h, 06ch, 0c6h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3772 00016DED 00000000000000      <1>
  3773 00016DF4 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h
  3773 00016DFD 0000000000FF00      <1>
  3774 00016E04 303018000000000000- <1>     db  030h, 030h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3774 00016E0D 00000000000000      <1>
  3775 00016E14 000000780C7CCCCC76- <1>     db  000h, 000h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 000h, 0e0h, 060h
  3775 00016E1D 0000000000E060      <1>
  3776 00016E24 60786C6666667C0000- <1>     db  060h, 078h, 06ch, 066h, 066h, 066h, 07ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch
  3776 00016E2D 0000000000007C      <1>
  3777 00016E34 C6C0C0C67C00000000- <1>     db  0c6h, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 01ch, 00ch, 00ch, 03ch, 06ch, 0cch
  3777 00016E3D 001C0C0C3C6CCC      <1>
  3778 00016E44 CCCC76000000000000- <1>     db  0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h
  3778 00016E4D 00007CC6FEC0C6      <1>
  3779 00016E54 7C0000000000386C64- <1>     db  07ch, 000h, 000h, 000h, 000h, 000h, 038h, 06ch, 064h, 060h, 0f0h, 060h, 060h, 060h, 0f0h, 000h
  3779 00016E5D 60F0606060F000      <1>
  3780 00016E64 0000000000000076CC- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 076h, 0cch, 0cch, 0cch, 07ch, 00ch, 0cch, 078h, 000h
  3780 00016E6D CCCC7C0CCC7800      <1>
  3781 00016E74 0000E060606C766666- <1>     db  000h, 000h, 0e0h, 060h, 060h, 06ch, 076h, 066h, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h, 000h
  3781 00016E7D 66E60000000000      <1>
  3782 00016E84 18180038181818183C- <1>     db  018h, 018h, 000h, 038h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 006h, 006h
  3782 00016E8D 00000000000606      <1>
  3783 00016E94 000E0606060666663C- <1>     db  000h, 00eh, 006h, 006h, 006h, 006h, 066h, 066h, 03ch, 000h, 000h, 000h, 0e0h, 060h, 060h, 066h
  3783 00016E9D 000000E0606066      <1>
  3784 00016EA4 6C786C66E600000000- <1>     db  06ch, 078h, 06ch, 066h, 0e6h, 000h, 000h, 000h, 000h, 000h, 038h, 018h, 018h, 018h, 018h, 018h
  3784 00016EAD 00381818181818      <1>
  3785 00016EB4 18183C000000000000- <1>     db  018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ech, 0feh, 0d6h, 0d6h, 0d6h
  3785 00016EBD 0000ECFED6D6D6      <1>
  3786 00016EC4 C60000000000000000- <1>     db  0c6h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0dch, 066h, 066h, 066h, 066h, 066h, 000h
  3786 00016ECD DC666666666600      <1>
  3787 00016ED4 000000000000007CC6- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h
  3787 00016EDD C6C6C67C000000      <1>
  3788 00016EE4 0000000000DC666666- <1>     db  000h, 000h, 000h, 000h, 000h, 0dch, 066h, 066h, 066h, 07ch, 060h, 060h, 0f0h, 000h, 000h, 000h
  3788 00016EED 7C6060F0000000      <1>
  3789 00016EF4 00000076CCCCCC7C0C- <1>     db  000h, 000h, 000h, 076h, 0cch, 0cch, 0cch, 07ch, 00ch, 00ch, 01eh, 000h, 000h, 000h, 000h, 000h
  3789 00016EFD 0C1E0000000000      <1>
  3790 00016F04 00DC76666060F00000- <1>     db  000h, 0dch, 076h, 066h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch
  3790 00016F0D 0000000000007C      <1>
  3791 00016F14 C6701CC67C00000000- <1>     db  0c6h, 070h, 01ch, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 010h, 030h, 030h, 0fch, 030h, 030h
  3791 00016F1D 00103030FC3030      <1>
  3792 00016F24 30361C000000000000- <1>     db  030h, 036h, 01ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch
  3792 00016F2D 0000CCCCCCCCCC      <1>
  3793 00016F34 760000000000000000- <1>     db  076h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 066h, 066h, 03ch, 018h, 000h
  3793 00016F3D 666666663C1800      <1>
  3794 00016F44 00000000000000C6C6- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 0d6h, 0d6h, 0feh, 06ch, 000h, 000h, 000h
  3794 00016F4D D6D6FE6C000000      <1>
  3795 00016F54 0000000000C66C3838- <1>     db  000h, 000h, 000h, 000h, 000h, 0c6h, 06ch, 038h, 038h, 06ch, 0c6h, 000h, 000h, 000h, 000h, 000h
  3795 00016F5D 6CC60000000000      <1>
  3796 00016F64 000000C6C6C6C67E06- <1>     db  000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 07eh, 006h, 00ch, 0f8h, 000h, 000h, 000h, 000h, 000h
  3796 00016F6D 0CF80000000000      <1>
  3797 00016F74 00FECC183066FE0000- <1>     db  000h, 0feh, 0cch, 018h, 030h, 066h, 0feh, 000h, 000h, 000h, 000h, 000h, 00eh, 018h, 018h, 018h
  3797 00016F7D 0000000E181818      <1>
  3798 00016F84 701818180E00000000- <1>     db  070h, 018h, 018h, 018h, 00eh, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 000h, 018h
  3798 00016F8D 00181818180018      <1>
  3799 00016F94 181818000000000070- <1>     db  018h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 070h, 018h, 018h, 018h, 00eh, 018h, 018h, 018h
  3799 00016F9D 1818180E181818      <1>
  3800 00016FA4 70000000000076DC00- <1>     db  070h, 000h, 000h, 000h, 000h, 000h, 076h, 0dch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3800 00016FAD 00000000000000      <1>
  3801 00016FB4 00000000000010386C- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 000h, 000h, 000h, 000h
  3801 00016FBD C6C6FE00000000      <1>
  3802 00016FC4 00003C66C2C0C0C266- <1>     db  000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0c2h, 066h, 03ch, 00ch, 006h, 07ch, 000h, 000h, 000h
  3802 00016FCD 3C0C067C000000      <1>
  3803 00016FD4 CCCC00CCCCCCCCCC76- <1>     db  0cch, 0cch, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 00ch, 018h, 030h
  3803 00016FDD 000000000C1830      <1>
  3804 00016FE4 007CC6FEC0C67C0000- <1>     db  000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 010h, 038h, 06ch, 000h, 078h
  3804 00016FED 000010386C0078      <1>
  3805 00016FF4 0C7CCCCC7600000000- <1>     db  00ch, 07ch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 000h, 0cch, 0cch, 000h, 078h, 00ch, 07ch
  3805 00016FFD 00CCCC00780C7C      <1>
  3806 00017004 CCCC76000000006030- <1>     db  0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 060h, 030h, 018h, 000h, 078h, 00ch, 07ch, 0cch, 0cch
  3806 0001700D 1800780C7CCCCC      <1>
  3807 00017014 7600000000386C3800- <1>     db  076h, 000h, 000h, 000h, 000h, 038h, 06ch, 038h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 076h, 000h
  3807 0001701D 780C7CCCCC7600      <1>
  3808 00017024 0000000000003C6660- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 03ch, 066h, 060h, 066h, 03ch, 00ch, 006h, 03ch, 000h, 000h
  3808 0001702D 663C0C063C0000      <1>
  3809 00017034 0010386C007CC6FEC0- <1>     db  000h, 010h, 038h, 06ch, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h
  3809 0001703D C67C0000000000      <1>
  3810 00017044 CCCC007CC6FEC0C67C- <1>     db  0cch, 0cch, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 060h, 030h, 018h
  3810 0001704D 00000000603018      <1>
  3811 00017054 007CC6FEC0C67C0000- <1>     db  000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 000h, 038h
  3811 0001705D 00000066660038      <1>
  3812 00017064 181818183C00000000- <1>     db  018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 018h, 03ch, 066h, 000h, 038h, 018h, 018h
  3812 0001706D 183C6600381818      <1>
  3813 00017074 18183C000000006030- <1>     db  018h, 018h, 03ch, 000h, 000h, 000h, 000h, 060h, 030h, 018h, 000h, 038h, 018h, 018h, 018h, 018h
  3813 0001707D 18003818181818      <1>
  3814 00017084 3C00000000C6C61038- <1>     db  03ch, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 000h
  3814 0001708D 6CC6C6FEC6C600      <1>
  3815 00017094 0000386C3800386CC6- <1>     db  000h, 000h, 038h, 06ch, 038h, 000h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 000h, 000h, 000h
  3815 0001709D C6FEC6C6000000      <1>
  3816 000170A4 18306000FE66607C60- <1>     db  018h, 030h, 060h, 000h, 0feh, 066h, 060h, 07ch, 060h, 066h, 0feh, 000h, 000h, 000h, 000h, 000h
  3816 000170AD 66FE0000000000      <1>
  3817 000170B4 0000CC76367ED8D86E- <1>     db  000h, 000h, 0cch, 076h, 036h, 07eh, 0d8h, 0d8h, 06eh, 000h, 000h, 000h, 000h, 000h, 03eh, 06ch
  3817 000170BD 00000000003E6C      <1>
  3818 000170C4 CCCCFECCCCCCCE0000- <1>     db  0cch, 0cch, 0feh, 0cch, 0cch, 0cch, 0ceh, 000h, 000h, 000h, 000h, 010h, 038h, 06ch, 000h, 07ch
  3818 000170CD 000010386C007C      <1>
  3819 000170D4 C6C6C6C67C00000000- <1>     db  0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 000h, 07ch, 0c6h, 0c6h
  3819 000170DD 00C6C6007CC6C6      <1>
  3820 000170E4 C6C67C000000006030- <1>     db  0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 060h, 030h, 018h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h
  3820 000170ED 18007CC6C6C6C6      <1>
  3821 000170F4 7C000000003078CC00- <1>     db  07ch, 000h, 000h, 000h, 000h, 030h, 078h, 0cch, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h
  3821 000170FD CCCCCCCCCC7600      <1>
  3822 00017104 00000060301800CCCC- <1>     db  000h, 000h, 000h, 060h, 030h, 018h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h
  3822 0001710D CCCCCC76000000      <1>
  3823 00017114 0000C6C600C6C6C6C6- <1>     db  000h, 000h, 0c6h, 0c6h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 07eh, 006h, 00ch, 078h, 000h, 000h, 0c6h
  3823 0001711D 7E060C780000C6      <1>
  3824 00017124 C6386CC6C6C6C66C38- <1>     db  0c6h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 0c6h, 06ch, 038h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 000h
  3824 0001712D 00000000C6C600      <1>
  3825 00017134 C6C6C6C6C6C67C0000- <1>     db  0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 018h, 018h, 03ch, 066h, 060h
  3825 0001713D 000018183C6660      <1>
  3826 00017144 60663C181800000000- <1>     db  060h, 066h, 03ch, 018h, 018h, 000h, 000h, 000h, 000h, 038h, 06ch, 064h, 060h, 0f0h, 060h, 060h
  3826 0001714D 386C6460F06060      <1>
  3827 00017154 60E6FC000000000066- <1>     db  060h, 0e6h, 0fch, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 03ch, 018h, 07eh, 018h, 07eh, 018h
  3827 0001715D 663C187E187E18      <1>
  3828 00017164 1800000000F8CCCCF8- <1>     db  018h, 000h, 000h, 000h, 000h, 0f8h, 0cch, 0cch, 0f8h, 0c4h, 0cch, 0deh, 0cch, 0cch, 0c6h, 000h
  3828 0001716D C4CCDECCCCC600      <1>
  3829 00017174 0000000E1B1818187E- <1>     db  000h, 000h, 000h, 00eh, 01bh, 018h, 018h, 018h, 07eh, 018h, 018h, 018h, 018h, 0d8h, 070h, 000h
  3829 0001717D 18181818D87000      <1>
  3830 00017184 0018306000780C7CCC- <1>     db  000h, 018h, 030h, 060h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 00ch
  3830 0001718D CC76000000000C      <1>
  3831 00017194 18300038181818183C- <1>     db  018h, 030h, 000h, 038h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 018h, 030h, 060h
  3831 0001719D 00000000183060      <1>
  3832 000171A4 007CC6C6C6C67C0000- <1>     db  000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 018h, 030h, 060h, 000h, 0cch
  3832 000171AD 000018306000CC      <1>
  3833 000171B4 CCCCCCCC7600000000- <1>     db  0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 000h, 076h, 0dch, 000h, 0dch, 066h, 066h
  3833 000171BD 0076DC00DC6666      <1>
  3834 000171C4 66666600000076DC00- <1>     db  066h, 066h, 066h, 000h, 000h, 000h, 076h, 0dch, 000h, 0c6h, 0e6h, 0f6h, 0feh, 0deh, 0ceh, 0c6h
  3834 000171CD C6E6F6FEDECEC6      <1>
  3835 000171D4 C6000000003C6C6C3E- <1>     db  0c6h, 000h, 000h, 000h, 000h, 03ch, 06ch, 06ch, 03eh, 000h, 07eh, 000h, 000h, 000h, 000h, 000h
  3835 000171DD 007E0000000000      <1>
  3836 000171E4 000000386C6C38007C- <1>     db  000h, 000h, 000h, 038h, 06ch, 06ch, 038h, 000h, 07ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3836 000171ED 00000000000000      <1>
  3837 000171F4 0000303000303060C6- <1>     db  000h, 000h, 030h, 030h, 000h, 030h, 030h, 060h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h
  3837 000171FD C67C0000000000      <1>
  3838 00017204 00000000FEC0C0C000- <1>     db  000h, 000h, 000h, 000h, 0feh, 0c0h, 0c0h, 0c0h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3838 0001720D 00000000000000      <1>
  3839 00017214 0000FE060606000000- <1>     db  000h, 000h, 0feh, 006h, 006h, 006h, 000h, 000h, 000h, 000h, 000h, 0c0h, 0c0h, 0c6h, 0cch, 0d8h
  3839 0001721D 0000C0C0C6CCD8      <1>
  3840 00017224 3060DC860C183E0000- <1>     db  030h, 060h, 0dch, 086h, 00ch, 018h, 03eh, 000h, 000h, 0c0h, 0c0h, 0c6h, 0cch, 0d8h, 030h, 066h
  3840 0001722D C0C0C6CCD83066      <1>
  3841 00017234 CE9E3E060600000018- <1>     db  0ceh, 09eh, 03eh, 006h, 006h, 000h, 000h, 000h, 018h, 018h, 000h, 018h, 018h, 03ch, 03ch, 03ch
  3841 0001723D 180018183C3C3C      <1>
  3842 00017244 180000000000000036- <1>     db  018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 036h, 06ch, 0d8h, 06ch, 036h, 000h, 000h, 000h
  3842 0001724D 6CD86C36000000      <1>
  3843 00017254 000000000000D86C36- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 0d8h, 06ch, 036h, 06ch, 0d8h, 000h, 000h, 000h, 000h, 000h
  3843 0001725D 6CD80000000000      <1>
  3844 00017264 114411441144114411- <1>     db  011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 055h, 0aah
  3844 0001726D 441144114455AA      <1>
  3845 00017274 55AA55AA55AA55AA55- <1>     db  055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 0ddh, 077h, 0ddh, 077h
  3845 0001727D AA55AADD77DD77      <1>
  3846 00017284 DD77DD77DD77DD77DD- <1>     db  0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 018h, 018h, 018h, 018h, 018h, 018h
  3846 0001728D 77181818181818      <1>
  3847 00017294 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h
  3847 0001729D 181818181818F8      <1>
  3848 000172A4 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 018h, 018h
  3848 000172AD 1818F818F81818      <1>
  3849 000172B4 181818183636363636- <1>     db  018h, 018h, 018h, 018h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0f6h, 036h, 036h, 036h, 036h
  3849 000172BD 3636F636363636      <1>
  3850 000172C4 363600000000000000- <1>     db  036h, 036h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 036h, 036h, 036h, 036h, 036h, 036h
  3850 000172CD FE363636363636      <1>
  3851 000172D4 0000000000F818F818- <1>     db  000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 036h, 036h
  3851 000172DD 18181818183636      <1>
  3852 000172E4 363636F606F6363636- <1>     db  036h, 036h, 036h, 0f6h, 006h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
  3852 000172ED 36363636363636      <1>
  3853 000172F4 363636363636363636- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 000h, 000h, 000h, 000h, 000h, 0feh
  3853 000172FD 360000000000FE      <1>
  3854 00017304 06F636363636363636- <1>     db  006h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0f6h, 006h, 0feh
  3854 0001730D 36363636F606FE      <1>
  3855 00017314 000000000000363636- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0feh, 000h, 000h
  3855 0001731D 36363636FE0000      <1>
  3856 00017324 000000001818181818- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 000h, 000h, 000h, 000h
  3856 0001732D F818F800000000      <1>
  3857 00017334 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h
  3857 0001733D F8181818181818      <1>
  3858 00017344 181818181818181F00- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h
  3858 0001734D 00000000001818      <1>
  3859 00017354 1818181818FF000000- <1>     db  018h, 018h, 018h, 018h, 018h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3859 0001735D 00000000000000      <1>
  3860 00017364 000000FF1818181818- <1>     db  000h, 000h, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
  3860 0001736D 18181818181818      <1>
  3861 00017374 181F18181818181800- <1>     db  018h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh
  3861 0001737D 000000000000FF      <1>
  3862 00017384 000000000000181818- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0ffh, 018h, 018h
  3862 0001738D 18181818FF1818      <1>
  3863 00017394 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 018h, 01fh, 018h, 018h, 018h, 018h
  3863 0001739D 1F181F18181818      <1>
  3864 000173A4 181836363636363636- <1>     db  018h, 018h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 037h, 036h, 036h, 036h, 036h, 036h, 036h
  3864 000173AD 37363636363636      <1>
  3865 000173B4 363636363637303F00- <1>     db  036h, 036h, 036h, 036h, 036h, 037h, 030h, 03fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3865 000173BD 00000000000000      <1>
  3866 000173C4 0000003F3037363636- <1>     db  000h, 000h, 000h, 03fh, 030h, 037h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
  3866 000173CD 36363636363636      <1>
  3867 000173D4 36F700FF0000000000- <1>     db  036h, 0f7h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh
  3867 000173DD 000000000000FF      <1>
  3868 000173E4 00F736363636363636- <1>     db  000h, 0f7h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 037h, 030h, 037h
  3868 000173ED 36363636373037      <1>
  3869 000173F4 363636363636000000- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0ffh, 000h, 000h
  3869 000173FD 0000FF00FF0000      <1>
  3870 00017404 000000003636363636- <1>     db  000h, 000h, 000h, 000h, 036h, 036h, 036h, 036h, 036h, 0f7h, 000h, 0f7h, 036h, 036h, 036h, 036h
  3870 0001740D F700F736363636      <1>
  3871 00017414 36361818181818FF00- <1>     db  036h, 036h, 018h, 018h, 018h, 018h, 018h, 0ffh, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h
  3871 0001741D FF000000000000      <1>
  3872 00017424 36363636363636FF00- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3872 0001742D 00000000000000      <1>
  3873 00017434 000000FF00FF181818- <1>     db  000h, 000h, 000h, 0ffh, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h
  3873 0001743D 18181800000000      <1>
  3874 00017444 000000FF3636363636- <1>     db  000h, 000h, 000h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
  3874 0001744D 36363636363636      <1>
  3875 00017454 363F00000000000018- <1>     db  036h, 03fh, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 018h, 01fh, 018h, 01fh
  3875 0001745D 181818181F181F      <1>
  3876 00017464 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 01fh, 018h, 01fh, 018h, 018h
  3876 0001746D 00001F181F1818      <1>
  3877 00017474 181818180000000000- <1>     db  018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 03fh, 036h, 036h, 036h, 036h
  3877 0001747D 00003F36363636      <1>
  3878 00017484 363636363636363636- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h
  3878 0001748D FF363636363636      <1>
  3879 00017494 1818181818FF18FF18- <1>     db  018h, 018h, 018h, 018h, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
  3879 0001749D 18181818181818      <1>
  3880 000174A4 1818181818F8000000- <1>     db  018h, 018h, 018h, 018h, 018h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3880 000174AD 00000000000000      <1>
  3881 000174B4 0000001F1818181818- <1>     db  000h, 000h, 000h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
  3881 000174BD 18FFFFFFFFFFFF      <1>
  3882 000174C4 FFFFFFFFFFFFFFFF00- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh
  3882 000174CD 000000000000FF      <1>
  3883 000174D4 FFFFFFFFFFFFF0F0F0- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h
  3883 000174DD F0F0F0F0F0F0F0      <1>
  3884 000174E4 F0F0F0F00F0F0F0F0F- <1>     db  0f0h, 0f0h, 0f0h, 0f0h, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh
  3884 000174ED 0F0F0F0F0F0F0F      <1>
  3885 000174F4 0F0FFFFFFFFFFFFFFF- <1>     db  00fh, 00fh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3885 000174FD 00000000000000      <1>
  3886 00017504 000000000076DCD8D8- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0dch, 0d8h, 0d8h, 0dch, 076h, 000h, 000h, 000h, 000h, 000h
  3886 0001750D DC760000000000      <1>
  3887 00017514 00007CC6FCC6C6FCC0- <1>     db  000h, 000h, 07ch, 0c6h, 0fch, 0c6h, 0c6h, 0fch, 0c0h, 0c0h, 040h, 000h, 000h, 000h, 0feh, 0c6h
  3887 0001751D C040000000FEC6      <1>
  3888 00017524 C6C0C0C0C0C0C00000- <1>     db  0c6h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 06ch
  3888 0001752D 0000000000FE6C      <1>
  3889 00017534 6C6C6C6C6C00000000- <1>     db  06ch, 06ch, 06ch, 06ch, 06ch, 000h, 000h, 000h, 000h, 000h, 0feh, 0c6h, 060h, 030h, 018h, 030h
  3889 0001753D 00FEC660301830      <1>
  3890 00017544 60C6FE000000000000- <1>     db  060h, 0c6h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07eh, 0d8h, 0d8h, 0d8h, 0d8h
  3890 0001754D 00007ED8D8D8D8      <1>
  3891 00017554 700000000000000066- <1>     db  070h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 066h, 066h, 07ch, 060h, 060h, 0c0h
  3891 0001755D 6666667C6060C0      <1>
  3892 00017564 00000000000076DC18- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 076h, 0dch, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h
  3892 0001756D 18181818000000      <1>
  3893 00017574 00007E183C6666663C- <1>     db  000h, 000h, 07eh, 018h, 03ch, 066h, 066h, 066h, 03ch, 018h, 07eh, 000h, 000h, 000h, 000h, 000h
  3893 0001757D 187E0000000000      <1>
  3894 00017584 386CC6C6FEC6C66C38- <1>     db  038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 06ch, 038h, 000h, 000h, 000h, 000h, 000h, 038h, 06ch
  3894 0001758D 0000000000386C      <1>
  3895 00017594 C6C6C66C6C6CEE0000- <1>     db  0c6h, 0c6h, 0c6h, 06ch, 06ch, 06ch, 0eeh, 000h, 000h, 000h, 000h, 000h, 01eh, 030h, 018h, 00ch
  3895 0001759D 0000001E30180C      <1>
  3896 000175A4 3E6666663C00000000- <1>     db  03eh, 066h, 066h, 066h, 03ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07eh, 0dbh, 0dbh
  3896 000175AD 000000007EDBDB      <1>
  3897 000175B4 7E0000000000000003- <1>     db  07eh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 003h, 006h, 07eh, 0dbh, 0dbh, 0f3h, 07eh, 060h
  3897 000175BD 067EDBDBF37E60      <1>
  3898 000175C4 C000000000001C3060- <1>     db  0c0h, 000h, 000h, 000h, 000h, 000h, 01ch, 030h, 060h, 060h, 07ch, 060h, 060h, 030h, 01ch, 000h
  3898 000175CD 607C6060301C00      <1>
  3899 000175D4 00000000007CC6C6C6- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h
  3899 000175DD C6C6C6C6000000      <1>
  3900 000175E4 000000FE0000FE0000- <1>     db  000h, 000h, 000h, 0feh, 000h, 000h, 0feh, 000h, 000h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h
  3900 000175ED FE000000000000      <1>
  3901 000175F4 0018187E18180000FF- <1>     db  000h, 018h, 018h, 07eh, 018h, 018h, 000h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 030h, 018h
  3901 000175FD 00000000003018      <1>
  3902 00017604 0C060C1830007E0000- <1>     db  00ch, 006h, 00ch, 018h, 030h, 000h, 07eh, 000h, 000h, 000h, 000h, 000h, 00ch, 018h, 030h, 060h
  3902 0001760D 0000000C183060      <1>
  3903 00017614 30180C007E00000000- <1>     db  030h, 018h, 00ch, 000h, 07eh, 000h, 000h, 000h, 000h, 000h, 00eh, 01bh, 01bh, 018h, 018h, 018h
  3903 0001761D 000E1B1B181818      <1>
  3904 00017624 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0d8h, 0d8h
  3904 0001762D 1818181818D8D8      <1>
  3905 00017634 700000000000001818- <1>     db  070h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h, 07eh, 000h, 018h, 018h, 000h, 000h
  3905 0001763D 007E0018180000      <1>
  3906 00017644 00000000000076DC00- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 076h, 0dch, 000h, 076h, 0dch, 000h, 000h, 000h, 000h, 000h
  3906 0001764D 76DC0000000000      <1>
  3907 00017654 00386C6C3800000000- <1>     db  000h, 038h, 06ch, 06ch, 038h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3907 0001765D 00000000000000      <1>
  3908 00017664 000000001818000000- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3908 0001766D 00000000000000      <1>
  3909 00017674 000000180000000000- <1>     db  000h, 000h, 000h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 00fh, 00ch, 00ch, 00ch, 00ch
  3909 0001767D 00000F0C0C0C0C      <1>
  3910 00017684 0CEC6C3C1C00000000- <1>     db  00ch, 0ech, 06ch, 03ch, 01ch, 000h, 000h, 000h, 000h, 0d8h, 06ch, 06ch, 06ch, 06ch, 06ch, 000h
  3910 0001768D D86C6C6C6C6C00      <1>
  3911 00017694 0000000000000070D8- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 070h, 0d8h, 030h, 060h, 0c8h, 0f8h, 000h, 000h, 000h
  3911 0001769D 3060C8F8000000      <1>
  3912 000176A4 00000000000000007C- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch, 07ch, 07ch, 07ch, 07ch, 07ch, 000h, 000h
  3912 000176AD 7C7C7C7C7C0000      <1>
  3913 000176B4 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3913 000176BD 00000000000000      <1>
  3914                              <1> vgafont16:
  3915 000176C4 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3915 000176CD 00000000000000      <1>
  3916 000176D4 00007E81A58181BD99- <1>     db  000h, 000h, 07eh, 081h, 0a5h, 081h, 081h, 0bdh, 099h, 081h, 081h, 07eh, 000h, 000h, 000h, 000h
  3916 000176DD 81817E00000000      <1>
  3917 000176E4 00007EFFDBFFFFC3E7- <1>     db  000h, 000h, 07eh, 0ffh, 0dbh, 0ffh, 0ffh, 0c3h, 0e7h, 0ffh, 0ffh, 07eh, 000h, 000h, 000h, 000h
  3917 000176ED FFFF7E00000000      <1>
  3918 000176F4 000000006CFEFEFEFE- <1>     db  000h, 000h, 000h, 000h, 06ch, 0feh, 0feh, 0feh, 0feh, 07ch, 038h, 010h, 000h, 000h, 000h, 000h
  3918 000176FD 7C381000000000      <1>
  3919 00017704 0000000010387CFE7C- <1>     db  000h, 000h, 000h, 000h, 010h, 038h, 07ch, 0feh, 07ch, 038h, 010h, 000h, 000h, 000h, 000h, 000h
  3919 0001770D 38100000000000      <1>
  3920 00017714 000000183C3CE7E7E7- <1>     db  000h, 000h, 000h, 018h, 03ch, 03ch, 0e7h, 0e7h, 0e7h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
  3920 0001771D 18183C00000000      <1>
  3921 00017724 000000183C7EFFFF7E- <1>     db  000h, 000h, 000h, 018h, 03ch, 07eh, 0ffh, 0ffh, 07eh, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
  3921 0001772D 18183C00000000      <1>
  3922 00017734 000000000000183C3C- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 018h, 03ch, 03ch, 018h, 000h, 000h, 000h, 000h, 000h, 000h
  3922 0001773D 18000000000000      <1>
  3923 00017744 FFFFFFFFFFFFE7C3C3- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0e7h, 0c3h, 0c3h, 0e7h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
  3923 0001774D E7FFFFFFFFFFFF      <1>
  3924 00017754 00000000003C664242- <1>     db  000h, 000h, 000h, 000h, 000h, 03ch, 066h, 042h, 042h, 066h, 03ch, 000h, 000h, 000h, 000h, 000h
  3924 0001775D 663C0000000000      <1>
  3925 00017764 FFFFFFFFFFC399BDBD- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0c3h, 099h, 0bdh, 0bdh, 099h, 0c3h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
  3925 0001776D 99C3FFFFFFFFFF      <1>
  3926 00017774 00001E0E1A3278CCCC- <1>     db  000h, 000h, 01eh, 00eh, 01ah, 032h, 078h, 0cch, 0cch, 0cch, 0cch, 078h, 000h, 000h, 000h, 000h
  3926 0001777D CCCC7800000000      <1>
  3927 00017784 00003C666666663C18- <1>     db  000h, 000h, 03ch, 066h, 066h, 066h, 066h, 03ch, 018h, 07eh, 018h, 018h, 000h, 000h, 000h, 000h
  3927 0001778D 7E181800000000      <1>
  3928 00017794 00003F333F30303030- <1>     db  000h, 000h, 03fh, 033h, 03fh, 030h, 030h, 030h, 030h, 070h, 0f0h, 0e0h, 000h, 000h, 000h, 000h
  3928 0001779D 70F0E000000000      <1>
  3929 000177A4 00007F637F63636363- <1>     db  000h, 000h, 07fh, 063h, 07fh, 063h, 063h, 063h, 063h, 067h, 0e7h, 0e6h, 0c0h, 000h, 000h, 000h
  3929 000177AD 67E7E6C0000000      <1>
  3930 000177B4 0000001818DB3CE73C- <1>     db  000h, 000h, 000h, 018h, 018h, 0dbh, 03ch, 0e7h, 03ch, 0dbh, 018h, 018h, 000h, 000h, 000h, 000h
  3930 000177BD DB181800000000      <1>
  3931 000177C4 0080C0E0F0F8FEF8F0- <1>     db  000h, 080h, 0c0h, 0e0h, 0f0h, 0f8h, 0feh, 0f8h, 0f0h, 0e0h, 0c0h, 080h, 000h, 000h, 000h, 000h
  3931 000177CD E0C08000000000      <1>
  3932 000177D4 0002060E1E3EFE3E1E- <1>     db  000h, 002h, 006h, 00eh, 01eh, 03eh, 0feh, 03eh, 01eh, 00eh, 006h, 002h, 000h, 000h, 000h, 000h
  3932 000177DD 0E060200000000      <1>
  3933 000177E4 0000183C7E1818187E- <1>     db  000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h, 000h, 000h, 000h, 000h
  3933 000177ED 3C180000000000      <1>
  3934 000177F4 000066666666666666- <1>     db  000h, 000h, 066h, 066h, 066h, 066h, 066h, 066h, 066h, 000h, 066h, 066h, 000h, 000h, 000h, 000h
  3934 000177FD 00666600000000      <1>
  3935 00017804 00007FDBDBDB7B1B1B- <1>     db  000h, 000h, 07fh, 0dbh, 0dbh, 0dbh, 07bh, 01bh, 01bh, 01bh, 01bh, 01bh, 000h, 000h, 000h, 000h
  3935 0001780D 1B1B1B00000000      <1>
  3936 00017814 007CC660386CC6C66C- <1>     db  000h, 07ch, 0c6h, 060h, 038h, 06ch, 0c6h, 0c6h, 06ch, 038h, 00ch, 0c6h, 07ch, 000h, 000h, 000h
  3936 0001781D 380CC67C000000      <1>
  3937 00017824 0000000000000000FE- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 0feh, 0feh, 0feh, 000h, 000h, 000h, 000h
  3937 0001782D FEFEFE00000000      <1>
  3938 00017834 0000183C7E1818187E- <1>     db  000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 07eh, 03ch, 018h, 07eh, 000h, 000h, 000h, 000h
  3938 0001783D 3C187E00000000      <1>
  3939 00017844 0000183C7E18181818- <1>     db  000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h
  3939 0001784D 18181800000000      <1>
  3940 00017854 000018181818181818- <1>     db  000h, 000h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h, 000h, 000h, 000h
  3940 0001785D 7E3C1800000000      <1>
  3941 00017864 0000000000180CFE0C- <1>     db  000h, 000h, 000h, 000h, 000h, 018h, 00ch, 0feh, 00ch, 018h, 000h, 000h, 000h, 000h, 000h, 000h
  3941 0001786D 18000000000000      <1>
  3942 00017874 00000000003060FE60- <1>     db  000h, 000h, 000h, 000h, 000h, 030h, 060h, 0feh, 060h, 030h, 000h, 000h, 000h, 000h, 000h, 000h
  3942 0001787D 30000000000000      <1>
  3943 00017884 000000000000C0C0C0- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 0c0h, 0c0h, 0c0h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h
  3943 0001788D FE000000000000      <1>
  3944 00017894 00000000002466FF66- <1>     db  000h, 000h, 000h, 000h, 000h, 024h, 066h, 0ffh, 066h, 024h, 000h, 000h, 000h, 000h, 000h, 000h
  3944 0001789D 24000000000000      <1>
  3945 000178A4 000000001038387C7C- <1>     db  000h, 000h, 000h, 000h, 010h, 038h, 038h, 07ch, 07ch, 0feh, 0feh, 000h, 000h, 000h, 000h, 000h
  3945 000178AD FEFE0000000000      <1>
  3946 000178B4 00000000FEFE7C7C38- <1>     db  000h, 000h, 000h, 000h, 0feh, 0feh, 07ch, 07ch, 038h, 038h, 010h, 000h, 000h, 000h, 000h, 000h
  3946 000178BD 38100000000000      <1>
  3947 000178C4 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3947 000178CD 00000000000000      <1>
  3948 000178D4 0000183C3C3C181818- <1>     db  000h, 000h, 018h, 03ch, 03ch, 03ch, 018h, 018h, 018h, 000h, 018h, 018h, 000h, 000h, 000h, 000h
  3948 000178DD 00181800000000      <1>
  3949 000178E4 006666662400000000- <1>     db  000h, 066h, 066h, 066h, 024h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3949 000178ED 00000000000000      <1>
  3950 000178F4 0000006C6CFE6C6C6C- <1>     db  000h, 000h, 000h, 06ch, 06ch, 0feh, 06ch, 06ch, 06ch, 0feh, 06ch, 06ch, 000h, 000h, 000h, 000h
  3950 000178FD FE6C6C00000000      <1>
  3951 00017904 18187CC6C2C07C0606- <1>     db  018h, 018h, 07ch, 0c6h, 0c2h, 0c0h, 07ch, 006h, 006h, 086h, 0c6h, 07ch, 018h, 018h, 000h, 000h
  3951 0001790D 86C67C18180000      <1>
  3952 00017914 00000000C2C60C1830- <1>     db  000h, 000h, 000h, 000h, 0c2h, 0c6h, 00ch, 018h, 030h, 060h, 0c6h, 086h, 000h, 000h, 000h, 000h
  3952 0001791D 60C68600000000      <1>
  3953 00017924 0000386C6C3876DCCC- <1>     db  000h, 000h, 038h, 06ch, 06ch, 038h, 076h, 0dch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
  3953 0001792D CCCC7600000000      <1>
  3954 00017934 003030306000000000- <1>     db  000h, 030h, 030h, 030h, 060h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3954 0001793D 00000000000000      <1>
  3955 00017944 00000C183030303030- <1>     db  000h, 000h, 00ch, 018h, 030h, 030h, 030h, 030h, 030h, 030h, 018h, 00ch, 000h, 000h, 000h, 000h
  3955 0001794D 30180C00000000      <1>
  3956 00017954 000030180C0C0C0C0C- <1>     db  000h, 000h, 030h, 018h, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 018h, 030h, 000h, 000h, 000h, 000h
  3956 0001795D 0C183000000000      <1>
  3957 00017964 0000000000663CFF3C- <1>     db  000h, 000h, 000h, 000h, 000h, 066h, 03ch, 0ffh, 03ch, 066h, 000h, 000h, 000h, 000h, 000h, 000h
  3957 0001796D 66000000000000      <1>
  3958 00017974 000000000018187E18- <1>     db  000h, 000h, 000h, 000h, 000h, 018h, 018h, 07eh, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h
  3958 0001797D 18000000000000      <1>
  3959 00017984 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 018h, 030h, 000h, 000h, 000h
  3959 0001798D 18181830000000      <1>
  3960 00017994 00000000000000FE00- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3960 0001799D 00000000000000      <1>
  3961 000179A4 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h
  3961 000179AD 00181800000000      <1>
  3962 000179B4 0000000002060C1830- <1>     db  000h, 000h, 000h, 000h, 002h, 006h, 00ch, 018h, 030h, 060h, 0c0h, 080h, 000h, 000h, 000h, 000h
  3962 000179BD 60C08000000000      <1>
  3963 000179C4 00003C66C3C3DBDBC3- <1>     db  000h, 000h, 03ch, 066h, 0c3h, 0c3h, 0dbh, 0dbh, 0c3h, 0c3h, 066h, 03ch, 000h, 000h, 000h, 000h
  3963 000179CD C3663C00000000      <1>
  3964 000179D4 000018387818181818- <1>     db  000h, 000h, 018h, 038h, 078h, 018h, 018h, 018h, 018h, 018h, 018h, 07eh, 000h, 000h, 000h, 000h
  3964 000179DD 18187E00000000      <1>
  3965 000179E4 00007CC6060C183060- <1>     db  000h, 000h, 07ch, 0c6h, 006h, 00ch, 018h, 030h, 060h, 0c0h, 0c6h, 0feh, 000h, 000h, 000h, 000h
  3965 000179ED C0C6FE00000000      <1>
  3966 000179F4 00007CC606063C0606- <1>     db  000h, 000h, 07ch, 0c6h, 006h, 006h, 03ch, 006h, 006h, 006h, 0c6h, 07ch, 000h, 000h, 000h, 000h
  3966 000179FD 06C67C00000000      <1>
  3967 00017A04 00000C1C3C6CCCFE0C- <1>     db  000h, 000h, 00ch, 01ch, 03ch, 06ch, 0cch, 0feh, 00ch, 00ch, 00ch, 01eh, 000h, 000h, 000h, 000h
  3967 00017A0D 0C0C1E00000000      <1>
  3968 00017A14 0000FEC0C0C0FC0606- <1>     db  000h, 000h, 0feh, 0c0h, 0c0h, 0c0h, 0fch, 006h, 006h, 006h, 0c6h, 07ch, 000h, 000h, 000h, 000h
  3968 00017A1D 06C67C00000000      <1>
  3969 00017A24 00003860C0C0FCC6C6- <1>     db  000h, 000h, 038h, 060h, 0c0h, 0c0h, 0fch, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
  3969 00017A2D C6C67C00000000      <1>
  3970 00017A34 0000FEC606060C1830- <1>     db  000h, 000h, 0feh, 0c6h, 006h, 006h, 00ch, 018h, 030h, 030h, 030h, 030h, 000h, 000h, 000h, 000h
  3970 00017A3D 30303000000000      <1>
  3971 00017A44 00007CC6C6C67CC6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
  3971 00017A4D C6C67C00000000      <1>
  3972 00017A54 00007CC6C6C67E0606- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 07eh, 006h, 006h, 006h, 00ch, 078h, 000h, 000h, 000h, 000h
  3972 00017A5D 060C7800000000      <1>
  3973 00017A64 000000001818000000- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h
  3973 00017A6D 18180000000000      <1>
  3974 00017A74 000000001818000000- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 018h, 018h, 030h, 000h, 000h, 000h, 000h
  3974 00017A7D 18183000000000      <1>
  3975 00017A84 000000060C18306030- <1>     db  000h, 000h, 000h, 006h, 00ch, 018h, 030h, 060h, 030h, 018h, 00ch, 006h, 000h, 000h, 000h, 000h
  3975 00017A8D 180C0600000000      <1>
  3976 00017A94 00000000007E00007E- <1>     db  000h, 000h, 000h, 000h, 000h, 07eh, 000h, 000h, 07eh, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  3976 00017A9D 00000000000000      <1>
  3977 00017AA4 0000006030180C060C- <1>     db  000h, 000h, 000h, 060h, 030h, 018h, 00ch, 006h, 00ch, 018h, 030h, 060h, 000h, 000h, 000h, 000h
  3977 00017AAD 18306000000000      <1>
  3978 00017AB4 00007CC6C60C181818- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 00ch, 018h, 018h, 018h, 000h, 018h, 018h, 000h, 000h, 000h, 000h
  3978 00017ABD 00181800000000      <1>
  3979 00017AC4 0000007CC6C6DEDEDE- <1>     db  000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0deh, 0deh, 0deh, 0dch, 0c0h, 07ch, 000h, 000h, 000h, 000h
  3979 00017ACD DCC07C00000000      <1>
  3980 00017AD4 000010386CC6C6FEC6- <1>     db  000h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
  3980 00017ADD C6C6C600000000      <1>
  3981 00017AE4 0000FC6666667C6666- <1>     db  000h, 000h, 0fch, 066h, 066h, 066h, 07ch, 066h, 066h, 066h, 066h, 0fch, 000h, 000h, 000h, 000h
  3981 00017AED 6666FC00000000      <1>
  3982 00017AF4 00003C66C2C0C0C0C0- <1>     db  000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0c0h, 0c0h, 0c2h, 066h, 03ch, 000h, 000h, 000h, 000h
  3982 00017AFD C2663C00000000      <1>
  3983 00017B04 0000F86C6666666666- <1>     db  000h, 000h, 0f8h, 06ch, 066h, 066h, 066h, 066h, 066h, 066h, 06ch, 0f8h, 000h, 000h, 000h, 000h
  3983 00017B0D 666CF800000000      <1>
  3984 00017B14 0000FE666268786860- <1>     db  000h, 000h, 0feh, 066h, 062h, 068h, 078h, 068h, 060h, 062h, 066h, 0feh, 000h, 000h, 000h, 000h
  3984 00017B1D 6266FE00000000      <1>
  3985 00017B24 0000FE666268786860- <1>     db  000h, 000h, 0feh, 066h, 062h, 068h, 078h, 068h, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h
  3985 00017B2D 6060F000000000      <1>
  3986 00017B34 00003C66C2C0C0DEC6- <1>     db  000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0deh, 0c6h, 0c6h, 066h, 03ah, 000h, 000h, 000h, 000h
  3986 00017B3D C6663A00000000      <1>
  3987 00017B44 0000C6C6C6C6FEC6C6- <1>     db  000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
  3987 00017B4D C6C6C600000000      <1>
  3988 00017B54 00003C181818181818- <1>     db  000h, 000h, 03ch, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
  3988 00017B5D 18183C00000000      <1>
  3989 00017B64 00001E0C0C0C0C0CCC- <1>     db  000h, 000h, 01eh, 00ch, 00ch, 00ch, 00ch, 00ch, 0cch, 0cch, 0cch, 078h, 000h, 000h, 000h, 000h
  3989 00017B6D CCCC7800000000      <1>
  3990 00017B74 0000E666666C78786C- <1>     db  000h, 000h, 0e6h, 066h, 066h, 06ch, 078h, 078h, 06ch, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h
  3990 00017B7D 6666E600000000      <1>
  3991 00017B84 0000F0606060606060- <1>     db  000h, 000h, 0f0h, 060h, 060h, 060h, 060h, 060h, 060h, 062h, 066h, 0feh, 000h, 000h, 000h, 000h
  3991 00017B8D 6266FE00000000      <1>
  3992 00017B94 0000C3E7FFFFDBC3C3- <1>     db  000h, 000h, 0c3h, 0e7h, 0ffh, 0ffh, 0dbh, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 000h, 000h, 000h, 000h
  3992 00017B9D C3C3C300000000      <1>
  3993 00017BA4 0000C6E6F6FEDECEC6- <1>     db  000h, 000h, 0c6h, 0e6h, 0f6h, 0feh, 0deh, 0ceh, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
  3993 00017BAD C6C6C600000000      <1>
  3994 00017BB4 00007CC6C6C6C6C6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
  3994 00017BBD C6C67C00000000      <1>
  3995 00017BC4 0000FC6666667C6060- <1>     db  000h, 000h, 0fch, 066h, 066h, 066h, 07ch, 060h, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h
  3995 00017BCD 6060F000000000      <1>
  3996 00017BD4 00007CC6C6C6C6C6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0d6h, 0deh, 07ch, 00ch, 00eh, 000h, 000h
  3996 00017BDD D6DE7C0C0E0000      <1>
  3997 00017BE4 0000FC6666667C6C66- <1>     db  000h, 000h, 0fch, 066h, 066h, 066h, 07ch, 06ch, 066h, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h
  3997 00017BED 6666E600000000      <1>
  3998 00017BF4 00007CC6C660380C06- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 060h, 038h, 00ch, 006h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
  3998 00017BFD C6C67C00000000      <1>
  3999 00017C04 0000FFDB9918181818- <1>     db  000h, 000h, 0ffh, 0dbh, 099h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
  3999 00017C0D 18183C00000000      <1>
  4000 00017C14 0000C6C6C6C6C6C6C6- <1>     db  000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
  4000 00017C1D C6C67C00000000      <1>
  4001 00017C24 0000C3C3C3C3C3C3C3- <1>     db  000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 000h, 000h, 000h, 000h
  4001 00017C2D 663C1800000000      <1>
  4002 00017C34 0000C3C3C3C3C3DBDB- <1>     db  000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh, 066h, 066h, 000h, 000h, 000h, 000h
  4002 00017C3D FF666600000000      <1>
  4003 00017C44 0000C3C3663C18183C- <1>     db  000h, 000h, 0c3h, 0c3h, 066h, 03ch, 018h, 018h, 03ch, 066h, 0c3h, 0c3h, 000h, 000h, 000h, 000h
  4003 00017C4D 66C3C300000000      <1>
  4004 00017C54 0000C3C3C3663C1818- <1>     db  000h, 000h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
  4004 00017C5D 18183C00000000      <1>
  4005 00017C64 0000FFC3860C183060- <1>     db  000h, 000h, 0ffh, 0c3h, 086h, 00ch, 018h, 030h, 060h, 0c1h, 0c3h, 0ffh, 000h, 000h, 000h, 000h
  4005 00017C6D C1C3FF00000000      <1>
  4006 00017C74 00003C303030303030- <1>     db  000h, 000h, 03ch, 030h, 030h, 030h, 030h, 030h, 030h, 030h, 030h, 03ch, 000h, 000h, 000h, 000h
  4006 00017C7D 30303C00000000      <1>
  4007 00017C84 00000080C0E070381C- <1>     db  000h, 000h, 000h, 080h, 0c0h, 0e0h, 070h, 038h, 01ch, 00eh, 006h, 002h, 000h, 000h, 000h, 000h
  4007 00017C8D 0E060200000000      <1>
  4008 00017C94 00003C0C0C0C0C0C0C- <1>     db  000h, 000h, 03ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 03ch, 000h, 000h, 000h, 000h
  4008 00017C9D 0C0C3C00000000      <1>
  4009 00017CA4 10386CC60000000000- <1>     db  010h, 038h, 06ch, 0c6h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4009 00017CAD 00000000000000      <1>
  4010 00017CB4 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 000h
  4010 00017CBD 00000000FF0000      <1>
  4011 00017CC4 303018000000000000- <1>     db  030h, 030h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4011 00017CCD 00000000000000      <1>
  4012 00017CD4 0000000000780C7CCC- <1>     db  000h, 000h, 000h, 000h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
  4012 00017CDD CCCC7600000000      <1>
  4013 00017CE4 0000E06060786C6666- <1>     db  000h, 000h, 0e0h, 060h, 060h, 078h, 06ch, 066h, 066h, 066h, 066h, 07ch, 000h, 000h, 000h, 000h
  4013 00017CED 66667C00000000      <1>
  4014 00017CF4 00000000007CC6C0C0- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c0h, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
  4014 00017CFD C0C67C00000000      <1>
  4015 00017D04 00001C0C0C3C6CCCCC- <1>     db  000h, 000h, 01ch, 00ch, 00ch, 03ch, 06ch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
  4015 00017D0D CCCC7600000000      <1>
  4016 00017D14 00000000007CC6FEC0- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
  4016 00017D1D C0C67C00000000      <1>
  4017 00017D24 0000386C6460F06060- <1>     db  000h, 000h, 038h, 06ch, 064h, 060h, 0f0h, 060h, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h
  4017 00017D2D 6060F000000000      <1>
  4018 00017D34 000000000076CCCCCC- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0cch, 0cch, 0cch, 0cch, 0cch, 07ch, 00ch, 0cch, 078h, 000h
  4018 00017D3D CCCC7C0CCC7800      <1>
  4019 00017D44 0000E060606C766666- <1>     db  000h, 000h, 0e0h, 060h, 060h, 06ch, 076h, 066h, 066h, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h
  4019 00017D4D 6666E600000000      <1>
  4020 00017D54 000018180038181818- <1>     db  000h, 000h, 018h, 018h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
  4020 00017D5D 18183C00000000      <1>
  4021 00017D64 00000606000E060606- <1>     db  000h, 000h, 006h, 006h, 000h, 00eh, 006h, 006h, 006h, 006h, 006h, 006h, 066h, 066h, 03ch, 000h
  4021 00017D6D 06060666663C00      <1>
  4022 00017D74 0000E06060666C7878- <1>     db  000h, 000h, 0e0h, 060h, 060h, 066h, 06ch, 078h, 078h, 06ch, 066h, 0e6h, 000h, 000h, 000h, 000h
  4022 00017D7D 6C66E600000000      <1>
  4023 00017D84 000038181818181818- <1>     db  000h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
  4023 00017D8D 18183C00000000      <1>
  4024 00017D94 0000000000E6FFDBDB- <1>     db  000h, 000h, 000h, 000h, 000h, 0e6h, 0ffh, 0dbh, 0dbh, 0dbh, 0dbh, 0dbh, 000h, 000h, 000h, 000h
  4024 00017D9D DBDBDB00000000      <1>
  4025 00017DA4 0000000000DC666666- <1>     db  000h, 000h, 000h, 000h, 000h, 0dch, 066h, 066h, 066h, 066h, 066h, 066h, 000h, 000h, 000h, 000h
  4025 00017DAD 66666600000000      <1>
  4026 00017DB4 00000000007CC6C6C6- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
  4026 00017DBD C6C67C00000000      <1>
  4027 00017DC4 0000000000DC666666- <1>     db  000h, 000h, 000h, 000h, 000h, 0dch, 066h, 066h, 066h, 066h, 066h, 07ch, 060h, 060h, 0f0h, 000h
  4027 00017DCD 66667C6060F000      <1>
  4028 00017DD4 000000000076CCCCCC- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0cch, 0cch, 0cch, 0cch, 0cch, 07ch, 00ch, 00ch, 01eh, 000h
  4028 00017DDD CCCC7C0C0C1E00      <1>
  4029 00017DE4 0000000000DC766660- <1>     db  000h, 000h, 000h, 000h, 000h, 0dch, 076h, 066h, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h
  4029 00017DED 6060F000000000      <1>
  4030 00017DF4 00000000007CC66038- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 060h, 038h, 00ch, 0c6h, 07ch, 000h, 000h, 000h, 000h
  4030 00017DFD 0CC67C00000000      <1>
  4031 00017E04 0000103030FC303030- <1>     db  000h, 000h, 010h, 030h, 030h, 0fch, 030h, 030h, 030h, 030h, 036h, 01ch, 000h, 000h, 000h, 000h
  4031 00017E0D 30361C00000000      <1>
  4032 00017E14 0000000000CCCCCCCC- <1>     db  000h, 000h, 000h, 000h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
  4032 00017E1D CCCC7600000000      <1>
  4033 00017E24 0000000000C3C3C3C3- <1>     db  000h, 000h, 000h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 000h, 000h, 000h, 000h
  4033 00017E2D 663C1800000000      <1>
  4034 00017E34 0000000000C3C3C3DB- <1>     db  000h, 000h, 000h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh, 066h, 000h, 000h, 000h, 000h
  4034 00017E3D DBFF6600000000      <1>
  4035 00017E44 0000000000C3663C18- <1>     db  000h, 000h, 000h, 000h, 000h, 0c3h, 066h, 03ch, 018h, 03ch, 066h, 0c3h, 000h, 000h, 000h, 000h
  4035 00017E4D 3C66C300000000      <1>
  4036 00017E54 0000000000C6C6C6C6- <1>     db  000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07eh, 006h, 00ch, 0f8h, 000h
  4036 00017E5D C6C67E060CF800      <1>
  4037 00017E64 0000000000FECC1830- <1>     db  000h, 000h, 000h, 000h, 000h, 0feh, 0cch, 018h, 030h, 060h, 0c6h, 0feh, 000h, 000h, 000h, 000h
  4037 00017E6D 60C6FE00000000      <1>
  4038 00017E74 00000E181818701818- <1>     db  000h, 000h, 00eh, 018h, 018h, 018h, 070h, 018h, 018h, 018h, 018h, 00eh, 000h, 000h, 000h, 000h
  4038 00017E7D 18180E00000000      <1>
  4039 00017E84 000018181818001818- <1>     db  000h, 000h, 018h, 018h, 018h, 018h, 000h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h
  4039 00017E8D 18181800000000      <1>
  4040 00017E94 0000701818180E1818- <1>     db  000h, 000h, 070h, 018h, 018h, 018h, 00eh, 018h, 018h, 018h, 018h, 070h, 000h, 000h, 000h, 000h
  4040 00017E9D 18187000000000      <1>
  4041 00017EA4 000076DC0000000000- <1>     db  000h, 000h, 076h, 0dch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4041 00017EAD 00000000000000      <1>
  4042 00017EB4 0000000010386CC6C6- <1>     db  000h, 000h, 000h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 0feh, 000h, 000h, 000h, 000h, 000h
  4042 00017EBD C6FE0000000000      <1>
  4043 00017EC4 00003C66C2C0C0C0C2- <1>     db  000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0c0h, 0c2h, 066h, 03ch, 00ch, 006h, 07ch, 000h, 000h
  4043 00017ECD 663C0C067C0000      <1>
  4044 00017ED4 0000CC0000CCCCCCCC- <1>     db  000h, 000h, 0cch, 000h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
  4044 00017EDD CCCC7600000000      <1>
  4045 00017EE4 000C1830007CC6FEC0- <1>     db  000h, 00ch, 018h, 030h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
  4045 00017EED C0C67C00000000      <1>
  4046 00017EF4 0010386C00780C7CCC- <1>     db  000h, 010h, 038h, 06ch, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
  4046 00017EFD CCCC7600000000      <1>
  4047 00017F04 0000CC0000780C7CCC- <1>     db  000h, 000h, 0cch, 000h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
  4047 00017F0D CCCC7600000000      <1>
  4048 00017F14 0060301800780C7CCC- <1>     db  000h, 060h, 030h, 018h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
  4048 00017F1D CCCC7600000000      <1>
  4049 00017F24 00386C3800780C7CCC- <1>     db  000h, 038h, 06ch, 038h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
  4049 00017F2D CCCC7600000000      <1>
  4050 00017F34 000000003C66606066- <1>     db  000h, 000h, 000h, 000h, 03ch, 066h, 060h, 060h, 066h, 03ch, 00ch, 006h, 03ch, 000h, 000h, 000h
  4050 00017F3D 3C0C063C000000      <1>
  4051 00017F44 0010386C007CC6FEC0- <1>     db  000h, 010h, 038h, 06ch, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
  4051 00017F4D C0C67C00000000      <1>
  4052 00017F54 0000C600007CC6FEC0- <1>     db  000h, 000h, 0c6h, 000h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
  4052 00017F5D C0C67C00000000      <1>
  4053 00017F64 00603018007CC6FEC0- <1>     db  000h, 060h, 030h, 018h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
  4053 00017F6D C0C67C00000000      <1>
  4054 00017F74 000066000038181818- <1>     db  000h, 000h, 066h, 000h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
  4054 00017F7D 18183C00000000      <1>
  4055 00017F84 00183C660038181818- <1>     db  000h, 018h, 03ch, 066h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
  4055 00017F8D 18183C00000000      <1>
  4056 00017F94 006030180038181818- <1>     db  000h, 060h, 030h, 018h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
  4056 00017F9D 18183C00000000      <1>
  4057 00017FA4 00C60010386CC6C6FE- <1>     db  000h, 0c6h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
  4057 00017FAD C6C6C600000000      <1>
  4058 00017FB4 386C3800386CC6C6FE- <1>     db  038h, 06ch, 038h, 000h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
  4058 00017FBD C6C6C600000000      <1>
  4059 00017FC4 18306000FE66607C60- <1>     db  018h, 030h, 060h, 000h, 0feh, 066h, 060h, 07ch, 060h, 060h, 066h, 0feh, 000h, 000h, 000h, 000h
  4059 00017FCD 6066FE00000000      <1>
  4060 00017FD4 00000000006E3B1B7E- <1>     db  000h, 000h, 000h, 000h, 000h, 06eh, 03bh, 01bh, 07eh, 0d8h, 0dch, 077h, 000h, 000h, 000h, 000h
  4060 00017FDD D8DC7700000000      <1>
  4061 00017FE4 00003E6CCCCCFECCCC- <1>     db  000h, 000h, 03eh, 06ch, 0cch, 0cch, 0feh, 0cch, 0cch, 0cch, 0cch, 0ceh, 000h, 000h, 000h, 000h
  4061 00017FED CCCCCE00000000      <1>
  4062 00017FF4 0010386C007CC6C6C6- <1>     db  000h, 010h, 038h, 06ch, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
  4062 00017FFD C6C67C00000000      <1>
  4063 00018004 0000C600007CC6C6C6- <1>     db  000h, 000h, 0c6h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
  4063 0001800D C6C67C00000000      <1>
  4064 00018014 00603018007CC6C6C6- <1>     db  000h, 060h, 030h, 018h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
  4064 0001801D C6C67C00000000      <1>
  4065 00018024 003078CC00CCCCCCCC- <1>     db  000h, 030h, 078h, 0cch, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
  4065 0001802D CCCC7600000000      <1>
  4066 00018034 0060301800CCCCCCCC- <1>     db  000h, 060h, 030h, 018h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
  4066 0001803D CCCC7600000000      <1>
  4067 00018044 0000C60000C6C6C6C6- <1>     db  000h, 000h, 0c6h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07eh, 006h, 00ch, 078h, 000h
  4067 0001804D C6C67E060C7800      <1>
  4068 00018054 00C6007CC6C6C6C6C6- <1>     db  000h, 0c6h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
  4068 0001805D C6C67C00000000      <1>
  4069 00018064 00C600C6C6C6C6C6C6- <1>     db  000h, 0c6h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
  4069 0001806D C6C67C00000000      <1>
  4070 00018074 0018187EC3C0C0C0C3- <1>     db  000h, 018h, 018h, 07eh, 0c3h, 0c0h, 0c0h, 0c0h, 0c3h, 07eh, 018h, 018h, 000h, 000h, 000h, 000h
  4070 0001807D 7E181800000000      <1>
  4071 00018084 00386C6460F0606060- <1>     db  000h, 038h, 06ch, 064h, 060h, 0f0h, 060h, 060h, 060h, 060h, 0e6h, 0fch, 000h, 000h, 000h, 000h
  4071 0001808D 60E6FC00000000      <1>
  4072 00018094 0000C3663C18FF18FF- <1>     db  000h, 000h, 0c3h, 066h, 03ch, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 000h, 000h, 000h, 000h
  4072 0001809D 18181800000000      <1>
  4073 000180A4 00FC66667C62666F66- <1>     db  000h, 0fch, 066h, 066h, 07ch, 062h, 066h, 06fh, 066h, 066h, 066h, 0f3h, 000h, 000h, 000h, 000h
  4073 000180AD 6666F300000000      <1>
  4074 000180B4 000E1B1818187E1818- <1>     db  000h, 00eh, 01bh, 018h, 018h, 018h, 07eh, 018h, 018h, 018h, 018h, 018h, 0d8h, 070h, 000h, 000h
  4074 000180BD 181818D8700000      <1>
  4075 000180C4 0018306000780C7CCC- <1>     db  000h, 018h, 030h, 060h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
  4075 000180CD CCCC7600000000      <1>
  4076 000180D4 000C18300038181818- <1>     db  000h, 00ch, 018h, 030h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
  4076 000180DD 18183C00000000      <1>
  4077 000180E4 00183060007CC6C6C6- <1>     db  000h, 018h, 030h, 060h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
  4077 000180ED C6C67C00000000      <1>
  4078 000180F4 0018306000CCCCCCCC- <1>     db  000h, 018h, 030h, 060h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
  4078 000180FD CCCC7600000000      <1>
  4079 00018104 000076DC00DC666666- <1>     db  000h, 000h, 076h, 0dch, 000h, 0dch, 066h, 066h, 066h, 066h, 066h, 066h, 000h, 000h, 000h, 000h
  4079 0001810D 66666600000000      <1>
  4080 00018114 76DC00C6E6F6FEDECE- <1>     db  076h, 0dch, 000h, 0c6h, 0e6h, 0f6h, 0feh, 0deh, 0ceh, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
  4080 0001811D C6C6C600000000      <1>
  4081 00018124 003C6C6C3E007E0000- <1>     db  000h, 03ch, 06ch, 06ch, 03eh, 000h, 07eh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4081 0001812D 00000000000000      <1>
  4082 00018134 00386C6C38007C0000- <1>     db  000h, 038h, 06ch, 06ch, 038h, 000h, 07ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4082 0001813D 00000000000000      <1>
  4083 00018144 0000303000303060C0- <1>     db  000h, 000h, 030h, 030h, 000h, 030h, 030h, 060h, 0c0h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
  4083 0001814D C6C67C00000000      <1>
  4084 00018154 000000000000FEC0C0- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 0feh, 0c0h, 0c0h, 0c0h, 0c0h, 000h, 000h, 000h, 000h, 000h
  4084 0001815D C0C00000000000      <1>
  4085 00018164 000000000000FE0606- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 0feh, 006h, 006h, 006h, 006h, 000h, 000h, 000h, 000h, 000h
  4085 0001816D 06060000000000      <1>
  4086 00018174 00C0C0C2C6CC183060- <1>     db  000h, 0c0h, 0c0h, 0c2h, 0c6h, 0cch, 018h, 030h, 060h, 0ceh, 09bh, 006h, 00ch, 01fh, 000h, 000h
  4086 0001817D CE9B060C1F0000      <1>
  4087 00018184 00C0C0C2C6CC183066- <1>     db  000h, 0c0h, 0c0h, 0c2h, 0c6h, 0cch, 018h, 030h, 066h, 0ceh, 096h, 03eh, 006h, 006h, 000h, 000h
  4087 0001818D CE963E06060000      <1>
  4088 00018194 00001818001818183C- <1>     db  000h, 000h, 018h, 018h, 000h, 018h, 018h, 018h, 03ch, 03ch, 03ch, 018h, 000h, 000h, 000h, 000h
  4088 0001819D 3C3C1800000000      <1>
  4089 000181A4 0000000000366CD86C- <1>     db  000h, 000h, 000h, 000h, 000h, 036h, 06ch, 0d8h, 06ch, 036h, 000h, 000h, 000h, 000h, 000h, 000h
  4089 000181AD 36000000000000      <1>
  4090 000181B4 0000000000D86C366C- <1>     db  000h, 000h, 000h, 000h, 000h, 0d8h, 06ch, 036h, 06ch, 0d8h, 000h, 000h, 000h, 000h, 000h, 000h
  4090 000181BD D8000000000000      <1>
  4091 000181C4 114411441144114411- <1>     db  011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h
  4091 000181CD 44114411441144      <1>
  4092 000181D4 55AA55AA55AA55AA55- <1>     db  055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah
  4092 000181DD AA55AA55AA55AA      <1>
  4093 000181E4 DD77DD77DD77DD77DD- <1>     db  0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h
  4093 000181ED 77DD77DD77DD77      <1>
  4094 000181F4 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
  4094 000181FD 18181818181818      <1>
  4095 00018204 18181818181818F818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
  4095 0001820D 18181818181818      <1>
  4096 00018214 1818181818F818F818- <1>     db  018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
  4096 0001821D 18181818181818      <1>
  4097 00018224 36363636363636F636- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
  4097 0001822D 36363636363636      <1>
  4098 00018234 00000000000000FE36- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
  4098 0001823D 36363636363636      <1>
  4099 00018244 0000000000F818F818- <1>     db  000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
  4099 0001824D 18181818181818      <1>
  4100 00018254 3636363636F606F636- <1>     db  036h, 036h, 036h, 036h, 036h, 0f6h, 006h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
  4100 0001825D 36363636363636      <1>
  4101 00018264 363636363636363636- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
  4101 0001826D 36363636363636      <1>
  4102 00018274 0000000000FE06F636- <1>     db  000h, 000h, 000h, 000h, 000h, 0feh, 006h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
  4102 0001827D 36363636363636      <1>
  4103 00018284 3636363636F606FE00- <1>     db  036h, 036h, 036h, 036h, 036h, 0f6h, 006h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4103 0001828D 00000000000000      <1>
  4104 00018294 36363636363636FE00- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4104 0001829D 00000000000000      <1>
  4105 000182A4 1818181818F818F800- <1>     db  018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4105 000182AD 00000000000000      <1>
  4106 000182B4 00000000000000F818- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
  4106 000182BD 18181818181818      <1>
  4107 000182C4 181818181818181F00- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4107 000182CD 00000000000000      <1>
  4108 000182D4 18181818181818FF00- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4108 000182DD 00000000000000      <1>
  4109 000182E4 00000000000000FF18- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
  4109 000182ED 18181818181818      <1>
  4110 000182F4 181818181818181F18- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
  4110 000182FD 18181818181818      <1>
  4111 00018304 00000000000000FF00- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4111 0001830D 00000000000000      <1>
  4112 00018314 18181818181818FF18- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
  4112 0001831D 18181818181818      <1>
  4113 00018324 18181818181F181F18- <1>     db  018h, 018h, 018h, 018h, 018h, 01fh, 018h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
  4113 0001832D 18181818181818      <1>
  4114 00018334 363636363636363736- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 037h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
  4114 0001833D 36363636363636      <1>
  4115 00018344 363636363637303F00- <1>     db  036h, 036h, 036h, 036h, 036h, 037h, 030h, 03fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4115 0001834D 00000000000000      <1>
  4116 00018354 00000000003F303736- <1>     db  000h, 000h, 000h, 000h, 000h, 03fh, 030h, 037h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
  4116 0001835D 36363636363636      <1>
  4117 00018364 3636363636F700FF00- <1>     db  036h, 036h, 036h, 036h, 036h, 0f7h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4117 0001836D 00000000000000      <1>
  4118 00018374 0000000000FF00F736- <1>     db  000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0f7h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
  4118 0001837D 36363636363636      <1>
  4119 00018384 363636363637303736- <1>     db  036h, 036h, 036h, 036h, 036h, 037h, 030h, 037h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
  4119 0001838D 36363636363636      <1>
  4120 00018394 0000000000FF00FF00- <1>     db  000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4120 0001839D 00000000000000      <1>
  4121 000183A4 3636363636F700F736- <1>     db  036h, 036h, 036h, 036h, 036h, 0f7h, 000h, 0f7h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
  4121 000183AD 36363636363636      <1>
  4122 000183B4 1818181818FF00FF00- <1>     db  018h, 018h, 018h, 018h, 018h, 0ffh, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4122 000183BD 00000000000000      <1>
  4123 000183C4 36363636363636FF00- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4123 000183CD 00000000000000      <1>
  4124 000183D4 0000000000FF00FF18- <1>     db  000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
  4124 000183DD 18181818181818      <1>
  4125 000183E4 00000000000000FF36- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
  4125 000183ED 36363636363636      <1>
  4126 000183F4 363636363636363F00- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 03fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4126 000183FD 00000000000000      <1>
  4127 00018404 18181818181F181F00- <1>     db  018h, 018h, 018h, 018h, 018h, 01fh, 018h, 01fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4127 0001840D 00000000000000      <1>
  4128 00018414 00000000001F181F18- <1>     db  000h, 000h, 000h, 000h, 000h, 01fh, 018h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
  4128 0001841D 18181818181818      <1>
  4129 00018424 000000000000003F36- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 03fh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
  4129 0001842D 36363636363636      <1>
  4130 00018434 36363636363636FF36- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
  4130 0001843D 36363636363636      <1>
  4131 00018444 1818181818FF18FF18- <1>     db  018h, 018h, 018h, 018h, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
  4131 0001844D 18181818181818      <1>
  4132 00018454 18181818181818F800- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4132 0001845D 00000000000000      <1>
  4133 00018464 000000000000001F18- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
  4133 0001846D 18181818181818      <1>
  4134 00018474 FFFFFFFFFFFFFFFFFF- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
  4134 0001847D FFFFFFFFFFFFFF      <1>
  4135 00018484 00000000000000FFFF- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
  4135 0001848D FFFFFFFFFFFFFF      <1>
  4136 00018494 F0F0F0F0F0F0F0F0F0- <1>     db  0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h
  4136 0001849D F0F0F0F0F0F0F0      <1>
  4137 000184A4 0F0F0F0F0F0F0F0F0F- <1>     db  00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh
  4137 000184AD 0F0F0F0F0F0F0F      <1>
  4138 000184B4 FFFFFFFFFFFFFF0000- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4138 000184BD 00000000000000      <1>
  4139 000184C4 000000000076DCD8D8- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0dch, 0d8h, 0d8h, 0d8h, 0dch, 076h, 000h, 000h, 000h, 000h
  4139 000184CD D8DC7600000000      <1>
  4140 000184D4 000078CCCCCCD8CCC6- <1>     db  000h, 000h, 078h, 0cch, 0cch, 0cch, 0d8h, 0cch, 0c6h, 0c6h, 0c6h, 0cch, 000h, 000h, 000h, 000h
  4140 000184DD C6C6CC00000000      <1>
  4141 000184E4 0000FEC6C6C0C0C0C0- <1>     db  000h, 000h, 0feh, 0c6h, 0c6h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 000h, 000h, 000h, 000h
  4141 000184ED C0C0C000000000      <1>
  4142 000184F4 00000000FE6C6C6C6C- <1>     db  000h, 000h, 000h, 000h, 0feh, 06ch, 06ch, 06ch, 06ch, 06ch, 06ch, 06ch, 000h, 000h, 000h, 000h
  4142 000184FD 6C6C6C00000000      <1>
  4143 00018504 000000FEC660301830- <1>     db  000h, 000h, 000h, 0feh, 0c6h, 060h, 030h, 018h, 030h, 060h, 0c6h, 0feh, 000h, 000h, 000h, 000h
  4143 0001850D 60C6FE00000000      <1>
  4144 00018514 00000000007ED8D8D8- <1>     db  000h, 000h, 000h, 000h, 000h, 07eh, 0d8h, 0d8h, 0d8h, 0d8h, 0d8h, 070h, 000h, 000h, 000h, 000h
  4144 0001851D D8D87000000000      <1>
  4145 00018524 000000006666666666- <1>     db  000h, 000h, 000h, 000h, 066h, 066h, 066h, 066h, 066h, 07ch, 060h, 060h, 0c0h, 000h, 000h, 000h
  4145 0001852D 7C6060C0000000      <1>
  4146 00018534 0000000076DC181818- <1>     db  000h, 000h, 000h, 000h, 076h, 0dch, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h
  4146 0001853D 18181800000000      <1>
  4147 00018544 0000007E183C666666- <1>     db  000h, 000h, 000h, 07eh, 018h, 03ch, 066h, 066h, 066h, 03ch, 018h, 07eh, 000h, 000h, 000h, 000h
  4147 0001854D 3C187E00000000      <1>
  4148 00018554 000000386CC6C6FEC6- <1>     db  000h, 000h, 000h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 06ch, 038h, 000h, 000h, 000h, 000h
  4148 0001855D C66C3800000000      <1>
  4149 00018564 0000386CC6C6C66C6C- <1>     db  000h, 000h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 06ch, 06ch, 06ch, 06ch, 0eeh, 000h, 000h, 000h, 000h
  4149 0001856D 6C6CEE00000000      <1>
  4150 00018574 00001E30180C3E6666- <1>     db  000h, 000h, 01eh, 030h, 018h, 00ch, 03eh, 066h, 066h, 066h, 066h, 03ch, 000h, 000h, 000h, 000h
  4150 0001857D 66663C00000000      <1>
  4151 00018584 00000000007EDBDBDB- <1>     db  000h, 000h, 000h, 000h, 000h, 07eh, 0dbh, 0dbh, 0dbh, 07eh, 000h, 000h, 000h, 000h, 000h, 000h
  4151 0001858D 7E000000000000      <1>
  4152 00018594 00000003067EDBDBF3- <1>     db  000h, 000h, 000h, 003h, 006h, 07eh, 0dbh, 0dbh, 0f3h, 07eh, 060h, 0c0h, 000h, 000h, 000h, 000h
  4152 0001859D 7E60C000000000      <1>
  4153 000185A4 00001C3060607C6060- <1>     db  000h, 000h, 01ch, 030h, 060h, 060h, 07ch, 060h, 060h, 060h, 030h, 01ch, 000h, 000h, 000h, 000h
  4153 000185AD 60301C00000000      <1>
  4154 000185B4 0000007CC6C6C6C6C6- <1>     db  000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
  4154 000185BD C6C6C600000000      <1>
  4155 000185C4 00000000FE0000FE00- <1>     db  000h, 000h, 000h, 000h, 0feh, 000h, 000h, 0feh, 000h, 000h, 0feh, 000h, 000h, 000h, 000h, 000h
  4155 000185CD 00FE0000000000      <1>
  4156 000185D4 0000000018187E1818- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 07eh, 018h, 018h, 000h, 000h, 0ffh, 000h, 000h, 000h, 000h
  4156 000185DD 0000FF00000000      <1>
  4157 000185E4 00000030180C060C18- <1>     db  000h, 000h, 000h, 030h, 018h, 00ch, 006h, 00ch, 018h, 030h, 000h, 07eh, 000h, 000h, 000h, 000h
  4157 000185ED 30007E00000000      <1>
  4158 000185F4 0000000C1830603018- <1>     db  000h, 000h, 000h, 00ch, 018h, 030h, 060h, 030h, 018h, 00ch, 000h, 07eh, 000h, 000h, 000h, 000h
  4158 000185FD 0C007E00000000      <1>
  4159 00018604 00000E1B1B18181818- <1>     db  000h, 000h, 00eh, 01bh, 01bh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
  4159 0001860D 18181818181818      <1>
  4160 00018614 1818181818181818D8- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0d8h, 0d8h, 0d8h, 070h, 000h, 000h, 000h, 000h
  4160 0001861D D8D87000000000      <1>
  4161 00018624 000000001818007E00- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 000h, 07eh, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h
  4161 0001862D 18180000000000      <1>
  4162 00018634 000000000076DC0076- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0dch, 000h, 076h, 0dch, 000h, 000h, 000h, 000h, 000h, 000h
  4162 0001863D DC000000000000      <1>
  4163 00018644 00386C6C3800000000- <1>     db  000h, 038h, 06ch, 06ch, 038h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4163 0001864D 00000000000000      <1>
  4164 00018654 000000000000001818- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4164 0001865D 00000000000000      <1>
  4165 00018664 000000000000000018- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4165 0001866D 00000000000000      <1>
  4166 00018674 000F0C0C0C0C0CEC6C- <1>     db  000h, 00fh, 00ch, 00ch, 00ch, 00ch, 00ch, 0ech, 06ch, 06ch, 03ch, 01ch, 000h, 000h, 000h, 000h
  4166 0001867D 6C3C1C00000000      <1>
  4167 00018684 00D86C6C6C6C6C0000- <1>     db  000h, 0d8h, 06ch, 06ch, 06ch, 06ch, 06ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4167 0001868D 00000000000000      <1>
  4168 00018694 0070D83060C8F80000- <1>     db  000h, 070h, 0d8h, 030h, 060h, 0c8h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4168 0001869D 00000000000000      <1>
  4169 000186A4 000000007C7C7C7C7C- <1>     db  000h, 000h, 000h, 000h, 07ch, 07ch, 07ch, 07ch, 07ch, 07ch, 07ch, 000h, 000h, 000h, 000h, 000h
  4169 000186AD 7C7C0000000000      <1>
  4170 000186B4 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  4170 000186BD 00000000000000      <1>
  4171                              <1> 
  4172                              <1> ; 01/01/2021 (TRDOS 386 v2.0.3)
  4173                              <1> 
  4174                              <1> %if 0
  4175                              <1> 
  4176                              <1> vgafont14alt:
  4177                              <1>     db  01dh, 000h, 000h, 000h, 000h, 024h, 066h, 0ffh, 066h, 024h, 000h, 000h, 000h, 000h, 000h, 022h
  4178                              <1>     db  000h, 063h, 063h, 063h, 022h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 02bh, 000h
  4179                              <1>     db  000h, 000h, 018h, 018h, 018h, 0ffh, 018h, 018h, 018h, 000h, 000h, 000h, 000h, 02dh, 000h, 000h
  4180                              <1>     db  000h, 000h, 000h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 04dh, 000h, 000h, 0c3h
  4181                              <1>     db  0e7h, 0ffh, 0dbh, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 000h, 000h, 000h, 054h, 000h, 000h, 0ffh, 0dbh
  4182                              <1>     db  099h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 056h, 000h, 000h, 0c3h, 0c3h, 0c3h
  4183                              <1>     db  0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 000h, 000h, 000h, 057h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h
  4184                              <1>     db  0dbh, 0dbh, 0ffh, 066h, 066h, 000h, 000h, 000h, 058h, 000h, 000h, 0c3h, 0c3h, 066h, 03ch, 018h
  4185                              <1>     db  03ch, 066h, 0c3h, 0c3h, 000h, 000h, 000h, 059h, 000h, 000h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h
  4186                              <1>     db  018h, 018h, 03ch, 000h, 000h, 000h, 05ah, 000h, 000h, 0ffh, 0c3h, 086h, 00ch, 018h, 030h, 061h
  4187                              <1>     db  0c3h, 0ffh, 000h, 000h, 000h, 06dh, 000h, 000h, 000h, 000h, 000h, 0e6h, 0ffh, 0dbh, 0dbh, 0dbh
  4188                              <1>     db  0dbh, 000h, 000h, 000h, 076h, 000h, 000h, 000h, 000h, 000h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h
  4189                              <1>     db  000h, 000h, 000h, 077h, 000h, 000h, 000h, 000h, 000h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh, 066h, 000h
  4190                              <1>     db  000h, 000h, 091h, 000h, 000h, 000h, 000h, 06eh, 03bh, 01bh, 07eh, 0d8h, 0dch, 077h, 000h, 000h
  4191                              <1>     db  000h, 09bh, 000h, 018h, 018h, 07eh, 0c3h, 0c0h, 0c0h, 0c3h, 07eh, 018h, 018h, 000h, 000h, 000h
  4192                              <1>     db  09dh, 000h, 000h, 0c3h, 066h, 03ch, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 000h, 000h, 000h, 09eh
  4193                              <1>     db  000h, 0fch, 066h, 066h, 07ch, 062h, 066h, 06fh, 066h, 066h, 0f3h, 000h, 000h, 000h, 0f1h, 000h
  4194                              <1>     db  000h, 018h, 018h, 018h, 0ffh, 018h, 018h, 018h, 000h, 0ffh, 000h, 000h, 000h, 0f6h, 000h, 000h
  4195                              <1>     db  018h, 018h, 000h, 000h, 0ffh, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h
  4196                              <1> vgafont16alt:
  4197                              <1>     db  01dh, 000h, 000h, 000h, 000h, 000h, 024h, 066h, 0ffh, 066h, 024h, 000h, 000h, 000h, 000h, 000h
  4198                              <1>     db  000h, 030h, 000h, 000h, 03ch, 066h, 0c3h, 0c3h, 0dbh, 0dbh, 0c3h, 0c3h, 066h, 03ch, 000h, 000h
  4199                              <1>     db  000h, 000h, 04dh, 000h, 000h, 0c3h, 0e7h, 0ffh, 0ffh, 0dbh, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 000h
  4200                              <1>     db  000h, 000h, 000h, 054h, 000h, 000h, 0ffh, 0dbh, 099h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch
  4201                              <1>     db  000h, 000h, 000h, 000h, 056h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 066h, 03ch
  4202                              <1>     db  018h, 000h, 000h, 000h, 000h, 057h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh
  4203                              <1>     db  066h, 066h, 000h, 000h, 000h, 000h, 058h, 000h, 000h, 0c3h, 0c3h, 066h, 03ch, 018h, 018h, 03ch
  4204                              <1>     db  066h, 0c3h, 0c3h, 000h, 000h, 000h, 000h, 059h, 000h, 000h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h
  4205                              <1>     db  018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 05ah, 000h, 000h, 0ffh, 0c3h, 086h, 00ch, 018h
  4206                              <1>     db  030h, 060h, 0c1h, 0c3h, 0ffh, 000h, 000h, 000h, 000h, 06dh, 000h, 000h, 000h, 000h, 000h, 0e6h
  4207                              <1>     db  0ffh, 0dbh, 0dbh, 0dbh, 0dbh, 0dbh, 000h, 000h, 000h, 000h, 076h, 000h, 000h, 000h, 000h, 000h
  4208                              <1>     db  0c3h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 000h, 000h, 000h, 000h, 077h, 000h, 000h, 000h, 000h
  4209                              <1>     db  000h, 0c3h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh, 066h, 000h, 000h, 000h, 000h, 078h, 000h, 000h, 000h
  4210                              <1>     db  000h, 000h, 0c3h, 066h, 03ch, 018h, 03ch, 066h, 0c3h, 000h, 000h, 000h, 000h, 091h, 000h, 000h
  4211                              <1>     db  000h, 000h, 000h, 06eh, 03bh, 01bh, 07eh, 0d8h, 0dch, 077h, 000h, 000h, 000h, 000h, 09bh, 000h
  4212                              <1>     db  018h, 018h, 07eh, 0c3h, 0c0h, 0c0h, 0c0h, 0c3h, 07eh, 018h, 018h, 000h, 000h, 000h, 000h, 09dh
  4213                              <1>     db  000h, 000h, 0c3h, 066h, 03ch, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 000h, 000h, 000h, 000h
  4214                              <1>     db  09eh, 000h, 0fch, 066h, 066h, 07ch, 062h, 066h, 06fh, 066h, 066h, 066h, 0f3h, 000h, 000h, 000h
  4215                              <1>     db  000h, 0abh, 000h, 0c0h, 0c0h, 0c2h, 0c6h, 0cch, 018h, 030h, 060h, 0ceh, 09bh, 006h, 00ch, 01fh
  4216                              <1>     db  000h, 000h, 0ach, 000h, 0c0h, 0c0h, 0c2h, 0c6h, 0cch, 018h, 030h, 066h, 0ceh, 096h, 03eh, 006h
  4217                              <1>     db  006h, 000h, 000h, 000h
  4218                              <1> 
  4219                              <1> %endif
  3437                                  
  3438                                  ; 20/11/2020
  3439                                  vbe2_bochs_vbios:
  3440                                  ;	db "BOCHS/QEMU"
  3441 000186C4 424F4348532F51454D-     	db "BOCHS/QEMU/VIRTUALBOX"  ; 26/11/2020
  3441 000186CD 552F5649525455414C-
  3441 000186D6 424F58             
  3442                                  ;vbe_vnumber equ vbe2_bochs_vbios + 28 ; "3" or "2"
  3443                                  ; 26/11/2020
  3444                                  vbe_vnumber equ vbe2_bochs_vbios + 30 ; "3" or "2"
  3445                                  ; 15/11/2020
  3446                                  vesa_vbe3_bios_msg:
  3447                                  	;db " VESA VBE version 3 Video BIOS ..."
  3448 000186D9 205645534120564245-     	db " VESA VBE3 Video BIOS ..." ; 26/11/2020
  3448 000186E2 3320566964656F2042-
  3448 000186EB 494F53202E2E2E     
  3449 000186F2 0D0A0D0A00              	db 0Dh, 0Ah, 0Dh, 0Ah, 0
  3450                                  
  3451                                  ; 28/02/2021
  3452 000186F7 18                      truecolor: db 24
  3453                                  
  3454                                  align 2
  3455                                  
  3456                                  ; EPOCH Variables
  3457                                  ; 13/04/2015 - Retro UNIX 386 v1 Beginning
  3458                                  ; 09/04/2013 epoch variables
  3459                                  ; Retro UNIX 8086 v1 Prototype: UNIXCOPY.ASM, 10/03/2013
  3460                                  ;
  3461 000186F8 B207                    year: 	dw 1970
  3462 000186FA 0100                    month: 	dw 1
  3463 000186FC 0100                    day: 	dw 1
  3464 000186FE 0000                    hour: 	dw 0
  3465 00018700 0000                    minute: dw 0
  3466 00018702 0000                    second: dw 0
  3467                                  
  3468                                  DMonth:
  3469 00018704 0000                    	dw 0
  3470 00018706 1F00                    	dw 31
  3471 00018708 3B00                    	dw 59
  3472 0001870A 5A00                    	dw 90
  3473 0001870C 7800                    	dw 120
  3474 0001870E 9700                    	dw 151
  3475 00018710 B500                    	dw 181
  3476 00018712 D400                    	dw 212
  3477 00018714 F300                    	dw 243
  3478 00018716 1101                    	dw 273
  3479 00018718 3001                    	dw 304
  3480 0001871A 4E01                    	dw 334
  3481                                  
  3482                                  ; 15/11/2020
  3483 0001871C 00                      db	0
  3484                                  kernel_version_msg: ; 20/11/2020
  3485 0001871D 5452444F5320283338-     db	"TRDOS (386) Kernel v2.0.3 by Erdogan Tan"
  3485 00018726 3629204B65726E656C-
  3485 0001872F 2076322E302E332062-
  3485 00018738 79204572646F67616E-
  3485 00018741 2054616E           
  3486 00018745 00                      db	0
  3487                                  
  3488                                  ; 20/02/2017
  3489                                  KERNELFSIZE  equ $  ; 04/07/2016
  3490                                  
  3491                                  bss_start:
  3492                                  
  3493                                  ABSOLUTE bss_start
  3494                                  
  3495 00018746 ????                    alignb 8 ; 25/12/2016
  3496                                  
  3497                                  	; 15/04/2016
  3498                                  	; TRDOS 386 (TRDOS v2.0)
  3499                                  	; 	80 interrupts 	
  3500                                  	; 11/03/2015
  3501                                  	; Interrupt Descriptor Table (20/08/2014)
  3502                                  idt:
  3503                                  	;resb	64*8 ; INT 0 to INT 3Fh
  3504                                  	; 15/04/2016
  3505 00018748 <res 280h>              	resb	80*8 ; INT 0 to INT 4Fh
  3506                                  
  3507                                  idt_end:
  3508                                  
  3509                                  ;alignb 4
  3510                                  
  3511                                  task_state_segment:
  3512                                  	; 24/03/2015
  3513 000189C8 ????                    tss.link:   resw 1
  3514 000189CA ????                    	    resw 1
  3515                                  ; tss offset 4	
  3516 000189CC ????????                tss.esp0:   resd 1
  3517 000189D0 ????                    tss.ss0:    resw 1
  3518 000189D2 ????                    	    resw 1	
  3519 000189D4 ????????                tss.esp1:   resd 1
  3520 000189D8 ????                    tss.ss1:    resw 1
  3521 000189DA ????                    	    resw 1 	
  3522 000189DC ????????                tss.esp2:   resd 1
  3523 000189E0 ????                    tss.ss2:    resw 1
  3524 000189E2 ????                    	    resw 1
  3525                                  ; tss offset 28
  3526 000189E4 ????????                tss.CR3:    resd 1
  3527 000189E8 ????????                tss.eip:    resd 1
  3528 000189EC ????????                tss.eflags: resd 1
  3529                                  ; tss offset 40
  3530 000189F0 ????????                tss.eax:    resd 1		 		
  3531 000189F4 ????????                tss.ecx:    resd 1
  3532 000189F8 ????????                tss.edx:    resd 1
  3533 000189FC ????????                tss.ebx:    resd 1
  3534 00018A00 ????????                tss.esp:    resd 1
  3535 00018A04 ????????                tss.ebp:    resd 1
  3536 00018A08 ????????                tss.esi:    resd 1
  3537 00018A0C ????????                tss.edi:    resd 1
  3538                                  ; tss offset 72
  3539 00018A10 ????                    tss.ES:     resw 1
  3540 00018A12 ????                    	    resw 1	
  3541 00018A14 ????                    tss.CS:	    resw 1
  3542 00018A16 ????                    	    resw 1
  3543 00018A18 ????                    tss.SS:	    resw 1
  3544 00018A1A ????                    	    resw 1
  3545 00018A1C ????                    tss.DS:	    resw 1
  3546 00018A1E ????                    	    resw 1
  3547 00018A20 ????                    tss.FS:	    resw 1
  3548 00018A22 ????                    	    resw 1
  3549 00018A24 ????                    tss.GS:	    resw 1
  3550 00018A26 ????                    	    resw 1		
  3551 00018A28 ????                    tss.LDTR:   resw 1
  3552 00018A2A ????                    	    resw 1
  3553                                  ; tss offset 100		
  3554 00018A2C ????                    	    resw 1		
  3555 00018A2E ????                    tss.IOPB:   resw 1
  3556                                  ; tss offset 104 
  3557                                  tss_end:
  3558                                  
  3559 00018A30 ????????                k_page_dir:  resd 1 ; Kernel's (System) Page Directory address
  3560                                  		    ; (Physical address = Virtual address)	 	
  3561 00018A34 ????????                memory_size: resd 1 ; memory size in pages
  3562 00018A38 ????????                free_pages:  resd 1 ; number of free pages		
  3563 00018A3C ????????                next_page:   resd 1 ; offset value in M.A.T. for
  3564                                  		    ; first free page search
  3565 00018A40 ????????                last_page:   resd 1 ; offset value in M.A.T. which
  3566                                  		    ; next free page search will be
  3567                                  		    ; stopped after it. (end of M.A.T.)
  3568 00018A44 ????????                first_page:  resd 1 ; offset value in M.A.T. which
  3569                                  		    ; first free page search
  3570                                  		    ; will be started on it. (for user)
  3571 00018A48 ????????                mat_size:    resd 1 ; Memory Allocation Table size in pages
  3572                                  
  3573                                  ; 20/11/2020
  3574                                  ;vbe2bios:    resw 1 ; VBE2 video bios ID (bochs/qemu)
  3575                                  ;		    ; (0B0C4h or 0B0C5h for bochs/plex86 vgabios)				
  3576                                  
  3577                                  ; 02/09/2014 (Retro UNIX 386 v1)
  3578                                  ; 04/12/2013 (Retro UNIX 8086 v1)
  3579 00018A4C ????                    CRT_START:   resw 1 	  ; starting address in regen buffer
  3580                                  			  ; NOTE: active page only	
  3581 00018A4E <res 10h>               CURSOR_POSN: resw 8 ; cursor positions for video pages
  3582                                  ACTIVE_PAGE: 
  3583 00018A5E ??                      ptty: 	     resb 1 ; current tty
  3584                                  ; 01/07/2015 - 29/01/2016
  3585 00018A5F ??                      ccolor:	     resb 1 ; current color attribute
  3586                                  ; 26/10/2015
  3587                                  ; 07/09/2014
  3588 00018A60 <res 14h>               ttychr:      resw ntty+2 ; Character buffer (multiscreen)
  3589                                  
  3590                                  ; 18/05/2015 (03/06/2013 - Retro UNIX 8086 v1 feature only!)
  3591 00018A74 ????????                p_time:      resd 1     ; present time (for systime & sysmdate)
  3592                                  
  3593                                  ; 18/05/2015 (16/08/2013 - Retro UNIX 8086 v1 feature only !)
  3594                                  ; (open mode locks for pseudo TTYs)
  3595                                  ; [ major tty locks (return error in any conflicts) ]
  3596 00018A78 <res 14h>               ttyl:        resw ntty+2 ; opening locks for TTYs.
  3597                                  
  3598                                  ; 15/04/2015 (Retro UNIX 386 v1)
  3599                                  ; 22/09/2013 (Retro UNIX 8086 v1)
  3600 00018A8C <res Ah>                wlist:       resb ntty+2 ; wait channel list (0 to 9 for TTYs)
  3601                                  ; 15/04/2015 (Retro UNIX 386 v1)
  3602                                  ;; 12/07/2014 -> sp_init set comm. parameters as 0E3h
  3603                                  ;; 0 means serial port is not available 
  3604                                  ;;comprm: ; 25/06/2014
  3605 00018A96 ??                      com1p:       resb 1  ;;0E3h
  3606 00018A97 ??                      com2p:       resb 1  ;;0E3h
  3607                                  
  3608                                  ; 17/11/2015
  3609                                  ; request for response (from the terminal)	
  3610 00018A98 ????                    req_resp:    resw 1 			
  3611                                  ; 07/11/2015
  3612 00018A9A ??                      ccomport:    resb 1 ; current COM (serial) port
  3613                                  		    ; (0= COM1, 1= COM2)
  3614                                  ; 09/11/2015
  3615 00018A9B ??                      comqr:	     resb 1 ; 'query or response' sign (u9.s, 'sndc')
  3616                                  ; 07/11/2015
  3617 00018A9C ????                    rchar:	     resw 1 ; last received char for COM 1 and COM 2		
  3618 00018A9E ????                    schar:	     resw 1 ; last sent char for COM 1 and COM 2
  3619                                  
  3620                                  ; 22/08/2014 (RTC)
  3621                                  ; (Packed BCD)
  3622 00018AA0 ??                      time_seconds: resb 1
  3623 00018AA1 ??                      time_minutes: resb 1
  3624 00018AA2 ??                      time_hours:   resb 1
  3625 00018AA3 ??                      date_wday:    resb 1
  3626 00018AA4 ??                      date_day:     resb 1
  3627 00018AA5 ??                      date_month:   resb 1			
  3628 00018AA6 ??                      date_year:    resb 1
  3629 00018AA7 ??                      date_century: resb 1
  3630                                  
  3631                                  ; 24/01/2016
  3632 00018AA8 ????????                RTC_LH:	       resd 1
  3633 00018AAC ??                      RTC_WAIT_FLAG: resb 1
  3634 00018AAD ??                      USER_FLAG:     resb 1
  3635                                  ; 19/05/2016
  3636                                  ;RTC_second:
  3637 00018AAE ??                      RTC_2Hz:       resb 1 ;  from 2Hz interrupt to 1Hz timer event function	
  3638                                  
  3639                                  %include 'diskbss.s'	; UNINITIALIZED DISK (BIOS) DATA
  3640                              <1> ; ****************************************************************************
  3641                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.0 - diskbss.s
  3642                              <1> ; ----------------------------------------------------------------------------
  3643                              <1> ; Last Update: 24/01/2016
  3644                              <1> ; ----------------------------------------------------------------------------
  3645                              <1> ; Beginning: 24/01/2016
  3646                              <1> ; ----------------------------------------------------------------------------
  3647                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
  3648                              <1> ; ----------------------------------------------------------------------------
  3649                              <1> ; Turkish Rational DOS
  3650                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
  3651                              <1> ;
  3652                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
  3653                              <1> ; diskbss.inc (10/07/2015)
  3654                              <1> ;
  3655                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
  3656                              <1> ; ****************************************************************************
  3657                              <1> 
  3658                              <1> ; Retro UNIX 386 v1 Kernel - DISKBSS.INC
  3659                              <1> ; Last Modification: 10/07/2015
  3660                              <1> ;	(Unnitialized Disk Parameters Data section for 'DISKIO.INC') 
  3661                              <1> 
  3662 00018AAF ??                  <1> alignb 2
  3663                              <1> 
  3664                              <1> ;----------------------------------------
  3665                              <1> ;	TIMER DATA AREA 		:
  3666                              <1> ;----------------------------------------
  3667                              <1> 
  3668                              <1> TIMER_LH:	; 16/02/205
  3669 00018AB0 ????                <1> TIMER_LOW:      resw	1               ; LOW WORD OF TIMER COUNT
  3670 00018AB2 ????                <1> TIMER_HIGH:     resw	1               ; HIGH WORD OF TIMER COUNT
  3671 00018AB4 ??                  <1> TIMER_OFL:      resb 	1               ; TIMER HAS ROLLED OVER SINCE LAST READ
  3672                              <1> 
  3673                              <1> ;----------------------------------------
  3674                              <1> ;	DISKETTE DATA AREAS		:
  3675                              <1> ;----------------------------------------
  3676                              <1> 
  3677 00018AB5 ??                  <1> SEEK_STATUS:	resb	1
  3678 00018AB6 ??                  <1> MOTOR_STATUS:	resb	1
  3679 00018AB7 ??                  <1> MOTOR_COUNT:	resb	1
  3680 00018AB8 ??                  <1> DSKETTE_STATUS:	resb	1
  3681 00018AB9 ??????????????      <1> NEC_STATUS:	resb	7
  3682                              <1> 
  3683                              <1> ;----------------------------------------
  3684                              <1> ;	ADDITIONAL MEDIA DATA		:
  3685                              <1> ;----------------------------------------
  3686                              <1> 
  3687 00018AC0 ??                  <1> LASTRATE:	resb 	1
  3688 00018AC1 ??                  <1> HF_STATUS:	resb 	1
  3689 00018AC2 ??                  <1> HF_ERROR:	resb 	1
  3690 00018AC3 ??                  <1> HF_INT_FLAG:	resb 	1
  3691 00018AC4 ??                  <1> HF_CNTRL:	resb 	1
  3692 00018AC5 ????????            <1> DSK_STATE:	resb 	4
  3693 00018AC9 ????                <1> DSK_TRK:	resb 	2
  3694                              <1> 
  3695                              <1> ;----------------------------------------
  3696                              <1> ;	FIXED DISK DATA AREAS		:
  3697                              <1> ;----------------------------------------
  3698                              <1> 
  3699 00018ACB ??                  <1> DISK_STATUS1:	resb 	1		; FIXED DISK STATUS
  3700 00018ACC ??                  <1> HF_NUM:		resb 	1		; COUNT OF FIXED DISK DRIVES
  3701 00018ACD ??                  <1> CONTROL_BYTE:	resb 	1		; HEAD CONTROL BYTE
  3702                              <1> ;@PORT_OFF	resb	1		; RESERVED (PORT OFFSET)
  3703                              <1> ;port1_off	resb	1		; Hard disk controller 1 - port offset
  3704                              <1> ;port2_off	resb	1		; Hard idsk controller 2 - port offset
  3705                              <1> 
  3706 00018ACE ????                <1> alignb 4
  3707                              <1> 
  3708                              <1> ;HF_TBL_VEC:	resd	1 		; Primary master disk param. tbl. pointer
  3709                              <1> ;HF1_TBL_VEC:	resd	1		; Primary slave disk param. tbl. pointer
  3710                              <1> HF_TBL_VEC: ; 22/12/2014	
  3711 00018AD0 ????????            <1> HDPM_TBL_VEC:	resd	1 		; Primary master disk param. tbl. pointer
  3712 00018AD4 ????????            <1> HDPS_TBL_VEC:	resd	1		; Primary slave disk param. tbl. pointer
  3713 00018AD8 ????????            <1> HDSM_TBL_VEC:	resd	1 		; Secondary master disk param. tbl. pointer
  3714 00018ADC ????????            <1> HDSS_TBL_VEC:	resd	1		; Secondary slave disk param. tbl. pointer
  3715                              <1> 
  3716                              <1> ; 03/01/2015
  3717 00018AE0 ??                  <1> LBAMode:     	resb	1
  3718                              <1> 
  3719                              <1> ; *****************************************************************************
  3640                                  
  3641                                  ;;; Real Mode Data (10/07/2015 - BSS)
  3642                                  
  3643                                  ;alignb 2
  3644                                  
  3645                                  ; 10/01/2016
  3646                                  %include 'trdoskx.s'	; UNINITIALIZED KERNEL (Logical Drive & FS) DATA
  3647                              <1> ; ****************************************************************************
  3648                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.2) - UNINITIALIZED DATA : trdoskx.s
  3649                              <1> ; ----------------------------------------------------------------------------
  3650                              <1> ; Last Update: 30/08/2020
  3651                              <1> ; ----------------------------------------------------------------------------
  3652                              <1> ; Beginning: 04/01/2016
  3653                              <1> ; ----------------------------------------------------------------------------
  3654                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
  3655                              <1> ; ----------------------------------------------------------------------------
  3656                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
  3657                              <1> ; TRDOS2.ASM (09/11/2011)
  3658                              <1> ; ****************************************************************************
  3659                              <1> ; DRV_INIT.ASM [26/09/2009] Last Update: 07/08/2011
  3660                              <1> ; MAINPROG.ASM [17/01/2004] Last Update: 09/11/2011
  3661                              <1> ; DIR.ASM      [17/01/2004] Last Update: 09/10/2011
  3662                              <1> ; CMD_INTR.ASM [29/01/2005] Last update: 09/11/2011
  3663                              <1> ; DRV_FAT.ASM  [07/07/2009] Last update: 21/08/2011
  3664                              <1> 
  3665 00018AE1 ??????              <1> alignb 4
  3666                              <1> 
  3667                              <1> ; MAINPROG.ASM
  3668 00018AE4 ????????            <1> MainProgCfg_FileSize:   resd 1 ; 14/04/2016
  3669 00018AE8 ????????            <1> MainProgCfg_LineOffset: resd 1 ; 14/04/2016
  3670                              <1> 
  3671 00018AEC ????????            <1> Current_VolSerial: resd 1
  3672                              <1> 
  3673 00018AF0 ????????            <1> Current_Dir_FCluster: resd 1
  3674                              <1> 
  3675 00018AF4 ??                  <1> Current_Dir_Level: resb 1
  3676 00018AF5 ??                  <1> Current_FATType: resb 1
  3677 00018AF6 ??                  <1> Current_Drv: resb 1
  3678 00018AF7 ??                  <1> Current_Dir_Drv:   resb 1 ; '?'
  3679 00018AF8 ??                  <1>                    resb 1 ; ':'
  3680 00018AF9 ??                  <1> Current_Dir_Root:  resb 1 ; '/' 
  3681 00018AFA <res 5Ah>           <1> Current_Directory: resb 90
  3682 00018B54 ??                  <1> End_Of_Current_Dir_Str: resb 1
  3683 00018B55 ??                  <1> Current_Dir_StrLen: resb 1   
  3684                              <1> 
  3685 00018B56 ??                  <1> CursorColumn: 	resb 1
  3686 00018B57 ??                  <1> CmdArgStart:    resb 1
  3687                              <1> 
  3688                              <1> ; 03/02/2016
  3689 00018B58 <res 4Eh>           <1> Remark:		resb 78
  3690                              <1> 
  3691 00018BA6 <res 50h>           <1> CommandBuffer: 	resb 80
  3692                              <1> 
  3693 00018BF6 <res 100h>          <1> TextBuffer:	resb 256
  3694                              <1> 
  3695                              <1> MasterBootBuff:
  3696 00018CF6 <res 1BEh>          <1> MasterBootCode: resb 1BEh
  3697 00018EB4 <res 40h>           <1> PartitionTable: resb 64
  3698 00018EF4 ????                <1> MBIDCode: resw 1
  3699                              <1> 
  3700                              <1> PTable_Buffer:
  3701 00018EF6 <res 40h>           <1> PTable_hd0: resb 64
  3702 00018F36 <res 40h>           <1> PTable_hd1: resb 64
  3703 00018F76 <res 40h>           <1> PTable_hd2: resb 64
  3704 00018FB6 <res 40h>           <1> PTable_hd3: resb 64
  3705                              <1> ; 15/07/2020
  3706                              <1> ;PTable_ep0: resb 64
  3707                              <1> ;PTable_ep1: resb 64
  3708                              <1> ;PTable_ep2: resb 64
  3709                              <1> ;PTable_ep3: resb 64
  3710                              <1> 
  3711                              <1> ; 13/08/2020
  3712 00018FF6 ??                  <1> scount: resb 1 ; 16/05/2016 (diskio.s, 'int33h:')
  3713 00018FF7 ??                  <1> 	resb 1
  3714 00018FF8 ??                  <1> 	resb 1
  3715 00018FF9 ??                  <1> 	resb 1
  3716                              <1> 	
  3717 00018FFA ??                  <1> HD_LBA_yes: resb 1
  3718 00018FFB ??                  <1> PP_Counter: resb 1
  3719 00018FFC ??                  <1> EP_Counter: resb 1
  3720                              <1> ; 13/08/2020
  3721 00018FFD ??                  <1> LD_Counter: resb 1
  3722                              <1> 
  3723                              <1> ; 30/08/2020
  3724 00018FFE ????????            <1> MBR_EP_StartSector: resd 1 
  3725                              <1> 		; Extd partition start sector as in MBR
  3726 00019002 ????????            <1> EP_StartSector: resd 1 ; next extd partition start sector
  3727                              <1> 	; 15/07/2020	
  3728                              <1>                 ;resd 1
  3729                              <1>                 ;resd 1
  3730                              <1> 
  3731                              <1> ; 20/07/2020
  3732 00019006 <res 200h>          <1> DOSBootSectorBuff: resb 512
  3733                              <1> ; 15/07/2020
  3734                              <1> ;DOSBootSectorBuff: resb 446 ; 1BEh
  3735                              <1> ;MiniPartitionTable: resb 64 ;  40h
  3736                              <1> ;MiniPartitionMagic: resw  1 ;  02h 		
  3737                              <1> 
  3738                              <1> FAT_BuffDescriptor:
  3739 00019206 ????????            <1> FAT_CurrentCluster: resd 1
  3740 0001920A ??                  <1> FAT_BuffValidData: resb 1
  3741 0001920B ??                  <1> FAT_BuffDrvName: resb 1
  3742 0001920C ????                <1> FAT_BuffOffset: resw 1
  3743 0001920E ????????            <1> FAT_BuffSector: resd 1
  3744                              <1> 
  3745 00019212 ????????            <1> FAT_ClusterCounter: resd 1
  3746 00019216 ????????            <1> LastCluster: resd 1
  3747                              <1> 
  3748                              <1> ; 16/05/2016
  3749                              <1> ;; 18/03/2016 (TRDOS v2.0)
  3750                              <1> ;ClusterBuffer_Valid: resb 1
  3751                              <1> 
  3752                              <1> Dir_BuffDescriptor:
  3753 0001921A ??                  <1> DirBuff_DRV: resb 1
  3754 0001921B ??                  <1> DirBuff_FATType: resb 1
  3755 0001921C ??                  <1> DirBuff_ValidData: resb 1
  3756 0001921D ????                <1> DirBuff_CurrentEntry: resw 1
  3757 0001921F ????                <1> DirBuff_LastEntry: resw 1
  3758 00019221 ????????            <1> DirBuff_Cluster: resd 1 
  3759 00019225 ????                <1> DirBuffer_Size: resw 1
  3760                              <1> ;DirBuff_EntryCounter: resw 1
  3761                              <1> 
  3762                              <1> ; 01/02/2016
  3763                              <1> ; these are on (real mode) segment 8000h and later
  3764                              <1> ; FAT_Buffer:	resb 1536 ; 3 sectors
  3765                              <1> ; Dir_Buffer:	resb 512*32
  3766                              <1> ; Logical_DOSDisks:  resb 6656 ; 26 * 256 bytes
  3767                              <1> 
  3768                              <1> ; 18/01/2016
  3769                              <1> 
  3770 00019227 ????????            <1> FreeClusterCount: resd 1
  3771                              <1> 
  3772 0001922B ????????            <1> VolSize_Unit1:   resd 1
  3773 0001922F ????????            <1> VolSize_Unit2:   resd 1
  3774                              <1> 
  3775 00019233 ????????            <1> Vol_Tot_Sec_Str_Start:	    resd 1
  3776 00019237 <res Ah>            <1> Vol_Tot_Sec_Str: 	    resb 10
  3777 00019241 ??                  <1> Vol_Tot_Sec_Str_End:	    resb 1
  3778 00019242 ??                  <1> resb 1
  3779 00019243 ????????            <1> Vol_Free_Sectors_Str_Start: resd 1
  3780 00019247 <res Ah>            <1> Vol_Free_Sectors_Str:	    resb 10				
  3781 00019251 ??                  <1> Vol_Free_Sectors_Str_End:   resb 1
  3782                              <1> 
  3783                              <1> ; 10/02/2016
  3784 00019252 ??                  <1> RUN_CDRV: resb 1 ; CMD_INTR.ASM  ; 09/11/2011
  3785                              <1> 
  3786                              <1> ; 24/01/2016
  3787 00019253 <res 80h>           <1> PATH_Array:     resb 128 ; DIR.ASM ; 09/10/2011
  3788                              <1> ; 06/02/2016
  3789 000192D3 ????????            <1> CCD_DriveDT:	resd 1 ; DIR.ASM ; (word)
  3790 000192D7 ??                  <1> CCD_Level:	resb 1 ; DIR.ASM
  3791 000192D8 ??                  <1> Last_Dir_Level:	resb 1 ; DIR.ASM
  3792                              <1> ;
  3793 000192D9 ????                <1> CDLF_AttributesMask: resw 1 ; DIR.ASM
  3794 000192DB ????????            <1> CDLF_FNAddress:	resd 1 ; DIR.ASM (word)
  3795 000192DF ????                <1> CDLF_DEType:	resw 1 ; DIR.ASM
  3796                              <1> ;
  3797 000192E1 ??                  <1> CD_COMMAND:	resb 1 ; DIR.ASM
  3798                              <1> 
  3799 000192E2 ????                <1> alignb 4
  3800                              <1> 
  3801                              <1> ; 29/01/2016
  3802 000192E4 ??                  <1> Program_Exit:	resb 1 ; CMD_INTR.ASM  ; 09/11/2011
  3803                              <1> 
  3804                              <1> ;alignb 4
  3805                              <1> ; 23/02/2016
  3806 000192E5 ??                  <1> disk_rw_op:	resb 1 ;  0 = disk read, 1 = disk write
  3807                              <1> ;disk_rw_spt:	resb 1 ; sectors per track (<= 63) /// (<256)
  3808                              <1> ; 31/01/2016
  3809 000192E6 ??                  <1> retry_count: 	resb 1 ; DISK_IO.ASM ; 20/07/2011 (CHS_RetryCount)
  3810 000192E7 ??                  <1> disk_rw_err: 	resb 1 ; DISK_IO.ASM ; (Disk_IO_err_code)
  3811 000192E8 ????????            <1> sector_count:	resd 1 ; DISK_IO.ASM ; (Disk_RW_SectorCount)
  3812                              <1> 
  3813                              <1> ; 06/02/2016 (long name)
  3814 000192EC ????                <1> FDE_AttrMask:	   resw 1 ; DIR.ASM
  3815 000192EE ????                <1> AmbiguousFileName: resw 1 ; DIR.ASM
  3816 000192F0 ??                  <1> PreviousAttr:	   resb 1 ; DIR.ASM
  3817                              <1> ;	
  3818 000192F1 ??                  <1> LongNameFound:   resb 1	  ; DIR.ASM
  3819 000192F2 ??                  <1> LFN_EntryLength: resb 1   ; DIR.ASM
  3820 000192F3 ??                  <1> LFN_CheckSum:    resb 1   ; DIR.ASM
  3821 000192F4 <res 84h>           <1> LongFileName:    resb 132 ; DIR.ASM
  3822                              <1> 
  3823                              <1> ;PATH_Array_Ptr: resw 1 ; DIR.ASM
  3824 00019378 ??                  <1> PATH_CDLevel:	 resb 1 ; DIR.ASM
  3825 00019379 ??                  <1> PATH_Level:	 resb 1 ; DIR.ASM
  3826                              <1> 
  3827                              <1> ; 07/02/2016
  3828 0001937A <res Dh>            <1> Dir_File_Name:	resb 13 ; DIR.ASM ; 09/10/2011
  3829                              <1> 
  3830                              <1> ; 10/02/2016
  3831 00019387 <res Dh>            <1> Dir_Entry_Name:	resb 13 ; DIR.ASM
  3832                              <1> 
  3833                              <1> alignb 2
  3834                              <1> 
  3835 00019394 ????                <1> AttributesMask: resw 1 ; CMD_INTR.ASM ; 09/11/2011
  3836                              <1> 
  3837                              <1> ; 10/02/2016 (128 bytes -> 126 bytes)
  3838                              <1> ; 08/02/2016
  3839                              <1> ;FFF Structure (128 bytes) ; DIR.ASM ; 09/10/2011
  3840 00019396 ??                  <1> FindFile_Drv:		  resb 1
  3841 00019397 <res 41h>           <1> FindFile_Directory:	  resb 65
  3842 000193D8 <res Dh>            <1> FindFile_Name:		  resb 13
  3843                              <1> FindFile_LongNameEntryLength:
  3844 000193E5 ??                  <1> FindFile_LongNameYes: 	  resb 1 ; Sign for longname procedures
  3845                              <1> ;Above 80 bytes form
  3846                              <1> ;TR-DOS Source/Destination File FullName Format/Structure
  3847 000193E6 ????                <1> FindFile_AttributesMask:  resw 1
  3848 000193E8 <res 20h>           <1> FindFile_DirEntry:	  resb 32
  3849 00019408 ????????            <1> FindFile_DirFirstCluster: resd 1
  3850 0001940C ????????            <1> FindFile_DirCluster:	  resd 1
  3851 00019410 ????                <1> FindFile_DirEntryNumber:  resw 1
  3852 00019412 ????                <1> FindFile_MatchCounter:	  resw 1
  3853 00019414 ????                <1> FindFile_Reserved:	  resw 1 ; 06/03/2016
  3854                              <1> 
  3855 00019416 ????????            <1> First_Path_Pos: resd 1	; DIR.ASM ; 09/10/2011
  3856 0001941A ????????            <1> Last_Slash_Pos: resd 1	; DIR.ASM 
  3857                              <1> 
  3858                              <1> ; 10/02/2016
  3859 0001941E ????                <1> File_Count:     resw 1 	; DIR.ASM ; 09/10/2011
  3860 00019420 ????                <1> Dir_Count:      resw 1
  3861 00019422 ????????            <1> Total_FSize:    resd 1
  3862 00019426 ????????            <1> TFS_Dec_Begin:  resd 1
  3863 0001942A <res Ah>            <1>                 resb 10
  3864 00019434 ??                  <1> TFS_Dec_End:    resb 1
  3865                              <1> 
  3866 00019435 ??                  <1> PrintDir_RowCounter: resb 1
  3867                              <1> 
  3868 00019436 ????                <1> alignb 4
  3869                              <1> ; 15/02/2015 ('show' command variables)
  3870 00019438 ????????            <1> Show_FDT:	resd 1
  3871 0001943C ????????            <1> Show_LDDDT:	resd 1
  3872 00019440 ????????            <1> Show_Cluster:	resd 1
  3873 00019444 ????????            <1> Show_FileSize:	resd 1
  3874 00019448 ????????            <1> Show_FilePointer: resd 1
  3875 0001944C ????                <1> Show_ClusterPointer: resw 1
  3876 0001944E ????                <1> Show_ClusterSize: resw 1
  3877 00019450 ??                  <1> Show_RowCount:	resb 1
  3878                              <1> 
  3879 00019451 ??????              <1> alignb 4
  3880                              <1> ; 21/02/2016
  3881 00019454 ????????            <1> DelFile_FNPointer:	resd 1 ; ; CMD_INTR.ASM (word) ; 09/11/2011
  3882                              <1> ; 27/02/2016
  3883                              <1> ; DIR.ASM (09/10/2011)
  3884 00019458 ????????            <1> DelFile_FCluster:	resd 1
  3885 0001945C ????                <1> DelFile_EntryCounter:	resw 1
  3886 0001945E ??                  <1> DelFile_LNEL:		resb 1
  3887 0001945F ??                  <1> resb 1
  3888                              <1> 
  3889                              <1> ; DIR.ASM
  3890 00019460 ????????            <1> mkdir_DirName_Offset: 	resd 1
  3891 00019464 ????????            <1> mkdir_FFCluster:	resd 1
  3892 00019468 ????????            <1> mkdir_LastDirCluster:	resd 1
  3893 0001946C ????????            <1> mkdir_FreeSectors:	resd 1
  3894 00019470 ????                <1> mkdir_attrib:		resw 1 
  3895 00019472 ??                  <1> mkdir_SecPerClust:	resb 1
  3896 00019473 ??                  <1> mkdir_add_new_cluster:	resb 1
  3897 00019474 <res Dh>            <1> mkdir_Name:		resb 13
  3898 00019481 ????                <1> resw 1 ; 01/03/2016
  3899                              <1> ; 27/02/2016
  3900 00019483 ??                  <1> RmDir_MultiClusters:	resb 1  
  3901 00019484 ????????            <1> RmDir_DirEntryOffset:	resd 1 ; 01/03/2016 (word -> dword)
  3902 00019488 ????????            <1> RmDir_ParentDirCluster: resd 1
  3903 0001948C ????????            <1> RmDir_DirLastCluster:   resd 1
  3904 00019490 ????????            <1> RmDir_PreviousCluster:  resd 1
  3905                              <1> ; 22/02/2016
  3906 00019494 ??                  <1> UPDLMDT_CDirLevel:	resb 1
  3907 00019495 ????????            <1> UPDLMDT_CDirFCluster:	resd 1
  3908                              <1> 	
  3909 00019499 ??????              <1> alignb 4
  3910                              <1> ; DRV_FAT.ASM ; 21/08/2011
  3911 0001949C ????????            <1> gffc_next_free_cluster:  resd 1
  3912 000194A0 ????????            <1> gffc_first_free_cluster: resd 1
  3913 000194A4 ????????            <1> gffc_last_free_cluster:  resd 1
  3914                              <1> 
  3915                              <1> ;29/04/2016
  3916                              <1> Cluster_Index: ; resd 1
  3917                              <1> ; 22/02/2016
  3918 000194A8 ????????            <1> ClusterValue:	resd 1
  3919                              <1> ; 04/03/2016
  3920 000194AC ??                  <1> Attributes:	resb 1 
  3921                              <1> ;;CFS_error:  resb 1 ;; 01/03/2016
  3922 000194AD ??                  <1> resb 1
  3923 000194AE ??                  <1> CFS_OPType: resb 1
  3924 000194AF ??                  <1> CFS_Drv:    resb 1
  3925 000194B0 ????????            <1> CFS_CC:	    resd 1
  3926 000194B4 ????????            <1> CFS_FAT32FSINFOSEC: resd 1
  3927 000194B8 ????????            <1> CFS_FAT32FC: resd 1
  3928                              <1> 
  3929                              <1> ; 27/02/2016
  3930                              <1> ;alignb 4
  3931 000194BC ????????            <1> glc_prevcluster: resd 1 ; DRV_FAT.ASM (21/08/2011)
  3932                              <1> ; 22/10/2016
  3933 000194C0 ????????            <1> glc_index:	 resd 1 ;  Last Cluster Index (22/10/2016)	
  3934                              <1> 
  3935                              <1> ; DIR.ASM
  3936 000194C4 ????                <1> DLN_EntryNumber: resw 1
  3937 000194C6 ??                  <1> DLN_40h:	 resb 1
  3938                              <1> ; 28/02/2016
  3939 000194C7 ??                  <1> TCC_FATErr:	 resb 1 ; DRV_FAT.ASM
  3940                              <1> 
  3941                              <1> alignb 4
  3942                              <1> ; DIR.ASM (09/10/2011)
  3943 000194C8 ????                <1> LCDE_EntryIndex: resw 1 ; LCDE_EntryOffset
  3944 000194CA ????                <1> LCDE_ClusterSN:  resw 1
  3945 000194CC ????????            <1> LCDE_Cluster: 	 resd 1
  3946 000194D0 ????????            <1> LCDE_ByteOffset: resd 1
  3947                              <1> 
  3948                              <1> ;alignb4
  3949                              <1> ; 06/03/2016 (word -> dword)
  3950                              <1> ; CMD_INTR.ASM (01/08/2010)
  3951 000194D4 ????????            <1> SourceFilePath:	     resd 1
  3952 000194D8 ????????            <1> DestinationFilePath: resd 1
  3953                              <1> 
  3954                              <1> ;alignb 4
  3955                              <1> ; 06/03/2016
  3956                              <1> ; FILE.ASM (09/10/2011)
  3957                              <1> ;Source File Structure (same with 'Find File' Structure)
  3958 000194DC ??                  <1> SourceFile_Drv:			resb 1
  3959 000194DD <res 41h>           <1> SourceFile_Directory:		resb 65
  3960 0001951E <res Dh>            <1> SourceFile_Name:		resb 13
  3961                              <1> SourceFile_LongNameEntryLength: 
  3962 0001952B ??                  <1> SourceFile_LongNameYes:		resb 1 ; Sign for longname procedures
  3963                              <1> ;Above 80 bytes
  3964                              <1> ;is TR-DOS Source File FullName Format/Structure
  3965 0001952C ????                <1> SourceFile_AttributesMask:	resw 1
  3966 0001952E <res 20h>           <1> SourceFile_DirEntry:		resb 32
  3967 0001954E ????????            <1> SourceFile_DirFirstCluster:	resd 1
  3968 00019552 ????????            <1> SourceFile_DirCluster:		resd 1
  3969 00019556 ????                <1> SourceFile_DirEntryNumber:	resw 1
  3970 00019558 ????                <1> SourceFile_MatchCounter:	resw 1
  3971                              <1> ; 16/03/2016
  3972 0001955A ??                  <1> SourceFile_SecPerClust:		resb 1
  3973 0001955B ??                  <1> SourceFile_Reserved:		resb 1
  3974                              <1> ; Above is 128 bytes
  3975                              <1> 
  3976                              <1> ;Destination File Structure (same with 'Find File' Structure)
  3977 0001955C ??                  <1> DestinationFile_Drv:		resb 1
  3978 0001955D <res 41h>           <1> DestinationFile_Directory: 	resb 65
  3979 0001959E <res Dh>            <1> DestinationFile_Name:		resb 13
  3980                              <1> DestinationFile_LongNameEntryLength:
  3981 000195AB ??                  <1> DestinationFile_LongNameYes:	resb 1 ; Sign for longname procedures
  3982                              <1> ;Above 80 bytes
  3983                              <1> ;is TR-DOS Destination File FullName Format/Structure
  3984 000195AC ????                <1> DestinationFile_AttributesMask: resw 1
  3985 000195AE <res 20h>           <1> DestinationFile_DirEntry:	resb 32
  3986 000195CE ????????            <1> DestinationFile_DirFirstCluster: resd 1
  3987 000195D2 ????????            <1> DestinationFile_DirCluster:	resd 1
  3988 000195D6 ????                <1> DestinationFile_DirEntryNumber: resw 1
  3989 000195D8 ????                <1> DestinationFile_MatchCounter:	resw 1
  3990                              <1> ; 16/03/2016
  3991 000195DA ??                  <1> DestinationFile_SecPerClust:	resb 1
  3992 000195DB ??                  <1> DestinationFile_Reserved:	resb 1
  3993                              <1> ; Above is 128 bytes
  3994                              <1> 
  3995                              <1> ; 24/04/2016
  3996 000195DC ????                <1> resw 1
  3997                              <1> 
  3998                              <1> ; 10/03/2016
  3999                              <1> ; FILE.ASM
  4000 000195DE ??                  <1> move_cmd_phase:	   resb 1
  4001 000195DF ??                  <1> msftdf_sf_df_drv:  resb 1
  4002 000195E0 ????????            <1> msftdf_drv_offset: resd 1
  4003                              <1> 
  4004                              <1> ; 11/03/2016
  4005                              <1> ; DRV_FAT.ASM (21/08/2011)
  4006 000195E4 ????????            <1> FAT_anc_LCluster:  resd 1
  4007 000195E8 ????????            <1> FAT_anc_FFCluster: resd 1
  4008                              <1> 
  4009                              <1> ;alignb 4
  4010                              <1> 
  4011                              <1> ; 14/03/2016
  4012                              <1> ; TRDOS 386 = TRDOS v2.0 feature only !
  4013                              <1> ; 'allocate_memory_block' in 'memory.s'
  4014 000195EC ????????            <1> mem_ipg_count:	resd 1 ; page count (for contiguous allocation)
  4015 000195F0 ????????            <1> mem_pg_count:	resd 1 ; page count (for count down)
  4016 000195F4 ????????            <1> mem_aperture:	resd 1 ; contiguous free pages (current)
  4017 000195F8 ????????            <1> mem_max_aperture: resd 1 ; maximum value of contiguous free pages
  4018 000195FC ????????            <1> mem_pg_pos:	resd 1 ; mem. position (page #) of current aperture
  4019 00019600 ????????            <1> mem_max_pg_pos: resd 1 ; mem. position (page #) of max. aperture
  4020                              <1> 
  4021                              <1> ; 15/03/2016
  4022                              <1> ; FILE.ASM ('copy_source_file_to_destination_file')
  4023 00019604 ??                  <1> copy_cmd_phase:       resb 1
  4024 00019605 ??                  <1> csftdf_rw_err:	      resb 1
  4025 00019606 ??                  <1> DestinationFileFound: resb 1
  4026 00019607 ??                  <1> csftdf_cdrv: 	      resb 1
  4027 00019608 ????????            <1> csftdf_filesize:      resd 1
  4028                              <1> ; TRDOS386 (TRDOS v2.0)
  4029 0001960C ????????            <1> csftdf_sf_mem_addr:   resd 1
  4030 00019610 ????????            <1> csftdf_sf_mem_bsize:  resd 1
  4031                              <1> ;
  4032                              <1> 
  4033 00019614 ????????            <1> csftdf_sf_cluster:    resd 1 ; 16/03/2016
  4034 00019618 ????????            <1> csftdf_df_cluster:    resd 1
  4035                              <1> ; 16/03/2016
  4036 0001961C ????????            <1> csftdf_r_size:        resd 1
  4037 00019620 ????????            <1> csftdf_w_size:        resd 1
  4038 00019624 ????????            <1> csftdf_sf_rbytes:     resd 1
  4039 00019628 ????????            <1> csftdf_df_wbytes:     resd 1
  4040 0001962C ??                  <1> csftdf_percentage:    resb 1
  4041                              <1> ; 17/03/2016
  4042 0001962D ??                  <1> csftdf_videopage:     resb 1
  4043 0001962E ????                <1> csftdf_cursorpos:     resw 1
  4044 00019630 ????????            <1> csftdf_sf_drv_dt:     resd 1
  4045 00019634 ????????            <1> csftdf_df_drv_dt:     resd 1
  4046                              <1> 
  4047                              <1> ; 21/03/2016
  4048                              <1> ; 20/03/2016
  4049                              <1> ; FILE.ASM
  4050 00019638 ????????            <1> createfile_Name_Offset:  resd 1
  4051 0001963C ????????            <1> createfile_FreeSectors:  resd 1 
  4052 00019640 ????????            <1> createfile_size:         resd 1
  4053 00019644 ????????            <1> createfile_FFCluster:    resd 1 ; 11/03/2016
  4054 00019648 ????????            <1> createfile_LastDirCluster: resd 1
  4055 0001964C ????????            <1> createfile_Cluster:      resd 1
  4056 00019650 ????????            <1> createfile_PCluster:     resd 1
  4057 00019654 ??                  <1> createfile_attrib:	 resb 1
  4058 00019655 ??                  <1> createfile_SecPerClust:  resb 1
  4059 00019656 ????                <1> createfile_DirIndex:     resw 1
  4060 00019658 ????????            <1> createfile_CCount:	 resd 1
  4061 0001965C ????                <1> createfile_BytesPerSec:	 resw 1 ; 23/03/2016
  4062 0001965E ??                  <1> createfile_wfc:	         resb 1
  4063 0001965F ??                  <1> createfile_UpdatePDir:	 resb 1 ; 31/03/2016
  4064                              <1> 
  4065                              <1> ;alignb 4
  4066                              <1> 
  4067                              <1> ; 11/04/2016
  4068 00019660 ????                <1> env_var_length:	   resw 1
  4069                              <1> 
  4070 00019662 ????                <1> alignb 4
  4071                              <1> 
  4072                              <1> ; 25/04/2016
  4073 00019664 ??                  <1> readi.valid:	resb 1 ; valid data (>0 = valid for readi)
  4074 00019665 ??                  <1> readi.drv:	resb 1 ; drive number (0, 1,2,3,4..)
  4075 00019666 ??                  <1> readi.spc:	resb 1 ; sectors per cluster for 'readi' drive
  4076 00019667 ??                  <1> readi.s_index:  resb 1 ; sector index in current cluster (buffer)
  4077 00019668 ????????            <1> readi.sector:	resd 1 ; current disk sector
  4078 0001966C ????                <1> readi.bpc:	resw 1 ; bytes per cluster - 1
  4079 0001966E ????                <1> readi.offset:	resw 1 ; byte offset in cluster buffer
  4080 00019670 ????????            <1> readi.cluster:  resd 1 ; current cluster number
  4081 00019674 ????????            <1> readi.c_index:	resd 1 ; cluster index of the current cluster (0,1,2,3..)
  4082 00019678 ????????            <1> readi.fclust:	resd 1 ; first cluster of the current cluster
  4083 0001967C ????????            <1> readi.fs_index: resd 1 ; sector index in disk/file section (for Singlix FS)
  4084                              <1> ;readi.buffer:	resd 1 ; readi sector buffer address
  4085                              <1> 
  4086                              <1> ;alignb 4
  4087                              <1> 
  4088 00019680 ??                  <1> writei.valid:	resb 1 ; valid data (>0 = valid for writei)
  4089 00019681 ??                  <1> writei.drv:	resb 1 ; drive number (0, 1,2,3,4..)
  4090 00019682 ??                  <1> writei.spc:	resb 1 ; sectors per cluster for 'writei' drive
  4091 00019683 ??                  <1> writei.s_index: resb 1 ; sector index in current cluster (buffer)
  4092 00019684 ????????            <1> writei.sector:	resd 1 ; current disk sector
  4093 00019688 ????                <1> writei.bpc:	resw 1 ; bytes per cluster - 1
  4094 0001968A ????                <1> writei.offset:	resw 1 ; byte offset in cluster buffer
  4095 0001968C ????????            <1> writei.cluster: resd 1 ; current cluster number
  4096 00019690 ????????            <1> writei.c_index:	resd 1 ; cluster index of the current cluster (0,1,2,3..)
  4097 00019694 ????????            <1> writei.fclust:  resd 1 ; first cluster of the current cluster
  4098 00019698 ????????            <1> writei.fs_index: resd 1 ; sector index in disk/file section (for Singlix FS)
  4099                              <1> ;writei.buffer:	resd 1 ; writei sector buffer address
  4100 0001969C ????????            <1> writei.lclust:	resd 1 ; writei last cluster (mget_w) ; 23/10/2016
  4101 000196A0 ????????            <1> writei.l_index:	resd 1 ; writei last cluster index (mget_w) ; 23/10/2016
  4102 000196A4 ??                  <1> writei.ofn:	resb 1 ; open file number (to be written) ; 23/10/2016
  4103                              <1> 
  4104 000196A5 ??????              <1> alignb 4
  4105                              <1> 
  4106                              <1> ; 29/04/2016
  4107 000196A8 ????????            <1> Run_CDirFC:	resd 1
  4108 000196AC ??                  <1> Run_Auto_Path:	resb 1
  4109 000196AD ??                  <1> Run_Manual_Path: resb 1 ; 0 -> auto path sequence needed
  4110 000196AE ??                  <1> EXE_ID:		resb 1	
  4111 000196AF ??                  <1> EXE_dot:	resb 1
  4112                              <1> 
  4113                              <1> ; 06/05/2016
  4114 000196B0 ????????            <1> mainprog_return_addr: resd 1
  4115 000196B4 ????????            <1> last_error:	resd 1  ; this will be used to return error code to MainProg
  4116                              <1> 			; 'lasterror' keyword will be used later to get the
  4117                              <1> 			; last error code/number/status.
  4118                              <1> ; 12/05/2016
  4119 000196B8 ????????            <1> video_eax:	resd 1  ; eax return value of video function
  4120                              <1> 
  4121                              <1> ; 01/06/2016
  4122 000196BC ????????            <1> user_buffer:	resd 1  ; 'diskio.s' (INT 33h, Function 08h, floppy disk type)
  4123                              <1> 
  4124                              <1> ; 21/05/2016 - TRDOS 386 ('swap/switch', 'rswap', [u.pri])
  4125 000196C0 ??                  <1> priority:	resb 1  ; running priority level of process (0,1,2)
  4126                              <1> 			; (run queue which is process comes from)
  4127                              <1> ; 22/05/2016 - TRDOS 386 ('set_run_sequence', 'rtc_int', 'u_timer')
  4128 000196C1 ??                  <1> p_change:	resb 1  ; process change status (for timer events)
  4129                              <1> ; 23/05/2016 - TRDOS 386 ('clock')
  4130 000196C2 ??                  <1> multi_tasking:	resb 1   ; Multi Tasking status (0 = disabled, >0 = enabled)
  4131                              <1> 			; (EBX will return with user buffer addr or disk type)
  4132                              <1> ; 07/06/2016
  4133 000196C3 ??                  <1> timer_events:	resb 1  ; number of (active) timer events, <= 16		
  4134                              <1> 
  4135                              <1> ; 24/06/2016
  4136 000196C4 ??                  <1> w_str_cmd:	resb 1	; WRITE_STRING command (0,1,2,3) ; video.s
  4137 000196C5 ??                  <1> p_crt_mode:	resb 1  ; previous video mode (=3 or 0), backup mark/sign
  4138                              <1> ; 26/06/2016
  4139 000196C6 ??                  <1> p_crt_page:	resb 1  ; previous active page (for 'set_mode')
  4140                              <1> ; 04/07/2016
  4141 000196C7 ??                  <1> noclearmem:	resb 1  ; if set, 'SET MODE' (INT 31h) function (AH = 4)
  4142                              <1> 			; will not clear the video memory
  4143                              <1> 			; (usable for graphics modes only)
  4144                              <1> alignb 2
  4145 000196C8 ????                <1> CRT_LEN:	resw 1  ; length of regen buffer in bytes
  4146 000196CA <res 10h>           <1> cursor_pposn:	resw 8  ; cursor positions backup
  4147                              <1> 
  4148                              <1> ; 10/07/2016 ('VGA_FONT_SETUP', INT 43H address for x86 real mode bios)
  4149 000196DA ????????            <1> VGA_INT43H:	resd 1	; 0 = default (not configured by user)
  4150                              <1> 			; 0FFFFFFFFh = user defined fonts
  4151                              <1> 			; address:
  4152                              <1> 			; 	vgafont8
  4153                              <1> 			; 	vgafont16
  4154                              <1> 			; 	vgafont14
  4155                              <1> 
  4156                              <1> ; 25/07/2016
  4157 000196DE ??                  <1> VGA_MTYPE:	resb 1  ; 0=CTEXT,1=MTEXT,2=CGA,3=PLANAR1,4=PLANAR4,5=LINEAR 
  4158                              <1> 
  4159                              <1> ; 23/10/2016
  4160 000196DF ??                  <1> setfmod		resb 1	; update last modification date&time sign (if >0)
  4161                              <1> 			; (it is Open File Number + 1, if > 0)
  4162                              <1> alignb 4
  4163                              <1> 
  4164                              <1> ; 16/10/2016
  4165 000196E0 ????????            <1> FFF_UBuffer:	resd 1  ; User's buffer address for FFF & FNF system calls 
  4166                              <1> ; 15/10/2016
  4167 000196E4 ??                  <1> FFF_Valid:	resb 1  ; Find First File Structure validation byte
  4168                              <1> 			; 0  = invalid (Find Next File can't use FFF struct)
  4169                              <1> 			; >0 = valid, return type for FFF and Find Next File
  4170                              <1> 			; 24 = basic parameters, 24 bytes
  4171                              <1> 			; 128 = entire FFF structure/table, 128 bytes
  4172                              <1> ; 16/10/2016 (FFF_Attrib: resw 1)
  4173 000196E5 ??                  <1> FFF_Attrib:	resb 1	; Find First File attributes for Find Next File (LB)
  4174 000196E6 ??                  <1> FFF_RType:	resb 1  ; FFF return type (0 = Basic, >0 = complete) (HB)
  4175                              <1> ; 16/10/2016 - 05/10/2016 (Set Working Path)
  4176 000196E7 ??                  <1> SWP_inv_fname:	resb 1	; Set Working Path - Invalid File Name
  4177 000196E8 ????                <1> SWP_Mode:	resw 1	; Set Working Path - Mode
  4178 000196EA ??                  <1> SWP_DRV:	resb 1	; Set Working Path - Drive	
  4179 000196EB ??                  <1> SWP_DRV_chg:	resb 1	; Set Working Path - Drive Change
  4180                              <1> 
  4181                              <1> ; 27/02/2017
  4182 000196EC ??                  <1> fpready:	resb 1	; '80387 fpu is ready' flag	
  4183                              <1> 
  4184                              <1> ; 08/10/2016
  4185 000196ED <res 9h>            <1> device_name:    resb 9  ; capitalized (and zero padded) device canem 
  4186                              <1> 			; (example: "TTY0",0,0,0,0,0")
  4187                              <1> 
  4188 000196F6 ????                <1> alignb 4
  4189                              <1> 
  4190                              <1> ; 08/10/2016
  4191                              <1> ; 07/10/2016
  4192                              <1> ; Table of kernel devices (which do not use installable device drivers)
  4193                              <1> ; has been coded into KERNEL (trdosk9.s) 
  4194                              <1> ; 07/10/2016
  4195                              <1> ; 8 installable device drivers available to install (NUMIDEV)
  4196 000196F8 <res 20h>           <1> IDEV_PGDIR: resd NUMIDEV
  4197                              <1> 			; Page directories of installable device drivers
  4198                              <1> 			;
  4199                              <1> 			; Note: Virtual start address is always 400000h
  4200                              <1> 			; (end of the 1st 4MB). [org 400000h]
  4201                              <1> 			; Segments: KCODE, KDATA
  4202                              <1> 			; Method: call 400000h (after changing page dir) 	
  4203                              <1> 			; Query code located at the start (400000h).
  4204                              <1> 			; Query code returns with
  4205                              <1> 			;   eax = device type and driver version
  4206                              <1> 			;         AL = Device Type minor
  4207                              <1> 			;         AH = Device Type major
  4208                              <1> 			;         Byte 16-23 : Version minor
  4209                              <1> 			;	  Byte 24-31 : Version major - 1
  4210                              <1> 			;		       (0:0 -> 1.0)
  4211                              <1> 			;   ebx = initialization code address
  4212                              <1> 			;   ecx = configuration table address
  4213                              <1> 			;   edx = description table address
  4214                              <1> 			;   esi = device (default) name address (ASCIIZ)
  4215                              <1> 			;	 (name has "/DEV/" prefix)		
  4216                              <1> 			;   edi = dispatch table address
  4217                              <1> 			;        (for calling kernel-device functions)
  4218                              <1> 			;   ebp = address table address
  4219                              <1> 			; Initialization code returns with
  4220                              <1> 			;   eax = open code address
  4221                              <1> 			;   ecx = close code address 
  4222                              <1> 			;   ebx = read code address
  4223                              <1> 			;   edx = write code address 	
  4224                              <1> 			;   esi = IOCTL code address
  4225                              <1> 			;   edi = dispatch table address
  4226                              <1> 			;   ebp = address table address
  4227                              <1> 			; Address Table:
  4228                              <1> 			;    Offset 0  : open code address
  4229                              <1> 			;    Offset 4  : read code address
  4230                              <1> 			;    Offset 8  : write code address
  4231                              <1> 			;    Offset 12 : close code address
  4232                              <1> 			;    Offset 16 : IOCTL code address
  4233                              <1> 			;    Offset 20 : initialization code address
  4234                              <1> 			;    Offset 24 : description table address
  4235                              <1> 			;    Offset 28 : configuration table address
  4236                              <1> 			;    Offset 32 : device name address
  4237                              <1> 			;    Offset 36 : dispatch table address
  4238                              <1> 			;          (for calling kernel-device functions)
  4239                              <1> 
  4240 00019718 <res 40h>           <1> IDEV_NAME:  resb 8*NUMIDEV 
  4241                              <1> 			; 8 byte names of installable device drivers
  4242                              <1> 
  4243 00019758 ????????????????    <1> IDEV_TYPE:  resb NUMIDEV ; Driver type of installable device drivers
  4244 00019760 ????????????????    <1> IDEV_FLAGS: resb NUMIDEV ; Device access parameters for installable
  4245                              <1>                          ; device drivers (These values are set while
  4246                              <1> 			 ; the device driver is being loaded.)
  4247 00019768 <res 20h>           <1> IDEV_OADDR: resd NUMIDEV ; open function addr for installable dev driver
  4248 00019788 <res 20h>           <1> IDEV_CADDR: resd NUMIDEV ; close function addr for installable dev driver
  4249 000197A8 <res 20h>           <1> IDEV_RADDR: resd NUMIDEV ; read function addr for installable dev driver
  4250 000197C8 <res 20h>           <1> IDEV_WADDR: resd NUMIDEV ; write function addr for installable dev driver
  4251                              <1> 	
  4252                              <1> ; 08/10/2016	
  4253                              <1> ; 07/10/2016
  4254                              <1> ; Device Open and Access parameters
  4255 000197E8 <res 1Eh>           <1> DEV_ACCESS:	 resb NUMOFDEVICES   ; bit 0 = accessable by normal users
  4256                              <1> 				     ; bit 1 = read access permission
  4257                              <1> 				     ; bit 2 = write access permission
  4258                              <1> 				     ; bit 3 = IOCTL permission to users
  4259                              <1> 				     ; bit 4 = block device if it is set	
  4260                              <1> 				     ; bit 5 = 16 bit or 1024 byte data
  4261                              <1> 				     ; bit 6 = 32 bit or 2048 byte data
  4262                              <1> 				     ; bit 7 = installable device driver
  4263 00019806 <res 1Eh>           <1> DEV_R_OWNER:	 resb NUMOFDEVICES   ; Reading owner no (u.uid) of devices		
  4264 00019824 <res 1Eh>           <1> DEV_R_OPENCOUNT: resb NUMOFDEVICES   ; Reading open count 
  4265 00019842 <res 1Eh>           <1> DEV_W_OWNER:	 resb NUMOFDEVICES   ; Writing owner no (u.uid) of devices		
  4266 00019860 <res 1Eh>           <1> DEV_W_OPENCOUNT: resb NUMOFDEVICES   ; Writing open count
  4267 0001987E <res 1Eh>           <1> DEV_DRIVER:	 resb NUMOFDEVICES   ; device driver number (1 to 7Fh)
  4268                              <1> 				     ; *if bit 7 is set (80 to FFh)
  4269                              <1> 				     ; *if it is installable device driver
  4270                              <1> 				     ; *index (0 to 7Fh)
  4271                              <1> 				     ; otherwise it is kernel device index
  4272 0001989C <res 1Eh>           <1> DEV_OPENMODE:	 resb NUMOFDEVICES   ; 1 = read mode
  4273                              <1> 				     ; 2 = write mode
  4274                              <1> 				     ; 3 = read & write 	  
  4275                              <1> 				     ; 0 = not open (free)		
  4276 000198BA <res 78h>           <1> DEV_NAME_PTR:    resd NUMOFDEVICES   ; pointers to name addresses of drivers
  4277                              <1> 				     ; Address base: KDEV_NAME+		
  4278                              <1> 				     ; or IDEV_NAME+
  4279 00019932 <res 78h>           <1> DEV_R_POINTER:	 resd NUMOFDEVICES   ; reading pointer, writing pointer	
  4280 000199AA <res 78h>           <1> DEV_W_POINTER:	 resd NUMOFDEVICES   ; sector number if block device
  4281                              <1> 				     ; character offset if char device
  4282 00019A22 ????                <1> alignb 4
  4283                              <1> 
  4284                              <1> ; 06/10/2016
  4285                              <1> ; Open File Parameters
  4286 00019A24 <res 28h>           <1> OF_FCLUSTER:	resd OPENFILES  ; First clusters of open files
  4287 00019A4C <res Ah>            <1> OF_DRIVE:	resb OPENFILES  ; Logical DOS drive numbers of open files 
  4288 00019A56 <res Ah>            <1> OF_MODE:	resb OPENFILES  ; Open mode (1 = read, 2 = write, 3 = r&w) 
  4289 00019A60 <res Ah>            <1> OF_STATUS:	resb OPENFILES  ; (bit 0 = read, bit 1 = write)
  4290 00019A6A <res Ah>            <1> OF_OPENCOUNT:	resb OPENFILES  ; Open counts of open files
  4291 00019A74 <res 28h>           <1> OF_POINTER:	resd OPENFILES	; File seek/read/write pointer
  4292 00019A9C <res 28h>           <1> OF_SIZE:	resd OPENFILES	; File sizes of open files (in bytes)
  4293 00019AC4 <res 28h>           <1> OF_DIRFCLUSTER:	resd OPENFILES  ; Directory First Clusters of open files
  4294 00019AEC <res 28h>           <1> OF_DIRCLUSTER:	resd OPENFILES  ; Directory (Entry) Clusters of open files
  4295 00019B14 <res 28h>           <1> OF_VOLUMEID:	resd OPENFILES  ; Vol ID for removable drives of open files
  4296 00019B3C <res 28h>           <1> OF_CCLUSTER:	resd OPENFILES  ; Current clusters of open files
  4297 00019B64 <res 28h>           <1> OF_CCINDEX:	resd OPENFILES  ; Cluster index numbers of current clusters
  4298                              <1> ; 24/10/2016
  4299 00019B8C <res 14h>           <1> OF_DIRENTRY:	resw OPENFILES  ; Directory entry index no. in dir cluster 
  4300                              <1> 				; Sector index = entry index / 16
  4301                              <1> ;alignb 2
  4302                              <1> 
  4303 00019BA0 <res 60h>           <1> DTA:		resd 24		; Find First File data transfer area
  4304                              <1> 
  4305                              <1> ; 19/12/2016
  4306 00019C00 ??                  <1> tcallback:	resb 1		; Timer callback method flag for 'systimer'
  4307 00019C01 ??                  <1> trtc:		resb 1		; Timer interrupt type flag for 'systimer'
  4308                              <1> ; 20/02/2017
  4309 00019C02 ??                  <1> no_page_swap:	resb 1		; Swap lock for Signal Response Byte pages 
  4310                              <1> ;;15/01/2017
  4311                              <1> ; 02/01/2017
  4312                              <1> ;;intflg:	resb 1		; software interrupt in progress signal
  4313                              <1> 				; (for timer interrupt)
  4314                              <1> 
  4315 00019C03 ??                  <1> alignb 4
  4316                              <1> ; 13/04/2017
  4317 00019C04 <res 1Eh>           <1> DEV_INTR:	resb NUMOFDEVICES ; Device Interrupt (IRQ) number + 1	
  4318                              <1> 				; (0= not available, 1= IRQ 0, 16= IRQ 15)
  4319 00019C22 <res 40h>           <1> DEV_INT_HNDLR:	resd 16		; Device Interrupt Handler addr, if > 0 	
  4320                              <1> 
  4321                              <1> 
  4322                              <1> ;alignb 4
  4323                              <1> 
  4324                              <1> ; 26/02/2017 ; IRQ Callback parameters ('syscalbac')
  4325                              <1> ;Index: ; 0 to 8
  4326                              <1> ;	0 = IRQ3, 1 = IRQ4, 2 = IRQ5, 3 = IRQ7
  4327                              <1> ;	4 = IRQ9, 5 = IRQ10, 6 = IRQ11, 7 = IRQ12, 8 = IRQ13  
  4328 00019C62 <res 9h>            <1> IRQ.owner:	resb 9		; owner, 0 = free, >0 = [u.uno]
  4329 00019C6B <res 9h>            <1> IRQ.dev:	resb 9		; 0 = default/kernel, >0 = device number
  4330 00019C74 <res 9h>            <1> IRQ.method:	resb 9 		; 0 = Signal Response Byte, 1 = Callback
  4331 00019C7D <res 9h>            <1> IRQ.srb:	resb 9 		; Signal Response/Return Byte value
  4332 00019C86 <res 24h>           <1> IRQ.addr:	resd 9		; Rignal Response Byte address (physical)
  4333                              <1> 				; or Callback service address (virtual)
  4334                              <1> ; 28/02/2017
  4335 00019CAA ????????            <1> IRQ_cr3:	resd 1		; for saving cr3 register in IRQ handler
  4336 00019CAE ??                  <1> IRQnum:		resb 1		; IRQ number for IRQ handler (trdosk8.s)
  4337                              <1> 
  4338                              <1> ; 10/04/2017
  4339                              <1> ; 03/04/2017
  4340                              <1> ; UNINITIALIZED AUDIO DATA
  4341 00019CAF ??                  <1> alignb 4
  4342 00019CB0 ??                  <1> audio_pci:	resb 1
  4343 00019CB1 ??                  <1> audio_device:	resb 1
  4344 00019CB2 ??                  <1> audio_mode:	resb 1
  4345 00019CB3 ??                  <1> audio_intr:	resb 1
  4346 00019CB4 ??                  <1> audio_busy:	resb 1  ; Busy flag for audio irq ; 21/04/2017
  4347 00019CB5 ??                  <1> audio_reserved: resb 1
  4348 00019CB6 ????                <1> audio_io_base:	resw 1 	; Base I/O address of audio device
  4349 00019CB8 ????????            <1> audio_dev_id:	resd 1	; BUS/DEV/FN ; 00000000BBBBBBBBDDDDDFFF00000000
  4350 00019CBC ????????            <1> audio_vendor:	resd 1
  4351 00019CC0 ????????            <1> audio_stats_cmd: resd 1
  4352                              <1> ;
  4353 00019CC4 ????????            <1> audio_buffer:	resd 1	; virtual address of user's audio buffer
  4354 00019CC8 ????????            <1> audio_p_buffer:	resd 1	; Physical address of user's audio buffer
  4355 00019CCC ????????            <1> audio_buff_size: resd 1 ; user's audio buffer size (half buffer size) 
  4356 00019CD0 ????????            <1> audio_dma_buff: resd 1  ; dma buffer address
  4357 00019CD4 ????????            <1> audio_dmabuff_size: resd 1 ; dma buffer size (2 * half buffer size)
  4358 00019CD8 ??                  <1> audio_flag:	resb 1  ; dma buffer flag (1st half = 0, 2nd half = 1)
  4359 00019CD9 ??                  <1> audio_user:	resb 1	; user number of the owner
  4360 00019CDA ??                  <1> audio_cb_mode:	resb 1	; 0 = signal response byte method
  4361                              <1> 			; 1 = callback method
  4362                              <1> 			; 2 = s.r.b. method with auto increment
  4363 00019CDB ??                  <1> audio_srb:	resb 1	; signal response byte value
  4364 00019CDC ????????            <1> audio_cb_addr:	resd 1  ; callback service address or s.r.b. address
  4365                              <1> 			; (s.r.b. addr is physical, cbs addr is virtual)
  4366                              <1> 
  4367 00019CE0 ??                  <1> audio_bps:	resb 1  ; selected mode: 8 bit, 16 bit
  4368 00019CE1 ??                  <1> audio_stmo:	resb 1	; selected mode: mono /stereo
  4369 00019CE2 ????                <1> audio_freq: 	resw 1	; sampling rate
  4370                              <1> 
  4371                              <1> ; 21/04/2017
  4372 00019CE4 ??                  <1> audio_play_cmd: resb 1  ; Play/Stop command (1 = play, 0 = stop)
  4373                              <1> audio_civ: ; 28/05/2017 ; Current Buffer Index (AC'97)
  4374 00019CE5 ??                  <1> audio_flag_eol:	resb 1  ; End of Link status (vt8233, EOL/FLAG)
  4375                              <1> 
  4376                              <1> audio_master_volume:
  4377 00019CE6 ??                  <1> audio_master_volume_l: resb 1 ; sound volume (lineout) left channel
  4378 00019CE7 ??                  <1> audio_master_volume_r: resb 1 ; sound volume (lineout) right channel
  4379                              <1> 
  4380                              <1> alignb 4
  4381                              <1> ; 28/05/2017
  4382                              <1> ; AC'97 Audio Controller Base Adress Registers
  4383 00019CE8 ????                <1> NAMBAR:		resw 1	; Native Audio Mixer Base Address
  4384 00019CEA ????                <1> NABMBAR:	resw 1	; Native Audio Bus Mastering Base Address
  4385                              <1> 	
  4386                              <1> ;alignb 4
  4387                              <1> ; 21/04/2017
  4388 00019CEC <res 400h>          <1> audio_bdl_buff:	resd 32*8  ; VT8233 (AC97) BDL Buffer Size
  4389                              <1> ; 12/05/2017
  4390 0001A0EC ????????            <1> base_addr:	resd 1	; 'direct_memory_access' (memory.s)
  4391                              <1> 
  4392                              <1> ; 28/08/2017
  4393                              <1> ; 20/08/2017
  4394 0001A0F0 ??                  <1> 		resb 1  ;
  4395 0001A0F1 ??                  <1> dma_user:	resb 1	; user number for sysdma
  4396 0001A0F2 ??                  <1> dma_channel:	resb 1	; dma channel for sysdma
  4397 0001A0F3 ??                  <1> dma_mode:	resb 1  ; dma mode for sysdma	
  4398 0001A0F4 ????????            <1> dma_addr:	resd 1	; dma buffer physical addr for sysdma
  4399 0001A0F8 ????????            <1> dma_size:	resd 1  ; dma buffer size (in bytes) for sysdma
  4400 0001A0FC ????????            <1> dma_start:	resd 1  ; dma start address for sysdma
  4401 0001A100 ????????            <1> dma_count:	resd 1  ; dma count (in bytes) for sysdma 
  4402                              <1> 
  4403 0001A104 <res 5EFCh>         <1> alignb 65536
  4404                              <1> ; 09/08/2017
  4405                              <1> ; 12/05/2017
  4406 00020000 <res 10000h>        <1> sb16_dma_buffer: resb 65536 ; DMA buffer for sb16 audio playing.
  3647                                  ; 24/01/2016
  3648                                  %include 'ubss.s'	; UNINITIALIZED KERNEL (USER) DATA
  3649                              <1> ; ****************************************************************************
  3650                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - UNINITIALIZED USER DATA : ubss.s
  3651                              <1> ; ----------------------------------------------------------------------------
  3652                              <1> ; Last Update: 28/02/2017
  3653                              <1> ; ----------------------------------------------------------------------------
  3654                              <1> ; Beginning: 24/01/2016
  3655                              <1> ; ----------------------------------------------------------------------------
  3656                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
  3657                              <1> ; ----------------------------------------------------------------------------
  3658                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
  3659                              <1> ; ux.s (04/12/2015)
  3660                              <1> ; ****************************************************************************
  3661                              <1> 
  3662                              <1> ; Retro UNIX 386 v1 Kernel - ux.s
  3663                              <1> ; Last Modification: 04/12/2015
  3664                              <1> ;
  3665                              <1> ; ///////// RETRO UNIX 386 V1 SYSTEM DEFINITIONS ///////////////
  3666                              <1> ; (Modified from 
  3667                              <1> ;	Retro UNIX 8086 v1 system definitions in 'UNIX.ASM', 01/09/2014)
  3668                              <1> ; ((UNIX.ASM (RETRO UNIX 8086 V1 Kernel), 11/03/2013 - 01/09/2014))
  3669                              <1> ; ----------------------------------------------------------------------------
  3670                              <1> ; Derived from UNIX Operating System (v1.0 for PDP-11) 
  3671                              <1> ; (Original) Source Code by Ken Thompson (1971-1972)
  3672                              <1> ; <Bell Laboratories (17/3/1972)>
  3673                              <1> ; <Preliminary Release of UNIX Implementation Document>
  3674                              <1> ; (Section E10 (17/3/1972) - ux.s)
  3675                              <1> ; ****************************************************************************
  3676                              <1> 
  3677                              <1> alignb 2
  3678                              <1> 
  3679                              <1> inode:
  3680                              <1> 	; 11/03/2013. 
  3681                              <1> 	;Derived from UNIX v1 source code 'inode' structure (ux).
  3682                              <1> 	;i.
  3683                              <1> 
  3684 00030000 ????                <1> 	i.flgs:	 resw 1
  3685 00030002 ??                  <1> 	i.nlks:	 resb 1
  3686 00030003 ??                  <1> 	i.uid:	 resb 1
  3687                              <1>         ;i.size:  resw 1 ; size
  3688 00030004 ????                <1> 	resw 1 ; 29/04/2016
  3689 00030006 <res 10h>           <1> 	i.dskp:	 resw 8 ; 16 bytes
  3690 00030016 ????????            <1> 	i.ctim:	 resd 1
  3691 0003001A ????????            <1> 	i.mtim:	 resd 1
  3692 0003001E ????                <1> 	i.rsvd:  resw 1 ; Reserved (ZERO/Undefined word for UNIX v1.)
  3693                              <1> 
  3694                              <1> I_SIZE	equ $ - inode 
  3695                              <1> 
  3696                              <1> process:
  3697                              <1> 	; 19/12/2016
  3698                              <1> 	; 21/05/2016
  3699                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
  3700                              <1> 	; 06/05/2015 - Retro UNIX 386 v1
  3701                              <1> 	; 11/03/2013 - 05/02/2014 (Retro UNIX 8086 v1)
  3702                              <1> 	;Derived from UNIX v1 source code 'proc' structure (ux).
  3703                              <1> 	;p.
  3704                              <1> 	
  3705 00030020 <res 20h>           <1>         p.pid:   resw nproc
  3706 00030040 <res 20h>           <1>         p.ppid:  resw nproc
  3707 00030060 <res 20h>           <1>         p.break: resw nproc
  3708 00030080 <res 10h>           <1>         p.ttyc:  resb nproc ; console tty in Retro UNIX 8086 v1.
  3709 00030090 <res 10h>           <1> 	p.waitc: resb nproc ; waiting channel in Retro UNIX 8086 v1.
  3710 000300A0 <res 10h>           <1> 	p.link:	 resb nproc
  3711 000300B0 <res 10h>           <1> 	p.stat:	 resb nproc
  3712                              <1> 
  3713                              <1> 	; 06/05/2015 (Retro UNIX 386 v1 feature only !) 
  3714 000300C0 <res 40h>           <1> 	p.upage: resd nproc ; Physical address of the process's
  3715                              <1> 			    ; 'user' structure
  3716                              <1> 	; 21/05/2016	
  3717                              <1> 	; 19/05/2016 (TRDOS 386 feature only!)
  3718 00030100 <res 10h>           <1> 	p.timer: resb nproc ; number of timer events of the processs
  3719                              <1> 
  3720                              <1> 	; 19/12/2016
  3721 00030110 <res 40h>           <1> 	p.tcb:	resd nproc ; timer callback service address (if > 0)
  3722                              <1> 			  		 			 	  
  3723                              <1> P_SIZE	equ $ - process
  3724                              <1> 
  3725                              <1> ; fsp table (original UNIX v1)
  3726                              <1> ;
  3727                              <1> ;Entry
  3728                              <1> ;          15                                      0
  3729                              <1> ;  1     |---|---------------------------------------|
  3730                              <1> ;        |r/w|       i-number of open file           |
  3731                              <1> ;        |---|---------------------------------------| 
  3732                              <1> ;        |               device number               |
  3733                              <1> ;        |-------------------------------------------|
  3734                              <1> ;    (*) | offset pointer, i.e., r/w pointer to file |
  3735                              <1> ;        |-------------------------------------------| 
  3736                              <1> ;        |  flag that says    | number of processes  |
  3737                              <1> ;        |   file deleted     | that have file open  |
  3738                              <1> ;        |-------------------------------------------| 
  3739                              <1> ;  2     |                                           |
  3740                              <1> ;        |-------------------------------------------| 
  3741                              <1> ;        |                                           |
  3742                              <1> ;        |-------------------------------------------|
  3743                              <1> ;        |                                           |
  3744                              <1> ;        |-------------------------------------------|
  3745                              <1> ;        |                                           |
  3746                              <1> ;        |-------------------------------------------| 
  3747                              <1> ;  3     |                                           | 
  3748                              <1> ;        |                                           |  
  3749                              <1> ;
  3750                              <1> ; (*) Retro UNIX 386 v1 modification: 32 bit offset pointer 
  3751                              <1> 
  3752                              <1> 
  3753                              <1> ; 15/04/2015
  3754 00030150 <res 1F4h>          <1> fsp:	 resb nfiles * 10 ; 11/05/2015 (8 -> 10)
  3755 00030344 ????                <1> idev:	 resw 1 ; device number is 1 byte in Retro UNIX 8086 v1 !
  3756 00030346 ????                <1> cdev:    resw 1 ; device number is 1 byte in Retro UNIX 8086 v1 !
  3757                              <1> ; 18/05/2015
  3758                              <1> ; 26/04/2013 device/drive parameters (Retro UNIX 8086 v1 feature only!)
  3759                              <1> ; 'UNIX' device numbers (as in 'cdev' and 'u.cdrv')
  3760                              <1> ;	0 -> root device (which has Retro UNIX 8086 v1 file system)
  3761                              <1> ; 	1 -> mounted device (which has Retro UNIX 8086 v1 file system)
  3762                              <1> ; 'Retro UNIX 8086 v1' device numbers: (for disk I/O procedures)
  3763                              <1> ;	0 -> fd0 (physical drive, floppy disk 1), physical drive number = 0
  3764                              <1> ;	1 -> fd1 (physical drive, floppy disk 2), physical drive number = 1
  3765                              <1> ;	2 -> hd0 (physical drive, hard disk 1), physical drive number = 80h
  3766                              <1> ;	3 -> hd1 (physical drive, hard disk 2), physical drive number = 81h
  3767                              <1> ;	4 -> hd2 (physical drive, hard disk 3), physical drive number = 82h
  3768                              <1> ;	5 -> hd3 (physical drive, hard disk 4), physical drive number = 83h
  3769 00030348 ??                  <1> rdev:	 resb 1 ; root device number ; Retro UNIX 8086 v1 feature only!
  3770                              <1> 	        ; as above, for physical drives numbers in following table
  3771 00030349 ??                  <1> mdev:	 resb 1 ; mounted device number ; Retro UNIX 8086 v1 feature only!
  3772                              <1> ; 15/04/2015
  3773 0003034A ??                  <1> active:	 resb 1 
  3774 0003034B ??                  <1> 	 resb 1 ; 09/06/2015
  3775 0003034C ????                <1> mnti:	 resw 1
  3776 0003034E ????                <1> mpid:	 resw 1
  3777 00030350 ????                <1> rootdir: resw 1
  3778                              <1> 
  3779                              <1> ; 21/05/2016 - TRDOS 386 (TRDOS v2.0) - priority levels, 3 run queues 
  3780                              <1> runq:
  3781 00030352 ????                <1> runq_event:	 resw 1 ; high priority, 'run for event'            ; 2
  3782 00030354 ????                <1> runq_normal:	 resw 1 ; normal/regular priority, 'run as reqular' ; 1
  3783 00030356 ????                <1> runq_background: resw 1 ; low priority, 'run on background'         ; 0
  3784                              <1> ;
  3785 00030358 ??                  <1> imod:	 resb 1
  3786 00030359 ??                  <1> smod:	 resb 1
  3787 0003035A ??                  <1> mmod:	 resb 1
  3788 0003035B ??                  <1> sysflg:	 resb 1
  3789                              <1> 
  3790                              <1> alignb 4
  3791                              <1> 
  3792                              <1> user:
  3793                              <1> 	; 13/01/2017
  3794                              <1> 	; 19/12/2016
  3795                              <1> 	; 21/05/2016 - TRDOS 386 (TRDOS v2.0) 
  3796                              <1> 	; 	       [u.pri] usage method modification
  3797                              <1> 	; 04/12/2015 
  3798                              <1> 	; 18/10/2015
  3799                              <1> 	; 12/10/2015
  3800                              <1> 	; 21/09/2015
  3801                              <1> 	; 24/07/2015
  3802                              <1> 	; 16/06/2015
  3803                              <1> 	; 09/06/2015
  3804                              <1> 	; 11/05/2015
  3805                              <1> 	; 16/04/2015 (Retro UNIX 386 v1 - 32 bit modifications)
  3806                              <1> 	; 10/10/2013
  3807                              <1> 	; 11/03/2013. 
  3808                              <1> 	;Derived from UNIX v1 source code 'user' structure (ux).
  3809                              <1> 	;u.
  3810                              <1> 
  3811 0003035C ????????            <1> 	u.sp:	  resd 1 ; esp (kernel stack at the beginning of 'sysent')
  3812 00030360 ????????            <1> 	u.usp:	  resd 1 ; esp (kernel stack points to user's registers)
  3813 00030364 ????????            <1> 	u.r0:	  resd 1 ; eax
  3814 00030368 ????                <1> 	u.cdir:	  resw 1
  3815 0003036A <res Ah>            <1> 	u.fp:	  resb 10
  3816 00030374 ????????            <1> 	u.fofp:	  resd 1
  3817 00030378 ????????            <1> 	u.dirp:	  resd 1
  3818 0003037C ????????            <1> 	u.namep:  resd 1
  3819 00030380 ????????            <1> 	u.off:	  resd 1
  3820 00030384 ????????            <1> 	u.base:	  resd 1
  3821 00030388 ????????            <1> 	u.count:  resd 1
  3822 0003038C ????????            <1> 	u.nread:  resd 1
  3823 00030390 ????????            <1> 	u.break:  resd 1 ; break
  3824 00030394 ????                <1> 	u.ttyp:	  resw 1 
  3825                              <1> 	; 10/01/2017 (TRDOS 386, relocation and dword alignment)
  3826                              <1> 	; tty number (rtty, rcvt, wtty)
  3827 00030396 ??                  <1> 	u.ttyn:	  resb 1 ; 28/07/2013 - Retro Unix 8086 v1 feature only !
  3828 00030397 ??                  <1> 	u.resb:   resb 1 ; 10/01/2017 (TRDOS 386, temporary)
  3829 00030398 <res 10h>           <1> 	u.dirbuf: resb 16 ; 04/12/2015 (10 -> 16) 
  3830                              <1> 	;u.pri:	  resw 1 ; 14/02/2014
  3831 000303A8 ??                  <1> 	u.quant:  resb 1 ; Retro UNIX 8086 v1 Feature only ! (uquant)
  3832 000303A9 ??                  <1> 	u.pri:	  resb 1 ; Modification: 21/05/2016 (priority levels: 0, 1, 2)
  3833 000303AA ????                <1> 	u.intr:	  resw 1
  3834 000303AC ????                <1> 	u.quit:	  resw 1
  3835                              <1> 	;u.emt:	  resw 1 ; 10/10/2013
  3836                              <1> 	;u.ilgins: resw 1 ; 10/01/2017
  3837 000303AE ????                <1> 	u.cdrv:	  resw 1 ; cdev
  3838 000303B0 ??                  <1> 	u.uid:	  resb 1 ; uid
  3839 000303B1 ??                  <1> 	u.ruid:	  resb 1
  3840 000303B2 ??                  <1> 	u.bsys:	  resb 1
  3841 000303B3 ??                  <1> 	u.uno:	  resb 1
  3842 000303B4 ????????            <1>         u.upage:  resd 1 ; 16/04/2015 - Retro Unix 386 v1 feature only !
  3843 000303B8 ????????            <1> 	u.pgdir:  resd 1 ; 09/03/2015 (page dir addr of process)
  3844 000303BC ????????            <1> 	u.ppgdir: resd 1 ; 06/05/2015 (page dir addr of the parent process)
  3845 000303C0 ????????            <1> 	u.pbase:  resd 1 ; 20/05/2015 (physical base/transfer address)
  3846 000303C4 ????                <1> 	u.pcount: resw 1 ; 20/05/2015 (byte -transfer- count for page)
  3847                              <1> 	;u.pncount: resw 1 
  3848                              <1> 		; 16/06/2015 (byte -transfer- count for page, 'namei', 'mkdir')
  3849                              <1> 	;u.pnbase:  resd 1 
  3850                              <1> 		; 16/06/2015 (physical base/transfer address, 'namei', 'mkdir')
  3851                              <1> 			 ; 09/06/2015
  3852 000303C6 ??                  <1> 	u.kcall:  resb 1 ; The caller is 'namei' (dskr) or 'mkdir' (dskw) sign		
  3853 000303C7 ??                  <1> 	u.brwdev: resb 1 ; Block device number for direct I/O (bread & bwrite)
  3854                              <1> 			 ; 24/07/2015 - 24/06/2015
  3855                              <1> 	;u.args:  resd 1 ; arguments list (line) offset from start of [u.upage]
  3856                              <1> 			 ; (arg list/line is from offset [u.args] to 4096 in [u.upage])
  3857                              <1> 			 ; ([u.args] points to argument count -argc- address offset)
  3858                              <1>  			 ; 24/06/2015	  	
  3859                              <1> 	;u.core:  resd 1 ; physical start address of user's memory space (for sys exec)
  3860                              <1> 	;u.ecore: resd 1 ; physical end address of user's memory space (for sys exec)
  3861                              <1> 	; last error number
  3862 000303C8 ????????            <1> 	u.error:  resd 1 ; 28/07/2013 - 09/03/2015 
  3863                              <1> 		        ; Retro UNIX 8086/386 v1 feature only!
  3864                              <1> 			; 21/09/2015 (debugging - page fault analyze)
  3865 000303CC ????????            <1> 	u.pfcount: resd 1 ; page fault count for (this) process (for sys geterr)
  3866                              <1> 		; 19/12/2016 (TRDOS 386)	
  3867 000303D0 ????????            <1> 	u.tcb:	  resd 1 ; Timer callback address/flag which will be used by timer int
  3868                              <1> 		; 13/01/2017 (TRDOS 386)
  3869 000303D4 ??                  <1> 	u.t_lock: resb 1 ; Timer interrupt (callback) lock (unlocked by 'sysrele')
  3870 000303D5 ??                  <1> 	u.t_mode: resb 1 ; running mode during timer interrupt (0= system, 0FFh= user)
  3871                              <1> 		; 26/02/2017 (TRDOS 386)
  3872 000303D6 ??                  <1> 	u.irqc:	  resb 1  ; Count of IRQ callback services (IRQs in use)
  3873                              <1> 		; 28/02/2017 (TRDOS 386) 
  3874 000303D7 ??                  <1> 	u.irqwait: resb 1 ; IRQ waiting for callback service flag (IRQ number, If > 0)
  3875 000303D8 ??                  <1> 	u.r_lock:  resb 1 ; 'IRQ callback service is in progress' flag (IRQ lock)
  3876 000303D9 ??                  <1> 	u.r_mode:  resb 1 ; running mode during hadware interrupt	
  3877                              <1> 		; 27/02/2017 (TRDOS 386) 
  3878 000303DA ??                  <1> 	u.fpsave: resb 1  ; TRDOS 386, 'save/restore FPU registers' flag
  3879 000303DB ??                  <1> alignb 4
  3880 000303DC <res 5Eh>           <1> 	u.fpregs: resb 94 ; 94 byte area for saving and restoring FPU registers	
  3881                              <1> 
  3882 0003043A ????                <1> alignb 4
  3883                              <1> 
  3884                              <1> U_SIZE	equ $ - user
  3885                              <1> 
  3886                              <1> ; 18/10/2015 - Retro UNIX 386 v1 (local variables for 'namei' and 'sysexec')
  3887 0003043C ????????            <1> pcore:  resd 1  ; physical start address of user's memory space (for sys exec)
  3888 00030440 ????????            <1> ecore:  resd 1  ; physical address of user's stack/last page (for sys exec)
  3889 00030444 ????????            <1> nbase:	resd 1	; physical base address for 'namei' & 'sysexec'
  3890 00030448 ????                <1> ncount: resw 1	; remain byte count in page for 'namei' & 'sysexec'
  3891 0003044A ????                <1> argc:	resw 1	; argument count for 'sysexec'
  3892 0003044C ????????            <1> argv:	resd 1	; argument list (recent) address for 'sysexec'
  3893                              <1> 
  3894                              <1> ; 03/06/2015 - Retro UNIX 386 v1 Beginning
  3895                              <1> ; 07/04/2013 - 31/07/2013 - Retro UNIX 8086 v1
  3896 00030450 ??                  <1> rw: 	 resb 1 ;; Read/Write sign (iget)
  3897                              <1> 
  3898                              <1> ;alignb 4
  3899                              <1> 
  3900                              <1> ; 24/04/2016
  3901 00030451 ????????            <1> ii:		resd 1 ; first cluster of the program file
  3902 00030455 ????????            <1> i.size:		resd 1 ; size of the program file
  3649                                  
  3650 00030459 ??????                  alignb 4
  3651                                  
  3652                                  ; 23/05/2016 (TRDOS 386)
  3653                                  ; 14/10/2015 (Retro UNIX 386 v1, 'unix386.s')
  3654 0003045C ????????                cr3reg:	 resd 1  ; cr3 register content at the beginning of the timer
  3655                                  		 ; (or RTC) interrupt handler.
  3656                                  
  3657                                  ; 10/12/2016 (callback)
  3658                                  ; 10/06/2016
  3659                                  ; 19/05/2016
  3660                                  ; 18/05/2016 - TRDOS 386 feature only !
  3661 00030460 <res 100h>              timer_set: resd 16*4   ; 256 bytes memory space for 16 timer events
  3662                                  	; Timer Event Structure: (max. 16 timer events, 16*16 bytes)
  3663                                  	;       Owner:	        resb 1 ; 0 = free
  3664                                  	;		  	       ;>0 = process number (u.uno)
  3665                                  	;	Callback:	resb 1 ; 0 = response byte address (phy)
  3666                                  	;				 1 = callback address (virtual)				
  3667                                  	;	Interrupt:      resb 1 ; 0 = Timer interrupt (or none)
  3668                                  	;		   	       ; 1 = Real Time Clock interrupt 
  3669                                  	;	Response:       resb 1 ; 0 to 255, signal return value
  3670                                  	;	Count Limit:	resd 1 ; count of ticks (total/set)
  3671                                  	;	Current Count: 	resd 1 ; count of ticks (current)
  3672                                  	;	Response Addr:  resd 1 ; response byte (pointer) address
  3673                                  	;			       ; (or callback -user service- address)	
  3674                                  
  3675                                  ;; Memory (swap) Data (11/03/2015)
  3676                                  ; 09/03/2015
  3677 00030560 ????                    swpq_count: resw 1 ; count of pages on the swap queue
  3678 00030562 ????????                swp_drv:    resd 1 ; logical drive description table address of the swap drive/disk
  3679 00030566 ????????                swpd_size:  resd 1 ; size of swap drive/disk (volume) in sectors (512 bytes). 		  				
  3680 0003056A ????????                swpd_free:  resd 1 ; free page blocks (4096 bytes) on swap disk/drive (logical)
  3681 0003056E ????????                swpd_next:  resd 1 ; next free page block
  3682 00030572 ????????                swpd_last:  resd 1 ; last swap page block	
  3683                                  
  3684 00030576 ????                    alignb 4
  3685                                  
  3686                                  ; 10/07/2015
  3687                                  ; 28/08/2014
  3688 00030578 ????????                error_code:	resd 1
  3689                                  ; 29/08/2014
  3690 0003057C ????????                FaultOffset: 	resd 1
  3691                                  ; 21/09/2015
  3692 00030580 ????????                PF_Count:	resd 1	; total page fault count
  3693                                  		       	; (for debugging - page fault analyze)
  3694                                  		 	; 'page_fault_handler' (memory.inc)
  3695                                  			; 'sysgeterr' (u9.s)
  3696                                  
  3697                                  ; 29/04/2016 (TRDOS 386 = TRDOS v2.0)
  3698                                  ; 22/08/2015 (Retro UNIX 386 v1)
  3699                                  buffer: 
  3700 00030584 ????????????????        	resb	8 
  3701                                  readi_buffer:
  3702 0003058C <res 200h>              	resb 	512
  3703 0003078C ????????????????        	resb	8
  3704                                  writei_buffer:
  3705 00030794 <res 200h>              	resb	512	
  3706                                  ; 24/10/2016
  3707 00030994 ????????????????        	resb	8 
  3708                                  rw_buffer:
  3709 0003099C <res 800h>              	resb 	2048  ; general purposed, r/w sector buffer
  3710                                  
  3711                                  %if 1
  3712                                  ; 17/01/2021
  3713 0003119C <res 80h>               edid_info:	resb 128 ; VESA EDID (monitor capabilities) info	
  3714                                  ; 28/11/2020
  3715 0003121C ??                      pmi32:		resb 1	; (>0) use VESA VBE3 protected mode calls 
  3716 0003121D ??                      vbe_mode_x:	resb 1  ; VESA VBE3 video bios mode set options
  3717 0003121E ????                    video_mode:	resw 1	; VESA VBE3 video mode (with option flags)
  3718                                  ; 30/11/2020
  3719 00031220 ????????                vbe3bios_addr:	resd 1	; new (writable mem) address of VBE3 bios
  3720                                  ; 02/12/2020
  3721 00031224 ????????                pmid_addr:	resd 1	; PMInfoBlock ('PMID') linear address
  3722                                  ; 14/01/2021
  3723                                  ; 06/12/2020		; VESA VBE 3 video state
  3724                                  ;vbe3stbufsize: resw 1	; video regs/dac/bios state buffer size
  3725                                  ;			; block size in bytes
  3726                                  ; 16/01/2021
  3727 00031228 ????                    vbe3stbsflags: resw 1	; video regs/dac/bios state buffer size
  3728                                  ;			; pointer flags for buffer state options
  3729                                  %endif
  3730                                  
  3731                                  %if 1
  3732                                  ; 10/12/2020
  3733                                  LFB_Info:
  3734 0003122A <res 10h>               		resb 16	; Linear Frame Buffer info block
  3735                                  
  3736                                  ;24/11/2020 - TRDOS 386 v2.0.3
  3737                                  ; BOCHS/PLEX86 VESA VBE3 MODE INFO extension to TRDOS 386 v2 kernel	
  3738                                  MODE_INFO_LIST:
  3739 0003123A <res 44h>               		resb 68	; mode + 66 byte VESA vbe3 mode info (4F01h) 
  3740                                  %endif
  3741                                  
  3742                                  ; 05/01/2021
  3743 0003127E ??                      ufont:		resb 1	; (VGA graphics) user font flags
  3744                                  			; bit 7 - permission flag for int 31h
  3745                                  			; bit 4 - 8x16 user font ready/loaded flag  
  3746                                  			; bit 3 - 8x8 user font ready/loaded flag
  3747                                  			; bit 1 - select 8x16 user font (sysvideo)
  3748                                  			; bit 0 - select 8x8 user font (sysvideo)
  3749 0003127F ??                      		resb 1	; 19/01/2021
  3750                                  ; 17/01/2021
  3751 00031280 ??                      srvsf:		resb 1	; 'save restore video state' permission flag
  3752                                  ; 18/01/2021
  3753 00031281 ??                      srvso:		resb 1	; video state buffer save/restore option
  3754 00031282 ????????                VideoStateID:	resd 1	; used to verify state saved by same prog
  3755                                  ; 29/01/2021
  3756 00031286 ????                    v_width:	resw 1	; screen (display page) width
  3757 00031288 ??                      v_ops:		resb 1	; 'sysvideo' graphics data transfer option	
  3758 00031289 ??                      v_bpp:		resb 1	; bits per pixels ('sysvideo')
  3759 0003128A ????????                v_mem:		resd 1	; video memory ('sysvideo')	
  3760 0003128E ????????                v_siz:		resd 1	; video page size ('sysvideo')
  3761 00031292 ????????                v_str:		resd 1	; window start adress ('sysvideo')
  3762 00031296 ????????                v_end:		resd 1	; window end (end+1) adress ('sysvideo')
  3763                                  ; 31/01/2021
  3764                                  ; 01/01/2021
  3765                                  ;maskbuff:     ;resd 1	; user's bitmask buffer addr ('sysvideo')
  3766 0003129A ????????                maskcolor:	resd 1	; VGA/SVGA pixel mask color ('sysvideo')
  3767                                  ; 27/02/2021
  3768 0003129E ????????                pixcount:	resd 1	; pixel count ('sysvideo' window ops) 
  3769                                  ; 02/02/2021
  3770 000312A2 ????????????????        buffer8:	resd 2	; 8 bytes small buffer for 'sysvideo'  
  3771                                  
  3772                                  bss_end:
  3773                                  
  3774                                  ; 27/12/2013
  3775                                  _end:  ; end of kernel code
